@depict-ai/react-ui 0.0.106 → 1.0.3
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 +73 -4
- package/dist/main.js +67 -6
- package/dist/module.js +70 -9
- package/dist-server/index.d.ts +22 -2
- package/dist-server/main.js +9 -5
- package/dist-server/module.js +9 -5
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseProductListingConfig, BaseProviderConfig, BaseSearchProviderConfig, BaseSearchPageConfig, BaseCategoryPageConfig, CategoryTitle, embedded_num_products, ImagePlaceholderProps, TextPlaceholderProps } from "@depict-ai/ui";
|
|
1
|
+
import { BaseProductListingConfig, BaseProviderConfig, BaseSearchProviderConfig, BaseSearchPageConfig, BaseCategoryPageConfig, CategoryTitle, embedded_num_products, ImagePlaceholderProps, TextPlaceholderProps, fetchDepictRecommendations, ExclusiveId } from "@depict-ai/ui";
|
|
2
2
|
import { Display } from "@depict-ai/utilishared";
|
|
3
3
|
import React, { ReactNode, PropsWithChildren, ReactElement } from "react";
|
|
4
4
|
import { DPC } from "@depict-ai/dpc";
|
|
5
5
|
import { Locale } from "@depict-ai/ui/locales";
|
|
6
|
-
export const version = "
|
|
6
|
+
export const version = "1.0.3";
|
|
7
7
|
interface PLPConfig<T extends Display> extends BaseProductListingConfig {
|
|
8
8
|
/**
|
|
9
9
|
* The product card to use for rendering products.
|
|
@@ -38,7 +38,7 @@ interface UsePerformanceClientReturn {
|
|
|
38
38
|
*
|
|
39
39
|
* useEffect(() => {
|
|
40
40
|
* dpc.setProductId(productId);
|
|
41
|
-
* }, [dpc]);
|
|
41
|
+
* }, [dpc, productId]);
|
|
42
42
|
*
|
|
43
43
|
* return <div>Showing product {productId}</div>;
|
|
44
44
|
* }
|
|
@@ -410,11 +410,80 @@ interface UseSearchFieldReturn {
|
|
|
410
410
|
* @returns {UseSearchFieldReturn}
|
|
411
411
|
*/
|
|
412
412
|
export const useSearchField: (props?: SearchFieldProps) => UseSearchFieldReturn;
|
|
413
|
+
type FetchRecsOptions = Omit<Parameters<typeof fetchDepictRecommendations>[0], "merchant" | "market" | "userId" | "sessionId"> & ExclusiveId;
|
|
414
|
+
interface UseFetchRecommendationsReturn<T extends Display> {
|
|
415
|
+
/**
|
|
416
|
+
* Fetch recommendations from the Depict API.
|
|
417
|
+
* @example
|
|
418
|
+
* General recommendations for a landing page:
|
|
419
|
+
* ```tsx
|
|
420
|
+
* fetchRecommendations({ type: "landing_page" });
|
|
421
|
+
* ```
|
|
422
|
+
* @example
|
|
423
|
+
* Fetch targeted recommendations for a product details page (PDP):
|
|
424
|
+
* ```tsx
|
|
425
|
+
* fetchRecommendations({ type: "related", productId: "t-shirt-white" })
|
|
426
|
+
* ```
|
|
427
|
+
* @returns {Promise<T[]>}
|
|
428
|
+
*/
|
|
429
|
+
fetchRecommendations: (opts: FetchRecsOptions) => Promise<T[]>;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Hook used to fetch Depict recommendations.
|
|
433
|
+
* @example
|
|
434
|
+
* Fetch general recommendations for a landing page:
|
|
435
|
+
* ```tsx
|
|
436
|
+
* import React from "react";
|
|
437
|
+
* import { useFetchRecommendations } from "@depict-ai/react-ui";
|
|
438
|
+
*
|
|
439
|
+
* export const LandingPage = () => {
|
|
440
|
+
* const [recs, setRecs] = React.useState();
|
|
441
|
+
* const { fetchRecommendations } = useFetchRecommendations();
|
|
442
|
+
*
|
|
443
|
+
* React.useEffect(() => {
|
|
444
|
+
* fetchRecommendations({ type: "landing_page" }).then(setRecs);
|
|
445
|
+
* }, [fetchRecommendations]);
|
|
446
|
+
*
|
|
447
|
+
* return (
|
|
448
|
+
* <div>
|
|
449
|
+
* {recs?.map((display) => (
|
|
450
|
+
* <ProductCard display={display} />
|
|
451
|
+
* ))}
|
|
452
|
+
* </div>
|
|
453
|
+
* );
|
|
454
|
+
* };
|
|
455
|
+
* ```
|
|
456
|
+
* @example
|
|
457
|
+
* Fetch targeted recommendations for a product details page (PDP):
|
|
458
|
+
* ```tsx
|
|
459
|
+
* import React from "react";
|
|
460
|
+
* import { useFetchRecommendations } from "@depict-ai/react-ui";
|
|
461
|
+
*
|
|
462
|
+
* export const ProductPage = ({ productId }) => {
|
|
463
|
+
* const [recs, setRecs] = React.useState();
|
|
464
|
+
* const { fetchRecommendations } = useFetchRecommendations();
|
|
465
|
+
*
|
|
466
|
+
* React.useEffect(() => {
|
|
467
|
+
* fetchRecommendations({ type: "related", productId }).then(setRecs);
|
|
468
|
+
* }, [fetchRecommendations, productId]);
|
|
469
|
+
*
|
|
470
|
+
* return (
|
|
471
|
+
* <div>
|
|
472
|
+
* {recs?.map((display) => (
|
|
473
|
+
* <ProductCard display={display} />
|
|
474
|
+
* ))}
|
|
475
|
+
* </div>
|
|
476
|
+
* );
|
|
477
|
+
* };
|
|
478
|
+
* ```
|
|
479
|
+
* @returns {UseFetchRecommendationsReturn}
|
|
480
|
+
*/
|
|
481
|
+
export function useFetchRecommendations<T extends Display>(): UseFetchRecommendationsReturn<T>;
|
|
413
482
|
/**
|
|
414
483
|
* Helper function to navigate to a new page depending on the navigation library used.
|
|
415
484
|
*/
|
|
416
485
|
export const Navigation: {
|
|
417
486
|
nextRouterNavigation: (router: import("next/router").NextRouter) => (relativeUrl: string) => void;
|
|
418
487
|
};
|
|
419
|
-
export { CategoryTitle, embedded_num_products as EmbeddedNumProducts
|
|
488
|
+
export { CategoryTitle, embedded_num_products as EmbeddedNumProducts } from "@depict-ai/ui";
|
|
420
489
|
export type { Locale } from "@depict-ai/ui/locales";
|
package/dist/main.js
CHANGED
|
@@ -23,15 +23,15 @@ $parcel$export(module.exports, "ImagePlaceholder", () => $df522c8a81ed5a01$expor
|
|
|
23
23
|
$parcel$export(module.exports, "TextPlaceholder", () => $7c8b440edc188ad5$export$89c6019e4baa40b1);
|
|
24
24
|
$parcel$export(module.exports, "useSearchModal", () => $ae73b15c325f1b21$export$912994940e660d32);
|
|
25
25
|
$parcel$export(module.exports, "useSearchField", () => $913da7f4d0bc77f2$export$9bb30bbe003b82e0);
|
|
26
|
+
$parcel$export(module.exports, "useFetchRecommendations", () => $a134ea100690b628$export$6501da23a2770fc);
|
|
26
27
|
$parcel$export(module.exports, "usePerformanceClient", () => $25c0a91312868994$export$38b98fae14bd1f64);
|
|
27
28
|
$parcel$export(module.exports, "CategoryTitle", () => $b03e4eee8610ebbe$re_export$CategoryTitle);
|
|
28
29
|
$parcel$export(module.exports, "EmbeddedNumProducts", () => $b03e4eee8610ebbe$re_export$EmbeddedNumProducts);
|
|
29
|
-
$parcel$export(module.exports, "fetchDepictRecommendations", () => $b03e4eee8610ebbe$re_export$fetchDepictRecommendations);
|
|
30
30
|
$parcel$export(module.exports, "version", () => $db7b67857900028b$export$83d89fbfd8236492);
|
|
31
31
|
$parcel$export(module.exports, "Navigation", () => $b742053c966024b4$export$b8a61e5c71402559);
|
|
32
32
|
/*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
|
|
33
33
|
// Note, if you add an export here, also add one in src-server/main.ts
|
|
34
|
-
const $db7b67857900028b$export$83d89fbfd8236492 = "
|
|
34
|
+
const $db7b67857900028b$export$83d89fbfd8236492 = "1.0.3";
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
@@ -47,6 +47,8 @@ const $0b7cd4fb39fc3502$export$8e769ad4338a911e = {
|
|
|
47
47
|
category: null,
|
|
48
48
|
api: null,
|
|
49
49
|
dpc: null,
|
|
50
|
+
merchant: null,
|
|
51
|
+
market: null,
|
|
50
52
|
userId: undefined,
|
|
51
53
|
sessionId: undefined,
|
|
52
54
|
metaData: undefined,
|
|
@@ -64,6 +66,34 @@ const $0b7cd4fb39fc3502$export$8e769ad4338a911e = {
|
|
|
64
66
|
|
|
65
67
|
|
|
66
68
|
|
|
69
|
+
|
|
70
|
+
class $d7a14567b529586f$export$d0f82e3ef89b1f22 extends (0, $4GYXz$react.Component) {
|
|
71
|
+
constructor(props){
|
|
72
|
+
super(props);
|
|
73
|
+
this.state = {
|
|
74
|
+
hasError: false
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static getDerivedStateFromError() {
|
|
78
|
+
// Update state so the next render will show the fallback UI.
|
|
79
|
+
return {
|
|
80
|
+
hasError: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
componentDidCatch(error) {
|
|
84
|
+
this.props.on_error(error);
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
if (this.state.hasError) // You can render any custom fallback UI
|
|
88
|
+
return (0, $4GYXz$react.createElement)("div", {
|
|
89
|
+
children: "Component failed"
|
|
90
|
+
});
|
|
91
|
+
return this.props.children;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
67
97
|
let $b4d0d98857ed9934$var$run_on_href_change;
|
|
68
98
|
let $b4d0d98857ed9934$var$old_href = location.href;
|
|
69
99
|
function $b4d0d98857ed9934$export$74f3924c5027fe1d(cb) {
|
|
@@ -71,8 +101,7 @@ function $b4d0d98857ed9934$export$74f3924c5027fe1d(cb) {
|
|
|
71
101
|
}
|
|
72
102
|
(0, $4GYXz$depictaiutilishared.instant_exec_on_suspect_history_change).add((0, $4GYXz$depictaiutilishared.catchify)(()=>{
|
|
73
103
|
const { href: href } = location;
|
|
74
|
-
if (
|
|
75
|
-
$b4d0d98857ed9934$var$run_on_href_change?.(href);
|
|
104
|
+
if ($b4d0d98857ed9934$var$run_on_href_change && $b4d0d98857ed9934$var$old_href !== href) $b4d0d98857ed9934$var$run_on_href_change(href);
|
|
76
105
|
$b4d0d98857ed9934$var$old_href = href;
|
|
77
106
|
}));
|
|
78
107
|
const $b4d0d98857ed9934$export$775e6b3892b5ad52 = (url = location)=>url.pathname == (0, $4GYXz$solidjs.untrack)((0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search_page_path_[0]); // might have changed therefore get it from globalState
|
|
@@ -108,21 +137,31 @@ function $b4d0d98857ed9934$export$e5139bbbb9a05035(component, is_set = (0, $0b7c
|
|
|
108
137
|
}
|
|
109
138
|
async function $b4d0d98857ed9934$export$79c79419c1ef0081({ display: display , component_portals: component_portals , set_portals: set_portals , react_template: react_template }) {
|
|
110
139
|
let set_react_has_ran_hooks;
|
|
140
|
+
let was_cleaned_up = false;
|
|
111
141
|
const react_has_ran_hooks = new Promise((r)=>set_react_has_ran_hooks = r);
|
|
112
142
|
const solid_container = document.createElement("div");
|
|
143
|
+
const owner = (0, $4GYXz$solidjs.getOwner)();
|
|
113
144
|
const reactProductCard = (0, $4GYXz$reactjsxruntime.jsx)((props)=>{
|
|
114
|
-
// Sneak in a hook into their product card component
|
|
145
|
+
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
115
146
|
(0, $4GYXz$react.useEffect)(set_react_has_ran_hooks, []);
|
|
116
147
|
return react_template(props);
|
|
117
148
|
}, {
|
|
118
149
|
display: display
|
|
119
150
|
});
|
|
120
|
-
const
|
|
151
|
+
const reactProductCardInErrorBoundary = (0, $4GYXz$reactjsxruntime.jsx)((0, $d7a14567b529586f$export$d0f82e3ef89b1f22), {
|
|
152
|
+
children: reactProductCard,
|
|
153
|
+
on_error: (error)=>(0, $4GYXz$solidjs.runWithOwner)(owner, ()=>{
|
|
154
|
+
if (was_cleaned_up) return; // Would infinite loop if we'd throw after we've already been cleaned up. That is because the `ErrorBoundary` won't be "registered" with the cleaned-up owner anymore so react would hear about the throw and attempt to re-render the error boundary or something which would throw again, etc.
|
|
155
|
+
throw new (0, $4GYXz$depictaiui.ProductCardError)(error);
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
const portal = $4GYXz$reactdom.createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
121
159
|
component_portals.add(portal);
|
|
122
160
|
set_portals([
|
|
123
161
|
...component_portals
|
|
124
162
|
]);
|
|
125
163
|
(0, $4GYXz$solidjs.onCleanup)(()=>{
|
|
164
|
+
was_cleaned_up = true;
|
|
126
165
|
// this will stop working after any await so be careful to not await before this, or you'll have to carry the owner over with getOwner and runWithOwner
|
|
127
166
|
component_portals.delete(portal);
|
|
128
167
|
set_portals([
|
|
@@ -275,6 +314,8 @@ function $24b00503eef73528$export$9fac37a9c21c2f3b(props) {
|
|
|
275
314
|
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).userId = userId;
|
|
276
315
|
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).sessionId = sessionId;
|
|
277
316
|
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).metaData = metaData;
|
|
317
|
+
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).market = market;
|
|
318
|
+
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).merchant = merchant;
|
|
278
319
|
(0, $25c0a91312868994$export$47e064413edabf36)(merchant, market, userId, sessionId);
|
|
279
320
|
if (!market || !merchant) {
|
|
280
321
|
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).required_state_set_[1](false);
|
|
@@ -581,6 +622,26 @@ const $913da7f4d0bc77f2$export$9bb30bbe003b82e0 = (props)=>{
|
|
|
581
622
|
|
|
582
623
|
|
|
583
624
|
|
|
625
|
+
function $a134ea100690b628$export$6501da23a2770fc() {
|
|
626
|
+
return {
|
|
627
|
+
fetchRecommendations: $a134ea100690b628$var$fetchRecommendations
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
function $a134ea100690b628$var$fetchRecommendations(opts) {
|
|
631
|
+
const { merchant: merchant , market: market , userId: userId , sessionId: sessionId } = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e);
|
|
632
|
+
if (!merchant || !market) throw new Error("Depict recommendations are not configured. Wrap your app in a DepictProvider.");
|
|
633
|
+
return (0, $4GYXz$depictaiui.fetchDepictRecommendations)({
|
|
634
|
+
merchant: merchant,
|
|
635
|
+
market: market,
|
|
636
|
+
userId: userId,
|
|
637
|
+
sessionId: sessionId,
|
|
638
|
+
...opts
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
584
645
|
|
|
585
646
|
|
|
586
647
|
const $e387bd534de10acd$export$804fac5697cfbe35 = (router)=>(relativeUrl)=>{
|
package/dist/module.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {add_to_version_info as $TZSbU$add_to_version_info, catchify as $TZSbU$catchify, queueMacroTask as $TZSbU$queueMacroTask, instant_exec_on_suspect_history_change as $TZSbU$instant_exec_on_suspect_history_change, ContainedPlaceholderImage as $TZSbU$ContainedPlaceholderImage, Placeholder as $TZSbU$Placeholder} from "@depict-ai/utilishared";
|
|
2
|
-
import {CategoryTitle as $43099132aad1ceb6$re_export$CategoryTitle, embedded_num_products as $43099132aad1ceb6$re_export$EmbeddedNumProducts,
|
|
3
|
-
import {createRoot as $TZSbU$createRoot, untrack as $TZSbU$untrack, createEffect as $TZSbU$createEffect, createComponent as $TZSbU$createComponent, Show as $TZSbU$Show, onCleanup as $TZSbU$onCleanup, createSignal as $TZSbU$createSignal, createComputed as $TZSbU$createComputed, createMemo as $TZSbU$createMemo} from "solid-js";
|
|
4
|
-
import {createElement as $TZSbU$createElement, Fragment as $TZSbU$Fragment, useState as $TZSbU$useState, useRef as $TZSbU$useRef, useEffect as $TZSbU$useEffect, forwardRef as $TZSbU$forwardRef} from "react";
|
|
2
|
+
import {CategoryTitle as $43099132aad1ceb6$re_export$CategoryTitle, embedded_num_products as $43099132aad1ceb6$re_export$EmbeddedNumProducts, DepictAPI as $TZSbU$DepictAPI, DepictSearch as $TZSbU$DepictSearch, DepictCategory as $TZSbU$DepictCategory, ProductCardError as $TZSbU$ProductCardError, get_search_query_updating_blocked_signal as $TZSbU$get_search_query_updating_blocked_signal, SearchPage as $TZSbU$SearchPage, CategoryPage as $TZSbU$CategoryPage, BreadCrumbs as $TZSbU$BreadCrumbs, QuickLinks as $TZSbU$QuickLinks, open_modal_with_alignment as $TZSbU$open_modal_with_alignment, SearchField as $TZSbU$SearchField, fetchDepictRecommendations as $TZSbU$fetchDepictRecommendations} from "@depict-ai/ui";
|
|
3
|
+
import {createRoot as $TZSbU$createRoot, untrack as $TZSbU$untrack, createEffect as $TZSbU$createEffect, createComponent as $TZSbU$createComponent, Show as $TZSbU$Show, getOwner as $TZSbU$getOwner, runWithOwner as $TZSbU$runWithOwner, onCleanup as $TZSbU$onCleanup, createSignal as $TZSbU$createSignal, createComputed as $TZSbU$createComputed, createMemo as $TZSbU$createMemo} from "solid-js";
|
|
4
|
+
import {createElement as $TZSbU$createElement, Fragment as $TZSbU$Fragment, useState as $TZSbU$useState, useRef as $TZSbU$useRef, useEffect as $TZSbU$useEffect, Component as $TZSbU$Component, forwardRef as $TZSbU$forwardRef} from "react";
|
|
5
5
|
import {en as $TZSbU$en} from "@depict-ai/ui/locales";
|
|
6
6
|
import {render as $TZSbU$render} from "solid-js/web";
|
|
7
7
|
import {jsx as $TZSbU$jsx} from "react/jsx-runtime";
|
|
@@ -11,7 +11,7 @@ import {DPC as $TZSbU$DPC} from "@depict-ai/dpc";
|
|
|
11
11
|
|
|
12
12
|
/*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
|
|
13
13
|
// Note, if you add an export here, also add one in src-server/main.ts
|
|
14
|
-
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "
|
|
14
|
+
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "1.0.3";
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -27,6 +27,8 @@ const $42858f023ef23dab$export$8e769ad4338a911e = {
|
|
|
27
27
|
category: null,
|
|
28
28
|
api: null,
|
|
29
29
|
dpc: null,
|
|
30
|
+
merchant: null,
|
|
31
|
+
market: null,
|
|
30
32
|
userId: undefined,
|
|
31
33
|
sessionId: undefined,
|
|
32
34
|
metaData: undefined,
|
|
@@ -44,6 +46,34 @@ const $42858f023ef23dab$export$8e769ad4338a911e = {
|
|
|
44
46
|
|
|
45
47
|
|
|
46
48
|
|
|
49
|
+
|
|
50
|
+
class $d5c9e1f3545b4984$export$d0f82e3ef89b1f22 extends (0, $TZSbU$Component) {
|
|
51
|
+
constructor(props){
|
|
52
|
+
super(props);
|
|
53
|
+
this.state = {
|
|
54
|
+
hasError: false
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
static getDerivedStateFromError() {
|
|
58
|
+
// Update state so the next render will show the fallback UI.
|
|
59
|
+
return {
|
|
60
|
+
hasError: true
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
componentDidCatch(error) {
|
|
64
|
+
this.props.on_error(error);
|
|
65
|
+
}
|
|
66
|
+
render() {
|
|
67
|
+
if (this.state.hasError) // You can render any custom fallback UI
|
|
68
|
+
return (0, $TZSbU$createElement)("div", {
|
|
69
|
+
children: "Component failed"
|
|
70
|
+
});
|
|
71
|
+
return this.props.children;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
47
77
|
let $c83ba9ab79386687$var$run_on_href_change;
|
|
48
78
|
let $c83ba9ab79386687$var$old_href = location.href;
|
|
49
79
|
function $c83ba9ab79386687$export$74f3924c5027fe1d(cb) {
|
|
@@ -51,8 +81,7 @@ function $c83ba9ab79386687$export$74f3924c5027fe1d(cb) {
|
|
|
51
81
|
}
|
|
52
82
|
(0, $TZSbU$instant_exec_on_suspect_history_change).add((0, $TZSbU$catchify)(()=>{
|
|
53
83
|
const { href: href } = location;
|
|
54
|
-
if (
|
|
55
|
-
$c83ba9ab79386687$var$run_on_href_change?.(href);
|
|
84
|
+
if ($c83ba9ab79386687$var$run_on_href_change && $c83ba9ab79386687$var$old_href !== href) $c83ba9ab79386687$var$run_on_href_change(href);
|
|
56
85
|
$c83ba9ab79386687$var$old_href = href;
|
|
57
86
|
}));
|
|
58
87
|
const $c83ba9ab79386687$export$775e6b3892b5ad52 = (url = location)=>url.pathname == (0, $TZSbU$untrack)((0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_[0]); // might have changed therefore get it from globalState
|
|
@@ -88,21 +117,31 @@ function $c83ba9ab79386687$export$e5139bbbb9a05035(component, is_set = (0, $4285
|
|
|
88
117
|
}
|
|
89
118
|
async function $c83ba9ab79386687$export$79c79419c1ef0081({ display: display , component_portals: component_portals , set_portals: set_portals , react_template: react_template }) {
|
|
90
119
|
let set_react_has_ran_hooks;
|
|
120
|
+
let was_cleaned_up = false;
|
|
91
121
|
const react_has_ran_hooks = new Promise((r)=>set_react_has_ran_hooks = r);
|
|
92
122
|
const solid_container = document.createElement("div");
|
|
123
|
+
const owner = (0, $TZSbU$getOwner)();
|
|
93
124
|
const reactProductCard = (0, $TZSbU$jsx)((props)=>{
|
|
94
|
-
// Sneak in a hook into their product card component
|
|
125
|
+
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
95
126
|
(0, $TZSbU$useEffect)(set_react_has_ran_hooks, []);
|
|
96
127
|
return react_template(props);
|
|
97
128
|
}, {
|
|
98
129
|
display: display
|
|
99
130
|
});
|
|
100
|
-
const
|
|
131
|
+
const reactProductCardInErrorBoundary = (0, $TZSbU$jsx)((0, $d5c9e1f3545b4984$export$d0f82e3ef89b1f22), {
|
|
132
|
+
children: reactProductCard,
|
|
133
|
+
on_error: (error)=>(0, $TZSbU$runWithOwner)(owner, ()=>{
|
|
134
|
+
if (was_cleaned_up) return; // Would infinite loop if we'd throw after we've already been cleaned up. That is because the `ErrorBoundary` won't be "registered" with the cleaned-up owner anymore so react would hear about the throw and attempt to re-render the error boundary or something which would throw again, etc.
|
|
135
|
+
throw new (0, $TZSbU$ProductCardError)(error);
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
const portal = $TZSbU$createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
101
139
|
component_portals.add(portal);
|
|
102
140
|
set_portals([
|
|
103
141
|
...component_portals
|
|
104
142
|
]);
|
|
105
143
|
(0, $TZSbU$onCleanup)(()=>{
|
|
144
|
+
was_cleaned_up = true;
|
|
106
145
|
// this will stop working after any await so be careful to not await before this, or you'll have to carry the owner over with getOwner and runWithOwner
|
|
107
146
|
component_portals.delete(portal);
|
|
108
147
|
set_portals([
|
|
@@ -255,6 +294,8 @@ function $5376eb2a386cd90d$export$9fac37a9c21c2f3b(props) {
|
|
|
255
294
|
(0, $42858f023ef23dab$export$8e769ad4338a911e).userId = userId;
|
|
256
295
|
(0, $42858f023ef23dab$export$8e769ad4338a911e).sessionId = sessionId;
|
|
257
296
|
(0, $42858f023ef23dab$export$8e769ad4338a911e).metaData = metaData;
|
|
297
|
+
(0, $42858f023ef23dab$export$8e769ad4338a911e).market = market;
|
|
298
|
+
(0, $42858f023ef23dab$export$8e769ad4338a911e).merchant = merchant;
|
|
258
299
|
(0, $a00d8f27abd5d0b0$export$47e064413edabf36)(merchant, market, userId, sessionId);
|
|
259
300
|
if (!market || !merchant) {
|
|
260
301
|
(0, $42858f023ef23dab$export$8e769ad4338a911e).required_state_set_[1](false);
|
|
@@ -561,6 +602,26 @@ const $2b886cf548a4775c$export$9bb30bbe003b82e0 = (props)=>{
|
|
|
561
602
|
|
|
562
603
|
|
|
563
604
|
|
|
605
|
+
function $1bb4271dc44722e2$export$6501da23a2770fc() {
|
|
606
|
+
return {
|
|
607
|
+
fetchRecommendations: $1bb4271dc44722e2$var$fetchRecommendations
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
function $1bb4271dc44722e2$var$fetchRecommendations(opts) {
|
|
611
|
+
const { merchant: merchant , market: market , userId: userId , sessionId: sessionId } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
|
|
612
|
+
if (!merchant || !market) throw new Error("Depict recommendations are not configured. Wrap your app in a DepictProvider.");
|
|
613
|
+
return (0, $TZSbU$fetchDepictRecommendations)({
|
|
614
|
+
merchant: merchant,
|
|
615
|
+
market: market,
|
|
616
|
+
userId: userId,
|
|
617
|
+
sessionId: sessionId,
|
|
618
|
+
...opts
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
564
625
|
|
|
565
626
|
|
|
566
627
|
const $a92aa2beb560b8af$export$804fac5697cfbe35 = (router)=>(relativeUrl)=>{
|
|
@@ -588,4 +649,4 @@ const $97603d19204ec48d$export$b8a61e5c71402559 = {
|
|
|
588
649
|
(0, $TZSbU$add_to_version_info)("react-ui", (0, $c9c4d066f9a5b51b$export$83d89fbfd8236492));
|
|
589
650
|
|
|
590
651
|
|
|
591
|
-
export {$b68a14248b7ef667$export$466cdc317043f6cb as QuickLinks, $f866f7ed9f751af4$export$5646050d516e06bc as BreadCrumbs, $421f32789b6f111f$export$80e99ee6b29cadd2 as ComponentAligner, $5376eb2a386cd90d$export$9fac37a9c21c2f3b as DepictProvider, $48d7f568740a317d$export$f7d2f673fc2f091d as CategoryPage, $4a678f0c87b12e78$export$a54ec244c8863715 as SearchPage, $f446a84f85ba06f6$export$3f37af283f8fb843 as ImagePlaceholder, $cbd250061abf11cb$export$89c6019e4baa40b1 as TextPlaceholder, $70344e5e0d0fea06$export$912994940e660d32 as useSearchModal, $2b886cf548a4775c$export$9bb30bbe003b82e0 as useSearchField, $
|
|
652
|
+
export {$b68a14248b7ef667$export$466cdc317043f6cb as QuickLinks, $f866f7ed9f751af4$export$5646050d516e06bc as BreadCrumbs, $421f32789b6f111f$export$80e99ee6b29cadd2 as ComponentAligner, $5376eb2a386cd90d$export$9fac37a9c21c2f3b as DepictProvider, $48d7f568740a317d$export$f7d2f673fc2f091d as CategoryPage, $4a678f0c87b12e78$export$a54ec244c8863715 as SearchPage, $f446a84f85ba06f6$export$3f37af283f8fb843 as ImagePlaceholder, $cbd250061abf11cb$export$89c6019e4baa40b1 as TextPlaceholder, $70344e5e0d0fea06$export$912994940e660d32 as useSearchModal, $2b886cf548a4775c$export$9bb30bbe003b82e0 as useSearchField, $1bb4271dc44722e2$export$6501da23a2770fc as useFetchRecommendations, $a00d8f27abd5d0b0$export$38b98fae14bd1f64 as usePerformanceClient, $43099132aad1ceb6$re_export$CategoryTitle as CategoryTitle, $43099132aad1ceb6$re_export$EmbeddedNumProducts as EmbeddedNumProducts, $c9c4d066f9a5b51b$export$83d89fbfd8236492 as version, $97603d19204ec48d$export$b8a61e5c71402559 as Navigation};
|
package/dist-server/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
2
|
import { DPC } from "@depict-ai/dpc";
|
|
3
|
+
import { fetchDepictRecommendations, ExclusiveId } from "@depict-ai/ui";
|
|
4
|
+
import { Display } from "@depict-ai/utilishared";
|
|
3
5
|
type OpenModal = () => void;
|
|
4
6
|
interface UseSearchModalReturn {
|
|
5
7
|
open: OpenModal;
|
|
@@ -13,8 +15,25 @@ interface UseSearchFieldReturn {
|
|
|
13
15
|
interface UsePerformanceClientReturn {
|
|
14
16
|
dpc: DPC;
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
type FetchRecsOptions = Omit<Parameters<typeof fetchDepictRecommendations>[0], "merchant" | "market" | "userId" | "sessionId"> & ExclusiveId;
|
|
19
|
+
interface UseFetchRecommendationsReturn<T extends Display> {
|
|
20
|
+
/**
|
|
21
|
+
* Fetch recommendations from the Depict API.
|
|
22
|
+
* @example
|
|
23
|
+
* General recommendations for a landing page:
|
|
24
|
+
* ```tsx
|
|
25
|
+
* fetchRecommendations({ type: "landing_page" });
|
|
26
|
+
* ```
|
|
27
|
+
* @example
|
|
28
|
+
* Fetch targeted recommendations for a product details page (PDP):
|
|
29
|
+
* ```tsx
|
|
30
|
+
* fetchRecommendations({ type: "related", productId: "t-shirt-white" })
|
|
31
|
+
* ```
|
|
32
|
+
* @returns {Promise<T[]>}
|
|
33
|
+
*/
|
|
34
|
+
fetchRecommendations: (opts: FetchRecsOptions) => Promise<T[]>;
|
|
35
|
+
}
|
|
36
|
+
export const version = "1.0.3";
|
|
18
37
|
export function DepictProvider(props: any): any;
|
|
19
38
|
export function SearchPage(): any;
|
|
20
39
|
export function CategoryPage(): any;
|
|
@@ -32,3 +51,4 @@ export function useSearchField(): UseSearchFieldReturn;
|
|
|
32
51
|
export function openModal(): void;
|
|
33
52
|
export function useSearchModal(): UseSearchModalReturn;
|
|
34
53
|
export function usePerformanceClient(): UsePerformanceClientReturn;
|
|
54
|
+
export function useFetchRecommendations<T extends Display>(): UseFetchRecommendationsReturn<T>;
|
package/dist-server/main.js
CHANGED
|
@@ -5,7 +5,6 @@ function $parcel$export(e, n, v, s) {
|
|
|
5
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
$parcel$export(module.exports, "fetchDepictRecommendations", () => $41e7e5d85b5e0d49$export$58e808b1db15d3bc);
|
|
9
8
|
$parcel$export(module.exports, "DepictProvider", () => $41e7e5d85b5e0d49$export$9fac37a9c21c2f3b);
|
|
10
9
|
$parcel$export(module.exports, "SearchPage", () => $41e7e5d85b5e0d49$export$a54ec244c8863715);
|
|
11
10
|
$parcel$export(module.exports, "CategoryPage", () => $41e7e5d85b5e0d49$export$f7d2f673fc2f091d);
|
|
@@ -18,15 +17,13 @@ $parcel$export(module.exports, "useSearchField", () => $41e7e5d85b5e0d49$export$
|
|
|
18
17
|
$parcel$export(module.exports, "openModal", () => $41e7e5d85b5e0d49$export$a7f6cffb6b8ba11c);
|
|
19
18
|
$parcel$export(module.exports, "useSearchModal", () => $41e7e5d85b5e0d49$export$912994940e660d32);
|
|
20
19
|
$parcel$export(module.exports, "usePerformanceClient", () => $41e7e5d85b5e0d49$export$38b98fae14bd1f64);
|
|
20
|
+
$parcel$export(module.exports, "useFetchRecommendations", () => $41e7e5d85b5e0d49$export$6501da23a2770fc);
|
|
21
21
|
$parcel$export(module.exports, "version", () => $db7b67857900028b$export$83d89fbfd8236492);
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
const $db7b67857900028b$export$83d89fbfd8236492 = "
|
|
24
|
+
const $db7b67857900028b$export$83d89fbfd8236492 = "1.0.3";
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
const $41e7e5d85b5e0d49$export$58e808b1db15d3bc = ()=>{
|
|
28
|
-
throw new Error("fetchDepictRecommendations is currently not available on the server due to personalisation/user_id related issues. Please only call it on the client");
|
|
29
|
-
};
|
|
30
27
|
function $41e7e5d85b5e0d49$export$9fac37a9c21c2f3b(props) {
|
|
31
28
|
return props.children;
|
|
32
29
|
}
|
|
@@ -94,5 +91,12 @@ function $41e7e5d85b5e0d49$export$38b98fae14bd1f64() {
|
|
|
94
91
|
dpc: new Proxy({}, mock)
|
|
95
92
|
};
|
|
96
93
|
}
|
|
94
|
+
function $41e7e5d85b5e0d49$export$6501da23a2770fc() {
|
|
95
|
+
return {
|
|
96
|
+
fetchRecommendations: ()=>{
|
|
97
|
+
throw new Error("fetchRecommendations is currently not available on the server due to personalisation/user_id related issues. Please only call it on the client.");
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
97
101
|
|
|
98
102
|
|
package/dist-server/module.js
CHANGED
|
@@ -3,12 +3,9 @@ import {jsx as $1RlIW$jsx} from "react/jsx-runtime";
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "
|
|
6
|
+
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "1.0.3";
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
const $2b1fdeb83610500f$export$58e808b1db15d3bc = ()=>{
|
|
10
|
-
throw new Error("fetchDepictRecommendations is currently not available on the server due to personalisation/user_id related issues. Please only call it on the client");
|
|
11
|
-
};
|
|
12
9
|
function $2b1fdeb83610500f$export$9fac37a9c21c2f3b(props) {
|
|
13
10
|
return props.children;
|
|
14
11
|
}
|
|
@@ -76,6 +73,13 @@ function $2b1fdeb83610500f$export$38b98fae14bd1f64() {
|
|
|
76
73
|
dpc: new Proxy({}, mock)
|
|
77
74
|
};
|
|
78
75
|
}
|
|
76
|
+
function $2b1fdeb83610500f$export$6501da23a2770fc() {
|
|
77
|
+
return {
|
|
78
|
+
fetchRecommendations: ()=>{
|
|
79
|
+
throw new Error("fetchRecommendations is currently not available on the server due to personalisation/user_id related issues. Please only call it on the client.");
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
79
83
|
|
|
80
84
|
|
|
81
|
-
export {$2b1fdeb83610500f$export$
|
|
85
|
+
export {$2b1fdeb83610500f$export$9fac37a9c21c2f3b as DepictProvider, $2b1fdeb83610500f$export$a54ec244c8863715 as SearchPage, $2b1fdeb83610500f$export$f7d2f673fc2f091d as CategoryPage, $2b1fdeb83610500f$export$5646050d516e06bc as BreadCrumbs, $2b1fdeb83610500f$export$466cdc317043f6cb as QuickLinks, $2b1fdeb83610500f$export$80e99ee6b29cadd2 as ComponentAligner, $2b1fdeb83610500f$export$3f37af283f8fb843 as ImagePlaceholder, $2b1fdeb83610500f$export$89c6019e4baa40b1 as TextPlaceholder, $2b1fdeb83610500f$export$9bb30bbe003b82e0 as useSearchField, $2b1fdeb83610500f$export$a7f6cffb6b8ba11c as openModal, $2b1fdeb83610500f$export$912994940e660d32 as useSearchModal, $2b1fdeb83610500f$export$38b98fae14bd1f64 as usePerformanceClient, $2b1fdeb83610500f$export$6501da23a2770fc as useFetchRecommendations, $c9c4d066f9a5b51b$export$83d89fbfd8236492 as version};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depict-ai/react-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"packageManager": "yarn@3.2.2",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -96,10 +96,10 @@
|
|
|
96
96
|
"/locales"
|
|
97
97
|
],
|
|
98
98
|
"dependencies": {
|
|
99
|
-
"@depict-ai/dpc": "^1.0.
|
|
100
|
-
"@depict-ai/plp-styling": "^1.0.
|
|
101
|
-
"@depict-ai/ui": "^1.0.
|
|
102
|
-
"@depict-ai/utilishared": "^1.0.
|
|
99
|
+
"@depict-ai/dpc": "^1.0.4",
|
|
100
|
+
"@depict-ai/plp-styling": "^1.0.5",
|
|
101
|
+
"@depict-ai/ui": "^1.0.5",
|
|
102
|
+
"@depict-ai/utilishared": "^1.0.4",
|
|
103
103
|
"solid-js": "^1.7.3"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"@babel/preset-typescript": "latest",
|
|
113
113
|
"@babel/runtime": "latest",
|
|
114
114
|
"@babel/runtime-corejs3": "latest",
|
|
115
|
-
"@depict-ai/plp-styling": "^1.0.
|
|
115
|
+
"@depict-ai/plp-styling": "^1.0.5",
|
|
116
116
|
"@jest/globals": "^29.3.1",
|
|
117
117
|
"@parcel/babel-preset-env": "latest",
|
|
118
118
|
"@parcel/resolver-default": "^2.8.0",
|