@uniformdev/canvas-next-rsc-shared 19.135.1-alpha.10 → 19.135.1-alpha.12
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.mts +52 -25
- package/dist/index.d.ts +52 -25
- package/dist/index.esm.js +99 -46
- package/dist/index.js +95 -45
- package/dist/index.mjs +99 -46
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as _uniformdev_context from '@uniformdev/context';
|
|
2
|
+
import { ContextInstance, ContextState, ContextOptions, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent } from '@uniformdev/context';
|
|
3
3
|
import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
|
|
4
4
|
import { PropsWithChildren } from 'react';
|
|
5
5
|
|
|
@@ -20,17 +20,24 @@ type UniformServerConfig = {
|
|
|
20
20
|
* Cache mode for manifest data.
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
manifestCache?: CacheMode
|
|
23
|
+
manifestCache?: CacheMode & {
|
|
24
|
+
bypassCache?: boolean;
|
|
25
|
+
};
|
|
24
26
|
/**
|
|
25
27
|
* Cache mode for canvas data.
|
|
26
28
|
*
|
|
27
29
|
*/
|
|
28
|
-
canvasCache?: CacheMode
|
|
30
|
+
canvasCache?: CacheMode & {
|
|
31
|
+
disableSWR?: boolean;
|
|
32
|
+
bypassCache?: boolean;
|
|
33
|
+
};
|
|
29
34
|
/**
|
|
30
35
|
* Cache mode for project map data.
|
|
31
36
|
*
|
|
32
37
|
*/
|
|
33
|
-
projectMapCache?: CacheMode
|
|
38
|
+
projectMapCache?: CacheMode & {
|
|
39
|
+
bypassCache?: boolean;
|
|
40
|
+
};
|
|
34
41
|
/**
|
|
35
42
|
* Options for Uniform Context
|
|
36
43
|
*/
|
|
@@ -80,6 +87,16 @@ type UniformServerConfig = {
|
|
|
80
87
|
*/
|
|
81
88
|
vercelVisualEditing?: boolean;
|
|
82
89
|
};
|
|
90
|
+
ppr?: {
|
|
91
|
+
/**
|
|
92
|
+
* Whether or not to wrap personalization components in a suspense boundary.
|
|
93
|
+
*/
|
|
94
|
+
personalizationSuspense?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Whether or not to wrap test components in a suspense boundary.
|
|
97
|
+
*/
|
|
98
|
+
testSuspense?: boolean;
|
|
99
|
+
};
|
|
83
100
|
};
|
|
84
101
|
|
|
85
102
|
type PageParameters = {
|
|
@@ -127,22 +144,38 @@ type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiRespo
|
|
|
127
144
|
};
|
|
128
145
|
type AppDirectoryContext = Omit<ContextInstance, 'update'> & {
|
|
129
146
|
update: (update: Partial<AppDirectoryContextState>) => Promise<void>;
|
|
130
|
-
};
|
|
131
|
-
type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
|
|
132
|
-
type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'> & {
|
|
133
147
|
/**
|
|
134
148
|
* Internal use only. Please use `ContextUpdateTransfer` to handle any Context updates.
|
|
135
149
|
*
|
|
136
150
|
* @deprecated
|
|
137
151
|
*/
|
|
138
|
-
|
|
139
|
-
update: AppDirectoryContext['update'];
|
|
140
|
-
};
|
|
152
|
+
internal_update: AppDirectoryContext['update'];
|
|
141
153
|
};
|
|
154
|
+
type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
|
|
155
|
+
type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'>;
|
|
142
156
|
|
|
143
157
|
declare const createUniformContext: ({ serverCookieValue, ...rest }: Omit<ContextOptions, "transitionStore"> & {
|
|
144
158
|
serverCookieValue: string | undefined;
|
|
145
|
-
}) =>
|
|
159
|
+
}) => AppDirectoryContextInstance;
|
|
160
|
+
declare class AppDirectoryContextInstance implements AppDirectoryContext {
|
|
161
|
+
#private;
|
|
162
|
+
readonly manifest: ContextInstance['manifest'];
|
|
163
|
+
readonly events: ContextInstance['events'];
|
|
164
|
+
constructor(context: Context);
|
|
165
|
+
get scores(): Readonly<_uniformdev_context.ScoreVector>;
|
|
166
|
+
get quirks(): Readonly<_uniformdev_context.Quirks>;
|
|
167
|
+
getTestVariantId(testName: string): string | null | undefined;
|
|
168
|
+
setTestVariantId(testName: string, variantId: string): void;
|
|
169
|
+
log(...message: LogMessage): void;
|
|
170
|
+
test<TVariant extends TestVariant>(options: TestOptions<TVariant>): _uniformdev_context.TestResult<TVariant>;
|
|
171
|
+
personalize<TVariant extends PersonalizedVariant>(options: PersonalizeOptions<TVariant>): _uniformdev_context.PersonalizedResult<TVariant>;
|
|
172
|
+
forget(fromAllDevices: boolean): Promise<void>;
|
|
173
|
+
getServerToClientTransitionState(): _uniformdev_context.ServerToClientTransitionState;
|
|
174
|
+
internal_processTestEvent(event: TestEvent): void;
|
|
175
|
+
internal_processPersonalizationEvent(event: PersonalizationEvent): void;
|
|
176
|
+
update(update: Partial<AppDirectoryContextState>): Promise<void>;
|
|
177
|
+
internal_update(update: Partial<AppDirectoryContextState>): Promise<void>;
|
|
178
|
+
}
|
|
146
179
|
|
|
147
180
|
type PersonalizeProps = {
|
|
148
181
|
trackingEventName: string;
|
|
@@ -153,9 +186,9 @@ type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
|
|
|
153
186
|
};
|
|
154
187
|
|
|
155
188
|
declare const runPersonalization: ({ component, trackingEventName, count, contextInstance, }: PersonalizeProps & {
|
|
156
|
-
component: ComponentProps[
|
|
189
|
+
component: ComponentProps["component"];
|
|
157
190
|
} & {
|
|
158
|
-
contextInstance: Pick<ContextInstance,
|
|
191
|
+
contextInstance: Pick<ContextInstance, "personalize"> | undefined;
|
|
159
192
|
}) => {
|
|
160
193
|
indexes: number[];
|
|
161
194
|
event: PersonalizationEvent;
|
|
@@ -165,25 +198,19 @@ type TestProps = {
|
|
|
165
198
|
test: string;
|
|
166
199
|
};
|
|
167
200
|
|
|
168
|
-
declare const runTest: ({ test, component, contextInstance, }: TestProps & {
|
|
169
|
-
|
|
170
|
-
context: CompositionContext;
|
|
171
|
-
slots: Record<string, SlotDefinition>;
|
|
172
|
-
slotName: string | undefined;
|
|
173
|
-
slotIndex: number | undefined;
|
|
174
|
-
} & {
|
|
175
|
-
contextInstance: Pick<ContextInstance, 'test'> | undefined;
|
|
201
|
+
declare const runTest: ({ test, component, contextInstance, }: ComponentProps<TestProps> & {
|
|
202
|
+
contextInstance: Pick<ContextInstance, "test" | "manifest"> | undefined;
|
|
176
203
|
}) => {
|
|
177
204
|
index: number | null;
|
|
178
|
-
event: TestEvent;
|
|
205
|
+
event: TestEvent | null;
|
|
179
206
|
};
|
|
180
207
|
|
|
181
208
|
type ResolvePathResult = {
|
|
182
209
|
type: 'path';
|
|
183
210
|
value: string;
|
|
184
211
|
};
|
|
185
|
-
declare const resolvePath: ({ params }: Pick<PageParameters,
|
|
212
|
+
declare const resolvePath: ({ params }: Pick<PageParameters, "params">) => ResolvePathResult;
|
|
186
213
|
|
|
187
214
|
declare function getBaseUrl(): string;
|
|
188
215
|
|
|
189
|
-
export { type AppDirectoryContext, type AppDirectoryContextState, type AppDirectoryServerContext, type CacheMode, type ComponentProps, type CompositionContext, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };
|
|
216
|
+
export { type AppDirectoryContext, AppDirectoryContextInstance, type AppDirectoryContextState, type AppDirectoryServerContext, type CacheMode, type ComponentProps, type CompositionContext, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as _uniformdev_context from '@uniformdev/context';
|
|
2
|
+
import { ContextInstance, ContextState, ContextOptions, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent } from '@uniformdev/context';
|
|
3
3
|
import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
|
|
4
4
|
import { PropsWithChildren } from 'react';
|
|
5
5
|
|
|
@@ -20,17 +20,24 @@ type UniformServerConfig = {
|
|
|
20
20
|
* Cache mode for manifest data.
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
manifestCache?: CacheMode
|
|
23
|
+
manifestCache?: CacheMode & {
|
|
24
|
+
bypassCache?: boolean;
|
|
25
|
+
};
|
|
24
26
|
/**
|
|
25
27
|
* Cache mode for canvas data.
|
|
26
28
|
*
|
|
27
29
|
*/
|
|
28
|
-
canvasCache?: CacheMode
|
|
30
|
+
canvasCache?: CacheMode & {
|
|
31
|
+
disableSWR?: boolean;
|
|
32
|
+
bypassCache?: boolean;
|
|
33
|
+
};
|
|
29
34
|
/**
|
|
30
35
|
* Cache mode for project map data.
|
|
31
36
|
*
|
|
32
37
|
*/
|
|
33
|
-
projectMapCache?: CacheMode
|
|
38
|
+
projectMapCache?: CacheMode & {
|
|
39
|
+
bypassCache?: boolean;
|
|
40
|
+
};
|
|
34
41
|
/**
|
|
35
42
|
* Options for Uniform Context
|
|
36
43
|
*/
|
|
@@ -80,6 +87,16 @@ type UniformServerConfig = {
|
|
|
80
87
|
*/
|
|
81
88
|
vercelVisualEditing?: boolean;
|
|
82
89
|
};
|
|
90
|
+
ppr?: {
|
|
91
|
+
/**
|
|
92
|
+
* Whether or not to wrap personalization components in a suspense boundary.
|
|
93
|
+
*/
|
|
94
|
+
personalizationSuspense?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Whether or not to wrap test components in a suspense boundary.
|
|
97
|
+
*/
|
|
98
|
+
testSuspense?: boolean;
|
|
99
|
+
};
|
|
83
100
|
};
|
|
84
101
|
|
|
85
102
|
type PageParameters = {
|
|
@@ -127,22 +144,38 @@ type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiRespo
|
|
|
127
144
|
};
|
|
128
145
|
type AppDirectoryContext = Omit<ContextInstance, 'update'> & {
|
|
129
146
|
update: (update: Partial<AppDirectoryContextState>) => Promise<void>;
|
|
130
|
-
};
|
|
131
|
-
type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
|
|
132
|
-
type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'> & {
|
|
133
147
|
/**
|
|
134
148
|
* Internal use only. Please use `ContextUpdateTransfer` to handle any Context updates.
|
|
135
149
|
*
|
|
136
150
|
* @deprecated
|
|
137
151
|
*/
|
|
138
|
-
|
|
139
|
-
update: AppDirectoryContext['update'];
|
|
140
|
-
};
|
|
152
|
+
internal_update: AppDirectoryContext['update'];
|
|
141
153
|
};
|
|
154
|
+
type AppDirectoryContextState = Omit<ContextState, 'url'> & PageParameters;
|
|
155
|
+
type AppDirectoryServerContext = Omit<AppDirectoryContext, 'update'>;
|
|
142
156
|
|
|
143
157
|
declare const createUniformContext: ({ serverCookieValue, ...rest }: Omit<ContextOptions, "transitionStore"> & {
|
|
144
158
|
serverCookieValue: string | undefined;
|
|
145
|
-
}) =>
|
|
159
|
+
}) => AppDirectoryContextInstance;
|
|
160
|
+
declare class AppDirectoryContextInstance implements AppDirectoryContext {
|
|
161
|
+
#private;
|
|
162
|
+
readonly manifest: ContextInstance['manifest'];
|
|
163
|
+
readonly events: ContextInstance['events'];
|
|
164
|
+
constructor(context: Context);
|
|
165
|
+
get scores(): Readonly<_uniformdev_context.ScoreVector>;
|
|
166
|
+
get quirks(): Readonly<_uniformdev_context.Quirks>;
|
|
167
|
+
getTestVariantId(testName: string): string | null | undefined;
|
|
168
|
+
setTestVariantId(testName: string, variantId: string): void;
|
|
169
|
+
log(...message: LogMessage): void;
|
|
170
|
+
test<TVariant extends TestVariant>(options: TestOptions<TVariant>): _uniformdev_context.TestResult<TVariant>;
|
|
171
|
+
personalize<TVariant extends PersonalizedVariant>(options: PersonalizeOptions<TVariant>): _uniformdev_context.PersonalizedResult<TVariant>;
|
|
172
|
+
forget(fromAllDevices: boolean): Promise<void>;
|
|
173
|
+
getServerToClientTransitionState(): _uniformdev_context.ServerToClientTransitionState;
|
|
174
|
+
internal_processTestEvent(event: TestEvent): void;
|
|
175
|
+
internal_processPersonalizationEvent(event: PersonalizationEvent): void;
|
|
176
|
+
update(update: Partial<AppDirectoryContextState>): Promise<void>;
|
|
177
|
+
internal_update(update: Partial<AppDirectoryContextState>): Promise<void>;
|
|
178
|
+
}
|
|
146
179
|
|
|
147
180
|
type PersonalizeProps = {
|
|
148
181
|
trackingEventName: string;
|
|
@@ -153,9 +186,9 @@ type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
|
|
|
153
186
|
};
|
|
154
187
|
|
|
155
188
|
declare const runPersonalization: ({ component, trackingEventName, count, contextInstance, }: PersonalizeProps & {
|
|
156
|
-
component: ComponentProps[
|
|
189
|
+
component: ComponentProps["component"];
|
|
157
190
|
} & {
|
|
158
|
-
contextInstance: Pick<ContextInstance,
|
|
191
|
+
contextInstance: Pick<ContextInstance, "personalize"> | undefined;
|
|
159
192
|
}) => {
|
|
160
193
|
indexes: number[];
|
|
161
194
|
event: PersonalizationEvent;
|
|
@@ -165,25 +198,19 @@ type TestProps = {
|
|
|
165
198
|
test: string;
|
|
166
199
|
};
|
|
167
200
|
|
|
168
|
-
declare const runTest: ({ test, component, contextInstance, }: TestProps & {
|
|
169
|
-
|
|
170
|
-
context: CompositionContext;
|
|
171
|
-
slots: Record<string, SlotDefinition>;
|
|
172
|
-
slotName: string | undefined;
|
|
173
|
-
slotIndex: number | undefined;
|
|
174
|
-
} & {
|
|
175
|
-
contextInstance: Pick<ContextInstance, 'test'> | undefined;
|
|
201
|
+
declare const runTest: ({ test, component, contextInstance, }: ComponentProps<TestProps> & {
|
|
202
|
+
contextInstance: Pick<ContextInstance, "test" | "manifest"> | undefined;
|
|
176
203
|
}) => {
|
|
177
204
|
index: number | null;
|
|
178
|
-
event: TestEvent;
|
|
205
|
+
event: TestEvent | null;
|
|
179
206
|
};
|
|
180
207
|
|
|
181
208
|
type ResolvePathResult = {
|
|
182
209
|
type: 'path';
|
|
183
210
|
value: string;
|
|
184
211
|
};
|
|
185
|
-
declare const resolvePath: ({ params }: Pick<PageParameters,
|
|
212
|
+
declare const resolvePath: ({ params }: Pick<PageParameters, "params">) => ResolvePathResult;
|
|
186
213
|
|
|
187
214
|
declare function getBaseUrl(): string;
|
|
188
215
|
|
|
189
|
-
export { type AppDirectoryContext, type AppDirectoryContextState, type AppDirectoryServerContext, type CacheMode, type ComponentProps, type CompositionContext, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };
|
|
216
|
+
export { type AppDirectoryContext, AppDirectoryContextInstance, type AppDirectoryContextState, type AppDirectoryServerContext, type CacheMode, type ComponentProps, type CompositionContext, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
var __typeError = (msg) => {
|
|
2
|
+
throw TypeError(msg);
|
|
3
|
+
};
|
|
4
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
+
|
|
1
9
|
// src/context/createUniformContext.ts
|
|
2
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
Context,
|
|
12
|
+
CookieTransitionDataStore
|
|
13
|
+
} from "@uniformdev/context";
|
|
3
14
|
|
|
4
15
|
// src/utils/path.ts
|
|
5
16
|
var resolvePath = ({ params }) => {
|
|
@@ -63,51 +74,84 @@ var createUniformContext = ({
|
|
|
63
74
|
serverCookieValue
|
|
64
75
|
})
|
|
65
76
|
});
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
const wrapped = new AppDirectoryContextInstance(context);
|
|
78
|
+
return wrapped;
|
|
79
|
+
};
|
|
80
|
+
var _context;
|
|
81
|
+
var AppDirectoryContextInstance = class {
|
|
82
|
+
constructor(context) {
|
|
83
|
+
__privateAdd(this, _context);
|
|
84
|
+
__privateSet(this, _context, context);
|
|
85
|
+
this.manifest = context.manifest;
|
|
86
|
+
this.events = context.events;
|
|
87
|
+
}
|
|
88
|
+
get scores() {
|
|
89
|
+
return __privateGet(this, _context).scores;
|
|
90
|
+
}
|
|
91
|
+
get quirks() {
|
|
92
|
+
return __privateGet(this, _context).quirks;
|
|
93
|
+
}
|
|
94
|
+
getTestVariantId(testName) {
|
|
95
|
+
return __privateGet(this, _context).getTestVariantId(testName);
|
|
96
|
+
}
|
|
97
|
+
setTestVariantId(testName, variantId) {
|
|
98
|
+
return __privateGet(this, _context).setTestVariantId(testName, variantId);
|
|
99
|
+
}
|
|
100
|
+
log(...message) {
|
|
101
|
+
return __privateGet(this, _context).log(...message);
|
|
102
|
+
}
|
|
103
|
+
test(options) {
|
|
104
|
+
return __privateGet(this, _context).test(options);
|
|
105
|
+
}
|
|
106
|
+
personalize(options) {
|
|
107
|
+
return __privateGet(this, _context).personalize(options);
|
|
108
|
+
}
|
|
109
|
+
forget(fromAllDevices) {
|
|
110
|
+
return __privateGet(this, _context).forget(fromAllDevices);
|
|
111
|
+
}
|
|
112
|
+
getServerToClientTransitionState() {
|
|
113
|
+
return __privateGet(this, _context).getServerToClientTransitionState();
|
|
114
|
+
}
|
|
115
|
+
internal_processTestEvent(event) {
|
|
116
|
+
return __privateGet(this, _context).internal_processTestEvent(event);
|
|
117
|
+
}
|
|
118
|
+
internal_processPersonalizationEvent(event) {
|
|
119
|
+
return __privateGet(this, _context).internal_processPersonalizationEvent(event);
|
|
120
|
+
}
|
|
121
|
+
update(update) {
|
|
122
|
+
const { params, searchParams } = update;
|
|
123
|
+
const DEFAULT_URL = `${getBaseUrl()}/`;
|
|
124
|
+
let url = void 0;
|
|
125
|
+
if (params) {
|
|
126
|
+
const path = resolvePath({
|
|
127
|
+
params
|
|
128
|
+
});
|
|
129
|
+
if (!url) {
|
|
130
|
+
url = new URL(DEFAULT_URL);
|
|
89
131
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
url
|
|
132
|
+
url.pathname = path.value;
|
|
133
|
+
}
|
|
134
|
+
if (searchParams) {
|
|
135
|
+
Object.keys(searchParams).forEach((key) => {
|
|
136
|
+
const value = searchParams[key];
|
|
137
|
+
if (typeof value === "string") {
|
|
138
|
+
if (!url) {
|
|
139
|
+
url = new URL(DEFAULT_URL);
|
|
98
140
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return context.update({
|
|
102
|
-
...update,
|
|
103
|
-
url
|
|
141
|
+
url.searchParams.set(key, value);
|
|
142
|
+
}
|
|
104
143
|
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
144
|
+
}
|
|
145
|
+
return __privateGet(this, _context).update({
|
|
146
|
+
...update,
|
|
147
|
+
url
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
internal_update(update) {
|
|
151
|
+
return this.update(update);
|
|
152
|
+
}
|
|
110
153
|
};
|
|
154
|
+
_context = new WeakMap();
|
|
111
155
|
|
|
112
156
|
// src/runPersonalization.ts
|
|
113
157
|
import { CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
@@ -192,11 +236,19 @@ var runTest = ({
|
|
|
192
236
|
component,
|
|
193
237
|
contextInstance
|
|
194
238
|
}) => {
|
|
195
|
-
var _a;
|
|
196
|
-
const
|
|
239
|
+
var _a, _b;
|
|
240
|
+
const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
|
|
241
|
+
if (!isTestDefined && process.env.NODE_ENV !== "production") {
|
|
242
|
+
console.warn(`Test "${test}" is not defined in Uniform manifest.`);
|
|
243
|
+
return {
|
|
244
|
+
index: null,
|
|
245
|
+
event: null
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const slot = ((_b = component.slots) == null ? void 0 : _b[CANVAS_TEST_SLOT]) || [];
|
|
197
249
|
const componentVariations = slot.map((v, i) => {
|
|
198
|
-
var _a2,
|
|
199
|
-
const contextTag = (
|
|
250
|
+
var _a2, _b2, _c;
|
|
251
|
+
const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b2.value;
|
|
200
252
|
const id = (_c = contextTag == null ? void 0 : contextTag.id) != null ? _c : "testId" in v ? v.testId : `ab-${i}-${v.type}`;
|
|
201
253
|
return {
|
|
202
254
|
id,
|
|
@@ -234,6 +286,7 @@ var runTest = ({
|
|
|
234
286
|
};
|
|
235
287
|
};
|
|
236
288
|
export {
|
|
289
|
+
AppDirectoryContextInstance,
|
|
237
290
|
createUniformContext,
|
|
238
291
|
getBaseUrl,
|
|
239
292
|
resolvePath,
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,9 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __typeError = (msg) => {
|
|
7
|
+
throw TypeError(msg);
|
|
8
|
+
};
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,10 +19,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
19
|
return to;
|
|
17
20
|
};
|
|
18
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
23
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
24
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
25
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
19
26
|
|
|
20
27
|
// src/index.ts
|
|
21
28
|
var src_exports = {};
|
|
22
29
|
__export(src_exports, {
|
|
30
|
+
AppDirectoryContextInstance: () => AppDirectoryContextInstance,
|
|
23
31
|
createUniformContext: () => createUniformContext,
|
|
24
32
|
getBaseUrl: () => getBaseUrl,
|
|
25
33
|
resolvePath: () => resolvePath,
|
|
@@ -93,51 +101,84 @@ var createUniformContext = ({
|
|
|
93
101
|
serverCookieValue
|
|
94
102
|
})
|
|
95
103
|
});
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
104
|
+
const wrapped = new AppDirectoryContextInstance(context);
|
|
105
|
+
return wrapped;
|
|
106
|
+
};
|
|
107
|
+
var _context;
|
|
108
|
+
var AppDirectoryContextInstance = class {
|
|
109
|
+
constructor(context) {
|
|
110
|
+
__privateAdd(this, _context);
|
|
111
|
+
__privateSet(this, _context, context);
|
|
112
|
+
this.manifest = context.manifest;
|
|
113
|
+
this.events = context.events;
|
|
114
|
+
}
|
|
115
|
+
get scores() {
|
|
116
|
+
return __privateGet(this, _context).scores;
|
|
117
|
+
}
|
|
118
|
+
get quirks() {
|
|
119
|
+
return __privateGet(this, _context).quirks;
|
|
120
|
+
}
|
|
121
|
+
getTestVariantId(testName) {
|
|
122
|
+
return __privateGet(this, _context).getTestVariantId(testName);
|
|
123
|
+
}
|
|
124
|
+
setTestVariantId(testName, variantId) {
|
|
125
|
+
return __privateGet(this, _context).setTestVariantId(testName, variantId);
|
|
126
|
+
}
|
|
127
|
+
log(...message) {
|
|
128
|
+
return __privateGet(this, _context).log(...message);
|
|
129
|
+
}
|
|
130
|
+
test(options) {
|
|
131
|
+
return __privateGet(this, _context).test(options);
|
|
132
|
+
}
|
|
133
|
+
personalize(options) {
|
|
134
|
+
return __privateGet(this, _context).personalize(options);
|
|
135
|
+
}
|
|
136
|
+
forget(fromAllDevices) {
|
|
137
|
+
return __privateGet(this, _context).forget(fromAllDevices);
|
|
138
|
+
}
|
|
139
|
+
getServerToClientTransitionState() {
|
|
140
|
+
return __privateGet(this, _context).getServerToClientTransitionState();
|
|
141
|
+
}
|
|
142
|
+
internal_processTestEvent(event) {
|
|
143
|
+
return __privateGet(this, _context).internal_processTestEvent(event);
|
|
144
|
+
}
|
|
145
|
+
internal_processPersonalizationEvent(event) {
|
|
146
|
+
return __privateGet(this, _context).internal_processPersonalizationEvent(event);
|
|
147
|
+
}
|
|
148
|
+
update(update) {
|
|
149
|
+
const { params, searchParams } = update;
|
|
150
|
+
const DEFAULT_URL = `${getBaseUrl()}/`;
|
|
151
|
+
let url = void 0;
|
|
152
|
+
if (params) {
|
|
153
|
+
const path = resolvePath({
|
|
154
|
+
params
|
|
155
|
+
});
|
|
156
|
+
if (!url) {
|
|
157
|
+
url = new URL(DEFAULT_URL);
|
|
119
158
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
url
|
|
159
|
+
url.pathname = path.value;
|
|
160
|
+
}
|
|
161
|
+
if (searchParams) {
|
|
162
|
+
Object.keys(searchParams).forEach((key) => {
|
|
163
|
+
const value = searchParams[key];
|
|
164
|
+
if (typeof value === "string") {
|
|
165
|
+
if (!url) {
|
|
166
|
+
url = new URL(DEFAULT_URL);
|
|
128
167
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return context.update({
|
|
132
|
-
...update,
|
|
133
|
-
url
|
|
168
|
+
url.searchParams.set(key, value);
|
|
169
|
+
}
|
|
134
170
|
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
171
|
+
}
|
|
172
|
+
return __privateGet(this, _context).update({
|
|
173
|
+
...update,
|
|
174
|
+
url
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
internal_update(update) {
|
|
178
|
+
return this.update(update);
|
|
179
|
+
}
|
|
140
180
|
};
|
|
181
|
+
_context = new WeakMap();
|
|
141
182
|
|
|
142
183
|
// src/runPersonalization.ts
|
|
143
184
|
var import_canvas = require("@uniformdev/canvas");
|
|
@@ -222,11 +263,19 @@ var runTest = ({
|
|
|
222
263
|
component,
|
|
223
264
|
contextInstance
|
|
224
265
|
}) => {
|
|
225
|
-
var _a;
|
|
226
|
-
const
|
|
266
|
+
var _a, _b;
|
|
267
|
+
const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
|
|
268
|
+
if (!isTestDefined && process.env.NODE_ENV !== "production") {
|
|
269
|
+
console.warn(`Test "${test}" is not defined in Uniform manifest.`);
|
|
270
|
+
return {
|
|
271
|
+
index: null,
|
|
272
|
+
event: null
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
const slot = ((_b = component.slots) == null ? void 0 : _b[import_canvas2.CANVAS_TEST_SLOT]) || [];
|
|
227
276
|
const componentVariations = slot.map((v, i) => {
|
|
228
|
-
var _a2,
|
|
229
|
-
const contextTag = (
|
|
277
|
+
var _a2, _b2, _c;
|
|
278
|
+
const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[import_canvas2.CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b2.value;
|
|
230
279
|
const id = (_c = contextTag == null ? void 0 : contextTag.id) != null ? _c : "testId" in v ? v.testId : `ab-${i}-${v.type}`;
|
|
231
280
|
return {
|
|
232
281
|
id,
|
|
@@ -265,6 +314,7 @@ var runTest = ({
|
|
|
265
314
|
};
|
|
266
315
|
// Annotate the CommonJS export names for ESM import in node:
|
|
267
316
|
0 && (module.exports = {
|
|
317
|
+
AppDirectoryContextInstance,
|
|
268
318
|
createUniformContext,
|
|
269
319
|
getBaseUrl,
|
|
270
320
|
resolvePath,
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
var __typeError = (msg) => {
|
|
2
|
+
throw TypeError(msg);
|
|
3
|
+
};
|
|
4
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
+
|
|
1
9
|
// src/context/createUniformContext.ts
|
|
2
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
Context,
|
|
12
|
+
CookieTransitionDataStore
|
|
13
|
+
} from "@uniformdev/context";
|
|
3
14
|
|
|
4
15
|
// src/utils/path.ts
|
|
5
16
|
var resolvePath = ({ params }) => {
|
|
@@ -63,51 +74,84 @@ var createUniformContext = ({
|
|
|
63
74
|
serverCookieValue
|
|
64
75
|
})
|
|
65
76
|
});
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
const wrapped = new AppDirectoryContextInstance(context);
|
|
78
|
+
return wrapped;
|
|
79
|
+
};
|
|
80
|
+
var _context;
|
|
81
|
+
var AppDirectoryContextInstance = class {
|
|
82
|
+
constructor(context) {
|
|
83
|
+
__privateAdd(this, _context);
|
|
84
|
+
__privateSet(this, _context, context);
|
|
85
|
+
this.manifest = context.manifest;
|
|
86
|
+
this.events = context.events;
|
|
87
|
+
}
|
|
88
|
+
get scores() {
|
|
89
|
+
return __privateGet(this, _context).scores;
|
|
90
|
+
}
|
|
91
|
+
get quirks() {
|
|
92
|
+
return __privateGet(this, _context).quirks;
|
|
93
|
+
}
|
|
94
|
+
getTestVariantId(testName) {
|
|
95
|
+
return __privateGet(this, _context).getTestVariantId(testName);
|
|
96
|
+
}
|
|
97
|
+
setTestVariantId(testName, variantId) {
|
|
98
|
+
return __privateGet(this, _context).setTestVariantId(testName, variantId);
|
|
99
|
+
}
|
|
100
|
+
log(...message) {
|
|
101
|
+
return __privateGet(this, _context).log(...message);
|
|
102
|
+
}
|
|
103
|
+
test(options) {
|
|
104
|
+
return __privateGet(this, _context).test(options);
|
|
105
|
+
}
|
|
106
|
+
personalize(options) {
|
|
107
|
+
return __privateGet(this, _context).personalize(options);
|
|
108
|
+
}
|
|
109
|
+
forget(fromAllDevices) {
|
|
110
|
+
return __privateGet(this, _context).forget(fromAllDevices);
|
|
111
|
+
}
|
|
112
|
+
getServerToClientTransitionState() {
|
|
113
|
+
return __privateGet(this, _context).getServerToClientTransitionState();
|
|
114
|
+
}
|
|
115
|
+
internal_processTestEvent(event) {
|
|
116
|
+
return __privateGet(this, _context).internal_processTestEvent(event);
|
|
117
|
+
}
|
|
118
|
+
internal_processPersonalizationEvent(event) {
|
|
119
|
+
return __privateGet(this, _context).internal_processPersonalizationEvent(event);
|
|
120
|
+
}
|
|
121
|
+
update(update) {
|
|
122
|
+
const { params, searchParams } = update;
|
|
123
|
+
const DEFAULT_URL = `${getBaseUrl()}/`;
|
|
124
|
+
let url = void 0;
|
|
125
|
+
if (params) {
|
|
126
|
+
const path = resolvePath({
|
|
127
|
+
params
|
|
128
|
+
});
|
|
129
|
+
if (!url) {
|
|
130
|
+
url = new URL(DEFAULT_URL);
|
|
89
131
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
url
|
|
132
|
+
url.pathname = path.value;
|
|
133
|
+
}
|
|
134
|
+
if (searchParams) {
|
|
135
|
+
Object.keys(searchParams).forEach((key) => {
|
|
136
|
+
const value = searchParams[key];
|
|
137
|
+
if (typeof value === "string") {
|
|
138
|
+
if (!url) {
|
|
139
|
+
url = new URL(DEFAULT_URL);
|
|
98
140
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return context.update({
|
|
102
|
-
...update,
|
|
103
|
-
url
|
|
141
|
+
url.searchParams.set(key, value);
|
|
142
|
+
}
|
|
104
143
|
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
144
|
+
}
|
|
145
|
+
return __privateGet(this, _context).update({
|
|
146
|
+
...update,
|
|
147
|
+
url
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
internal_update(update) {
|
|
151
|
+
return this.update(update);
|
|
152
|
+
}
|
|
110
153
|
};
|
|
154
|
+
_context = new WeakMap();
|
|
111
155
|
|
|
112
156
|
// src/runPersonalization.ts
|
|
113
157
|
import { CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
@@ -192,11 +236,19 @@ var runTest = ({
|
|
|
192
236
|
component,
|
|
193
237
|
contextInstance
|
|
194
238
|
}) => {
|
|
195
|
-
var _a;
|
|
196
|
-
const
|
|
239
|
+
var _a, _b;
|
|
240
|
+
const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
|
|
241
|
+
if (!isTestDefined && process.env.NODE_ENV !== "production") {
|
|
242
|
+
console.warn(`Test "${test}" is not defined in Uniform manifest.`);
|
|
243
|
+
return {
|
|
244
|
+
index: null,
|
|
245
|
+
event: null
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const slot = ((_b = component.slots) == null ? void 0 : _b[CANVAS_TEST_SLOT]) || [];
|
|
197
249
|
const componentVariations = slot.map((v, i) => {
|
|
198
|
-
var _a2,
|
|
199
|
-
const contextTag = (
|
|
250
|
+
var _a2, _b2, _c;
|
|
251
|
+
const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b2.value;
|
|
200
252
|
const id = (_c = contextTag == null ? void 0 : contextTag.id) != null ? _c : "testId" in v ? v.testId : `ab-${i}-${v.type}`;
|
|
201
253
|
return {
|
|
202
254
|
id,
|
|
@@ -234,6 +286,7 @@ var runTest = ({
|
|
|
234
286
|
};
|
|
235
287
|
};
|
|
236
288
|
export {
|
|
289
|
+
AppDirectoryContextInstance,
|
|
237
290
|
createUniformContext,
|
|
238
291
|
getBaseUrl,
|
|
239
292
|
resolvePath,
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc-shared",
|
|
3
|
-
"version": "19.135.1-alpha.
|
|
3
|
+
"version": "19.135.1-alpha.12+5743153a1e",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
7
7
|
"dev": "tsup --watch",
|
|
8
|
-
"lint": "eslint \"
|
|
8
|
+
"lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
|
|
9
9
|
"test": "jest --maxWorkers=1 --passWithNoTests"
|
|
10
10
|
},
|
|
11
11
|
"sideEffects": false,
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"/dist"
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@types/node": "
|
|
28
|
-
"@types/react": "18.
|
|
29
|
-
"eslint": "
|
|
27
|
+
"@types/node": "20.10.6",
|
|
28
|
+
"@types/react": "18.3.3",
|
|
29
|
+
"eslint": "9.9.0",
|
|
30
30
|
"next": "^14.0.0",
|
|
31
|
-
"react": "18.
|
|
32
|
-
"react-dom": "18.
|
|
31
|
+
"react": "18.3.1",
|
|
32
|
+
"react-dom": "18.3.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@uniformdev/canvas": "19.135.1-alpha.
|
|
36
|
-
"@uniformdev/context": "19.135.1-alpha.
|
|
35
|
+
"@uniformdev/canvas": "19.135.1-alpha.12+5743153a1e",
|
|
36
|
+
"@uniformdev/context": "19.135.1-alpha.12+5743153a1e"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=16.14.0"
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "5743153a1e4308de3dfe7c0812eb493154421a71"
|
|
50
50
|
}
|