@uniformdev/canvas-next-rsc-shared 20.35.1-alpha.87 → 20.36.0

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
@@ -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, CompositionMetadata } from '@uniformdev/context';
2
+ import { ContextInstance, ContextState, ContextOptions, CookieTransitionDataStoreOptions, 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
 
@@ -208,14 +208,6 @@ 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>;
219
211
  updateConsent(consent: boolean): Promise<void>;
220
212
  get consent(): boolean | undefined;
221
213
  internal_update(update: Partial<AppDirectoryContextState>): Promise<void>;
@@ -230,10 +222,11 @@ type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
230
222
  contextInstance: AppDirectoryServerContext;
231
223
  };
232
224
 
233
- type RunPersonalizationProps = Omit<ComponentProps<PersonalizeProps & {
225
+ interface RunPersonalizationProps extends PersonalizeProps {
226
+ component: ComponentProps['component'];
234
227
  contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
235
- }>, 'slots' | 'slotName' | 'slotIndex'>;
236
- declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, context, }: RunPersonalizationProps) => {
228
+ }
229
+ declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, }: RunPersonalizationProps) => {
237
230
  indexes: number[];
238
231
  event: PersonalizationEvent;
239
232
  };
@@ -242,9 +235,9 @@ type TestProps = {
242
235
  test: string;
243
236
  };
244
237
 
245
- declare const runTest: ({ test, component, contextInstance, context, }: Omit<ComponentProps<TestProps> & {
238
+ declare const runTest: ({ test, component, contextInstance, context, }: ComponentProps<TestProps> & {
246
239
  contextInstance: Pick<ContextInstance, "test" | "manifest"> | undefined;
247
- }, "slots" | "slotName" | "slotIndex">) => {
240
+ }) => {
248
241
  index: number | null;
249
242
  event: TestEvent | null;
250
243
  };
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, CompositionMetadata } from '@uniformdev/context';
2
+ import { ContextInstance, ContextState, ContextOptions, CookieTransitionDataStoreOptions, 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
 
@@ -208,14 +208,6 @@ 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>;
219
211
  updateConsent(consent: boolean): Promise<void>;
220
212
  get consent(): boolean | undefined;
221
213
  internal_update(update: Partial<AppDirectoryContextState>): Promise<void>;
@@ -230,10 +222,11 @@ type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
230
222
  contextInstance: AppDirectoryServerContext;
231
223
  };
232
224
 
233
- type RunPersonalizationProps = Omit<ComponentProps<PersonalizeProps & {
225
+ interface RunPersonalizationProps extends PersonalizeProps {
226
+ component: ComponentProps['component'];
234
227
  contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
235
- }>, 'slots' | 'slotName' | 'slotIndex'>;
236
- declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, context, }: RunPersonalizationProps) => {
228
+ }
229
+ declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, }: RunPersonalizationProps) => {
237
230
  indexes: number[];
238
231
  event: PersonalizationEvent;
239
232
  };
@@ -242,9 +235,9 @@ type TestProps = {
242
235
  test: string;
243
236
  };
244
237
 
245
- declare const runTest: ({ test, component, contextInstance, context, }: Omit<ComponentProps<TestProps> & {
238
+ declare const runTest: ({ test, component, contextInstance, context, }: ComponentProps<TestProps> & {
246
239
  contextInstance: Pick<ContextInstance, "test" | "manifest"> | undefined;
247
- }, "slots" | "slotName" | "slotIndex">) => {
240
+ }) => {
248
241
  index: number | null;
249
242
  event: TestEvent | null;
250
243
  };
package/dist/index.esm.js CHANGED
@@ -153,18 +153,6 @@ 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
- }
168
156
  async updateConsent(consent) {
169
157
  return __privateGet(this, _context).storage.updateData([
170
158
  {
@@ -189,8 +177,7 @@ var runPersonalization = ({
189
177
  trackingEventName,
190
178
  count,
191
179
  algorithm,
192
- contextInstance,
193
- context
180
+ contextInstance
194
181
  }) => {
195
182
  var _a;
196
183
  const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT]) || [];
@@ -215,12 +202,7 @@ var runPersonalization = ({
215
202
  name: trackingEventName,
216
203
  take: parsedCount,
217
204
  variations: componentVariations,
218
- algorithm,
219
- compositionMetadata: {
220
- compositionId: context.composition._id,
221
- matchedRoute: context.matchedRoute,
222
- dynamicInputs: context.dynamicInputs
223
- }
205
+ algorithm
224
206
  });
225
207
  if (variations) {
226
208
  for (let i = 0; i < variations.length; i++) {
@@ -237,12 +219,7 @@ var runPersonalization = ({
237
219
  name: trackingEventName,
238
220
  variantIds,
239
221
  changed: true,
240
- control: false,
241
- compositionMetadata: {
242
- compositionId: context.composition._id,
243
- matchedRoute: context.matchedRoute,
244
- dynamicInputs: context.dynamicInputs
245
- }
222
+ control: false
246
223
  };
247
224
  return {
248
225
  indexes,
@@ -259,7 +236,7 @@ var runTest = ({
259
236
  contextInstance,
260
237
  context
261
238
  }) => {
262
- var _a, _b, _c, _d;
239
+ var _a, _b;
263
240
  const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
264
241
  const isContextualTest = context.isContextualEditing && test === CONTEXTUAL_EDITING_TEST_NAME;
265
242
  const shouldShowTest = isTestDefined || isContextualTest;
@@ -279,21 +256,14 @@ var runTest = ({
279
256
  });
280
257
  let index = null;
281
258
  let variantId = null;
282
- let variantAssigned = false;
283
259
  if (contextInstance) {
284
- const { result, variantAssigned: wasVariantAssigned } = contextInstance.test({
260
+ const { result } = contextInstance.test({
285
261
  name: test,
286
- variations: componentVariations,
287
- compositionMetadata: {
288
- compositionId: context.composition._id,
289
- matchedRoute: context.matchedRoute,
290
- dynamicInputs: context.dynamicInputs
291
- }
262
+ variations: componentVariations
292
263
  });
293
264
  if (result) {
294
265
  index = result.index;
295
266
  variantId = result.id;
296
- variantAssigned = wasVariantAssigned;
297
267
  }
298
268
  }
299
269
  if (!variantId) {
@@ -305,8 +275,7 @@ var runTest = ({
305
275
  }
306
276
  const event = {
307
277
  name: test,
308
- variantAssigned,
309
- control: variantId ? (_d = (_c = componentVariations.find((v) => v.id === variantId)) == null ? void 0 : _c.control) != null ? _d : false : false,
278
+ variantAssigned: true,
310
279
  variantId: variantId != null ? variantId : "NO_VARIANTS"
311
280
  };
312
281
  return {
package/dist/index.js CHANGED
@@ -180,18 +180,6 @@ 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
- }
195
183
  async updateConsent(consent) {
196
184
  return __privateGet(this, _context).storage.updateData([
197
185
  {
@@ -216,8 +204,7 @@ var runPersonalization = ({
216
204
  trackingEventName,
217
205
  count,
218
206
  algorithm,
219
- contextInstance,
220
- context
207
+ contextInstance
221
208
  }) => {
222
209
  var _a;
223
210
  const slot = ((_a = component.slots) == null ? void 0 : _a[import_canvas.CANVAS_PERSONALIZE_SLOT]) || [];
@@ -242,12 +229,7 @@ var runPersonalization = ({
242
229
  name: trackingEventName,
243
230
  take: parsedCount,
244
231
  variations: componentVariations,
245
- algorithm,
246
- compositionMetadata: {
247
- compositionId: context.composition._id,
248
- matchedRoute: context.matchedRoute,
249
- dynamicInputs: context.dynamicInputs
250
- }
232
+ algorithm
251
233
  });
252
234
  if (variations) {
253
235
  for (let i = 0; i < variations.length; i++) {
@@ -264,12 +246,7 @@ var runPersonalization = ({
264
246
  name: trackingEventName,
265
247
  variantIds,
266
248
  changed: true,
267
- control: false,
268
- compositionMetadata: {
269
- compositionId: context.composition._id,
270
- matchedRoute: context.matchedRoute,
271
- dynamicInputs: context.dynamicInputs
272
- }
249
+ control: false
273
250
  };
274
251
  return {
275
252
  indexes,
@@ -286,7 +263,7 @@ var runTest = ({
286
263
  contextInstance,
287
264
  context
288
265
  }) => {
289
- var _a, _b, _c, _d;
266
+ var _a, _b;
290
267
  const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
291
268
  const isContextualTest = context.isContextualEditing && test === import_context2.CONTEXTUAL_EDITING_TEST_NAME;
292
269
  const shouldShowTest = isTestDefined || isContextualTest;
@@ -306,21 +283,14 @@ var runTest = ({
306
283
  });
307
284
  let index = null;
308
285
  let variantId = null;
309
- let variantAssigned = false;
310
286
  if (contextInstance) {
311
- const { result, variantAssigned: wasVariantAssigned } = contextInstance.test({
287
+ const { result } = contextInstance.test({
312
288
  name: test,
313
- variations: componentVariations,
314
- compositionMetadata: {
315
- compositionId: context.composition._id,
316
- matchedRoute: context.matchedRoute,
317
- dynamicInputs: context.dynamicInputs
318
- }
289
+ variations: componentVariations
319
290
  });
320
291
  if (result) {
321
292
  index = result.index;
322
293
  variantId = result.id;
323
- variantAssigned = wasVariantAssigned;
324
294
  }
325
295
  }
326
296
  if (!variantId) {
@@ -332,8 +302,7 @@ var runTest = ({
332
302
  }
333
303
  const event = {
334
304
  name: test,
335
- variantAssigned,
336
- control: variantId ? (_d = (_c = componentVariations.find((v) => v.id === variantId)) == null ? void 0 : _c.control) != null ? _d : false : false,
305
+ variantAssigned: true,
337
306
  variantId: variantId != null ? variantId : "NO_VARIANTS"
338
307
  };
339
308
  return {
package/dist/index.mjs CHANGED
@@ -153,18 +153,6 @@ 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
- }
168
156
  async updateConsent(consent) {
169
157
  return __privateGet(this, _context).storage.updateData([
170
158
  {
@@ -189,8 +177,7 @@ var runPersonalization = ({
189
177
  trackingEventName,
190
178
  count,
191
179
  algorithm,
192
- contextInstance,
193
- context
180
+ contextInstance
194
181
  }) => {
195
182
  var _a;
196
183
  const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT]) || [];
@@ -215,12 +202,7 @@ var runPersonalization = ({
215
202
  name: trackingEventName,
216
203
  take: parsedCount,
217
204
  variations: componentVariations,
218
- algorithm,
219
- compositionMetadata: {
220
- compositionId: context.composition._id,
221
- matchedRoute: context.matchedRoute,
222
- dynamicInputs: context.dynamicInputs
223
- }
205
+ algorithm
224
206
  });
225
207
  if (variations) {
226
208
  for (let i = 0; i < variations.length; i++) {
@@ -237,12 +219,7 @@ var runPersonalization = ({
237
219
  name: trackingEventName,
238
220
  variantIds,
239
221
  changed: true,
240
- control: false,
241
- compositionMetadata: {
242
- compositionId: context.composition._id,
243
- matchedRoute: context.matchedRoute,
244
- dynamicInputs: context.dynamicInputs
245
- }
222
+ control: false
246
223
  };
247
224
  return {
248
225
  indexes,
@@ -259,7 +236,7 @@ var runTest = ({
259
236
  contextInstance,
260
237
  context
261
238
  }) => {
262
- var _a, _b, _c, _d;
239
+ var _a, _b;
263
240
  const isTestDefined = Boolean((_a = contextInstance == null ? void 0 : contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
264
241
  const isContextualTest = context.isContextualEditing && test === CONTEXTUAL_EDITING_TEST_NAME;
265
242
  const shouldShowTest = isTestDefined || isContextualTest;
@@ -279,21 +256,14 @@ var runTest = ({
279
256
  });
280
257
  let index = null;
281
258
  let variantId = null;
282
- let variantAssigned = false;
283
259
  if (contextInstance) {
284
- const { result, variantAssigned: wasVariantAssigned } = contextInstance.test({
260
+ const { result } = contextInstance.test({
285
261
  name: test,
286
- variations: componentVariations,
287
- compositionMetadata: {
288
- compositionId: context.composition._id,
289
- matchedRoute: context.matchedRoute,
290
- dynamicInputs: context.dynamicInputs
291
- }
262
+ variations: componentVariations
292
263
  });
293
264
  if (result) {
294
265
  index = result.index;
295
266
  variantId = result.id;
296
- variantAssigned = wasVariantAssigned;
297
267
  }
298
268
  }
299
269
  if (!variantId) {
@@ -305,8 +275,7 @@ var runTest = ({
305
275
  }
306
276
  const event = {
307
277
  name: test,
308
- variantAssigned,
309
- control: variantId ? (_d = (_c = componentVariations.find((v) => v.id === variantId)) == null ? void 0 : _c.control) != null ? _d : false : false,
278
+ variantAssigned: true,
310
279
  variantId: variantId != null ? variantId : "NO_VARIANTS"
311
280
  };
312
281
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc-shared",
3
- "version": "20.35.1-alpha.87+2cf616f622",
3
+ "version": "20.36.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -32,8 +32,8 @@
32
32
  "react-dom": "18.3.1"
33
33
  },
34
34
  "dependencies": {
35
- "@uniformdev/canvas": "20.35.1-alpha.87+2cf616f622",
36
- "@uniformdev/context": "20.35.1-alpha.87+2cf616f622"
35
+ "@uniformdev/canvas": "20.36.0",
36
+ "@uniformdev/context": "20.36.0"
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": "2cf616f622322e5322575c106742078b5e3d7992"
49
+ "gitHead": "3e8e0c88d24d2576b74b64a48f7d32851979bf40"
50
50
  }