@@ -13,10 +13,9 @@ import canonicalJSON from "canonical-json";
1313import {
1414 BucketClient ,
1515 BucketContext ,
16- FeedbackOptions ,
16+ InitOptions ,
1717 RawFeatures ,
1818 RequestFeedbackData ,
19- ToolbarOptions ,
2019 UnassignedFeedback ,
2120} from "@bucketco/browser-sdk" ;
2221
@@ -51,60 +50,45 @@ const ProviderContext = createContext<ProviderContextType>({
5150 } ,
5251} ) ;
5352
54- export type BucketProps = BucketContext & {
55- publishableKey : string ;
56-
57- children ?: ReactNode ;
58- loadingComponent ?: ReactNode ;
59- feedback ?: FeedbackOptions ;
60-
61- apiBaseUrl ?: string ;
62- appBaseUrl ?: string ;
63-
64- sseBaseUrl ?: string ;
65- debug ?: boolean ;
66- enableTracking ?: boolean ;
67-
68- features ?: Readonly < string [ ] > ;
69-
70- fallbackFeatures ?: FeatureKey [ ] | Record < FeatureKey , any > ;
71-
72- /**
73- * Timeout in milliseconds when fetching features
74- */
75- timeoutMs ?: number ;
76-
77- /**
78- * If set to true stale features will be returned while refetching features
79- */
80- staleWhileRevalidate ?: boolean ;
81-
82- /**
83- * If set, features will be cached between page loads for this duration
84- */
85- expireTimeMs ?: number ;
86-
87- /**
88- * Stale features will be returned if staleWhileRevalidate is true if no new features can be fetched
89- */
90- staleTimeMs ?: number ;
91-
92- toolbar ?: ToolbarOptions ;
93-
94- // for testing
95- newBucketClient ?: (
96- ...args : ConstructorParameters < typeof BucketClient >
97- ) => BucketClient ;
98- } ;
53+ /**
54+ * Props for the BucketProvider.
55+ */
56+ export type BucketProps = BucketContext &
57+ InitOptions & {
58+ /**
59+ * Children to be rendered.
60+ */
61+ children ?: ReactNode ;
62+
63+ /**
64+ * Loading component to be rendered while features are loading.
65+ */
66+ loadingComponent ?: ReactNode ;
67+
68+ /**
69+ * Whether to enable debug mode (optional).
70+ */
71+ debug ?: boolean ;
72+
73+ /**
74+ * New BucketClient constructor.
75+ *
76+ * @internal
77+ */
78+ newBucketClient ?: (
79+ ...args : ConstructorParameters < typeof BucketClient >
80+ ) => BucketClient ;
81+ } ;
9982
83+ /**
84+ * Provider for the BucketClient.
85+ */
10086export function BucketProvider ( {
10187 children,
10288 user,
10389 company,
10490 otherContext,
105- publishableKey,
10691 loadingComponent,
107- features,
10892 newBucketClient = ( ...args ) => new BucketClient ( ...args ) ,
10993 ...config
11094} : BucketProps ) {
@@ -131,29 +115,15 @@ export function BucketProvider({
131115 }
132116
133117 const client = newBucketClient ( {
134- publishableKey ,
118+ ... config ,
135119 user,
136120 company,
137121 otherContext,
138122
139- apiBaseUrl : config . apiBaseUrl ,
140- appBaseUrl : config . appBaseUrl ,
141- sseBaseUrl : config . sseBaseUrl ,
142-
143- enableTracking : config . enableTracking ,
144-
145- staleTimeMs : config . staleTimeMs ,
146- expireTimeMs : config . expireTimeMs ,
147- timeoutMs : config . timeoutMs ,
148- staleWhileRevalidate : config . staleWhileRevalidate ,
149- fallbackFeatures : config . fallbackFeatures ,
150-
151- feedback : config . feedback ,
152123 logger : config . debug ? console : undefined ,
153124 sdkVersion : SDK_VERSION ,
154- features,
155- toolbar : config . toolbar ,
156125 } ) ;
126+
157127 clientRef . current = client ;
158128
159129 client . onFeaturesUpdated ( ( ) => {
0 commit comments