@uniformdev/context 20.4.1-alpha.3 → 20.4.2-alpha.5

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.
@@ -1,4 +1,4 @@
1
- import { aD as paths$7, N as ManifestV2 } from '../types-C9cSPjHd.mjs';
1
+ import { aC as paths$7, N as ManifestV2 } from '../types-EJl31yuP.mjs';
2
2
  import 'mitt';
3
3
 
4
4
  type LimitPolicy = <ReturnValue>(func: () => Promise<ReturnValue>) => Promise<ReturnValue>;
package/dist/api/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { aD as paths$7, N as ManifestV2 } from '../types-C9cSPjHd.js';
1
+ import { aC as paths$7, N as ManifestV2 } from '../types-EJl31yuP.js';
2
2
  import 'mitt';
3
3
 
4
4
  type LimitPolicy = <ReturnValue>(func: () => Promise<ReturnValue>) => Promise<ReturnValue>;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-C9cSPjHd.mjs';
2
- export { a0 as AggregateDimensionInput, a6 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions, aA as ContextState, aB as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, ap as DecayOptions, q as DevToolsActions, t as DevToolsDataEvent, r as DevToolsEvent, x as DevToolsForgetEvent, u as DevToolsHelloEvent, s as DevToolsLogEvent, w as DevToolsRawCommandsEvent, p as DevToolsState, o as DevToolsUiVersion, v as DevToolsUpdateEvent, a3 as DimensionMatch, Z as EnrichmentCategory, av as EnrichmentData, ay as EventData, aC as GoalStateUpdate, au as Goals, H as GroupCriteriaEvaluator, ai as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ad as ModifyScoreCommand, ae as ModifySessionScoreCommand, _ as NumberMatch, P as PersonalizationEvent, U as PersonalizationManifest, aw as PersonalizeControlVariant, a4 as PersonalizeOptions, ax as PersonalizeVariants, a8 as PersonalizedResult, a7 as PersonalizedVariant, R as RankPersonalizationVariantOptions, an as SERVER_STATE_ID, am as ServerToClientTransitionState, af as SetConsentCommand, aj as SetControlGroupCommand, ac as SetGoalCommand, ak as SetPersonalizeVariantControlCommand, ag as SetQuirkCommand, ah as SetTestCommand, z as Severity, W as Signal, Y as SignalCriteria, X as SignalCriteriaGroup, K as SignalData, ab as StorageCommand, $ as TestDefinition, k as TestEvent, a1 as TestOptions, aa as TestResult, a9 as TestVariant, at as Tests, ao as TransitionDataStoreEvents, as as VisitorDataStore, ar as VisitorDataStoreEvents, aq as VisitorDataStoreOptions, al as areCommandsEqual, az as emptyVisitorData, a5 as personalizeVariations, a2 as testVariations } from './types-C9cSPjHd.mjs';
1
+ import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-EJl31yuP.mjs';
2
+ export { $ as AggregateDimensionInput, a5 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, ao as DecayOptions, q as DevToolsActions, t as DevToolsDataEvent, r as DevToolsEvent, x as DevToolsForgetEvent, u as DevToolsHelloEvent, s as DevToolsLogEvent, w as DevToolsRawCommandsEvent, p as DevToolsState, o as DevToolsUiVersion, v as DevToolsUpdateEvent, a2 as DimensionMatch, Y as EnrichmentCategory, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ah as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ac as ModifyScoreCommand, ad as ModifySessionScoreCommand, Z as NumberMatch, P as PersonalizationEvent, R as PersonalizationManifest, av as PersonalizeControlVariant, a3 as PersonalizeOptions, aw as PersonalizeVariants, a7 as PersonalizedResult, a6 as PersonalizedVariant, am as SERVER_STATE_ID, al as ServerToClientTransitionState, ae as SetConsentCommand, ai as SetControlGroupCommand, ab as SetGoalCommand, aj as SetPersonalizeVariantControlCommand, af as SetQuirkCommand, ag as SetTestCommand, z as Severity, U as Signal, X as SignalCriteria, W as SignalCriteriaGroup, K as SignalData, aa as StorageCommand, _ as TestDefinition, k as TestEvent, a0 as TestOptions, a9 as TestResult, a8 as TestVariant, as as Tests, an as TransitionDataStoreEvents, ar as VisitorDataStore, aq as VisitorDataStoreEvents, ap as VisitorDataStoreOptions, ak as areCommandsEqual, ay as emptyVisitorData, a4 as personalizeVariations, a1 as testVariations } from './types-EJl31yuP.mjs';
3
3
  import Cookies from 'js-cookie';
4
4
  import 'mitt';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-C9cSPjHd.js';
2
- export { a0 as AggregateDimensionInput, a6 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions, aA as ContextState, aB as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, ap as DecayOptions, q as DevToolsActions, t as DevToolsDataEvent, r as DevToolsEvent, x as DevToolsForgetEvent, u as DevToolsHelloEvent, s as DevToolsLogEvent, w as DevToolsRawCommandsEvent, p as DevToolsState, o as DevToolsUiVersion, v as DevToolsUpdateEvent, a3 as DimensionMatch, Z as EnrichmentCategory, av as EnrichmentData, ay as EventData, aC as GoalStateUpdate, au as Goals, H as GroupCriteriaEvaluator, ai as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ad as ModifyScoreCommand, ae as ModifySessionScoreCommand, _ as NumberMatch, P as PersonalizationEvent, U as PersonalizationManifest, aw as PersonalizeControlVariant, a4 as PersonalizeOptions, ax as PersonalizeVariants, a8 as PersonalizedResult, a7 as PersonalizedVariant, R as RankPersonalizationVariantOptions, an as SERVER_STATE_ID, am as ServerToClientTransitionState, af as SetConsentCommand, aj as SetControlGroupCommand, ac as SetGoalCommand, ak as SetPersonalizeVariantControlCommand, ag as SetQuirkCommand, ah as SetTestCommand, z as Severity, W as Signal, Y as SignalCriteria, X as SignalCriteriaGroup, K as SignalData, ab as StorageCommand, $ as TestDefinition, k as TestEvent, a1 as TestOptions, aa as TestResult, a9 as TestVariant, at as Tests, ao as TransitionDataStoreEvents, as as VisitorDataStore, ar as VisitorDataStoreEvents, aq as VisitorDataStoreOptions, al as areCommandsEqual, az as emptyVisitorData, a5 as personalizeVariations, a2 as testVariations } from './types-C9cSPjHd.js';
1
+ import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-EJl31yuP.js';
2
+ export { $ as AggregateDimensionInput, a5 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, ao as DecayOptions, q as DevToolsActions, t as DevToolsDataEvent, r as DevToolsEvent, x as DevToolsForgetEvent, u as DevToolsHelloEvent, s as DevToolsLogEvent, w as DevToolsRawCommandsEvent, p as DevToolsState, o as DevToolsUiVersion, v as DevToolsUpdateEvent, a2 as DimensionMatch, Y as EnrichmentCategory, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ah as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ac as ModifyScoreCommand, ad as ModifySessionScoreCommand, Z as NumberMatch, P as PersonalizationEvent, R as PersonalizationManifest, av as PersonalizeControlVariant, a3 as PersonalizeOptions, aw as PersonalizeVariants, a7 as PersonalizedResult, a6 as PersonalizedVariant, am as SERVER_STATE_ID, al as ServerToClientTransitionState, ae as SetConsentCommand, ai as SetControlGroupCommand, ab as SetGoalCommand, aj as SetPersonalizeVariantControlCommand, af as SetQuirkCommand, ag as SetTestCommand, z as Severity, U as Signal, X as SignalCriteria, W as SignalCriteriaGroup, K as SignalData, aa as StorageCommand, _ as TestDefinition, k as TestEvent, a0 as TestOptions, a9 as TestResult, a8 as TestVariant, as as Tests, an as TransitionDataStoreEvents, ar as VisitorDataStore, aq as VisitorDataStoreEvents, ap as VisitorDataStoreOptions, ak as areCommandsEqual, ay as emptyVisitorData, a4 as personalizeVariations, a1 as testVariations } from './types-EJl31yuP.js';
3
3
  import Cookies from 'js-cookie';
4
4
  import 'mitt';
5
5
 
package/dist/index.esm.js CHANGED
@@ -641,34 +641,12 @@ function explain(onLogMessage, result, crit, lhsScore, rhsScore) {
641
641
  }
642
642
 
643
643
  // src/placement/personalize.ts
644
- var sortVariations = ({
645
- variations,
646
- rankVariant
647
- }) => {
648
- const variationsWithScores = Array.from(variations).map((variant) => {
649
- const score = rankVariant == null ? void 0 : rankVariant(variant);
650
- return {
651
- variant,
652
- score
653
- };
654
- });
655
- const variantsWithDefinedScores = variationsWithScores.filter((v) => v.score !== void 0);
656
- const variantsWithUndefinedScores = variationsWithScores.filter((v) => v.score === void 0);
657
- return [
658
- ...variantsWithDefinedScores.sort((a, b) => {
659
- var _a, _b;
660
- return ((_a = b.score) != null ? _a : 0) - ((_b = a.score) != null ? _b : 0);
661
- }).map((v) => v.variant),
662
- ...variantsWithUndefinedScores.map((v) => v.variant)
663
- ];
664
- };
665
644
  function personalizeVariations({
666
645
  name,
667
646
  context,
668
- variations: providedVariations,
647
+ variations,
669
648
  take = 1,
670
- onLogMessage,
671
- rankVariant
649
+ onLogMessage
672
650
  }) {
673
651
  var _a, _b, _c;
674
652
  onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
@@ -677,7 +655,6 @@ function personalizeVariations({
677
655
  const defaultVariants = [];
678
656
  const needsConsent = context.requireConsentForPersonalization;
679
657
  const canEvaluate = !needsConsent || context.storage.data.consent;
680
- const variations = rankVariant ? sortVariations({ variations: providedVariations, rankVariant }) : providedVariations;
681
658
  for (const variant of variations) {
682
659
  if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
683
660
  if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
@@ -1536,7 +1513,7 @@ import { dequal as dequal5 } from "dequal/lite";
1536
1513
  import mitt3 from "mitt";
1537
1514
  var CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
1538
1515
  var CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID = "contextual_editing_test_selected_variant";
1539
- var _serverTransitionState, _scores, _state, _pzCache, _plugins, _commands, _requireConsentForPersonalization, _rankPersonalizationVariant, _mitt3, _Context_instances, emitTest_fn, updateGoals_fn, updateComputedScores_fn, calculateScores_fn;
1516
+ var _serverTransitionState, _scores, _state, _pzCache, _plugins, _commands, _requireConsentForPersonalization, _mitt3, _Context_instances, emitTest_fn, updateGoals_fn, updateComputedScores_fn, calculateScores_fn;
1540
1517
  var Context = class {
1541
1518
  constructor(options) {
1542
1519
  __privateAdd(this, _Context_instances);
@@ -1548,7 +1525,6 @@ var Context = class {
1548
1525
  __privateAdd(this, _plugins);
1549
1526
  __privateAdd(this, _commands);
1550
1527
  __privateAdd(this, _requireConsentForPersonalization);
1551
- __privateAdd(this, _rankPersonalizationVariant);
1552
1528
  __privateAdd(this, _mitt3, mitt3());
1553
1529
  /**
1554
1530
  * Subscribe to events
@@ -1563,7 +1539,6 @@ var Context = class {
1563
1539
  __privateSet(this, _state, {});
1564
1540
  __privateSet(this, _plugins, options.plugins);
1565
1541
  __privateSet(this, _requireConsentForPersonalization, options.requireConsentForPersonalization);
1566
- __privateSet(this, _rankPersonalizationVariant, options.rankPersonalizationVariant);
1567
1542
  if (typeof options.transitionStore !== "undefined") {
1568
1543
  __privateSet(this, _commands, []);
1569
1544
  }
@@ -1871,13 +1846,7 @@ var Context = class {
1871
1846
  const value = personalizeVariations({
1872
1847
  ...options,
1873
1848
  context: this,
1874
- onLogMessage: (message) => __privateGet(this, _mitt3).emit("log", message),
1875
- rankVariant: __privateGet(this, _rankPersonalizationVariant) ? (variant) => __privateGet(this, _rankPersonalizationVariant).call(this, {
1876
- placementName: options.name,
1877
- variant,
1878
- scores: __privateGet(this, _scores),
1879
- quirks: this.storage.data.quirks
1880
- }) : void 0
1849
+ onLogMessage: (message) => __privateGet(this, _mitt3).emit("log", message)
1881
1850
  });
1882
1851
  const previousPlacement = __privateGet(this, _pzCache)[options.name];
1883
1852
  const eventData = {
@@ -1955,7 +1924,6 @@ _pzCache = new WeakMap();
1955
1924
  _plugins = new WeakMap();
1956
1925
  _commands = new WeakMap();
1957
1926
  _requireConsentForPersonalization = new WeakMap();
1958
- _rankPersonalizationVariant = new WeakMap();
1959
1927
  _mitt3 = new WeakMap();
1960
1928
  _Context_instances = new WeakSet();
1961
1929
  emitTest_fn = function(event) {
package/dist/index.js CHANGED
@@ -730,34 +730,12 @@ function explain(onLogMessage, result, crit, lhsScore, rhsScore) {
730
730
  }
731
731
 
732
732
  // src/placement/personalize.ts
733
- var sortVariations = ({
734
- variations,
735
- rankVariant
736
- }) => {
737
- const variationsWithScores = Array.from(variations).map((variant) => {
738
- const score = rankVariant == null ? void 0 : rankVariant(variant);
739
- return {
740
- variant,
741
- score
742
- };
743
- });
744
- const variantsWithDefinedScores = variationsWithScores.filter((v) => v.score !== void 0);
745
- const variantsWithUndefinedScores = variationsWithScores.filter((v) => v.score === void 0);
746
- return [
747
- ...variantsWithDefinedScores.sort((a, b) => {
748
- var _a, _b;
749
- return ((_a = b.score) != null ? _a : 0) - ((_b = a.score) != null ? _b : 0);
750
- }).map((v) => v.variant),
751
- ...variantsWithUndefinedScores.map((v) => v.variant)
752
- ];
753
- };
754
733
  function personalizeVariations({
755
734
  name,
756
735
  context,
757
- variations: providedVariations,
736
+ variations,
758
737
  take = 1,
759
- onLogMessage,
760
- rankVariant
738
+ onLogMessage
761
739
  }) {
762
740
  var _a, _b, _c;
763
741
  onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
@@ -766,7 +744,6 @@ function personalizeVariations({
766
744
  const defaultVariants = [];
767
745
  const needsConsent = context.requireConsentForPersonalization;
768
746
  const canEvaluate = !needsConsent || context.storage.data.consent;
769
- const variations = rankVariant ? sortVariations({ variations: providedVariations, rankVariant }) : providedVariations;
770
747
  for (const variant of variations) {
771
748
  if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
772
749
  if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
@@ -1625,7 +1602,7 @@ var import_lite5 = require("dequal/lite");
1625
1602
  var import_mitt3 = __toESM(require("mitt"));
1626
1603
  var CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
1627
1604
  var CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID = "contextual_editing_test_selected_variant";
1628
- var _serverTransitionState, _scores, _state, _pzCache, _plugins, _commands, _requireConsentForPersonalization, _rankPersonalizationVariant, _mitt3, _Context_instances, emitTest_fn, updateGoals_fn, updateComputedScores_fn, calculateScores_fn;
1605
+ var _serverTransitionState, _scores, _state, _pzCache, _plugins, _commands, _requireConsentForPersonalization, _mitt3, _Context_instances, emitTest_fn, updateGoals_fn, updateComputedScores_fn, calculateScores_fn;
1629
1606
  var Context = class {
1630
1607
  constructor(options) {
1631
1608
  __privateAdd(this, _Context_instances);
@@ -1637,7 +1614,6 @@ var Context = class {
1637
1614
  __privateAdd(this, _plugins);
1638
1615
  __privateAdd(this, _commands);
1639
1616
  __privateAdd(this, _requireConsentForPersonalization);
1640
- __privateAdd(this, _rankPersonalizationVariant);
1641
1617
  __privateAdd(this, _mitt3, (0, import_mitt3.default)());
1642
1618
  /**
1643
1619
  * Subscribe to events
@@ -1652,7 +1628,6 @@ var Context = class {
1652
1628
  __privateSet(this, _state, {});
1653
1629
  __privateSet(this, _plugins, options.plugins);
1654
1630
  __privateSet(this, _requireConsentForPersonalization, options.requireConsentForPersonalization);
1655
- __privateSet(this, _rankPersonalizationVariant, options.rankPersonalizationVariant);
1656
1631
  if (typeof options.transitionStore !== "undefined") {
1657
1632
  __privateSet(this, _commands, []);
1658
1633
  }
@@ -1960,13 +1935,7 @@ var Context = class {
1960
1935
  const value = personalizeVariations({
1961
1936
  ...options,
1962
1937
  context: this,
1963
- onLogMessage: (message) => __privateGet(this, _mitt3).emit("log", message),
1964
- rankVariant: __privateGet(this, _rankPersonalizationVariant) ? (variant) => __privateGet(this, _rankPersonalizationVariant).call(this, {
1965
- placementName: options.name,
1966
- variant,
1967
- scores: __privateGet(this, _scores),
1968
- quirks: this.storage.data.quirks
1969
- }) : void 0
1938
+ onLogMessage: (message) => __privateGet(this, _mitt3).emit("log", message)
1970
1939
  });
1971
1940
  const previousPlacement = __privateGet(this, _pzCache)[options.name];
1972
1941
  const eventData = {
@@ -2044,7 +2013,6 @@ _pzCache = new WeakMap();
2044
2013
  _plugins = new WeakMap();
2045
2014
  _commands = new WeakMap();
2046
2015
  _requireConsentForPersonalization = new WeakMap();
2047
- _rankPersonalizationVariant = new WeakMap();
2048
2016
  _mitt3 = new WeakMap();
2049
2017
  _Context_instances = new WeakSet();
2050
2018
  emitTest_fn = function(event) {
package/dist/index.mjs CHANGED
@@ -641,34 +641,12 @@ function explain(onLogMessage, result, crit, lhsScore, rhsScore) {
641
641
  }
642
642
 
643
643
  // src/placement/personalize.ts
644
- var sortVariations = ({
645
- variations,
646
- rankVariant
647
- }) => {
648
- const variationsWithScores = Array.from(variations).map((variant) => {
649
- const score = rankVariant == null ? void 0 : rankVariant(variant);
650
- return {
651
- variant,
652
- score
653
- };
654
- });
655
- const variantsWithDefinedScores = variationsWithScores.filter((v) => v.score !== void 0);
656
- const variantsWithUndefinedScores = variationsWithScores.filter((v) => v.score === void 0);
657
- return [
658
- ...variantsWithDefinedScores.sort((a, b) => {
659
- var _a, _b;
660
- return ((_a = b.score) != null ? _a : 0) - ((_b = a.score) != null ? _b : 0);
661
- }).map((v) => v.variant),
662
- ...variantsWithUndefinedScores.map((v) => v.variant)
663
- ];
664
- };
665
644
  function personalizeVariations({
666
645
  name,
667
646
  context,
668
- variations: providedVariations,
647
+ variations,
669
648
  take = 1,
670
- onLogMessage,
671
- rankVariant
649
+ onLogMessage
672
650
  }) {
673
651
  var _a, _b, _c;
674
652
  onLogMessage == null ? void 0 : onLogMessage(["info", 300, "GROUP", { name, take }]);
@@ -677,7 +655,6 @@ function personalizeVariations({
677
655
  const defaultVariants = [];
678
656
  const needsConsent = context.requireConsentForPersonalization;
679
657
  const canEvaluate = !needsConsent || context.storage.data.consent;
680
- const variations = rankVariant ? sortVariations({ variations: providedVariations, rankVariant }) : providedVariations;
681
658
  for (const variant of variations) {
682
659
  if ((_a = variant.pz) == null ? void 0 : _a.crit.length) {
683
660
  if (canEvaluate && variantMatches.length !== take && evaluateVariantMatch(variant.id, variant.pz, context.scores, onLogMessage)) {
@@ -1536,7 +1513,7 @@ import { dequal as dequal5 } from "dequal/lite";
1536
1513
  import mitt3 from "mitt";
1537
1514
  var CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
1538
1515
  var CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID = "contextual_editing_test_selected_variant";
1539
- var _serverTransitionState, _scores, _state, _pzCache, _plugins, _commands, _requireConsentForPersonalization, _rankPersonalizationVariant, _mitt3, _Context_instances, emitTest_fn, updateGoals_fn, updateComputedScores_fn, calculateScores_fn;
1516
+ var _serverTransitionState, _scores, _state, _pzCache, _plugins, _commands, _requireConsentForPersonalization, _mitt3, _Context_instances, emitTest_fn, updateGoals_fn, updateComputedScores_fn, calculateScores_fn;
1540
1517
  var Context = class {
1541
1518
  constructor(options) {
1542
1519
  __privateAdd(this, _Context_instances);
@@ -1548,7 +1525,6 @@ var Context = class {
1548
1525
  __privateAdd(this, _plugins);
1549
1526
  __privateAdd(this, _commands);
1550
1527
  __privateAdd(this, _requireConsentForPersonalization);
1551
- __privateAdd(this, _rankPersonalizationVariant);
1552
1528
  __privateAdd(this, _mitt3, mitt3());
1553
1529
  /**
1554
1530
  * Subscribe to events
@@ -1563,7 +1539,6 @@ var Context = class {
1563
1539
  __privateSet(this, _state, {});
1564
1540
  __privateSet(this, _plugins, options.plugins);
1565
1541
  __privateSet(this, _requireConsentForPersonalization, options.requireConsentForPersonalization);
1566
- __privateSet(this, _rankPersonalizationVariant, options.rankPersonalizationVariant);
1567
1542
  if (typeof options.transitionStore !== "undefined") {
1568
1543
  __privateSet(this, _commands, []);
1569
1544
  }
@@ -1871,13 +1846,7 @@ var Context = class {
1871
1846
  const value = personalizeVariations({
1872
1847
  ...options,
1873
1848
  context: this,
1874
- onLogMessage: (message) => __privateGet(this, _mitt3).emit("log", message),
1875
- rankVariant: __privateGet(this, _rankPersonalizationVariant) ? (variant) => __privateGet(this, _rankPersonalizationVariant).call(this, {
1876
- placementName: options.name,
1877
- variant,
1878
- scores: __privateGet(this, _scores),
1879
- quirks: this.storage.data.quirks
1880
- }) : void 0
1849
+ onLogMessage: (message) => __privateGet(this, _mitt3).emit("log", message)
1881
1850
  });
1882
1851
  const previousPlacement = __privateGet(this, _pzCache)[options.name];
1883
1852
  const eventData = {
@@ -1955,7 +1924,6 @@ _pzCache = new WeakMap();
1955
1924
  _plugins = new WeakMap();
1956
1925
  _commands = new WeakMap();
1957
1926
  _requireConsentForPersonalization = new WeakMap();
1958
- _rankPersonalizationVariant = new WeakMap();
1959
1927
  _mitt3 = new WeakMap();
1960
1928
  _Context_instances = new WeakSet();
1961
1929
  emitTest_fn = function(event) {
@@ -1004,9 +1004,8 @@ type PersonalizeOptions<TVariant> = {
1004
1004
  /** Maximum number of variants to place (default: 1) */
1005
1005
  take?: number;
1006
1006
  onLogMessage?: (message: LogMessage) => void;
1007
- rankVariant?: (variant: TVariant) => number | undefined;
1008
1007
  };
1009
- declare function personalizeVariations<TVariant extends PersonalizedVariant>({ name, context, variations: providedVariations, take, onLogMessage, rankVariant, }: PersonalizeOptions<TVariant> & {
1008
+ declare function personalizeVariations<TVariant extends PersonalizedVariant>({ name, context, variations, take, onLogMessage, }: PersonalizeOptions<TVariant> & {
1010
1009
  context: Context;
1011
1010
  }): PersonalizedResult<TVariant>;
1012
1011
 
@@ -1051,32 +1050,7 @@ type ContextOptions = {
1051
1050
  * `true`: personalization is not run at all unless storage consent is given
1052
1051
  */
1053
1052
  requireConsentForPersonalization?: boolean;
1054
- /**
1055
- * Specify a rank for a personalized variant, controlling the order in which variants are considered.
1056
- * @param placementName The name of the personalized placement
1057
- * @param variant The variant to rank
1058
- * @returns A number representing the rank of the variant, where higher numbers are considered first
1059
- */
1060
- rankPersonalizationVariant?: (options: RankPersonalizationVariantOptions) => number | undefined;
1061
1053
  } & Omit<VisitorDataStoreOptions, 'manifest' | 'onServerTransitionScoresReceived'>;
1062
- type RankPersonalizationVariantOptions = {
1063
- /**
1064
- * The name of the personalized placement
1065
- */
1066
- placementName: string;
1067
- /**
1068
- * The variant to rank
1069
- */
1070
- variant: PersonalizedVariant;
1071
- /**
1072
- * The current scores of the visitor
1073
- */
1074
- scores: Readonly<ScoreVector>;
1075
- /**
1076
- * The current quirks of the visitor
1077
- */
1078
- quirks: Readonly<Quirks>;
1079
- };
1080
1054
  /** Emitted when a personalization runs */
1081
1055
  type PersonalizationEvent = {
1082
1056
  /** Name of the personalized placement */
@@ -1291,4 +1265,4 @@ declare global {
1291
1265
  }
1292
1266
  }
1293
1267
 
1294
- export { type TestDefinition as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type Quirks as Q, type RankPersonalizationVariantOptions as R, type ScoreVector as S, TransitionDataStore as T, type PersonalizationManifest as U, type VisitorData as V, type Signal as W, type SignalCriteriaGroup as X, type SignalCriteria as Y, type EnrichmentCategory as Z, type NumberMatch as _, type StorageCommands as a, type AggregateDimensionInput as a0, type TestOptions as a1, testVariations as a2, type DimensionMatch as a3, type PersonalizeOptions as a4, personalizeVariations as a5, type BehaviorTag as a6, type PersonalizedVariant as a7, type PersonalizedResult as a8, type TestVariant as a9, type ContextState as aA, type ContextStateUpdate as aB, type GoalStateUpdate as aC, type paths as aD, type TestResult as aa, type StorageCommand as ab, type SetGoalCommand as ac, type ModifyScoreCommand as ad, type ModifySessionScoreCommand as ae, type SetConsentCommand as af, type SetQuirkCommand as ag, type SetTestCommand as ah, type IdentifyCommand as ai, type SetControlGroupCommand as aj, type SetPersonalizeVariantControlCommand as ak, areCommandsEqual as al, type ServerToClientTransitionState as am, SERVER_STATE_ID as an, type TransitionDataStoreEvents as ao, type DecayOptions as ap, type VisitorDataStoreOptions as aq, type VisitorDataStoreEvents as ar, VisitorDataStore as as, type Tests as at, type Goals as au, type EnrichmentData as av, type PersonalizeControlVariant as aw, type PersonalizeVariants as ax, type EventData as ay, emptyVisitorData as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
1268
+ export { type AggregateDimensionInput as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type Quirks as Q, type PersonalizationManifest as R, type ScoreVector as S, TransitionDataStore as T, type Signal as U, type VisitorData as V, type SignalCriteriaGroup as W, type SignalCriteria as X, type EnrichmentCategory as Y, type NumberMatch as Z, type TestDefinition as _, type StorageCommands as a, type TestOptions as a0, testVariations as a1, type DimensionMatch as a2, type PersonalizeOptions as a3, personalizeVariations as a4, type BehaviorTag as a5, type PersonalizedVariant as a6, type PersonalizedResult as a7, type TestVariant as a8, type TestResult as a9, type ContextStateUpdate as aA, type GoalStateUpdate as aB, type paths as aC, type StorageCommand as aa, type SetGoalCommand as ab, type ModifyScoreCommand as ac, type ModifySessionScoreCommand as ad, type SetConsentCommand as ae, type SetQuirkCommand as af, type SetTestCommand as ag, type IdentifyCommand as ah, type SetControlGroupCommand as ai, type SetPersonalizeVariantControlCommand as aj, areCommandsEqual as ak, type ServerToClientTransitionState as al, SERVER_STATE_ID as am, type TransitionDataStoreEvents as an, type DecayOptions as ao, type VisitorDataStoreOptions as ap, type VisitorDataStoreEvents as aq, VisitorDataStore as ar, type Tests as as, type Goals as at, type EnrichmentData as au, type PersonalizeControlVariant as av, type PersonalizeVariants as aw, type EventData as ax, emptyVisitorData as ay, type ContextState as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
@@ -1004,9 +1004,8 @@ type PersonalizeOptions<TVariant> = {
1004
1004
  /** Maximum number of variants to place (default: 1) */
1005
1005
  take?: number;
1006
1006
  onLogMessage?: (message: LogMessage) => void;
1007
- rankVariant?: (variant: TVariant) => number | undefined;
1008
1007
  };
1009
- declare function personalizeVariations<TVariant extends PersonalizedVariant>({ name, context, variations: providedVariations, take, onLogMessage, rankVariant, }: PersonalizeOptions<TVariant> & {
1008
+ declare function personalizeVariations<TVariant extends PersonalizedVariant>({ name, context, variations, take, onLogMessage, }: PersonalizeOptions<TVariant> & {
1010
1009
  context: Context;
1011
1010
  }): PersonalizedResult<TVariant>;
1012
1011
 
@@ -1051,32 +1050,7 @@ type ContextOptions = {
1051
1050
  * `true`: personalization is not run at all unless storage consent is given
1052
1051
  */
1053
1052
  requireConsentForPersonalization?: boolean;
1054
- /**
1055
- * Specify a rank for a personalized variant, controlling the order in which variants are considered.
1056
- * @param placementName The name of the personalized placement
1057
- * @param variant The variant to rank
1058
- * @returns A number representing the rank of the variant, where higher numbers are considered first
1059
- */
1060
- rankPersonalizationVariant?: (options: RankPersonalizationVariantOptions) => number | undefined;
1061
1053
  } & Omit<VisitorDataStoreOptions, 'manifest' | 'onServerTransitionScoresReceived'>;
1062
- type RankPersonalizationVariantOptions = {
1063
- /**
1064
- * The name of the personalized placement
1065
- */
1066
- placementName: string;
1067
- /**
1068
- * The variant to rank
1069
- */
1070
- variant: PersonalizedVariant;
1071
- /**
1072
- * The current scores of the visitor
1073
- */
1074
- scores: Readonly<ScoreVector>;
1075
- /**
1076
- * The current quirks of the visitor
1077
- */
1078
- quirks: Readonly<Quirks>;
1079
- };
1080
1054
  /** Emitted when a personalization runs */
1081
1055
  type PersonalizationEvent = {
1082
1056
  /** Name of the personalized placement */
@@ -1291,4 +1265,4 @@ declare global {
1291
1265
  }
1292
1266
  }
1293
1267
 
1294
- export { type TestDefinition as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type Quirks as Q, type RankPersonalizationVariantOptions as R, type ScoreVector as S, TransitionDataStore as T, type PersonalizationManifest as U, type VisitorData as V, type Signal as W, type SignalCriteriaGroup as X, type SignalCriteria as Y, type EnrichmentCategory as Z, type NumberMatch as _, type StorageCommands as a, type AggregateDimensionInput as a0, type TestOptions as a1, testVariations as a2, type DimensionMatch as a3, type PersonalizeOptions as a4, personalizeVariations as a5, type BehaviorTag as a6, type PersonalizedVariant as a7, type PersonalizedResult as a8, type TestVariant as a9, type ContextState as aA, type ContextStateUpdate as aB, type GoalStateUpdate as aC, type paths as aD, type TestResult as aa, type StorageCommand as ab, type SetGoalCommand as ac, type ModifyScoreCommand as ad, type ModifySessionScoreCommand as ae, type SetConsentCommand as af, type SetQuirkCommand as ag, type SetTestCommand as ah, type IdentifyCommand as ai, type SetControlGroupCommand as aj, type SetPersonalizeVariantControlCommand as ak, areCommandsEqual as al, type ServerToClientTransitionState as am, SERVER_STATE_ID as an, type TransitionDataStoreEvents as ao, type DecayOptions as ap, type VisitorDataStoreOptions as aq, type VisitorDataStoreEvents as ar, VisitorDataStore as as, type Tests as at, type Goals as au, type EnrichmentData as av, type PersonalizeControlVariant as aw, type PersonalizeVariants as ax, type EventData as ay, emptyVisitorData as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
1268
+ export { type AggregateDimensionInput as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type Quirks as Q, type PersonalizationManifest as R, type ScoreVector as S, TransitionDataStore as T, type Signal as U, type VisitorData as V, type SignalCriteriaGroup as W, type SignalCriteria as X, type EnrichmentCategory as Y, type NumberMatch as Z, type TestDefinition as _, type StorageCommands as a, type TestOptions as a0, testVariations as a1, type DimensionMatch as a2, type PersonalizeOptions as a3, personalizeVariations as a4, type BehaviorTag as a5, type PersonalizedVariant as a6, type PersonalizedResult as a7, type TestVariant as a8, type TestResult as a9, type ContextStateUpdate as aA, type GoalStateUpdate as aB, type paths as aC, type StorageCommand as aa, type SetGoalCommand as ab, type ModifyScoreCommand as ac, type ModifySessionScoreCommand as ad, type SetConsentCommand as ae, type SetQuirkCommand as af, type SetTestCommand as ag, type IdentifyCommand as ah, type SetControlGroupCommand as ai, type SetPersonalizeVariantControlCommand as aj, areCommandsEqual as ak, type ServerToClientTransitionState as al, SERVER_STATE_ID as am, type TransitionDataStoreEvents as an, type DecayOptions as ao, type VisitorDataStoreOptions as ap, type VisitorDataStoreEvents as aq, VisitorDataStore as ar, type Tests as as, type Goals as at, type EnrichmentData as au, type PersonalizeControlVariant as av, type PersonalizeVariants as aw, type EventData as ax, emptyVisitorData as ay, type ContextState as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/context",
3
- "version": "20.4.1-alpha.3+bc2e6fc5f7",
3
+ "version": "20.4.2-alpha.5+23d2506573",
4
4
  "description": "Uniform Context core package",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "bc2e6fc5f7d2920e46605385db043782f023bbbb"
71
+ "gitHead": "23d25065730fa3fce441ddcf293ba87c99b723f0"
72
72
  }