@uniformdev/canvas-next-rsc-shared 19.61.1-alpha.23 → 19.62.1-alpha.127
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/LICENSE.txt +1 -1
- package/dist/index.d.mts +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/index.esm.js +40 -37
- package/dist/index.js +40 -30
- package/dist/index.mjs +40 -37
- package/package.json +8 -8
package/LICENSE.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
©
|
|
1
|
+
© 2024 Uniform Systems, Inc. All Rights Reserved.
|
|
2
2
|
See details of Uniform Systems, Inc. Master Subscription Agreement here: https://uniform.dev/eula
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextInstance, ContextState, ContextOptions } from '@uniformdev/context';
|
|
1
|
+
import { ContextInstance, ContextState, ContextOptions, PersonalizationEvent, TestEvent } from '@uniformdev/context';
|
|
2
2
|
import * as _uniformdev_canvas from '@uniformdev/canvas';
|
|
3
3
|
import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
|
|
4
4
|
import { PropsWithChildren } from 'react';
|
|
@@ -31,6 +31,17 @@ type UniformServerConfig = {
|
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
33
|
projectMapCache?: CacheMode;
|
|
34
|
+
/**
|
|
35
|
+
* Options for Uniform Context
|
|
36
|
+
*/
|
|
37
|
+
context?: {
|
|
38
|
+
/**
|
|
39
|
+
* Disables the Uniform Context dev tools.
|
|
40
|
+
*
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
disableDevTools?: boolean;
|
|
44
|
+
};
|
|
34
45
|
/**
|
|
35
46
|
* Configure where system components should be evaluated.
|
|
36
47
|
*/
|
|
@@ -71,14 +82,11 @@ type UniformServerConfig = {
|
|
|
71
82
|
};
|
|
72
83
|
};
|
|
73
84
|
|
|
74
|
-
declare const getServerConfig: () => UniformServerConfig;
|
|
75
|
-
|
|
76
85
|
type PageParameters = {
|
|
77
86
|
/**
|
|
78
87
|
* The params object from Next.js router. Used to resolve a composition.
|
|
79
88
|
*/
|
|
80
89
|
params: {
|
|
81
|
-
slug?: string | string[];
|
|
82
90
|
path?: string | string[];
|
|
83
91
|
};
|
|
84
92
|
/**
|
|
@@ -104,6 +112,8 @@ type ComponentProps<TProps = unknown, TSlotNames extends string = string> = TPro
|
|
|
104
112
|
component: ComponentInstance;
|
|
105
113
|
context: CompositionContext;
|
|
106
114
|
slots: Record<TSlotNames, SlotDefinition>;
|
|
115
|
+
slotName: string | undefined;
|
|
116
|
+
slotIndex: number | undefined;
|
|
107
117
|
};
|
|
108
118
|
type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiResponse'> & {
|
|
109
119
|
composition: RootComponentInstance;
|
|
@@ -148,6 +158,7 @@ declare const runPersonalization: ({ component, trackingEventName, count, contex
|
|
|
148
158
|
contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
|
|
149
159
|
}) => {
|
|
150
160
|
indexes: number[];
|
|
161
|
+
event: PersonalizationEvent;
|
|
151
162
|
};
|
|
152
163
|
|
|
153
164
|
type TestProps = {
|
|
@@ -158,18 +169,21 @@ declare const runTest: ({ test, component, contextInstance, }: TestProps & {
|
|
|
158
169
|
component: _uniformdev_canvas.ComponentInstance;
|
|
159
170
|
context: CompositionContext;
|
|
160
171
|
slots: Record<string, SlotDefinition>;
|
|
172
|
+
slotName: string | undefined;
|
|
173
|
+
slotIndex: number | undefined;
|
|
161
174
|
} & {
|
|
162
175
|
contextInstance: Pick<ContextInstance, 'test'> | undefined;
|
|
163
176
|
}) => {
|
|
164
177
|
index: number | null;
|
|
178
|
+
event: TestEvent;
|
|
165
179
|
};
|
|
166
180
|
|
|
167
181
|
type ResolvePathResult = {
|
|
168
|
-
type: '
|
|
182
|
+
type: 'path';
|
|
169
183
|
value: string;
|
|
170
184
|
};
|
|
171
185
|
declare const resolvePath: ({ params }: Pick<PageParameters, 'params'>) => ResolvePathResult;
|
|
172
186
|
|
|
173
187
|
declare function getBaseUrl(): string;
|
|
174
188
|
|
|
175
|
-
export { AppDirectoryContext, AppDirectoryContextState, AppDirectoryServerContext, CacheMode, ComponentProps, CompositionContext, PageParameters, PersonalizeProps, PersonalizeWithContextComponentProps, PlaygroundParameters, ResolvePathResult, SlotDefinition, TestProps, UniformServerConfig, createUniformContext, getBaseUrl,
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextInstance, ContextState, ContextOptions } from '@uniformdev/context';
|
|
1
|
+
import { ContextInstance, ContextState, ContextOptions, PersonalizationEvent, TestEvent } from '@uniformdev/context';
|
|
2
2
|
import * as _uniformdev_canvas from '@uniformdev/canvas';
|
|
3
3
|
import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
|
|
4
4
|
import { PropsWithChildren } from 'react';
|
|
@@ -31,6 +31,17 @@ type UniformServerConfig = {
|
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
33
|
projectMapCache?: CacheMode;
|
|
34
|
+
/**
|
|
35
|
+
* Options for Uniform Context
|
|
36
|
+
*/
|
|
37
|
+
context?: {
|
|
38
|
+
/**
|
|
39
|
+
* Disables the Uniform Context dev tools.
|
|
40
|
+
*
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
disableDevTools?: boolean;
|
|
44
|
+
};
|
|
34
45
|
/**
|
|
35
46
|
* Configure where system components should be evaluated.
|
|
36
47
|
*/
|
|
@@ -71,14 +82,11 @@ type UniformServerConfig = {
|
|
|
71
82
|
};
|
|
72
83
|
};
|
|
73
84
|
|
|
74
|
-
declare const getServerConfig: () => UniformServerConfig;
|
|
75
|
-
|
|
76
85
|
type PageParameters = {
|
|
77
86
|
/**
|
|
78
87
|
* The params object from Next.js router. Used to resolve a composition.
|
|
79
88
|
*/
|
|
80
89
|
params: {
|
|
81
|
-
slug?: string | string[];
|
|
82
90
|
path?: string | string[];
|
|
83
91
|
};
|
|
84
92
|
/**
|
|
@@ -104,6 +112,8 @@ type ComponentProps<TProps = unknown, TSlotNames extends string = string> = TPro
|
|
|
104
112
|
component: ComponentInstance;
|
|
105
113
|
context: CompositionContext;
|
|
106
114
|
slots: Record<TSlotNames, SlotDefinition>;
|
|
115
|
+
slotName: string | undefined;
|
|
116
|
+
slotIndex: number | undefined;
|
|
107
117
|
};
|
|
108
118
|
type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiResponse'> & {
|
|
109
119
|
composition: RootComponentInstance;
|
|
@@ -148,6 +158,7 @@ declare const runPersonalization: ({ component, trackingEventName, count, contex
|
|
|
148
158
|
contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
|
|
149
159
|
}) => {
|
|
150
160
|
indexes: number[];
|
|
161
|
+
event: PersonalizationEvent;
|
|
151
162
|
};
|
|
152
163
|
|
|
153
164
|
type TestProps = {
|
|
@@ -158,18 +169,21 @@ declare const runTest: ({ test, component, contextInstance, }: TestProps & {
|
|
|
158
169
|
component: _uniformdev_canvas.ComponentInstance;
|
|
159
170
|
context: CompositionContext;
|
|
160
171
|
slots: Record<string, SlotDefinition>;
|
|
172
|
+
slotName: string | undefined;
|
|
173
|
+
slotIndex: number | undefined;
|
|
161
174
|
} & {
|
|
162
175
|
contextInstance: Pick<ContextInstance, 'test'> | undefined;
|
|
163
176
|
}) => {
|
|
164
177
|
index: number | null;
|
|
178
|
+
event: TestEvent;
|
|
165
179
|
};
|
|
166
180
|
|
|
167
181
|
type ResolvePathResult = {
|
|
168
|
-
type: '
|
|
182
|
+
type: 'path';
|
|
169
183
|
value: string;
|
|
170
184
|
};
|
|
171
185
|
declare const resolvePath: ({ params }: Pick<PageParameters, 'params'>) => ResolvePathResult;
|
|
172
186
|
|
|
173
187
|
declare function getBaseUrl(): string;
|
|
174
188
|
|
|
175
|
-
export { AppDirectoryContext, AppDirectoryContextState, AppDirectoryServerContext, CacheMode, ComponentProps, CompositionContext, PageParameters, PersonalizeProps, PersonalizeWithContextComponentProps, PlaygroundParameters, ResolvePathResult, SlotDefinition, TestProps, UniformServerConfig, createUniformContext, getBaseUrl,
|
|
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 };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,38 +1,13 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
// src/config/helpers.ts
|
|
10
|
-
var getServerConfig = () => {
|
|
11
|
-
let serverConfig;
|
|
12
|
-
try {
|
|
13
|
-
serverConfig = __require("uniform.server.config.js");
|
|
14
|
-
} catch (e) {
|
|
15
|
-
serverConfig = {
|
|
16
|
-
defaultConsent: false
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
return serverConfig;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
1
|
// src/context/createUniformContext.ts
|
|
23
2
|
import { Context, CookieTransitionDataStore } from "@uniformdev/context";
|
|
24
3
|
|
|
25
4
|
// src/utils/path.ts
|
|
26
5
|
var resolvePath = ({ params }) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
} else {
|
|
34
|
-
throw new Error("Slug resolution is currently not implemented.");
|
|
35
|
-
}
|
|
6
|
+
const value = processPath(params.path || "");
|
|
7
|
+
return {
|
|
8
|
+
type: "path",
|
|
9
|
+
value
|
|
10
|
+
};
|
|
36
11
|
};
|
|
37
12
|
var processPath = (value) => {
|
|
38
13
|
const definedSlug = !Array.isArray(value) ? resolveSlugFromString(value) : resolveSlugFromArray(value);
|
|
@@ -82,10 +57,8 @@ var createUniformContext = ({
|
|
|
82
57
|
serverCookieValue,
|
|
83
58
|
...rest
|
|
84
59
|
}) => {
|
|
85
|
-
var _a;
|
|
86
60
|
const context = new Context({
|
|
87
61
|
...rest,
|
|
88
|
-
defaultConsent: (_a = getServerConfig()) == null ? void 0 : _a.defaultConsent,
|
|
89
62
|
transitionStore: new CookieTransitionDataStore({
|
|
90
63
|
serverCookieValue
|
|
91
64
|
})
|
|
@@ -100,6 +73,7 @@ var createUniformContext = ({
|
|
|
100
73
|
setTestVariantId: (...props) => context.setTestVariantId(...props),
|
|
101
74
|
scores: context.scores,
|
|
102
75
|
test: (...props) => context.test(...props),
|
|
76
|
+
manifest: context.manifest,
|
|
103
77
|
update: (update) => {
|
|
104
78
|
const { params, searchParams } = update;
|
|
105
79
|
const DEFAULT_URL = `${getBaseUrl()}/`;
|
|
@@ -128,7 +102,9 @@ var createUniformContext = ({
|
|
|
128
102
|
...update,
|
|
129
103
|
url
|
|
130
104
|
});
|
|
131
|
-
}
|
|
105
|
+
},
|
|
106
|
+
internal_processTestEvent: (...props) => context.internal_processTestEvent(...props),
|
|
107
|
+
internal_processPersonalizationEvent: (...props) => context.internal_processPersonalizationEvent(...props)
|
|
132
108
|
};
|
|
133
109
|
return appDirectoryContext;
|
|
134
110
|
};
|
|
@@ -154,6 +130,7 @@ var runPersonalization = ({
|
|
|
154
130
|
};
|
|
155
131
|
});
|
|
156
132
|
const indexes = [];
|
|
133
|
+
const variantIds = [];
|
|
157
134
|
let parsedCount;
|
|
158
135
|
if (typeof count === "string") {
|
|
159
136
|
parsedCount = parseInt(count, 10);
|
|
@@ -171,6 +148,10 @@ var runPersonalization = ({
|
|
|
171
148
|
if (variations) {
|
|
172
149
|
for (let i = 0; i < variations.length; i++) {
|
|
173
150
|
indexes.push(variations[i].index);
|
|
151
|
+
variantIds.push({
|
|
152
|
+
id: variations[i].id,
|
|
153
|
+
control: variations[i].control
|
|
154
|
+
});
|
|
174
155
|
}
|
|
175
156
|
}
|
|
176
157
|
} else {
|
|
@@ -185,9 +166,22 @@ var runPersonalization = ({
|
|
|
185
166
|
}
|
|
186
167
|
}
|
|
187
168
|
indexes.push(...defaults);
|
|
169
|
+
variantIds.push(
|
|
170
|
+
...defaults.map((i) => ({
|
|
171
|
+
id: componentVariations[i].id,
|
|
172
|
+
control: false
|
|
173
|
+
}))
|
|
174
|
+
);
|
|
188
175
|
}
|
|
176
|
+
const event = {
|
|
177
|
+
name: trackingEventName,
|
|
178
|
+
variantIds,
|
|
179
|
+
changed: true,
|
|
180
|
+
control: false
|
|
181
|
+
};
|
|
189
182
|
return {
|
|
190
|
-
indexes
|
|
183
|
+
indexes,
|
|
184
|
+
event
|
|
191
185
|
};
|
|
192
186
|
};
|
|
193
187
|
|
|
@@ -211,6 +205,7 @@ var runTest = ({
|
|
|
211
205
|
};
|
|
212
206
|
});
|
|
213
207
|
let index = null;
|
|
208
|
+
let variantId = null;
|
|
214
209
|
if (contextInstance) {
|
|
215
210
|
const { result } = contextInstance.test({
|
|
216
211
|
name: test,
|
|
@@ -218,21 +213,29 @@ var runTest = ({
|
|
|
218
213
|
});
|
|
219
214
|
if (result) {
|
|
220
215
|
index = result.index;
|
|
216
|
+
variantId = result.id;
|
|
221
217
|
}
|
|
222
|
-
}
|
|
218
|
+
}
|
|
219
|
+
if (!variantId) {
|
|
223
220
|
const [first] = componentVariations;
|
|
224
221
|
if (first) {
|
|
225
222
|
index = first.index;
|
|
223
|
+
variantId = first.id;
|
|
226
224
|
}
|
|
227
225
|
}
|
|
226
|
+
const event = {
|
|
227
|
+
name: test,
|
|
228
|
+
variantAssigned: true,
|
|
229
|
+
variantId: variantId != null ? variantId : "NO_VARIANTS"
|
|
230
|
+
};
|
|
228
231
|
return {
|
|
229
|
-
index
|
|
232
|
+
index,
|
|
233
|
+
event
|
|
230
234
|
};
|
|
231
235
|
};
|
|
232
236
|
export {
|
|
233
237
|
createUniformContext,
|
|
234
238
|
getBaseUrl,
|
|
235
|
-
getServerConfig,
|
|
236
239
|
resolvePath,
|
|
237
240
|
runPersonalization,
|
|
238
241
|
runTest
|
package/dist/index.js
CHANGED
|
@@ -22,40 +22,22 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
createUniformContext: () => createUniformContext,
|
|
24
24
|
getBaseUrl: () => getBaseUrl,
|
|
25
|
-
getServerConfig: () => getServerConfig,
|
|
26
25
|
resolvePath: () => resolvePath,
|
|
27
26
|
runPersonalization: () => runPersonalization,
|
|
28
27
|
runTest: () => runTest
|
|
29
28
|
});
|
|
30
29
|
module.exports = __toCommonJS(src_exports);
|
|
31
30
|
|
|
32
|
-
// src/config/helpers.ts
|
|
33
|
-
var getServerConfig = () => {
|
|
34
|
-
let serverConfig;
|
|
35
|
-
try {
|
|
36
|
-
serverConfig = require("uniform.server.config.js");
|
|
37
|
-
} catch (e) {
|
|
38
|
-
serverConfig = {
|
|
39
|
-
defaultConsent: false
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return serverConfig;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
31
|
// src/context/createUniformContext.ts
|
|
46
32
|
var import_context = require("@uniformdev/context");
|
|
47
33
|
|
|
48
34
|
// src/utils/path.ts
|
|
49
35
|
var resolvePath = ({ params }) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
} else {
|
|
57
|
-
throw new Error("Slug resolution is currently not implemented.");
|
|
58
|
-
}
|
|
36
|
+
const value = processPath(params.path || "");
|
|
37
|
+
return {
|
|
38
|
+
type: "path",
|
|
39
|
+
value
|
|
40
|
+
};
|
|
59
41
|
};
|
|
60
42
|
var processPath = (value) => {
|
|
61
43
|
const definedSlug = !Array.isArray(value) ? resolveSlugFromString(value) : resolveSlugFromArray(value);
|
|
@@ -105,10 +87,8 @@ var createUniformContext = ({
|
|
|
105
87
|
serverCookieValue,
|
|
106
88
|
...rest
|
|
107
89
|
}) => {
|
|
108
|
-
var _a;
|
|
109
90
|
const context = new import_context.Context({
|
|
110
91
|
...rest,
|
|
111
|
-
defaultConsent: (_a = getServerConfig()) == null ? void 0 : _a.defaultConsent,
|
|
112
92
|
transitionStore: new import_context.CookieTransitionDataStore({
|
|
113
93
|
serverCookieValue
|
|
114
94
|
})
|
|
@@ -123,6 +103,7 @@ var createUniformContext = ({
|
|
|
123
103
|
setTestVariantId: (...props) => context.setTestVariantId(...props),
|
|
124
104
|
scores: context.scores,
|
|
125
105
|
test: (...props) => context.test(...props),
|
|
106
|
+
manifest: context.manifest,
|
|
126
107
|
update: (update) => {
|
|
127
108
|
const { params, searchParams } = update;
|
|
128
109
|
const DEFAULT_URL = `${getBaseUrl()}/`;
|
|
@@ -151,7 +132,9 @@ var createUniformContext = ({
|
|
|
151
132
|
...update,
|
|
152
133
|
url
|
|
153
134
|
});
|
|
154
|
-
}
|
|
135
|
+
},
|
|
136
|
+
internal_processTestEvent: (...props) => context.internal_processTestEvent(...props),
|
|
137
|
+
internal_processPersonalizationEvent: (...props) => context.internal_processPersonalizationEvent(...props)
|
|
155
138
|
};
|
|
156
139
|
return appDirectoryContext;
|
|
157
140
|
};
|
|
@@ -177,6 +160,7 @@ var runPersonalization = ({
|
|
|
177
160
|
};
|
|
178
161
|
});
|
|
179
162
|
const indexes = [];
|
|
163
|
+
const variantIds = [];
|
|
180
164
|
let parsedCount;
|
|
181
165
|
if (typeof count === "string") {
|
|
182
166
|
parsedCount = parseInt(count, 10);
|
|
@@ -194,6 +178,10 @@ var runPersonalization = ({
|
|
|
194
178
|
if (variations) {
|
|
195
179
|
for (let i = 0; i < variations.length; i++) {
|
|
196
180
|
indexes.push(variations[i].index);
|
|
181
|
+
variantIds.push({
|
|
182
|
+
id: variations[i].id,
|
|
183
|
+
control: variations[i].control
|
|
184
|
+
});
|
|
197
185
|
}
|
|
198
186
|
}
|
|
199
187
|
} else {
|
|
@@ -208,9 +196,22 @@ var runPersonalization = ({
|
|
|
208
196
|
}
|
|
209
197
|
}
|
|
210
198
|
indexes.push(...defaults);
|
|
199
|
+
variantIds.push(
|
|
200
|
+
...defaults.map((i) => ({
|
|
201
|
+
id: componentVariations[i].id,
|
|
202
|
+
control: false
|
|
203
|
+
}))
|
|
204
|
+
);
|
|
211
205
|
}
|
|
206
|
+
const event = {
|
|
207
|
+
name: trackingEventName,
|
|
208
|
+
variantIds,
|
|
209
|
+
changed: true,
|
|
210
|
+
control: false
|
|
211
|
+
};
|
|
212
212
|
return {
|
|
213
|
-
indexes
|
|
213
|
+
indexes,
|
|
214
|
+
event
|
|
214
215
|
};
|
|
215
216
|
};
|
|
216
217
|
|
|
@@ -234,6 +235,7 @@ var runTest = ({
|
|
|
234
235
|
};
|
|
235
236
|
});
|
|
236
237
|
let index = null;
|
|
238
|
+
let variantId = null;
|
|
237
239
|
if (contextInstance) {
|
|
238
240
|
const { result } = contextInstance.test({
|
|
239
241
|
name: test,
|
|
@@ -241,22 +243,30 @@ var runTest = ({
|
|
|
241
243
|
});
|
|
242
244
|
if (result) {
|
|
243
245
|
index = result.index;
|
|
246
|
+
variantId = result.id;
|
|
244
247
|
}
|
|
245
|
-
}
|
|
248
|
+
}
|
|
249
|
+
if (!variantId) {
|
|
246
250
|
const [first] = componentVariations;
|
|
247
251
|
if (first) {
|
|
248
252
|
index = first.index;
|
|
253
|
+
variantId = first.id;
|
|
249
254
|
}
|
|
250
255
|
}
|
|
256
|
+
const event = {
|
|
257
|
+
name: test,
|
|
258
|
+
variantAssigned: true,
|
|
259
|
+
variantId: variantId != null ? variantId : "NO_VARIANTS"
|
|
260
|
+
};
|
|
251
261
|
return {
|
|
252
|
-
index
|
|
262
|
+
index,
|
|
263
|
+
event
|
|
253
264
|
};
|
|
254
265
|
};
|
|
255
266
|
// Annotate the CommonJS export names for ESM import in node:
|
|
256
267
|
0 && (module.exports = {
|
|
257
268
|
createUniformContext,
|
|
258
269
|
getBaseUrl,
|
|
259
|
-
getServerConfig,
|
|
260
270
|
resolvePath,
|
|
261
271
|
runPersonalization,
|
|
262
272
|
runTest
|
package/dist/index.mjs
CHANGED
|
@@ -1,38 +1,13 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
// src/config/helpers.ts
|
|
10
|
-
var getServerConfig = () => {
|
|
11
|
-
let serverConfig;
|
|
12
|
-
try {
|
|
13
|
-
serverConfig = __require("uniform.server.config.js");
|
|
14
|
-
} catch (e) {
|
|
15
|
-
serverConfig = {
|
|
16
|
-
defaultConsent: false
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
return serverConfig;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
1
|
// src/context/createUniformContext.ts
|
|
23
2
|
import { Context, CookieTransitionDataStore } from "@uniformdev/context";
|
|
24
3
|
|
|
25
4
|
// src/utils/path.ts
|
|
26
5
|
var resolvePath = ({ params }) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
} else {
|
|
34
|
-
throw new Error("Slug resolution is currently not implemented.");
|
|
35
|
-
}
|
|
6
|
+
const value = processPath(params.path || "");
|
|
7
|
+
return {
|
|
8
|
+
type: "path",
|
|
9
|
+
value
|
|
10
|
+
};
|
|
36
11
|
};
|
|
37
12
|
var processPath = (value) => {
|
|
38
13
|
const definedSlug = !Array.isArray(value) ? resolveSlugFromString(value) : resolveSlugFromArray(value);
|
|
@@ -82,10 +57,8 @@ var createUniformContext = ({
|
|
|
82
57
|
serverCookieValue,
|
|
83
58
|
...rest
|
|
84
59
|
}) => {
|
|
85
|
-
var _a;
|
|
86
60
|
const context = new Context({
|
|
87
61
|
...rest,
|
|
88
|
-
defaultConsent: (_a = getServerConfig()) == null ? void 0 : _a.defaultConsent,
|
|
89
62
|
transitionStore: new CookieTransitionDataStore({
|
|
90
63
|
serverCookieValue
|
|
91
64
|
})
|
|
@@ -100,6 +73,7 @@ var createUniformContext = ({
|
|
|
100
73
|
setTestVariantId: (...props) => context.setTestVariantId(...props),
|
|
101
74
|
scores: context.scores,
|
|
102
75
|
test: (...props) => context.test(...props),
|
|
76
|
+
manifest: context.manifest,
|
|
103
77
|
update: (update) => {
|
|
104
78
|
const { params, searchParams } = update;
|
|
105
79
|
const DEFAULT_URL = `${getBaseUrl()}/`;
|
|
@@ -128,7 +102,9 @@ var createUniformContext = ({
|
|
|
128
102
|
...update,
|
|
129
103
|
url
|
|
130
104
|
});
|
|
131
|
-
}
|
|
105
|
+
},
|
|
106
|
+
internal_processTestEvent: (...props) => context.internal_processTestEvent(...props),
|
|
107
|
+
internal_processPersonalizationEvent: (...props) => context.internal_processPersonalizationEvent(...props)
|
|
132
108
|
};
|
|
133
109
|
return appDirectoryContext;
|
|
134
110
|
};
|
|
@@ -154,6 +130,7 @@ var runPersonalization = ({
|
|
|
154
130
|
};
|
|
155
131
|
});
|
|
156
132
|
const indexes = [];
|
|
133
|
+
const variantIds = [];
|
|
157
134
|
let parsedCount;
|
|
158
135
|
if (typeof count === "string") {
|
|
159
136
|
parsedCount = parseInt(count, 10);
|
|
@@ -171,6 +148,10 @@ var runPersonalization = ({
|
|
|
171
148
|
if (variations) {
|
|
172
149
|
for (let i = 0; i < variations.length; i++) {
|
|
173
150
|
indexes.push(variations[i].index);
|
|
151
|
+
variantIds.push({
|
|
152
|
+
id: variations[i].id,
|
|
153
|
+
control: variations[i].control
|
|
154
|
+
});
|
|
174
155
|
}
|
|
175
156
|
}
|
|
176
157
|
} else {
|
|
@@ -185,9 +166,22 @@ var runPersonalization = ({
|
|
|
185
166
|
}
|
|
186
167
|
}
|
|
187
168
|
indexes.push(...defaults);
|
|
169
|
+
variantIds.push(
|
|
170
|
+
...defaults.map((i) => ({
|
|
171
|
+
id: componentVariations[i].id,
|
|
172
|
+
control: false
|
|
173
|
+
}))
|
|
174
|
+
);
|
|
188
175
|
}
|
|
176
|
+
const event = {
|
|
177
|
+
name: trackingEventName,
|
|
178
|
+
variantIds,
|
|
179
|
+
changed: true,
|
|
180
|
+
control: false
|
|
181
|
+
};
|
|
189
182
|
return {
|
|
190
|
-
indexes
|
|
183
|
+
indexes,
|
|
184
|
+
event
|
|
191
185
|
};
|
|
192
186
|
};
|
|
193
187
|
|
|
@@ -211,6 +205,7 @@ var runTest = ({
|
|
|
211
205
|
};
|
|
212
206
|
});
|
|
213
207
|
let index = null;
|
|
208
|
+
let variantId = null;
|
|
214
209
|
if (contextInstance) {
|
|
215
210
|
const { result } = contextInstance.test({
|
|
216
211
|
name: test,
|
|
@@ -218,21 +213,29 @@ var runTest = ({
|
|
|
218
213
|
});
|
|
219
214
|
if (result) {
|
|
220
215
|
index = result.index;
|
|
216
|
+
variantId = result.id;
|
|
221
217
|
}
|
|
222
|
-
}
|
|
218
|
+
}
|
|
219
|
+
if (!variantId) {
|
|
223
220
|
const [first] = componentVariations;
|
|
224
221
|
if (first) {
|
|
225
222
|
index = first.index;
|
|
223
|
+
variantId = first.id;
|
|
226
224
|
}
|
|
227
225
|
}
|
|
226
|
+
const event = {
|
|
227
|
+
name: test,
|
|
228
|
+
variantAssigned: true,
|
|
229
|
+
variantId: variantId != null ? variantId : "NO_VARIANTS"
|
|
230
|
+
};
|
|
228
231
|
return {
|
|
229
|
-
index
|
|
232
|
+
index,
|
|
233
|
+
event
|
|
230
234
|
};
|
|
231
235
|
};
|
|
232
236
|
export {
|
|
233
237
|
createUniformContext,
|
|
234
238
|
getBaseUrl,
|
|
235
|
-
getServerConfig,
|
|
236
239
|
resolvePath,
|
|
237
240
|
runPersonalization,
|
|
238
241
|
runTest
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc-shared",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.62.1-alpha.127+d49e5a0782",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"/dist"
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@types/node": "^
|
|
28
|
-
"@types/react": "
|
|
29
|
-
"eslint": "
|
|
30
|
-
"next": "^
|
|
27
|
+
"@types/node": "^20.0.0",
|
|
28
|
+
"@types/react": "18.2.40",
|
|
29
|
+
"eslint": "8.57.0",
|
|
30
|
+
"next": "^14.0.0",
|
|
31
31
|
"react": "18.2.0",
|
|
32
32
|
"react-dom": "18.2.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@uniformdev/canvas": "19.
|
|
36
|
-
"@uniformdev/context": "19.
|
|
35
|
+
"@uniformdev/canvas": "19.62.1-alpha.127+d49e5a0782",
|
|
36
|
+
"@uniformdev/context": "19.62.1-alpha.127+d49e5a0782"
|
|
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": "d49e5a07824d69e5df3a92ff10bc9acd88d0bc22"
|
|
50
50
|
}
|