@uniformdev/canvas-next-rsc-shared 19.79.0 → 19.79.1-alpha.7
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 +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.esm.js +26 -4
- package/dist/index.js +26 -4
- package/dist/index.mjs +26 -4
- package/package.json +6 -6
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';
|
|
@@ -115,6 +115,8 @@ type ComponentProps<TProps = unknown, TSlotNames extends string = string> = TPro
|
|
|
115
115
|
component: ComponentInstance;
|
|
116
116
|
context: CompositionContext;
|
|
117
117
|
slots: Record<TSlotNames, SlotDefinition>;
|
|
118
|
+
slotName: string | undefined;
|
|
119
|
+
slotIndex: number | undefined;
|
|
118
120
|
};
|
|
119
121
|
type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiResponse'> & {
|
|
120
122
|
composition: RootComponentInstance;
|
|
@@ -159,6 +161,7 @@ declare const runPersonalization: ({ component, trackingEventName, count, contex
|
|
|
159
161
|
contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
|
|
160
162
|
}) => {
|
|
161
163
|
indexes: number[];
|
|
164
|
+
event: PersonalizationEvent;
|
|
162
165
|
};
|
|
163
166
|
|
|
164
167
|
type TestProps = {
|
|
@@ -169,10 +172,13 @@ declare const runTest: ({ test, component, contextInstance, }: TestProps & {
|
|
|
169
172
|
component: _uniformdev_canvas.ComponentInstance;
|
|
170
173
|
context: CompositionContext;
|
|
171
174
|
slots: Record<string, SlotDefinition>;
|
|
175
|
+
slotName: string | undefined;
|
|
176
|
+
slotIndex: number | undefined;
|
|
172
177
|
} & {
|
|
173
178
|
contextInstance: Pick<ContextInstance, 'test'> | undefined;
|
|
174
179
|
}) => {
|
|
175
180
|
index: number | null;
|
|
181
|
+
event: TestEvent;
|
|
176
182
|
};
|
|
177
183
|
|
|
178
184
|
type ResolvePathResult = {
|
|
@@ -183,4 +189,4 @@ declare const resolvePath: ({ params }: Pick<PageParameters, 'params'>) => Resol
|
|
|
183
189
|
|
|
184
190
|
declare function getBaseUrl(): string;
|
|
185
191
|
|
|
186
|
-
export { AppDirectoryContext, AppDirectoryContextState, AppDirectoryServerContext, CacheMode, ComponentProps, CompositionContext, PageParameters, PersonalizeProps, PersonalizeWithContextComponentProps, PlaygroundParameters, ResolvePathResult, SlotDefinition, TestProps, UniformServerConfig, createUniformContext, getBaseUrl, getServerConfig, resolvePath, runPersonalization, runTest };
|
|
192
|
+
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, getServerConfig, 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';
|
|
@@ -115,6 +115,8 @@ type ComponentProps<TProps = unknown, TSlotNames extends string = string> = TPro
|
|
|
115
115
|
component: ComponentInstance;
|
|
116
116
|
context: CompositionContext;
|
|
117
117
|
slots: Record<TSlotNames, SlotDefinition>;
|
|
118
|
+
slotName: string | undefined;
|
|
119
|
+
slotIndex: number | undefined;
|
|
118
120
|
};
|
|
119
121
|
type CompositionContext = Omit<RouteGetResponseComposition, 'compositionApiResponse'> & {
|
|
120
122
|
composition: RootComponentInstance;
|
|
@@ -159,6 +161,7 @@ declare const runPersonalization: ({ component, trackingEventName, count, contex
|
|
|
159
161
|
contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
|
|
160
162
|
}) => {
|
|
161
163
|
indexes: number[];
|
|
164
|
+
event: PersonalizationEvent;
|
|
162
165
|
};
|
|
163
166
|
|
|
164
167
|
type TestProps = {
|
|
@@ -169,10 +172,13 @@ declare const runTest: ({ test, component, contextInstance, }: TestProps & {
|
|
|
169
172
|
component: _uniformdev_canvas.ComponentInstance;
|
|
170
173
|
context: CompositionContext;
|
|
171
174
|
slots: Record<string, SlotDefinition>;
|
|
175
|
+
slotName: string | undefined;
|
|
176
|
+
slotIndex: number | undefined;
|
|
172
177
|
} & {
|
|
173
178
|
contextInstance: Pick<ContextInstance, 'test'> | undefined;
|
|
174
179
|
}) => {
|
|
175
180
|
index: number | null;
|
|
181
|
+
event: TestEvent;
|
|
176
182
|
};
|
|
177
183
|
|
|
178
184
|
type ResolvePathResult = {
|
|
@@ -183,4 +189,4 @@ declare const resolvePath: ({ params }: Pick<PageParameters, 'params'>) => Resol
|
|
|
183
189
|
|
|
184
190
|
declare function getBaseUrl(): string;
|
|
185
191
|
|
|
186
|
-
export { AppDirectoryContext, AppDirectoryContextState, AppDirectoryServerContext, CacheMode, ComponentProps, CompositionContext, PageParameters, PersonalizeProps, PersonalizeWithContextComponentProps, PlaygroundParameters, ResolvePathResult, SlotDefinition, TestProps, UniformServerConfig, createUniformContext, getBaseUrl, getServerConfig, resolvePath, runPersonalization, runTest };
|
|
192
|
+
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, getServerConfig, resolvePath, runPersonalization, runTest };
|
package/dist/index.esm.js
CHANGED
|
@@ -100,6 +100,8 @@ var createUniformContext = ({
|
|
|
100
100
|
setTestVariantId: (...props) => context.setTestVariantId(...props),
|
|
101
101
|
scores: context.scores,
|
|
102
102
|
test: (...props) => context.test(...props),
|
|
103
|
+
internal_emitPersonalizationResult: (...props) => context.internal_emitPersonalizationResult(...props),
|
|
104
|
+
internal_emitTestResult: (...props) => context.internal_emitTestResult(...props),
|
|
103
105
|
update: (update) => {
|
|
104
106
|
const { params, searchParams } = update;
|
|
105
107
|
const DEFAULT_URL = `${getBaseUrl()}/`;
|
|
@@ -146,7 +148,7 @@ var runPersonalization = ({
|
|
|
146
148
|
const componentVariations = slot.map((v, i) => {
|
|
147
149
|
var _a2, _b2;
|
|
148
150
|
const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b2.value;
|
|
149
|
-
const id =
|
|
151
|
+
const id = v._id || `pz-${i}-${v.type}`;
|
|
150
152
|
return {
|
|
151
153
|
id,
|
|
152
154
|
pz: contextTag,
|
|
@@ -154,6 +156,7 @@ var runPersonalization = ({
|
|
|
154
156
|
};
|
|
155
157
|
});
|
|
156
158
|
const indexes = [];
|
|
159
|
+
const variantIds = [];
|
|
157
160
|
let parsedCount;
|
|
158
161
|
if (typeof count === "string") {
|
|
159
162
|
parsedCount = parseInt(count, 10);
|
|
@@ -171,6 +174,7 @@ var runPersonalization = ({
|
|
|
171
174
|
if (variations) {
|
|
172
175
|
for (let i = 0; i < variations.length; i++) {
|
|
173
176
|
indexes.push(variations[i].index);
|
|
177
|
+
variantIds.push(variations[i].id);
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
} else {
|
|
@@ -185,9 +189,17 @@ var runPersonalization = ({
|
|
|
185
189
|
}
|
|
186
190
|
}
|
|
187
191
|
indexes.push(...defaults);
|
|
192
|
+
variantIds.push(...defaults.map((i) => componentVariations[i].id));
|
|
188
193
|
}
|
|
194
|
+
const event = {
|
|
195
|
+
name: trackingEventName,
|
|
196
|
+
variantIds,
|
|
197
|
+
changed: false,
|
|
198
|
+
control: false
|
|
199
|
+
};
|
|
189
200
|
return {
|
|
190
|
-
indexes
|
|
201
|
+
indexes,
|
|
202
|
+
event
|
|
191
203
|
};
|
|
192
204
|
};
|
|
193
205
|
|
|
@@ -211,6 +223,7 @@ var runTest = ({
|
|
|
211
223
|
};
|
|
212
224
|
});
|
|
213
225
|
let index = null;
|
|
226
|
+
let variantId = null;
|
|
214
227
|
if (contextInstance) {
|
|
215
228
|
const { result } = contextInstance.test({
|
|
216
229
|
name: test,
|
|
@@ -218,15 +231,24 @@ var runTest = ({
|
|
|
218
231
|
});
|
|
219
232
|
if (result) {
|
|
220
233
|
index = result.index;
|
|
234
|
+
variantId = result.id;
|
|
221
235
|
}
|
|
222
|
-
}
|
|
236
|
+
}
|
|
237
|
+
if (!variantId) {
|
|
223
238
|
const [first] = componentVariations;
|
|
224
239
|
if (first) {
|
|
225
240
|
index = first.index;
|
|
241
|
+
variantId = first.id;
|
|
226
242
|
}
|
|
227
243
|
}
|
|
244
|
+
const event = {
|
|
245
|
+
name: test,
|
|
246
|
+
variantAssigned: true,
|
|
247
|
+
variantId: variantId != null ? variantId : "NO_VARIANTS"
|
|
248
|
+
};
|
|
228
249
|
return {
|
|
229
|
-
index
|
|
250
|
+
index,
|
|
251
|
+
event
|
|
230
252
|
};
|
|
231
253
|
};
|
|
232
254
|
export {
|
package/dist/index.js
CHANGED
|
@@ -123,6 +123,8 @@ var createUniformContext = ({
|
|
|
123
123
|
setTestVariantId: (...props) => context.setTestVariantId(...props),
|
|
124
124
|
scores: context.scores,
|
|
125
125
|
test: (...props) => context.test(...props),
|
|
126
|
+
internal_emitPersonalizationResult: (...props) => context.internal_emitPersonalizationResult(...props),
|
|
127
|
+
internal_emitTestResult: (...props) => context.internal_emitTestResult(...props),
|
|
126
128
|
update: (update) => {
|
|
127
129
|
const { params, searchParams } = update;
|
|
128
130
|
const DEFAULT_URL = `${getBaseUrl()}/`;
|
|
@@ -169,7 +171,7 @@ var runPersonalization = ({
|
|
|
169
171
|
const componentVariations = slot.map((v, i) => {
|
|
170
172
|
var _a2, _b2;
|
|
171
173
|
const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[import_canvas.CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b2.value;
|
|
172
|
-
const id =
|
|
174
|
+
const id = v._id || `pz-${i}-${v.type}`;
|
|
173
175
|
return {
|
|
174
176
|
id,
|
|
175
177
|
pz: contextTag,
|
|
@@ -177,6 +179,7 @@ var runPersonalization = ({
|
|
|
177
179
|
};
|
|
178
180
|
});
|
|
179
181
|
const indexes = [];
|
|
182
|
+
const variantIds = [];
|
|
180
183
|
let parsedCount;
|
|
181
184
|
if (typeof count === "string") {
|
|
182
185
|
parsedCount = parseInt(count, 10);
|
|
@@ -194,6 +197,7 @@ var runPersonalization = ({
|
|
|
194
197
|
if (variations) {
|
|
195
198
|
for (let i = 0; i < variations.length; i++) {
|
|
196
199
|
indexes.push(variations[i].index);
|
|
200
|
+
variantIds.push(variations[i].id);
|
|
197
201
|
}
|
|
198
202
|
}
|
|
199
203
|
} else {
|
|
@@ -208,9 +212,17 @@ var runPersonalization = ({
|
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
214
|
indexes.push(...defaults);
|
|
215
|
+
variantIds.push(...defaults.map((i) => componentVariations[i].id));
|
|
211
216
|
}
|
|
217
|
+
const event = {
|
|
218
|
+
name: trackingEventName,
|
|
219
|
+
variantIds,
|
|
220
|
+
changed: false,
|
|
221
|
+
control: false
|
|
222
|
+
};
|
|
212
223
|
return {
|
|
213
|
-
indexes
|
|
224
|
+
indexes,
|
|
225
|
+
event
|
|
214
226
|
};
|
|
215
227
|
};
|
|
216
228
|
|
|
@@ -234,6 +246,7 @@ var runTest = ({
|
|
|
234
246
|
};
|
|
235
247
|
});
|
|
236
248
|
let index = null;
|
|
249
|
+
let variantId = null;
|
|
237
250
|
if (contextInstance) {
|
|
238
251
|
const { result } = contextInstance.test({
|
|
239
252
|
name: test,
|
|
@@ -241,15 +254,24 @@ var runTest = ({
|
|
|
241
254
|
});
|
|
242
255
|
if (result) {
|
|
243
256
|
index = result.index;
|
|
257
|
+
variantId = result.id;
|
|
244
258
|
}
|
|
245
|
-
}
|
|
259
|
+
}
|
|
260
|
+
if (!variantId) {
|
|
246
261
|
const [first] = componentVariations;
|
|
247
262
|
if (first) {
|
|
248
263
|
index = first.index;
|
|
264
|
+
variantId = first.id;
|
|
249
265
|
}
|
|
250
266
|
}
|
|
267
|
+
const event = {
|
|
268
|
+
name: test,
|
|
269
|
+
variantAssigned: true,
|
|
270
|
+
variantId: variantId != null ? variantId : "NO_VARIANTS"
|
|
271
|
+
};
|
|
251
272
|
return {
|
|
252
|
-
index
|
|
273
|
+
index,
|
|
274
|
+
event
|
|
253
275
|
};
|
|
254
276
|
};
|
|
255
277
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -100,6 +100,8 @@ var createUniformContext = ({
|
|
|
100
100
|
setTestVariantId: (...props) => context.setTestVariantId(...props),
|
|
101
101
|
scores: context.scores,
|
|
102
102
|
test: (...props) => context.test(...props),
|
|
103
|
+
internal_emitPersonalizationResult: (...props) => context.internal_emitPersonalizationResult(...props),
|
|
104
|
+
internal_emitTestResult: (...props) => context.internal_emitTestResult(...props),
|
|
103
105
|
update: (update) => {
|
|
104
106
|
const { params, searchParams } = update;
|
|
105
107
|
const DEFAULT_URL = `${getBaseUrl()}/`;
|
|
@@ -146,7 +148,7 @@ var runPersonalization = ({
|
|
|
146
148
|
const componentVariations = slot.map((v, i) => {
|
|
147
149
|
var _a2, _b2;
|
|
148
150
|
const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b2.value;
|
|
149
|
-
const id =
|
|
151
|
+
const id = v._id || `pz-${i}-${v.type}`;
|
|
150
152
|
return {
|
|
151
153
|
id,
|
|
152
154
|
pz: contextTag,
|
|
@@ -154,6 +156,7 @@ var runPersonalization = ({
|
|
|
154
156
|
};
|
|
155
157
|
});
|
|
156
158
|
const indexes = [];
|
|
159
|
+
const variantIds = [];
|
|
157
160
|
let parsedCount;
|
|
158
161
|
if (typeof count === "string") {
|
|
159
162
|
parsedCount = parseInt(count, 10);
|
|
@@ -171,6 +174,7 @@ var runPersonalization = ({
|
|
|
171
174
|
if (variations) {
|
|
172
175
|
for (let i = 0; i < variations.length; i++) {
|
|
173
176
|
indexes.push(variations[i].index);
|
|
177
|
+
variantIds.push(variations[i].id);
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
} else {
|
|
@@ -185,9 +189,17 @@ var runPersonalization = ({
|
|
|
185
189
|
}
|
|
186
190
|
}
|
|
187
191
|
indexes.push(...defaults);
|
|
192
|
+
variantIds.push(...defaults.map((i) => componentVariations[i].id));
|
|
188
193
|
}
|
|
194
|
+
const event = {
|
|
195
|
+
name: trackingEventName,
|
|
196
|
+
variantIds,
|
|
197
|
+
changed: false,
|
|
198
|
+
control: false
|
|
199
|
+
};
|
|
189
200
|
return {
|
|
190
|
-
indexes
|
|
201
|
+
indexes,
|
|
202
|
+
event
|
|
191
203
|
};
|
|
192
204
|
};
|
|
193
205
|
|
|
@@ -211,6 +223,7 @@ var runTest = ({
|
|
|
211
223
|
};
|
|
212
224
|
});
|
|
213
225
|
let index = null;
|
|
226
|
+
let variantId = null;
|
|
214
227
|
if (contextInstance) {
|
|
215
228
|
const { result } = contextInstance.test({
|
|
216
229
|
name: test,
|
|
@@ -218,15 +231,24 @@ var runTest = ({
|
|
|
218
231
|
});
|
|
219
232
|
if (result) {
|
|
220
233
|
index = result.index;
|
|
234
|
+
variantId = result.id;
|
|
221
235
|
}
|
|
222
|
-
}
|
|
236
|
+
}
|
|
237
|
+
if (!variantId) {
|
|
223
238
|
const [first] = componentVariations;
|
|
224
239
|
if (first) {
|
|
225
240
|
index = first.index;
|
|
241
|
+
variantId = first.id;
|
|
226
242
|
}
|
|
227
243
|
}
|
|
244
|
+
const event = {
|
|
245
|
+
name: test,
|
|
246
|
+
variantAssigned: true,
|
|
247
|
+
variantId: variantId != null ? variantId : "NO_VARIANTS"
|
|
248
|
+
};
|
|
228
249
|
return {
|
|
229
|
-
index
|
|
250
|
+
index,
|
|
251
|
+
event
|
|
230
252
|
};
|
|
231
253
|
};
|
|
232
254
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc-shared",
|
|
3
|
-
"version": "19.79.
|
|
3
|
+
"version": "19.79.1-alpha.7+bd4b0c6f4",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^18.0.0",
|
|
28
|
-
"@types/react": "
|
|
29
|
-
"eslint": "
|
|
28
|
+
"@types/react": "18.2.40",
|
|
29
|
+
"eslint": "8.54.0",
|
|
30
30
|
"next": "^13.4.12",
|
|
31
31
|
"react": "18.2.0",
|
|
32
32
|
"react-dom": "18.2.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@uniformdev/canvas": "19.79.
|
|
36
|
-
"@uniformdev/context": "19.79.
|
|
35
|
+
"@uniformdev/canvas": "19.79.1-alpha.7+bd4b0c6f4",
|
|
36
|
+
"@uniformdev/context": "19.79.1-alpha.7+bd4b0c6f4"
|
|
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": "bd4b0c6f4a67549f8eb7e127a85927c798e7eed0"
|
|
50
50
|
}
|