@uniformdev/canvas-next-rsc-shared 20.34.3-alpha.70 → 20.35.1-alpha.188

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 CHANGED
@@ -230,11 +230,10 @@ type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
230
230
  contextInstance: AppDirectoryServerContext;
231
231
  };
232
232
 
233
- interface RunPersonalizationProps extends PersonalizeProps {
234
- component: ComponentProps['component'];
233
+ type RunPersonalizationProps = Omit<ComponentProps<PersonalizeProps & {
235
234
  contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
236
- }
237
- declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, }: RunPersonalizationProps) => {
235
+ }>, 'slots' | 'slotName' | 'slotIndex'>;
236
+ declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, context, }: RunPersonalizationProps) => {
238
237
  indexes: number[];
239
238
  event: PersonalizationEvent;
240
239
  };
@@ -243,9 +242,9 @@ type TestProps = {
243
242
  test: string;
244
243
  };
245
244
 
246
- declare const runTest: ({ test, component, contextInstance, context, }: ComponentProps<TestProps> & {
245
+ declare const runTest: ({ test, component, contextInstance, context, }: Omit<ComponentProps<TestProps> & {
247
246
  contextInstance: Pick<ContextInstance, "test" | "manifest"> | undefined;
248
- }) => {
247
+ }, "slots" | "slotName" | "slotIndex">) => {
249
248
  index: number | null;
250
249
  event: TestEvent | null;
251
250
  };
package/dist/index.d.ts CHANGED
@@ -230,11 +230,10 @@ type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
230
230
  contextInstance: AppDirectoryServerContext;
231
231
  };
232
232
 
233
- interface RunPersonalizationProps extends PersonalizeProps {
234
- component: ComponentProps['component'];
233
+ type RunPersonalizationProps = Omit<ComponentProps<PersonalizeProps & {
235
234
  contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
236
- }
237
- declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, }: RunPersonalizationProps) => {
235
+ }>, 'slots' | 'slotName' | 'slotIndex'>;
236
+ declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, context, }: RunPersonalizationProps) => {
238
237
  indexes: number[];
239
238
  event: PersonalizationEvent;
240
239
  };
@@ -243,9 +242,9 @@ type TestProps = {
243
242
  test: string;
244
243
  };
245
244
 
246
- declare const runTest: ({ test, component, contextInstance, context, }: ComponentProps<TestProps> & {
245
+ declare const runTest: ({ test, component, contextInstance, context, }: Omit<ComponentProps<TestProps> & {
247
246
  contextInstance: Pick<ContextInstance, "test" | "manifest"> | undefined;
248
- }) => {
247
+ }, "slots" | "slotName" | "slotIndex">) => {
249
248
  index: number | null;
250
249
  event: TestEvent | null;
251
250
  };
package/dist/index.esm.js CHANGED
@@ -189,7 +189,8 @@ var runPersonalization = ({
189
189
  trackingEventName,
190
190
  count,
191
191
  algorithm,
192
- contextInstance
192
+ contextInstance,
193
+ context
193
194
  }) => {
194
195
  var _a;
195
196
  const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT]) || [];
@@ -214,7 +215,12 @@ var runPersonalization = ({
214
215
  name: trackingEventName,
215
216
  take: parsedCount,
216
217
  variations: componentVariations,
217
- algorithm
218
+ algorithm,
219
+ compositionMetadata: {
220
+ compositionId: context.composition._id,
221
+ matchedRoute: context.matchedRoute,
222
+ dynamicInputs: context.dynamicInputs
223
+ }
218
224
  });
219
225
  if (variations) {
220
226
  for (let i = 0; i < variations.length; i++) {
@@ -231,7 +237,12 @@ var runPersonalization = ({
231
237
  name: trackingEventName,
232
238
  variantIds,
233
239
  changed: true,
234
- control: false
240
+ control: false,
241
+ compositionMetadata: {
242
+ compositionId: context.composition._id,
243
+ matchedRoute: context.matchedRoute,
244
+ dynamicInputs: context.dynamicInputs
245
+ }
235
246
  };
236
247
  return {
237
248
  indexes,
@@ -248,7 +259,7 @@ var runTest = ({
248
259
  contextInstance,
249
260
  context
250
261
  }) => {
251
- var _a, _b;
262
+ var _a, _b, _c, _d;
252
263
  const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
253
264
  const isContextualTest = context.isContextualEditing && test === CONTEXTUAL_EDITING_TEST_NAME;
254
265
  const shouldShowTest = isTestDefined || isContextualTest;
@@ -268,14 +279,21 @@ var runTest = ({
268
279
  });
269
280
  let index = null;
270
281
  let variantId = null;
282
+ let variantAssigned = false;
271
283
  if (contextInstance) {
272
- const { result } = contextInstance.test({
284
+ const { result, variantAssigned: wasVariantAssigned } = contextInstance.test({
273
285
  name: test,
274
- variations: componentVariations
286
+ variations: componentVariations,
287
+ compositionMetadata: {
288
+ compositionId: context.composition._id,
289
+ matchedRoute: context.matchedRoute,
290
+ dynamicInputs: context.dynamicInputs
291
+ }
275
292
  });
276
293
  if (result) {
277
294
  index = result.index;
278
295
  variantId = result.id;
296
+ variantAssigned = wasVariantAssigned;
279
297
  }
280
298
  }
281
299
  if (!variantId) {
@@ -287,9 +305,14 @@ var runTest = ({
287
305
  }
288
306
  const event = {
289
307
  name: test,
290
- variantAssigned: true,
291
- control: true,
292
- variantId: variantId != null ? variantId : "NO_VARIANTS"
308
+ variantAssigned,
309
+ control: variantId ? (_d = (_c = componentVariations.find((v) => v.id === variantId)) == null ? void 0 : _c.control) != null ? _d : false : false,
310
+ variantId: variantId != null ? variantId : "NO_VARIANTS",
311
+ compositionMetadata: {
312
+ compositionId: context.composition._id,
313
+ matchedRoute: context.matchedRoute,
314
+ dynamicInputs: context.dynamicInputs
315
+ }
293
316
  };
294
317
  return {
295
318
  index,
package/dist/index.js CHANGED
@@ -216,7 +216,8 @@ var runPersonalization = ({
216
216
  trackingEventName,
217
217
  count,
218
218
  algorithm,
219
- contextInstance
219
+ contextInstance,
220
+ context
220
221
  }) => {
221
222
  var _a;
222
223
  const slot = ((_a = component.slots) == null ? void 0 : _a[import_canvas.CANVAS_PERSONALIZE_SLOT]) || [];
@@ -241,7 +242,12 @@ var runPersonalization = ({
241
242
  name: trackingEventName,
242
243
  take: parsedCount,
243
244
  variations: componentVariations,
244
- algorithm
245
+ algorithm,
246
+ compositionMetadata: {
247
+ compositionId: context.composition._id,
248
+ matchedRoute: context.matchedRoute,
249
+ dynamicInputs: context.dynamicInputs
250
+ }
245
251
  });
246
252
  if (variations) {
247
253
  for (let i = 0; i < variations.length; i++) {
@@ -258,7 +264,12 @@ var runPersonalization = ({
258
264
  name: trackingEventName,
259
265
  variantIds,
260
266
  changed: true,
261
- control: false
267
+ control: false,
268
+ compositionMetadata: {
269
+ compositionId: context.composition._id,
270
+ matchedRoute: context.matchedRoute,
271
+ dynamicInputs: context.dynamicInputs
272
+ }
262
273
  };
263
274
  return {
264
275
  indexes,
@@ -275,7 +286,7 @@ var runTest = ({
275
286
  contextInstance,
276
287
  context
277
288
  }) => {
278
- var _a, _b;
289
+ var _a, _b, _c, _d;
279
290
  const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
280
291
  const isContextualTest = context.isContextualEditing && test === import_context2.CONTEXTUAL_EDITING_TEST_NAME;
281
292
  const shouldShowTest = isTestDefined || isContextualTest;
@@ -295,14 +306,21 @@ var runTest = ({
295
306
  });
296
307
  let index = null;
297
308
  let variantId = null;
309
+ let variantAssigned = false;
298
310
  if (contextInstance) {
299
- const { result } = contextInstance.test({
311
+ const { result, variantAssigned: wasVariantAssigned } = contextInstance.test({
300
312
  name: test,
301
- variations: componentVariations
313
+ variations: componentVariations,
314
+ compositionMetadata: {
315
+ compositionId: context.composition._id,
316
+ matchedRoute: context.matchedRoute,
317
+ dynamicInputs: context.dynamicInputs
318
+ }
302
319
  });
303
320
  if (result) {
304
321
  index = result.index;
305
322
  variantId = result.id;
323
+ variantAssigned = wasVariantAssigned;
306
324
  }
307
325
  }
308
326
  if (!variantId) {
@@ -314,9 +332,14 @@ var runTest = ({
314
332
  }
315
333
  const event = {
316
334
  name: test,
317
- variantAssigned: true,
318
- control: true,
319
- variantId: variantId != null ? variantId : "NO_VARIANTS"
335
+ variantAssigned,
336
+ control: variantId ? (_d = (_c = componentVariations.find((v) => v.id === variantId)) == null ? void 0 : _c.control) != null ? _d : false : false,
337
+ variantId: variantId != null ? variantId : "NO_VARIANTS",
338
+ compositionMetadata: {
339
+ compositionId: context.composition._id,
340
+ matchedRoute: context.matchedRoute,
341
+ dynamicInputs: context.dynamicInputs
342
+ }
320
343
  };
321
344
  return {
322
345
  index,
package/dist/index.mjs CHANGED
@@ -189,7 +189,8 @@ var runPersonalization = ({
189
189
  trackingEventName,
190
190
  count,
191
191
  algorithm,
192
- contextInstance
192
+ contextInstance,
193
+ context
193
194
  }) => {
194
195
  var _a;
195
196
  const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT]) || [];
@@ -214,7 +215,12 @@ var runPersonalization = ({
214
215
  name: trackingEventName,
215
216
  take: parsedCount,
216
217
  variations: componentVariations,
217
- algorithm
218
+ algorithm,
219
+ compositionMetadata: {
220
+ compositionId: context.composition._id,
221
+ matchedRoute: context.matchedRoute,
222
+ dynamicInputs: context.dynamicInputs
223
+ }
218
224
  });
219
225
  if (variations) {
220
226
  for (let i = 0; i < variations.length; i++) {
@@ -231,7 +237,12 @@ var runPersonalization = ({
231
237
  name: trackingEventName,
232
238
  variantIds,
233
239
  changed: true,
234
- control: false
240
+ control: false,
241
+ compositionMetadata: {
242
+ compositionId: context.composition._id,
243
+ matchedRoute: context.matchedRoute,
244
+ dynamicInputs: context.dynamicInputs
245
+ }
235
246
  };
236
247
  return {
237
248
  indexes,
@@ -248,7 +259,7 @@ var runTest = ({
248
259
  contextInstance,
249
260
  context
250
261
  }) => {
251
- var _a, _b;
262
+ var _a, _b, _c, _d;
252
263
  const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
253
264
  const isContextualTest = context.isContextualEditing && test === CONTEXTUAL_EDITING_TEST_NAME;
254
265
  const shouldShowTest = isTestDefined || isContextualTest;
@@ -268,14 +279,21 @@ var runTest = ({
268
279
  });
269
280
  let index = null;
270
281
  let variantId = null;
282
+ let variantAssigned = false;
271
283
  if (contextInstance) {
272
- const { result } = contextInstance.test({
284
+ const { result, variantAssigned: wasVariantAssigned } = contextInstance.test({
273
285
  name: test,
274
- variations: componentVariations
286
+ variations: componentVariations,
287
+ compositionMetadata: {
288
+ compositionId: context.composition._id,
289
+ matchedRoute: context.matchedRoute,
290
+ dynamicInputs: context.dynamicInputs
291
+ }
275
292
  });
276
293
  if (result) {
277
294
  index = result.index;
278
295
  variantId = result.id;
296
+ variantAssigned = wasVariantAssigned;
279
297
  }
280
298
  }
281
299
  if (!variantId) {
@@ -287,9 +305,14 @@ var runTest = ({
287
305
  }
288
306
  const event = {
289
307
  name: test,
290
- variantAssigned: true,
291
- control: true,
292
- variantId: variantId != null ? variantId : "NO_VARIANTS"
308
+ variantAssigned,
309
+ control: variantId ? (_d = (_c = componentVariations.find((v) => v.id === variantId)) == null ? void 0 : _c.control) != null ? _d : false : false,
310
+ variantId: variantId != null ? variantId : "NO_VARIANTS",
311
+ compositionMetadata: {
312
+ compositionId: context.composition._id,
313
+ matchedRoute: context.matchedRoute,
314
+ dynamicInputs: context.dynamicInputs
315
+ }
293
316
  };
294
317
  return {
295
318
  index,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc-shared",
3
- "version": "20.34.3-alpha.70+bc3f8ba0f4",
3
+ "version": "20.35.1-alpha.188+c2a5b9c45f",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -26,14 +26,14 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@types/node": "24.3.1",
29
- "@types/react": "18.3.24",
29
+ "@types/react": "19.2.2",
30
30
  "next": "15.2.4",
31
- "react": "18.3.1",
32
- "react-dom": "18.3.1"
31
+ "react": "19.2.0",
32
+ "react-dom": "19.2.0"
33
33
  },
34
34
  "dependencies": {
35
- "@uniformdev/canvas": "20.34.3-alpha.70+bc3f8ba0f4",
36
- "@uniformdev/context": "20.34.3-alpha.70+bc3f8ba0f4"
35
+ "@uniformdev/canvas": "20.35.1-alpha.188+c2a5b9c45f",
36
+ "@uniformdev/context": "20.35.1-alpha.188+c2a5b9c45f"
37
37
  },
38
38
  "engines": {
39
39
  "node": "^18.18.0 || ^19.8.0 || >= 20.0.0"
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "bc3f8ba0f4719673f92d9e8c48c3818dc439c364"
49
+ "gitHead": "c2a5b9c45fdbcd3199fba23e38beaf7ca0388c35"
50
50
  }