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

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
@@ -216,17 +216,16 @@ declare class AppDirectoryContextInstance implements AppDirectoryContext {
216
216
  type PersonalizeProps = {
217
217
  trackingEventName: string;
218
218
  count: number | string | undefined;
219
- algorithm?: string;
220
219
  };
221
220
  type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
222
221
  contextInstance: AppDirectoryServerContext;
223
222
  };
224
223
 
225
- interface RunPersonalizationProps extends PersonalizeProps {
226
- component: ComponentProps['component'];
227
- contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
228
- }
229
- declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, }: RunPersonalizationProps) => {
224
+ declare const runPersonalization: ({ component, trackingEventName, count, contextInstance, }: PersonalizeProps & {
225
+ component: ComponentProps["component"];
226
+ } & {
227
+ contextInstance: Pick<ContextInstance, "personalize"> | undefined;
228
+ }) => {
230
229
  indexes: number[];
231
230
  event: PersonalizationEvent;
232
231
  };
@@ -250,4 +249,4 @@ declare const resolvePath: ({ params }: Pick<AwaitedPageParameters, "params">) =
250
249
 
251
250
  declare function getBaseUrl(): string;
252
251
 
253
- export { type AppDirectoryContext, AppDirectoryContextInstance, type AppDirectoryContextState, type AppDirectoryServerContext, type AwaitedPageParameters, type AwaitedPlaygroundParameters, type CacheMode, type ComponentProps, type CompositionContext, type CreateUniformContextOptions, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type RunPersonalizationProps, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };
252
+ export { type AppDirectoryContext, AppDirectoryContextInstance, type AppDirectoryContextState, type AppDirectoryServerContext, type AwaitedPageParameters, type AwaitedPlaygroundParameters, type CacheMode, type ComponentProps, type CompositionContext, type CreateUniformContextOptions, 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
@@ -216,17 +216,16 @@ declare class AppDirectoryContextInstance implements AppDirectoryContext {
216
216
  type PersonalizeProps = {
217
217
  trackingEventName: string;
218
218
  count: number | string | undefined;
219
- algorithm?: string;
220
219
  };
221
220
  type PersonalizeWithContextComponentProps = ComponentProps<PersonalizeProps> & {
222
221
  contextInstance: AppDirectoryServerContext;
223
222
  };
224
223
 
225
- interface RunPersonalizationProps extends PersonalizeProps {
226
- component: ComponentProps['component'];
227
- contextInstance: Pick<ContextInstance, 'personalize'> | undefined;
228
- }
229
- declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, }: RunPersonalizationProps) => {
224
+ declare const runPersonalization: ({ component, trackingEventName, count, contextInstance, }: PersonalizeProps & {
225
+ component: ComponentProps["component"];
226
+ } & {
227
+ contextInstance: Pick<ContextInstance, "personalize"> | undefined;
228
+ }) => {
230
229
  indexes: number[];
231
230
  event: PersonalizationEvent;
232
231
  };
@@ -250,4 +249,4 @@ declare const resolvePath: ({ params }: Pick<AwaitedPageParameters, "params">) =
250
249
 
251
250
  declare function getBaseUrl(): string;
252
251
 
253
- export { type AppDirectoryContext, AppDirectoryContextInstance, type AppDirectoryContextState, type AppDirectoryServerContext, type AwaitedPageParameters, type AwaitedPlaygroundParameters, type CacheMode, type ComponentProps, type CompositionContext, type CreateUniformContextOptions, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type RunPersonalizationProps, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };
252
+ export { type AppDirectoryContext, AppDirectoryContextInstance, type AppDirectoryContextState, type AppDirectoryServerContext, type AwaitedPageParameters, type AwaitedPlaygroundParameters, type CacheMode, type ComponentProps, type CompositionContext, type CreateUniformContextOptions, 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
@@ -176,14 +176,13 @@ var runPersonalization = ({
176
176
  component,
177
177
  trackingEventName,
178
178
  count,
179
- algorithm,
180
179
  contextInstance
181
180
  }) => {
182
- var _a;
181
+ var _a, _b;
183
182
  const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT]) || [];
184
183
  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;
184
+ var _a2, _b2;
185
+ const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b2.value;
187
186
  const id = v._id || `pz-${i}-${v.type}`;
188
187
  return {
189
188
  id,
@@ -205,19 +204,35 @@ var runPersonalization = ({
205
204
  const { variations } = contextInstance.personalize({
206
205
  name: trackingEventName,
207
206
  take: parsedCount,
208
- variations: componentVariations,
209
- algorithm
207
+ variations: componentVariations
210
208
  });
211
209
  if (variations) {
212
210
  for (let i = 0; i < variations.length; i++) {
213
- const currentVariation = variations[i];
214
- indexes.push(currentVariation.index);
211
+ indexes.push(variations[i].index);
215
212
  variantIds.push({
216
- id: currentVariation.id,
217
- control: currentVariation.control
213
+ id: variations[i].id,
214
+ control: variations[i].control
218
215
  });
219
216
  }
220
217
  }
218
+ } else {
219
+ const defaults = [];
220
+ for (let i = 0; i < componentVariations.length; i++) {
221
+ const v = componentVariations[i];
222
+ if (!((_b = v.pz) == null ? void 0 : _b.crit)) {
223
+ defaults.push(v.index);
224
+ if (defaults.length >= (parsedCount || 1)) {
225
+ break;
226
+ }
227
+ }
228
+ }
229
+ indexes.push(...defaults);
230
+ variantIds.push(
231
+ ...defaults.map((i) => ({
232
+ id: componentVariations[i].id,
233
+ control: false
234
+ }))
235
+ );
221
236
  }
222
237
  const event = {
223
238
  name: trackingEventName,
package/dist/index.js CHANGED
@@ -203,14 +203,13 @@ var runPersonalization = ({
203
203
  component,
204
204
  trackingEventName,
205
205
  count,
206
- algorithm,
207
206
  contextInstance
208
207
  }) => {
209
- var _a;
208
+ var _a, _b;
210
209
  const slot = ((_a = component.slots) == null ? void 0 : _a[import_canvas.CANVAS_PERSONALIZE_SLOT]) || [];
211
210
  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;
211
+ var _a2, _b2;
212
+ const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[import_canvas.CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b2.value;
214
213
  const id = v._id || `pz-${i}-${v.type}`;
215
214
  return {
216
215
  id,
@@ -232,19 +231,35 @@ var runPersonalization = ({
232
231
  const { variations } = contextInstance.personalize({
233
232
  name: trackingEventName,
234
233
  take: parsedCount,
235
- variations: componentVariations,
236
- algorithm
234
+ variations: componentVariations
237
235
  });
238
236
  if (variations) {
239
237
  for (let i = 0; i < variations.length; i++) {
240
- const currentVariation = variations[i];
241
- indexes.push(currentVariation.index);
238
+ indexes.push(variations[i].index);
242
239
  variantIds.push({
243
- id: currentVariation.id,
244
- control: currentVariation.control
240
+ id: variations[i].id,
241
+ control: variations[i].control
245
242
  });
246
243
  }
247
244
  }
245
+ } else {
246
+ const defaults = [];
247
+ for (let i = 0; i < componentVariations.length; i++) {
248
+ const v = componentVariations[i];
249
+ if (!((_b = v.pz) == null ? void 0 : _b.crit)) {
250
+ defaults.push(v.index);
251
+ if (defaults.length >= (parsedCount || 1)) {
252
+ break;
253
+ }
254
+ }
255
+ }
256
+ indexes.push(...defaults);
257
+ variantIds.push(
258
+ ...defaults.map((i) => ({
259
+ id: componentVariations[i].id,
260
+ control: false
261
+ }))
262
+ );
248
263
  }
249
264
  const event = {
250
265
  name: trackingEventName,
package/dist/index.mjs CHANGED
@@ -176,14 +176,13 @@ var runPersonalization = ({
176
176
  component,
177
177
  trackingEventName,
178
178
  count,
179
- algorithm,
180
179
  contextInstance
181
180
  }) => {
182
- var _a;
181
+ var _a, _b;
183
182
  const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT]) || [];
184
183
  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;
184
+ var _a2, _b2;
185
+ const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b2.value;
187
186
  const id = v._id || `pz-${i}-${v.type}`;
188
187
  return {
189
188
  id,
@@ -205,19 +204,35 @@ var runPersonalization = ({
205
204
  const { variations } = contextInstance.personalize({
206
205
  name: trackingEventName,
207
206
  take: parsedCount,
208
- variations: componentVariations,
209
- algorithm
207
+ variations: componentVariations
210
208
  });
211
209
  if (variations) {
212
210
  for (let i = 0; i < variations.length; i++) {
213
- const currentVariation = variations[i];
214
- indexes.push(currentVariation.index);
211
+ indexes.push(variations[i].index);
215
212
  variantIds.push({
216
- id: currentVariation.id,
217
- control: currentVariation.control
213
+ id: variations[i].id,
214
+ control: variations[i].control
218
215
  });
219
216
  }
220
217
  }
218
+ } else {
219
+ const defaults = [];
220
+ for (let i = 0; i < componentVariations.length; i++) {
221
+ const v = componentVariations[i];
222
+ if (!((_b = v.pz) == null ? void 0 : _b.crit)) {
223
+ defaults.push(v.index);
224
+ if (defaults.length >= (parsedCount || 1)) {
225
+ break;
226
+ }
227
+ }
228
+ }
229
+ indexes.push(...defaults);
230
+ variantIds.push(
231
+ ...defaults.map((i) => ({
232
+ id: componentVariations[i].id,
233
+ control: false
234
+ }))
235
+ );
221
236
  }
222
237
  const event = {
223
238
  name: trackingEventName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc-shared",
3
- "version": "20.6.2-alpha.11+af78064791",
3
+ "version": "20.7.1-alpha.4+20185a97ff",
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.6.2-alpha.11+af78064791",
36
- "@uniformdev/context": "20.6.2-alpha.11+af78064791"
35
+ "@uniformdev/canvas": "20.7.1-alpha.4+20185a97ff",
36
+ "@uniformdev/context": "20.7.1-alpha.4+20185a97ff"
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": "af78064791c47044f8ba447bbe1221f672f6de3e"
49
+ "gitHead": "20185a97ff6c2de2f871223af12d73583fe300af"
50
50
  }