@uniformdev/canvas-next-rsc-shared 20.6.2-alpha.11 → 20.7.1-alpha.102

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 CHANGED
@@ -1,2 +1,2 @@
1
- © 2024 Uniform Systems, Inc. All Rights Reserved.
1
+ © 2025 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,5 +1,5 @@
1
1
  import * as _uniformdev_context from '@uniformdev/context';
2
- import { ContextInstance, ContextState, ContextOptions, CookieTransitionDataStoreOptions, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent } from '@uniformdev/context';
2
+ import { ContextInstance, ContextState, ContextOptions, CookieTransitionDataStoreOptions, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent, CompositionMetadata } from '@uniformdev/context';
3
3
  import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
4
4
  import { PropsWithChildren } from 'react';
5
5
 
@@ -208,6 +208,14 @@ declare class AppDirectoryContextInstance implements AppDirectoryContext {
208
208
  internal_processTestEvent(event: TestEvent): void;
209
209
  internal_processPersonalizationEvent(event: PersonalizationEvent): void;
210
210
  update(update: Partial<AppDirectoryContextState>): Promise<void>;
211
+ /**
212
+ * Gets the current canvas data
213
+ */
214
+ getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
215
+ /**
216
+ * Updates the canvas data and emits a canvasDataUpdated event
217
+ */
218
+ updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
211
219
  updateConsent(consent: boolean): Promise<void>;
212
220
  get consent(): boolean | undefined;
213
221
  internal_update(update: Partial<AppDirectoryContextState>): Promise<void>;
@@ -222,11 +230,10 @@ type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
222
230
  contextInstance: AppDirectoryServerContext;
223
231
  };
224
232
 
225
- interface RunPersonalizationProps extends PersonalizeProps {
226
- component: ComponentProps['component'];
233
+ type RunPersonalizationProps = Omit<ComponentProps<PersonalizeProps & {
227
234
  contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
228
- }
229
- declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, }: RunPersonalizationProps) => {
235
+ }>, 'slots' | 'slotName' | 'slotIndex'>;
236
+ declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, context, }: RunPersonalizationProps) => {
230
237
  indexes: number[];
231
238
  event: PersonalizationEvent;
232
239
  };
@@ -235,9 +242,9 @@ type TestProps = {
235
242
  test: string;
236
243
  };
237
244
 
238
- declare const runTest: ({ test, component, contextInstance, context, }: ComponentProps<TestProps> & {
245
+ declare const runTest: ({ test, component, contextInstance, context, }: Omit<ComponentProps<TestProps> & {
239
246
  contextInstance: Pick<ContextInstance, "test" | "manifest"> | undefined;
240
- }) => {
247
+ }, "slots" | "slotName" | "slotIndex">) => {
241
248
  index: number | null;
242
249
  event: TestEvent | null;
243
250
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _uniformdev_context from '@uniformdev/context';
2
- import { ContextInstance, ContextState, ContextOptions, CookieTransitionDataStoreOptions, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent } from '@uniformdev/context';
2
+ import { ContextInstance, ContextState, ContextOptions, CookieTransitionDataStoreOptions, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent, CompositionMetadata } from '@uniformdev/context';
3
3
  import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas';
4
4
  import { PropsWithChildren } from 'react';
5
5
 
@@ -208,6 +208,14 @@ declare class AppDirectoryContextInstance implements AppDirectoryContext {
208
208
  internal_processTestEvent(event: TestEvent): void;
209
209
  internal_processPersonalizationEvent(event: PersonalizationEvent): void;
210
210
  update(update: Partial<AppDirectoryContextState>): Promise<void>;
211
+ /**
212
+ * Gets the current canvas data
213
+ */
214
+ getCompositionMetadata(): Readonly<CompositionMetadata | undefined>;
215
+ /**
216
+ * Updates the canvas data and emits a canvasDataUpdated event
217
+ */
218
+ updateCompositionMetadata(newData: CompositionMetadata): Promise<void>;
211
219
  updateConsent(consent: boolean): Promise<void>;
212
220
  get consent(): boolean | undefined;
213
221
  internal_update(update: Partial<AppDirectoryContextState>): Promise<void>;
@@ -222,11 +230,10 @@ type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
222
230
  contextInstance: AppDirectoryServerContext;
223
231
  };
224
232
 
225
- interface RunPersonalizationProps extends PersonalizeProps {
226
- component: ComponentProps['component'];
233
+ type RunPersonalizationProps = Omit<ComponentProps<PersonalizeProps & {
227
234
  contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
228
- }
229
- declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, }: RunPersonalizationProps) => {
235
+ }>, 'slots' | 'slotName' | 'slotIndex'>;
236
+ declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, context, }: RunPersonalizationProps) => {
230
237
  indexes: number[];
231
238
  event: PersonalizationEvent;
232
239
  };
@@ -235,9 +242,9 @@ type TestProps = {
235
242
  test: string;
236
243
  };
237
244
 
238
- declare const runTest: ({ test, component, contextInstance, context, }: ComponentProps<TestProps> & {
245
+ declare const runTest: ({ test, component, contextInstance, context, }: Omit<ComponentProps<TestProps> & {
239
246
  contextInstance: Pick<ContextInstance, "test" | "manifest"> | undefined;
240
- }) => {
247
+ }, "slots" | "slotName" | "slotIndex">) => {
241
248
  index: number | null;
242
249
  event: TestEvent | null;
243
250
  };
package/dist/index.esm.js CHANGED
@@ -153,6 +153,18 @@ var AppDirectoryContextInstance = class {
153
153
  url
154
154
  });
155
155
  }
156
+ /**
157
+ * Gets the current canvas data
158
+ */
159
+ getCompositionMetadata() {
160
+ return __privateGet(this, _context).getCompositionMetadata();
161
+ }
162
+ /**
163
+ * Updates the canvas data and emits a canvasDataUpdated event
164
+ */
165
+ async updateCompositionMetadata(newData) {
166
+ return __privateGet(this, _context).updateCompositionMetadata(newData);
167
+ }
156
168
  async updateConsent(consent) {
157
169
  return __privateGet(this, _context).storage.updateData([
158
170
  {
@@ -171,23 +183,20 @@ var AppDirectoryContextInstance = class {
171
183
  _context = new WeakMap();
172
184
 
173
185
  // src/runPersonalization.ts
174
- import { CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
186
+ import { CANVAS_PERSONALIZE_SLOT, mapSlotToPersonalizedVariations } from "@uniformdev/canvas";
175
187
  var runPersonalization = ({
176
188
  component,
177
189
  trackingEventName,
178
190
  count,
179
191
  algorithm,
180
- contextInstance
192
+ contextInstance,
193
+ context
181
194
  }) => {
182
195
  var _a;
183
196
  const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT]) || [];
184
- const componentVariations = slot.map((v, i) => {
185
- var _a2, _b;
186
- const contextTag = (_b = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b.value;
187
- const id = v._id || `pz-${i}-${v.type}`;
197
+ const componentVariations = mapSlotToPersonalizedVariations(slot).map((v, i) => {
188
198
  return {
189
- id,
190
- pz: contextTag,
199
+ ...v,
191
200
  index: i
192
201
  };
193
202
  });
@@ -206,7 +215,12 @@ var runPersonalization = ({
206
215
  name: trackingEventName,
207
216
  take: parsedCount,
208
217
  variations: componentVariations,
209
- algorithm
218
+ algorithm,
219
+ compositionMetadata: {
220
+ compositionId: context.composition._id,
221
+ matchedRoute: context.matchedRoute,
222
+ dynamicInputs: context.dynamicInputs
223
+ }
210
224
  });
211
225
  if (variations) {
212
226
  for (let i = 0; i < variations.length; i++) {
@@ -223,7 +237,12 @@ var runPersonalization = ({
223
237
  name: trackingEventName,
224
238
  variantIds,
225
239
  changed: true,
226
- control: false
240
+ control: false,
241
+ compositionMetadata: {
242
+ compositionId: context.composition._id,
243
+ matchedRoute: context.matchedRoute,
244
+ dynamicInputs: context.dynamicInputs
245
+ }
227
246
  };
228
247
  return {
229
248
  indexes,
@@ -232,7 +251,7 @@ var runPersonalization = ({
232
251
  };
233
252
 
234
253
  // src/runTest.ts
235
- import { CANVAS_TEST_SLOT, CANVAS_TEST_VARIANT_PARAM } from "@uniformdev/canvas";
254
+ import { CANVAS_TEST_SLOT, mapSlotToTestVariations } from "@uniformdev/canvas";
236
255
  import { CONTEXTUAL_EDITING_TEST_NAME } from "@uniformdev/context";
237
256
  var runTest = ({
238
257
  test,
@@ -240,7 +259,7 @@ var runTest = ({
240
259
  contextInstance,
241
260
  context
242
261
  }) => {
243
- var _a, _b;
262
+ var _a, _b, _c, _d;
244
263
  const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
245
264
  const isContextualTest = context.isContextualEditing && test === CONTEXTUAL_EDITING_TEST_NAME;
246
265
  const shouldShowTest = isTestDefined || isContextualTest;
@@ -252,26 +271,29 @@ var runTest = ({
252
271
  };
253
272
  }
254
273
  const slot = ((_b = component.slots) == null ? void 0 : _b[CANVAS_TEST_SLOT]) || [];
255
- const componentVariations = slot.map((v, i) => {
256
- var _a2, _b2, _c;
257
- const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b2.value;
258
- const id = (_c = contextTag == null ? void 0 : contextTag.id) != null ? _c : "testId" in v ? v.testId : `ab-${i}-${v.type}`;
274
+ const componentVariations = mapSlotToTestVariations(slot).map((v, i) => {
259
275
  return {
260
- id,
261
- testDistribution: contextTag == null ? void 0 : contextTag.testDistribution,
276
+ ...v,
262
277
  index: i
263
278
  };
264
279
  });
265
280
  let index = null;
266
281
  let variantId = null;
282
+ let variantAssigned = false;
267
283
  if (contextInstance) {
268
- const { result } = contextInstance.test({
284
+ const { result, variantAssigned: wasVariantAssigned } = contextInstance.test({
269
285
  name: test,
270
- variations: componentVariations
286
+ variations: componentVariations,
287
+ compositionMetadata: {
288
+ compositionId: context.composition._id,
289
+ matchedRoute: context.matchedRoute,
290
+ dynamicInputs: context.dynamicInputs
291
+ }
271
292
  });
272
293
  if (result) {
273
294
  index = result.index;
274
295
  variantId = result.id;
296
+ variantAssigned = wasVariantAssigned;
275
297
  }
276
298
  }
277
299
  if (!variantId) {
@@ -283,8 +305,14 @@ var runTest = ({
283
305
  }
284
306
  const event = {
285
307
  name: test,
286
- variantAssigned: true,
287
- 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
+ }
288
316
  };
289
317
  return {
290
318
  index,
package/dist/index.js CHANGED
@@ -180,6 +180,18 @@ var AppDirectoryContextInstance = class {
180
180
  url
181
181
  });
182
182
  }
183
+ /**
184
+ * Gets the current canvas data
185
+ */
186
+ getCompositionMetadata() {
187
+ return __privateGet(this, _context).getCompositionMetadata();
188
+ }
189
+ /**
190
+ * Updates the canvas data and emits a canvasDataUpdated event
191
+ */
192
+ async updateCompositionMetadata(newData) {
193
+ return __privateGet(this, _context).updateCompositionMetadata(newData);
194
+ }
183
195
  async updateConsent(consent) {
184
196
  return __privateGet(this, _context).storage.updateData([
185
197
  {
@@ -204,17 +216,14 @@ var runPersonalization = ({
204
216
  trackingEventName,
205
217
  count,
206
218
  algorithm,
207
- contextInstance
219
+ contextInstance,
220
+ context
208
221
  }) => {
209
222
  var _a;
210
223
  const slot = ((_a = component.slots) == null ? void 0 : _a[import_canvas.CANVAS_PERSONALIZE_SLOT]) || [];
211
- const componentVariations = slot.map((v, i) => {
212
- var _a2, _b;
213
- const contextTag = (_b = (_a2 = v.parameters) == null ? void 0 : _a2[import_canvas.CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b.value;
214
- const id = v._id || `pz-${i}-${v.type}`;
224
+ const componentVariations = (0, import_canvas.mapSlotToPersonalizedVariations)(slot).map((v, i) => {
215
225
  return {
216
- id,
217
- pz: contextTag,
226
+ ...v,
218
227
  index: i
219
228
  };
220
229
  });
@@ -233,7 +242,12 @@ var runPersonalization = ({
233
242
  name: trackingEventName,
234
243
  take: parsedCount,
235
244
  variations: componentVariations,
236
- algorithm
245
+ algorithm,
246
+ compositionMetadata: {
247
+ compositionId: context.composition._id,
248
+ matchedRoute: context.matchedRoute,
249
+ dynamicInputs: context.dynamicInputs
250
+ }
237
251
  });
238
252
  if (variations) {
239
253
  for (let i = 0; i < variations.length; i++) {
@@ -250,7 +264,12 @@ var runPersonalization = ({
250
264
  name: trackingEventName,
251
265
  variantIds,
252
266
  changed: true,
253
- control: false
267
+ control: false,
268
+ compositionMetadata: {
269
+ compositionId: context.composition._id,
270
+ matchedRoute: context.matchedRoute,
271
+ dynamicInputs: context.dynamicInputs
272
+ }
254
273
  };
255
274
  return {
256
275
  indexes,
@@ -267,7 +286,7 @@ var runTest = ({
267
286
  contextInstance,
268
287
  context
269
288
  }) => {
270
- var _a, _b;
289
+ var _a, _b, _c, _d;
271
290
  const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
272
291
  const isContextualTest = context.isContextualEditing && test === import_context2.CONTEXTUAL_EDITING_TEST_NAME;
273
292
  const shouldShowTest = isTestDefined || isContextualTest;
@@ -279,26 +298,29 @@ var runTest = ({
279
298
  };
280
299
  }
281
300
  const slot = ((_b = component.slots) == null ? void 0 : _b[import_canvas2.CANVAS_TEST_SLOT]) || [];
282
- const componentVariations = slot.map((v, i) => {
283
- var _a2, _b2, _c;
284
- const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[import_canvas2.CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b2.value;
285
- const id = (_c = contextTag == null ? void 0 : contextTag.id) != null ? _c : "testId" in v ? v.testId : `ab-${i}-${v.type}`;
301
+ const componentVariations = (0, import_canvas2.mapSlotToTestVariations)(slot).map((v, i) => {
286
302
  return {
287
- id,
288
- testDistribution: contextTag == null ? void 0 : contextTag.testDistribution,
303
+ ...v,
289
304
  index: i
290
305
  };
291
306
  });
292
307
  let index = null;
293
308
  let variantId = null;
309
+ let variantAssigned = false;
294
310
  if (contextInstance) {
295
- const { result } = contextInstance.test({
311
+ const { result, variantAssigned: wasVariantAssigned } = contextInstance.test({
296
312
  name: test,
297
- variations: componentVariations
313
+ variations: componentVariations,
314
+ compositionMetadata: {
315
+ compositionId: context.composition._id,
316
+ matchedRoute: context.matchedRoute,
317
+ dynamicInputs: context.dynamicInputs
318
+ }
298
319
  });
299
320
  if (result) {
300
321
  index = result.index;
301
322
  variantId = result.id;
323
+ variantAssigned = wasVariantAssigned;
302
324
  }
303
325
  }
304
326
  if (!variantId) {
@@ -310,8 +332,14 @@ var runTest = ({
310
332
  }
311
333
  const event = {
312
334
  name: test,
313
- variantAssigned: true,
314
- 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
+ }
315
343
  };
316
344
  return {
317
345
  index,
package/dist/index.mjs CHANGED
@@ -153,6 +153,18 @@ var AppDirectoryContextInstance = class {
153
153
  url
154
154
  });
155
155
  }
156
+ /**
157
+ * Gets the current canvas data
158
+ */
159
+ getCompositionMetadata() {
160
+ return __privateGet(this, _context).getCompositionMetadata();
161
+ }
162
+ /**
163
+ * Updates the canvas data and emits a canvasDataUpdated event
164
+ */
165
+ async updateCompositionMetadata(newData) {
166
+ return __privateGet(this, _context).updateCompositionMetadata(newData);
167
+ }
156
168
  async updateConsent(consent) {
157
169
  return __privateGet(this, _context).storage.updateData([
158
170
  {
@@ -171,23 +183,20 @@ var AppDirectoryContextInstance = class {
171
183
  _context = new WeakMap();
172
184
 
173
185
  // src/runPersonalization.ts
174
- import { CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
186
+ import { CANVAS_PERSONALIZE_SLOT, mapSlotToPersonalizedVariations } from "@uniformdev/canvas";
175
187
  var runPersonalization = ({
176
188
  component,
177
189
  trackingEventName,
178
190
  count,
179
191
  algorithm,
180
- contextInstance
192
+ contextInstance,
193
+ context
181
194
  }) => {
182
195
  var _a;
183
196
  const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT]) || [];
184
- const componentVariations = slot.map((v, i) => {
185
- var _a2, _b;
186
- const contextTag = (_b = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b.value;
187
- const id = v._id || `pz-${i}-${v.type}`;
197
+ const componentVariations = mapSlotToPersonalizedVariations(slot).map((v, i) => {
188
198
  return {
189
- id,
190
- pz: contextTag,
199
+ ...v,
191
200
  index: i
192
201
  };
193
202
  });
@@ -206,7 +215,12 @@ var runPersonalization = ({
206
215
  name: trackingEventName,
207
216
  take: parsedCount,
208
217
  variations: componentVariations,
209
- algorithm
218
+ algorithm,
219
+ compositionMetadata: {
220
+ compositionId: context.composition._id,
221
+ matchedRoute: context.matchedRoute,
222
+ dynamicInputs: context.dynamicInputs
223
+ }
210
224
  });
211
225
  if (variations) {
212
226
  for (let i = 0; i < variations.length; i++) {
@@ -223,7 +237,12 @@ var runPersonalization = ({
223
237
  name: trackingEventName,
224
238
  variantIds,
225
239
  changed: true,
226
- control: false
240
+ control: false,
241
+ compositionMetadata: {
242
+ compositionId: context.composition._id,
243
+ matchedRoute: context.matchedRoute,
244
+ dynamicInputs: context.dynamicInputs
245
+ }
227
246
  };
228
247
  return {
229
248
  indexes,
@@ -232,7 +251,7 @@ var runPersonalization = ({
232
251
  };
233
252
 
234
253
  // src/runTest.ts
235
- import { CANVAS_TEST_SLOT, CANVAS_TEST_VARIANT_PARAM } from "@uniformdev/canvas";
254
+ import { CANVAS_TEST_SLOT, mapSlotToTestVariations } from "@uniformdev/canvas";
236
255
  import { CONTEXTUAL_EDITING_TEST_NAME } from "@uniformdev/context";
237
256
  var runTest = ({
238
257
  test,
@@ -240,7 +259,7 @@ var runTest = ({
240
259
  contextInstance,
241
260
  context
242
261
  }) => {
243
- var _a, _b;
262
+ var _a, _b, _c, _d;
244
263
  const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
245
264
  const isContextualTest = context.isContextualEditing && test === CONTEXTUAL_EDITING_TEST_NAME;
246
265
  const shouldShowTest = isTestDefined || isContextualTest;
@@ -252,26 +271,29 @@ var runTest = ({
252
271
  };
253
272
  }
254
273
  const slot = ((_b = component.slots) == null ? void 0 : _b[CANVAS_TEST_SLOT]) || [];
255
- const componentVariations = slot.map((v, i) => {
256
- var _a2, _b2, _c;
257
- const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b2.value;
258
- const id = (_c = contextTag == null ? void 0 : contextTag.id) != null ? _c : "testId" in v ? v.testId : `ab-${i}-${v.type}`;
274
+ const componentVariations = mapSlotToTestVariations(slot).map((v, i) => {
259
275
  return {
260
- id,
261
- testDistribution: contextTag == null ? void 0 : contextTag.testDistribution,
276
+ ...v,
262
277
  index: i
263
278
  };
264
279
  });
265
280
  let index = null;
266
281
  let variantId = null;
282
+ let variantAssigned = false;
267
283
  if (contextInstance) {
268
- const { result } = contextInstance.test({
284
+ const { result, variantAssigned: wasVariantAssigned } = contextInstance.test({
269
285
  name: test,
270
- variations: componentVariations
286
+ variations: componentVariations,
287
+ compositionMetadata: {
288
+ compositionId: context.composition._id,
289
+ matchedRoute: context.matchedRoute,
290
+ dynamicInputs: context.dynamicInputs
291
+ }
271
292
  });
272
293
  if (result) {
273
294
  index = result.index;
274
295
  variantId = result.id;
296
+ variantAssigned = wasVariantAssigned;
275
297
  }
276
298
  }
277
299
  if (!variantId) {
@@ -283,8 +305,14 @@ var runTest = ({
283
305
  }
284
306
  const event = {
285
307
  name: test,
286
- variantAssigned: true,
287
- 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
+ }
288
316
  };
289
317
  return {
290
318
  index,
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc-shared",
3
- "version": "20.6.2-alpha.11+af78064791",
3
+ "version": "20.7.1-alpha.102+d621aa22b2",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
7
7
  "dev": "tsup --watch",
8
8
  "lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
9
- "test": "jest --maxWorkers=1 --passWithNoTests"
9
+ "test": "jest --maxWorkers=1 --passWithNoTests",
10
+ "document": "api-extractor run --local"
10
11
  },
11
12
  "sideEffects": false,
12
13
  "main": "./dist/index.js",
@@ -24,27 +25,26 @@
24
25
  "/dist"
25
26
  ],
26
27
  "devDependencies": {
27
- "@types/node": "22.7.8",
28
- "@types/react": "18.3.11",
29
- "eslint": "9.9.0",
30
- "next": "15.1.0",
28
+ "@types/node": "24.3.1",
29
+ "@types/react": "18.3.24",
30
+ "next": "15.2.4",
31
31
  "react": "18.3.1",
32
32
  "react-dom": "18.3.1"
33
33
  },
34
34
  "dependencies": {
35
- "@uniformdev/canvas": "20.6.2-alpha.11+af78064791",
36
- "@uniformdev/context": "20.6.2-alpha.11+af78064791"
35
+ "@uniformdev/canvas": "20.7.1-alpha.102+d621aa22b2",
36
+ "@uniformdev/context": "20.7.1-alpha.102+d621aa22b2"
37
37
  },
38
38
  "engines": {
39
39
  "node": "^18.18.0 || ^19.8.0 || >= 20.0.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "next": ">=15.1.0",
42
+ "next": ">=15.2.3",
43
43
  "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",
44
44
  "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "af78064791c47044f8ba447bbe1221f672f6de3e"
49
+ "gitHead": "d621aa22b220347565e307b064fb1eda8963abbe"
50
50
  }