@ninetailed/experience.js-react 3.0.1-beta.3 → 3.0.2-beta.0
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/index.cjs +2980 -0
- package/{index.esm.js → index.js} +1404 -1254
- package/lib/Experience/ESRLoadingComponent.d.ts +4 -3
- package/lib/Experience/Experience.d.ts +11 -11
- package/lib/Experience/ExperimentsContext.d.ts +7 -4
- package/lib/Experience/ExperimentsProvider.d.ts +7 -6
- package/lib/Experience/TrackExperience.d.ts +1 -1
- package/lib/Experience/index.d.ts +6 -1
- package/lib/Experience/types/Baseline.d.ts +1 -1
- package/lib/Experience/types/BaselineWithVariants.d.ts +2 -2
- package/lib/Experience/types/Variant.d.ts +0 -1
- package/lib/Experience/useExperiementsContext.d.ts +4 -0
- package/lib/Experience/useExperience.d.ts +7 -7
- package/lib/Experience/useExperiments.d.ts +1 -1
- package/lib/Experience/useJoinExperiment.d.ts +1 -10
- package/lib/Experience/useProvideJoinExperiment.d.ts +13 -0
- package/lib/NinetailedContext.d.ts +1 -0
- package/lib/NinetailedProvider.d.ts +3 -2
- package/lib/Personalize.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/useProfile.d.ts +2 -2
- package/package.json +10 -15
- package/index.umd.js +0 -2362
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { ExperienceBaseProps } from './Experience';
|
|
3
|
+
import { Reference } from '@ninetailed/experience.js';
|
|
3
4
|
declare type ESRContextValue = {
|
|
4
5
|
experienceVariantsMap: Record<string, number>;
|
|
5
6
|
};
|
|
@@ -7,9 +8,9 @@ export declare const ESRContext: React.Context<ESRContextValue | undefined>;
|
|
|
7
8
|
declare type ESRProviderProps = {
|
|
8
9
|
experienceVariantsMap: Record<string, number>;
|
|
9
10
|
};
|
|
10
|
-
export declare const ESRProvider: React.FC<ESRProviderProps
|
|
11
|
+
export declare const ESRProvider: React.FC<PropsWithChildren<ESRProviderProps>>;
|
|
11
12
|
export declare const useESR: () => {
|
|
12
13
|
experienceVariantsMap: Record<string, number>;
|
|
13
14
|
};
|
|
14
|
-
export declare const ESRLoadingComponent: <P extends Record<string, unknown
|
|
15
|
+
export declare const ESRLoadingComponent: <P extends Record<string, unknown> & Reference>({ experiences, component: Component, passthroughProps, ...baseline }: ExperienceBaseProps<P, Partial<P>, Pick<P, Exclude<keyof P, keyof P>> & Reference>) => JSX.Element;
|
|
15
16
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Baseline, ExperienceConfiguration } from '@ninetailed/experience.js';
|
|
2
|
+
import { Baseline, ExperienceConfiguration, Reference } from '@ninetailed/experience.js';
|
|
3
3
|
export declare type ExperienceComponent<P> = React.ComponentType<Omit<P, 'id'> & {
|
|
4
4
|
ninetailed?: {
|
|
5
5
|
isPersonalized: boolean;
|
|
@@ -8,20 +8,20 @@ export declare type ExperienceComponent<P> = React.ComponentType<Omit<P, 'id'> &
|
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
}>;
|
|
11
|
-
export declare type ExperienceBaseProps<P, PassThroughProps extends Partial<P>> = Baseline<Pick<P, Exclude<keyof P, keyof PassThroughProps>>> & {
|
|
12
|
-
experiences: ExperienceConfiguration[];
|
|
13
|
-
component:
|
|
11
|
+
export declare type ExperienceBaseProps<P, PassThroughProps extends Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = Baseline<Pick<P, Exclude<keyof P, keyof PassThroughProps>>> & {
|
|
12
|
+
experiences: ExperienceConfiguration<Variant>[];
|
|
13
|
+
component: React.ComponentType<P>;
|
|
14
14
|
passthroughProps?: PassThroughProps;
|
|
15
15
|
};
|
|
16
|
-
export declare type ExperienceLoadingComponent<P, PassThroughProps extends Partial<P>> = React.ComponentType<ExperienceBaseProps<P, PassThroughProps>>;
|
|
17
|
-
export declare type ExperienceProps<P, PassThroughProps extends Partial<P>> = ExperienceBaseProps<P, PassThroughProps> & {
|
|
18
|
-
experiences: ExperienceConfiguration[];
|
|
19
|
-
component:
|
|
20
|
-
loadingComponent?: ExperienceLoadingComponent<P, PassThroughProps>;
|
|
16
|
+
export declare type ExperienceLoadingComponent<P, PassThroughProps extends Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = React.ComponentType<ExperienceBaseProps<P, PassThroughProps, Variant>>;
|
|
17
|
+
export declare type ExperienceProps<P, PassThroughProps extends Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = ExperienceBaseProps<P, PassThroughProps, Variant> & {
|
|
18
|
+
experiences: ExperienceConfiguration<Variant>[];
|
|
19
|
+
component: React.ComponentType<P>;
|
|
20
|
+
loadingComponent?: ExperienceLoadingComponent<P, PassThroughProps, Variant>;
|
|
21
21
|
};
|
|
22
|
-
declare type DefaultExperienceLoadingComponentProps = ExperienceBaseProps<
|
|
22
|
+
declare type DefaultExperienceLoadingComponentProps = ExperienceBaseProps<Record<string, unknown>, Record<string, unknown>, Record<string, unknown> & Reference> & {
|
|
23
23
|
unhideAfterMs?: number;
|
|
24
24
|
};
|
|
25
25
|
export declare const DefaultExperienceLoadingComponent: React.FC<DefaultExperienceLoadingComponentProps>;
|
|
26
|
-
export declare const Experience: <P
|
|
26
|
+
export declare const Experience: <P, PassThroughProps extends Partial<P> = Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference = Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference>({ experiences, component: Component, loadingComponent: LoadingComponent, passthroughProps, ...baseline }: ExperienceProps<P, PassThroughProps, Variant>) => JSX.Element;
|
|
27
27
|
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ExperienceConfiguration, Reference } from '@ninetailed/experience.js';
|
|
3
|
+
import { JoinExperiment } from './useProvideJoinExperiment';
|
|
4
|
+
declare type ExperimentsContextValue<Variant extends Reference> = {
|
|
5
|
+
experiments: ExperienceConfiguration<Variant>[];
|
|
6
|
+
joinExperiment: JoinExperiment;
|
|
4
7
|
};
|
|
5
|
-
export declare const ExperimentsContext: import("react").Context<ExperimentsContextValue | undefined>;
|
|
8
|
+
export declare const ExperimentsContext: import("react").Context<ExperimentsContextValue<any> | undefined>;
|
|
6
9
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ExperienceConfiguration } from '@ninetailed/experience.js';
|
|
3
|
-
declare type ExperimentsProviderProps = {
|
|
4
|
-
experiments: ExperienceConfiguration[];
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { ExperienceConfiguration, Reference } from '@ninetailed/experience.js';
|
|
3
|
+
declare type ExperimentsProviderProps<Variant extends Reference> = React.PropsWithChildren<{
|
|
4
|
+
experiments: ExperienceConfiguration<Variant>[];
|
|
5
|
+
maximumActiveExperiments?: number;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const ExperimentsProvider: <Variant extends Reference>({ experiments, maximumActiveExperiments, children, }: React.PropsWithChildren<ExperimentsProviderProps<Variant>>) => JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Profile } from '@ninetailed/experience.js-shared';
|
|
3
3
|
import { ExperienceConfiguration } from '@ninetailed/experience.js';
|
|
4
4
|
declare type TrackExperienceProps = {
|
|
5
|
-
experience: ExperienceConfiguration
|
|
5
|
+
experience: ExperienceConfiguration<any>;
|
|
6
6
|
variant: {
|
|
7
7
|
id: string;
|
|
8
8
|
};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export { Experience, DefaultExperienceLoadingComponent } from './Experience';
|
|
2
|
-
export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent } from './Experience';
|
|
2
|
+
export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent, } from './Experience';
|
|
3
3
|
export { ESRProvider, ESRLoadingComponent } from './ESRLoadingComponent';
|
|
4
|
+
export { useExperience } from './useExperience';
|
|
5
|
+
export { ExperimentsProvider } from './ExperimentsProvider';
|
|
6
|
+
export { useExperiments } from './useExperiments';
|
|
7
|
+
export { useJoinExperiment } from './useJoinExperiment';
|
|
8
|
+
export { TrackExperience } from './TrackExperience';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Baseline,
|
|
1
|
+
import { Baseline, ExperienceConfiguration, Profile, Reference, VariantRef } from '@ninetailed/experience.js';
|
|
2
2
|
declare type Load = {
|
|
3
3
|
status: 'loading';
|
|
4
4
|
loading: boolean;
|
|
@@ -11,12 +11,12 @@ declare type Load = {
|
|
|
11
11
|
profile: null;
|
|
12
12
|
error: null;
|
|
13
13
|
};
|
|
14
|
-
declare type Success = {
|
|
14
|
+
declare type Success<Variant extends Reference> = {
|
|
15
15
|
status: 'success';
|
|
16
16
|
loading: boolean;
|
|
17
17
|
hasVariants: boolean;
|
|
18
18
|
baseline: Baseline;
|
|
19
|
-
experience: ExperienceConfiguration | null;
|
|
19
|
+
experience: ExperienceConfiguration<Variant> | null;
|
|
20
20
|
variant: Variant | null;
|
|
21
21
|
audience: {
|
|
22
22
|
id: string;
|
|
@@ -37,10 +37,10 @@ declare type Fail = {
|
|
|
37
37
|
profile: null;
|
|
38
38
|
error: Error;
|
|
39
39
|
};
|
|
40
|
-
declare type UseExperienceArgs = {
|
|
40
|
+
declare type UseExperienceArgs<Variant extends Reference> = {
|
|
41
41
|
baseline: Baseline;
|
|
42
|
-
experiences: ExperienceConfiguration[];
|
|
42
|
+
experiences: ExperienceConfiguration<Variant>[];
|
|
43
43
|
};
|
|
44
|
-
declare type UseExperienceResponse = Load | Success | Fail;
|
|
45
|
-
export declare const useExperience: ({ baseline, experiences, }: UseExperienceArgs) => UseExperienceResponse
|
|
44
|
+
declare type UseExperienceResponse<Variant extends Reference> = Load | Success<Variant | VariantRef> | Fail;
|
|
45
|
+
export declare const useExperience: <Variant extends Reference>({ baseline, experiences, }: UseExperienceArgs<Variant>) => UseExperienceResponse<Variant>;
|
|
46
46
|
export {};
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
declare type UseJoinExperimentArgs = {
|
|
3
|
-
experiences: ExperienceConfiguration[];
|
|
4
|
-
};
|
|
5
|
-
declare type JoinExperimentArgs = {
|
|
6
|
-
experiment: ExperienceConfiguration;
|
|
7
|
-
profile: Profile;
|
|
8
|
-
};
|
|
9
|
-
export declare const useJoinExperiment: ({ experiences }: UseJoinExperimentArgs) => ({ experiment, profile }: JoinExperimentArgs) => void;
|
|
10
|
-
export {};
|
|
1
|
+
export declare const useJoinExperiment: () => import("./useProvideJoinExperiment").JoinExperiment;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Profile, ExperienceConfiguration, Reference, VariantRef } from '@ninetailed/experience.js';
|
|
2
|
+
export declare type JoinExperimentArgs = {
|
|
3
|
+
experiences: ExperienceConfiguration[];
|
|
4
|
+
experiment: ExperienceConfiguration<Reference | VariantRef>;
|
|
5
|
+
profile: Profile;
|
|
6
|
+
};
|
|
7
|
+
export declare type JoinExperiment = (args: JoinExperimentArgs) => Promise<void>;
|
|
8
|
+
declare type UseJoinExperimentArgs = {
|
|
9
|
+
experiments: ExperienceConfiguration[];
|
|
10
|
+
maximumActiveExperiments?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const useProvideJoinExperiment: ({ experiments, maximumActiveExperiments, }: UseJoinExperimentArgs) => (data: JoinExperimentArgs) => Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -5,7 +5,8 @@ import { Profile, Locale, OnErrorHandler, OnLogHandler } from '@ninetailed/exper
|
|
|
5
5
|
export declare type NinetailedProviderProps = {
|
|
6
6
|
clientId: string;
|
|
7
7
|
environment?: string;
|
|
8
|
-
experiments?: ExperienceConfiguration[];
|
|
8
|
+
experiments?: ExperienceConfiguration<any>[];
|
|
9
|
+
maximumActiveExperiments?: number;
|
|
9
10
|
preview?: boolean;
|
|
10
11
|
url?: string;
|
|
11
12
|
plugins?: (AnalyticsPlugin | AnalyticsPlugin[])[];
|
|
@@ -15,4 +16,4 @@ export declare type NinetailedProviderProps = {
|
|
|
15
16
|
onLog?: OnLogHandler;
|
|
16
17
|
onError?: OnErrorHandler;
|
|
17
18
|
};
|
|
18
|
-
export declare const NinetailedProvider: React.
|
|
19
|
+
export declare const NinetailedProvider: ({ children, clientId, experiments, maximumActiveExperiments, environment, preview, url, profile, locale, requestTimeout, plugins, onLog, onError, }: React.PropsWithChildren<NinetailedProviderProps>) => JSX.Element;
|
package/lib/Personalize.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ declare type PersonalizeProps<P> = Baseline<P> & {
|
|
|
19
19
|
loadingComponent?: React.ComponentType;
|
|
20
20
|
holdout?: number;
|
|
21
21
|
};
|
|
22
|
-
export declare const Personalize: <P extends
|
|
22
|
+
export declare const Personalize: <P extends object>({ component: Component, loadingComponent: LoadingComponent, variants, holdout, ...baseline }: PersonalizeProps<P>) => JSX.Element;
|
|
23
23
|
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export { Personalize } from './Personalize';
|
|
|
9
9
|
export type { PersonalizedComponent } from './Personalize';
|
|
10
10
|
export { MergeTag } from './MergeTag';
|
|
11
11
|
export { TrackHasSeenComponent } from './TrackHasSeenComponent';
|
|
12
|
-
export { Experience, ESRProvider, ESRLoadingComponent, DefaultExperienceLoadingComponent } from './Experience';
|
|
12
|
+
export { ExperimentsProvider, Experience, ESRProvider, ESRLoadingComponent, DefaultExperienceLoadingComponent, TrackExperience, useExperience, useExperiments, useJoinExperiment, } from './Experience';
|
|
13
13
|
export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent, } from './Experience';
|
package/lib/useProfile.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const useProfile: () => {
|
|
|
12
12
|
id: string;
|
|
13
13
|
random: number;
|
|
14
14
|
audiences: string[];
|
|
15
|
-
traits: import("@ninetailed/experience.js-shared").
|
|
15
|
+
traits: import("@ninetailed/experience.js-shared").Properties;
|
|
16
16
|
location: {
|
|
17
17
|
coordinates?: {
|
|
18
18
|
latitude: number;
|
|
@@ -29,7 +29,7 @@ export declare const useProfile: () => {
|
|
|
29
29
|
};
|
|
30
30
|
session: {
|
|
31
31
|
isReturningVisitor: boolean;
|
|
32
|
-
|
|
32
|
+
landingPage: {
|
|
33
33
|
path: string;
|
|
34
34
|
url: string;
|
|
35
35
|
query: Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-react",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2-beta.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=16.8.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@analytics/google-analytics": "0.5.3",
|
|
9
9
|
"react-visibility-sensor": "5.1.1",
|
|
10
|
-
"lodash": "
|
|
11
|
-
"@ninetailed/experience.js": "3.0.
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"zod": "^3.18.0",
|
|
16
|
-
"locale-enum": "^1.1.1",
|
|
17
|
-
"i18n-iso-countries": "^7.3.0",
|
|
18
|
-
"analytics": "^0.8.0",
|
|
19
|
-
"murmurhash-js": "^1.0.0",
|
|
20
|
-
"react-intersection-observer": "^8.33.1"
|
|
10
|
+
"lodash": "4.17.21",
|
|
11
|
+
"@ninetailed/experience.js": "3.0.2-beta.0",
|
|
12
|
+
"react-intersection-observer": "8.34.0",
|
|
13
|
+
"@ninetailed/experience.js-shared": "3.0.2-beta.0",
|
|
14
|
+
"analytics": "0.8.1"
|
|
21
15
|
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
16
|
+
"module": "./index.js",
|
|
17
|
+
"main": "./index.cjs",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"types": "./index.d.ts"
|
|
25
20
|
}
|