Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 203d8e8

Browse files
committed
Get rollup working with react-sdk
1 parent 0224dcb commit 203d8e8

27 files changed

+3226
-96
lines changed

packages/js-web-sdk/packages/react-example-ts/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
OptimizelyExperiment,
1111
OptimizelyVariation,
1212
withOptimizely,
13-
initialize
1413
} from '@optimizely/react-sdk'
1514

1615
import { OptimizelySDKWrapper } from '@optimizely/js-web-sdk'

packages/js-web-sdk/packages/react-example-ts/src/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import * as optimizelyReactSdk from '@optimizely/react-sdk'
1010
userId: 'user' + Date.now(),
1111
sdkKey: 'BsSyVRsUbE3ExgGCJ9w1to',
1212
})
13-
console.log('passing optimizely')
1413

1514
ReactDOM.render(
1615
<App optimizely={optimizely} />,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.rpt2_cache
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export declare const OptimizelyContextConsumer: any;
2+
export declare const OptimizelyContextProvider: any;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import * as React from 'react';
2+
import { WithOptimizelyProps } from './withOptimizely';
3+
import { VariableValuesObject } from '@optimizely/js-web-sdk';
4+
export declare type ChildrenRenderFunction = (variableValues: VariableValuesObject) => React.ReactNode;
5+
declare type ChildRenderFunction = (variation: string | null) => React.ReactNode;
6+
export interface ExperimentProps extends WithOptimizelyProps {
7+
experiment: string;
8+
children: React.ReactNode | ChildRenderFunction;
9+
}
10+
export interface ExperimentState {
11+
canRender: boolean;
12+
variation: string | null;
13+
}
14+
export declare class Experiment extends React.Component<ExperimentProps, ExperimentState> {
15+
constructor(props: ExperimentProps);
16+
componentDidMount(): void;
17+
render(): {} | null | undefined;
18+
}
19+
export declare const OptimizelyExperiment: {
20+
new (props: Readonly<Pick<ExperimentProps, "children" | "experiment">>): {
21+
render(): JSX.Element;
22+
context: any;
23+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<Pick<ExperimentProps, "children" | "experiment">>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
24+
forceUpdate(callBack?: (() => void) | undefined): void;
25+
readonly props: Readonly<{
26+
children?: React.ReactNode;
27+
}> & Readonly<Pick<ExperimentProps, "children" | "experiment">>;
28+
state: Readonly<{}>;
29+
refs: {
30+
[key: string]: React.ReactInstance;
31+
};
32+
};
33+
new (props: Pick<ExperimentProps, "children" | "experiment">, context?: any): {
34+
render(): JSX.Element;
35+
context: any;
36+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<Pick<ExperimentProps, "children" | "experiment">>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
37+
forceUpdate(callBack?: (() => void) | undefined): void;
38+
readonly props: Readonly<{
39+
children?: React.ReactNode;
40+
}> & Readonly<Pick<ExperimentProps, "children" | "experiment">>;
41+
state: Readonly<{}>;
42+
refs: {
43+
[key: string]: React.ReactInstance;
44+
};
45+
};
46+
contextType?: React.Context<any> | undefined;
47+
};
48+
export {};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import * as React from 'react';
2+
import { WithOptimizelyProps } from './withOptimizely';
3+
import { VariableValuesObject } from '@optimizely/js-web-sdk';
4+
export interface FeatureProps extends WithOptimizelyProps {
5+
feature: string;
6+
children: (isEnabled: boolean, variables: VariableValuesObject) => React.ReactNode;
7+
}
8+
export interface FeatureState {
9+
canRender: boolean;
10+
isEnabled: boolean;
11+
variables: VariableValuesObject;
12+
}
13+
export declare const OptimizelyFeature: {
14+
new (props: Readonly<Pick<FeatureProps, "children" | "feature">>): {
15+
render(): JSX.Element;
16+
context: any;
17+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<Pick<FeatureProps, "children" | "feature">>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
18+
forceUpdate(callBack?: (() => void) | undefined): void;
19+
readonly props: Readonly<{
20+
children?: React.ReactNode;
21+
}> & Readonly<Pick<FeatureProps, "children" | "feature">>;
22+
state: Readonly<{}>;
23+
refs: {
24+
[key: string]: React.ReactInstance;
25+
};
26+
};
27+
new (props: Pick<FeatureProps, "children" | "feature">, context?: any): {
28+
render(): JSX.Element;
29+
context: any;
30+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<Pick<FeatureProps, "children" | "feature">>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
31+
forceUpdate(callBack?: (() => void) | undefined): void;
32+
readonly props: Readonly<{
33+
children?: React.ReactNode;
34+
}> & Readonly<Pick<FeatureProps, "children" | "feature">>;
35+
state: Readonly<{}>;
36+
refs: {
37+
[key: string]: React.ReactInstance;
38+
};
39+
};
40+
contextType?: React.Context<any> | undefined;
41+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as React from 'react';
2+
import { OptimizelySDKWrapper } from '@optimizely/js-web-sdk';
3+
interface OptimizelyProviderProps {
4+
optimizely: OptimizelySDKWrapper;
5+
timeout: number;
6+
}
7+
interface OptimizelyProviderState {
8+
userId: string;
9+
attributes: {
10+
[key: string]: string;
11+
} | undefined;
12+
}
13+
export declare class OptimizelyProvider extends React.Component<OptimizelyProviderProps, OptimizelyProviderState> {
14+
sdkWrapper: OptimizelySDKWrapper;
15+
static defaultProps: {
16+
timeout: number;
17+
};
18+
constructor(props: OptimizelyProviderProps);
19+
render(): JSX.Element;
20+
}
21+
export {};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
export declare type VariationProps = {
3+
variation?: any;
4+
default?: any;
5+
children?: React.ReactNode;
6+
};
7+
declare class Variation extends React.Component<VariationProps, {}> {
8+
render(): React.ReactNode;
9+
}
10+
export declare const OptimizelyVariation: typeof Variation;
11+
export {};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { OptimizelyProvider } from './Provider';
2+
export { OptimizelyFeature } from './Feature';
3+
export { withOptimizely } from './withOptimizely';
4+
export { OptimizelyExperiment } from './Experiment';
5+
export { OptimizelyVariation } from './Variation';

0 commit comments

Comments
 (0)