@ninetailed/experience.js-plugin-preview 4.0.0-beta.10 → 4.0.0-beta.13
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/index.cjs +113 -106
- package/index.js +113 -106
- package/package.json +7 -7
package/index.cjs
CHANGED
|
@@ -2308,6 +2308,79 @@ $$4({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }
|
|
|
2308
2308
|
assign: assign
|
|
2309
2309
|
});
|
|
2310
2310
|
|
|
2311
|
+
var aCallable = aCallable$8;
|
|
2312
|
+
var toObject$1 = toObject$4;
|
|
2313
|
+
var IndexedObject = indexedObject;
|
|
2314
|
+
var lengthOfArrayLike = lengthOfArrayLike$3;
|
|
2315
|
+
|
|
2316
|
+
var $TypeError$1 = TypeError;
|
|
2317
|
+
|
|
2318
|
+
// `Array.prototype.{ reduce, reduceRight }` methods implementation
|
|
2319
|
+
var createMethod = function (IS_RIGHT) {
|
|
2320
|
+
return function (that, callbackfn, argumentsLength, memo) {
|
|
2321
|
+
aCallable(callbackfn);
|
|
2322
|
+
var O = toObject$1(that);
|
|
2323
|
+
var self = IndexedObject(O);
|
|
2324
|
+
var length = lengthOfArrayLike(O);
|
|
2325
|
+
var index = IS_RIGHT ? length - 1 : 0;
|
|
2326
|
+
var i = IS_RIGHT ? -1 : 1;
|
|
2327
|
+
if (argumentsLength < 2) while (true) {
|
|
2328
|
+
if (index in self) {
|
|
2329
|
+
memo = self[index];
|
|
2330
|
+
index += i;
|
|
2331
|
+
break;
|
|
2332
|
+
}
|
|
2333
|
+
index += i;
|
|
2334
|
+
if (IS_RIGHT ? index < 0 : length <= index) {
|
|
2335
|
+
throw $TypeError$1('Reduce of empty array with no initial value');
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
|
|
2339
|
+
memo = callbackfn(memo, self[index], index, O);
|
|
2340
|
+
}
|
|
2341
|
+
return memo;
|
|
2342
|
+
};
|
|
2343
|
+
};
|
|
2344
|
+
|
|
2345
|
+
var arrayReduce = {
|
|
2346
|
+
// `Array.prototype.reduce` method
|
|
2347
|
+
// https://tc39.es/ecma262/#sec-array.prototype.reduce
|
|
2348
|
+
left: createMethod(false),
|
|
2349
|
+
// `Array.prototype.reduceRight` method
|
|
2350
|
+
// https://tc39.es/ecma262/#sec-array.prototype.reduceright
|
|
2351
|
+
right: createMethod(true)
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
var fails$3 = fails$f;
|
|
2355
|
+
|
|
2356
|
+
var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
|
|
2357
|
+
var method = [][METHOD_NAME];
|
|
2358
|
+
return !!method && fails$3(function () {
|
|
2359
|
+
// eslint-disable-next-line no-useless-call -- required for testing
|
|
2360
|
+
method.call(null, argument || function () { return 1; }, 1);
|
|
2361
|
+
});
|
|
2362
|
+
};
|
|
2363
|
+
|
|
2364
|
+
var $$3 = _export;
|
|
2365
|
+
var $reduce = arrayReduce.left;
|
|
2366
|
+
var arrayMethodIsStrict = arrayMethodIsStrict$1;
|
|
2367
|
+
var CHROME_VERSION = engineV8Version;
|
|
2368
|
+
var IS_NODE = engineIsNode;
|
|
2369
|
+
|
|
2370
|
+
var STRICT_METHOD = arrayMethodIsStrict('reduce');
|
|
2371
|
+
// Chrome 80-82 has a critical bug
|
|
2372
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
|
|
2373
|
+
var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
|
|
2374
|
+
|
|
2375
|
+
// `Array.prototype.reduce` method
|
|
2376
|
+
// https://tc39.es/ecma262/#sec-array.prototype.reduce
|
|
2377
|
+
$$3({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
|
|
2378
|
+
reduce: function reduce(callbackfn /* , initialValue */) {
|
|
2379
|
+
var length = arguments.length;
|
|
2380
|
+
return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
|
|
2381
|
+
}
|
|
2382
|
+
});
|
|
2383
|
+
|
|
2311
2384
|
var objectDefineProperties = {};
|
|
2312
2385
|
|
|
2313
2386
|
var DESCRIPTORS$1 = descriptors;
|
|
@@ -2437,9 +2510,9 @@ var addToUnscopables$2 = function (key) {
|
|
|
2437
2510
|
ArrayPrototype[UNSCOPABLES][key] = true;
|
|
2438
2511
|
};
|
|
2439
2512
|
|
|
2440
|
-
var fails$
|
|
2513
|
+
var fails$2 = fails$f;
|
|
2441
2514
|
|
|
2442
|
-
var correctPrototypeGetter = !fails$
|
|
2515
|
+
var correctPrototypeGetter = !fails$2(function () {
|
|
2443
2516
|
function F() { /* empty */ }
|
|
2444
2517
|
F.prototype.constructor = null;
|
|
2445
2518
|
// eslint-disable-next-line es/no-object-getprototypeof -- required for testing
|
|
@@ -2448,7 +2521,7 @@ var correctPrototypeGetter = !fails$3(function () {
|
|
|
2448
2521
|
|
|
2449
2522
|
var hasOwn = hasOwnProperty_1;
|
|
2450
2523
|
var isCallable$2 = isCallable$k;
|
|
2451
|
-
var toObject
|
|
2524
|
+
var toObject = toObject$4;
|
|
2452
2525
|
var sharedKey = sharedKey$3;
|
|
2453
2526
|
var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
|
|
2454
2527
|
|
|
@@ -2460,7 +2533,7 @@ var ObjectPrototype = $Object.prototype;
|
|
|
2460
2533
|
// https://tc39.es/ecma262/#sec-object.getprototypeof
|
|
2461
2534
|
// eslint-disable-next-line es/no-object-getprototypeof -- safe
|
|
2462
2535
|
var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
|
|
2463
|
-
var object = toObject
|
|
2536
|
+
var object = toObject(O);
|
|
2464
2537
|
if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
|
|
2465
2538
|
var constructor = object.constructor;
|
|
2466
2539
|
if (isCallable$2(constructor) && object instanceof constructor) {
|
|
@@ -2468,7 +2541,7 @@ var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : f
|
|
|
2468
2541
|
} return object instanceof $Object ? ObjectPrototype : null;
|
|
2469
2542
|
};
|
|
2470
2543
|
|
|
2471
|
-
var fails$
|
|
2544
|
+
var fails$1 = fails$f;
|
|
2472
2545
|
var isCallable$1 = isCallable$k;
|
|
2473
2546
|
var isObject$1 = isObject$9;
|
|
2474
2547
|
var getPrototypeOf$1 = objectGetPrototypeOf;
|
|
@@ -2493,7 +2566,7 @@ if ([].keys) {
|
|
|
2493
2566
|
}
|
|
2494
2567
|
}
|
|
2495
2568
|
|
|
2496
|
-
var NEW_ITERATOR_PROTOTYPE = !isObject$1(IteratorPrototype$2) || fails$
|
|
2569
|
+
var NEW_ITERATOR_PROTOTYPE = !isObject$1(IteratorPrototype$2) || fails$1(function () {
|
|
2497
2570
|
var test = {};
|
|
2498
2571
|
// FF44- legacy iterators case
|
|
2499
2572
|
return IteratorPrototype$2[ITERATOR$2].call(test) !== test;
|
|
@@ -2530,7 +2603,7 @@ var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUME
|
|
|
2530
2603
|
return IteratorConstructor;
|
|
2531
2604
|
};
|
|
2532
2605
|
|
|
2533
|
-
var $$
|
|
2606
|
+
var $$2 = _export;
|
|
2534
2607
|
var call = functionCall;
|
|
2535
2608
|
var FunctionName = functionName;
|
|
2536
2609
|
var isCallable = isCallable$k;
|
|
@@ -2615,7 +2688,7 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
|
|
|
2615
2688
|
if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
|
|
2616
2689
|
defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
|
|
2617
2690
|
}
|
|
2618
|
-
} else $$
|
|
2691
|
+
} else $$2({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
|
|
2619
2692
|
}
|
|
2620
2693
|
|
|
2621
2694
|
// define iterator
|
|
@@ -2777,19 +2850,19 @@ for (var COLLECTION_NAME in DOMIterables) {
|
|
|
2777
2850
|
|
|
2778
2851
|
handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
|
|
2779
2852
|
|
|
2780
|
-
var $$
|
|
2853
|
+
var $$1 = _export;
|
|
2781
2854
|
var $includes = arrayIncludes.includes;
|
|
2782
|
-
var fails
|
|
2855
|
+
var fails = fails$f;
|
|
2783
2856
|
var addToUnscopables = addToUnscopables$2;
|
|
2784
2857
|
|
|
2785
2858
|
// FF99+ bug
|
|
2786
|
-
var BROKEN_ON_SPARSE = fails
|
|
2859
|
+
var BROKEN_ON_SPARSE = fails(function () {
|
|
2787
2860
|
return !Array(1).includes();
|
|
2788
2861
|
});
|
|
2789
2862
|
|
|
2790
2863
|
// `Array.prototype.includes` method
|
|
2791
2864
|
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
2792
|
-
$$
|
|
2865
|
+
$$1({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
|
|
2793
2866
|
includes: function includes(el /* , fromIndex = 0 */) {
|
|
2794
2867
|
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
|
2795
2868
|
}
|
|
@@ -2813,11 +2886,11 @@ var isRegexp = function (it) {
|
|
|
2813
2886
|
|
|
2814
2887
|
var isRegExp = isRegexp;
|
|
2815
2888
|
|
|
2816
|
-
var $TypeError
|
|
2889
|
+
var $TypeError = TypeError;
|
|
2817
2890
|
|
|
2818
2891
|
var notARegexp = function (it) {
|
|
2819
2892
|
if (isRegExp(it)) {
|
|
2820
|
-
throw $TypeError
|
|
2893
|
+
throw $TypeError("The method doesn't accept regular expressions");
|
|
2821
2894
|
} return it;
|
|
2822
2895
|
};
|
|
2823
2896
|
|
|
@@ -2846,7 +2919,7 @@ var correctIsRegexpLogic = function (METHOD_NAME) {
|
|
|
2846
2919
|
} return false;
|
|
2847
2920
|
};
|
|
2848
2921
|
|
|
2849
|
-
var
|
|
2922
|
+
var $ = _export;
|
|
2850
2923
|
var uncurryThis = functionUncurryThis;
|
|
2851
2924
|
var notARegExp = notARegexp;
|
|
2852
2925
|
var requireObjectCoercible = requireObjectCoercible$3;
|
|
@@ -2857,7 +2930,7 @@ var stringIndexOf = uncurryThis(''.indexOf);
|
|
|
2857
2930
|
|
|
2858
2931
|
// `String.prototype.includes` method
|
|
2859
2932
|
// https://tc39.es/ecma262/#sec-string.prototype.includes
|
|
2860
|
-
|
|
2933
|
+
$({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
|
|
2861
2934
|
includes: function includes(searchString /* , position = 0 */) {
|
|
2862
2935
|
return !!~stringIndexOf(
|
|
2863
2936
|
toString(requireObjectCoercible(this)),
|
|
@@ -2867,79 +2940,6 @@ $$1({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }
|
|
|
2867
2940
|
}
|
|
2868
2941
|
});
|
|
2869
2942
|
|
|
2870
|
-
var aCallable = aCallable$8;
|
|
2871
|
-
var toObject = toObject$4;
|
|
2872
|
-
var IndexedObject = indexedObject;
|
|
2873
|
-
var lengthOfArrayLike = lengthOfArrayLike$3;
|
|
2874
|
-
|
|
2875
|
-
var $TypeError = TypeError;
|
|
2876
|
-
|
|
2877
|
-
// `Array.prototype.{ reduce, reduceRight }` methods implementation
|
|
2878
|
-
var createMethod = function (IS_RIGHT) {
|
|
2879
|
-
return function (that, callbackfn, argumentsLength, memo) {
|
|
2880
|
-
aCallable(callbackfn);
|
|
2881
|
-
var O = toObject(that);
|
|
2882
|
-
var self = IndexedObject(O);
|
|
2883
|
-
var length = lengthOfArrayLike(O);
|
|
2884
|
-
var index = IS_RIGHT ? length - 1 : 0;
|
|
2885
|
-
var i = IS_RIGHT ? -1 : 1;
|
|
2886
|
-
if (argumentsLength < 2) while (true) {
|
|
2887
|
-
if (index in self) {
|
|
2888
|
-
memo = self[index];
|
|
2889
|
-
index += i;
|
|
2890
|
-
break;
|
|
2891
|
-
}
|
|
2892
|
-
index += i;
|
|
2893
|
-
if (IS_RIGHT ? index < 0 : length <= index) {
|
|
2894
|
-
throw $TypeError('Reduce of empty array with no initial value');
|
|
2895
|
-
}
|
|
2896
|
-
}
|
|
2897
|
-
for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
|
|
2898
|
-
memo = callbackfn(memo, self[index], index, O);
|
|
2899
|
-
}
|
|
2900
|
-
return memo;
|
|
2901
|
-
};
|
|
2902
|
-
};
|
|
2903
|
-
|
|
2904
|
-
var arrayReduce = {
|
|
2905
|
-
// `Array.prototype.reduce` method
|
|
2906
|
-
// https://tc39.es/ecma262/#sec-array.prototype.reduce
|
|
2907
|
-
left: createMethod(false),
|
|
2908
|
-
// `Array.prototype.reduceRight` method
|
|
2909
|
-
// https://tc39.es/ecma262/#sec-array.prototype.reduceright
|
|
2910
|
-
right: createMethod(true)
|
|
2911
|
-
};
|
|
2912
|
-
|
|
2913
|
-
var fails = fails$f;
|
|
2914
|
-
|
|
2915
|
-
var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
|
|
2916
|
-
var method = [][METHOD_NAME];
|
|
2917
|
-
return !!method && fails(function () {
|
|
2918
|
-
// eslint-disable-next-line no-useless-call -- required for testing
|
|
2919
|
-
method.call(null, argument || function () { return 1; }, 1);
|
|
2920
|
-
});
|
|
2921
|
-
};
|
|
2922
|
-
|
|
2923
|
-
var $ = _export;
|
|
2924
|
-
var $reduce = arrayReduce.left;
|
|
2925
|
-
var arrayMethodIsStrict = arrayMethodIsStrict$1;
|
|
2926
|
-
var CHROME_VERSION = engineV8Version;
|
|
2927
|
-
var IS_NODE = engineIsNode;
|
|
2928
|
-
|
|
2929
|
-
var STRICT_METHOD = arrayMethodIsStrict('reduce');
|
|
2930
|
-
// Chrome 80-82 has a critical bug
|
|
2931
|
-
// https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
|
|
2932
|
-
var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
|
|
2933
|
-
|
|
2934
|
-
// `Array.prototype.reduce` method
|
|
2935
|
-
// https://tc39.es/ecma262/#sec-array.prototype.reduce
|
|
2936
|
-
$({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
|
|
2937
|
-
reduce: function reduce(callbackfn /* , initialValue */) {
|
|
2938
|
-
var length = arguments.length;
|
|
2939
|
-
return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
|
|
2940
|
-
}
|
|
2941
|
-
});
|
|
2942
|
-
|
|
2943
2943
|
/******************************************************************************
|
|
2944
2944
|
Copyright (c) Microsoft Corporation.
|
|
2945
2945
|
|
|
@@ -3046,21 +3046,21 @@ const PreviewRenderPlugin = ctx => {
|
|
|
3046
3046
|
};
|
|
3047
3047
|
}, [id]);
|
|
3048
3048
|
react.useEffect(() => {
|
|
3049
|
-
const
|
|
3050
|
-
const
|
|
3051
|
-
return
|
|
3049
|
+
const experienceIds = Object.keys(pluginApi.experienceVariantIndexes);
|
|
3050
|
+
const experience = experiences.find(experience => {
|
|
3051
|
+
return experienceIds.includes(experience.id);
|
|
3052
3052
|
});
|
|
3053
|
-
if (!
|
|
3053
|
+
if (!experience) {
|
|
3054
3054
|
setComponentProps({});
|
|
3055
3055
|
return;
|
|
3056
3056
|
}
|
|
3057
|
-
const baselineComponent =
|
|
3057
|
+
const baselineComponent = experience.components.find(component => component.baseline.id === baseline.id);
|
|
3058
3058
|
if (!baselineComponent) {
|
|
3059
3059
|
setComponentProps({});
|
|
3060
3060
|
return;
|
|
3061
3061
|
}
|
|
3062
3062
|
const allVariants = [baseline, ...baselineComponent.variants];
|
|
3063
|
-
const variantIndex = pluginApi.
|
|
3063
|
+
const variantIndex = pluginApi.experienceVariantIndexes[experience.id];
|
|
3064
3064
|
if (allVariants.length <= variantIndex) {
|
|
3065
3065
|
setComponentProps({});
|
|
3066
3066
|
return;
|
|
@@ -3071,7 +3071,7 @@ const PreviewRenderPlugin = ctx => {
|
|
|
3071
3071
|
return;
|
|
3072
3072
|
}
|
|
3073
3073
|
setComponentProps(Object.assign({}, variant));
|
|
3074
|
-
}, [experiences, baseline, setComponentProps, pluginApi.
|
|
3074
|
+
}, [experiences, baseline, setComponentProps, pluginApi.experienceVariantIndexes]);
|
|
3075
3075
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
3076
3076
|
children: children
|
|
3077
3077
|
});
|
|
@@ -3195,10 +3195,14 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
3195
3195
|
this.audienceOverwrites = Object.assign(Object.assign({}, this.audienceOverwrites), {
|
|
3196
3196
|
[id]: true
|
|
3197
3197
|
});
|
|
3198
|
-
this.experienceVariantIndexOverwrites =
|
|
3198
|
+
this.experienceVariantIndexOverwrites = Object.assign(Object.assign({}, this.experienceVariantIndexOverwrites), this.experiences.filter(experience => {
|
|
3199
3199
|
var _b;
|
|
3200
3200
|
return ((_b = experience.audience) === null || _b === void 0 ? void 0 : _b.id) === id;
|
|
3201
|
-
}).map(experience => experience.id))
|
|
3201
|
+
}).map(experience => experience.id).reduce((acc, curr) => {
|
|
3202
|
+
return Object.assign(Object.assign({}, acc), {
|
|
3203
|
+
[curr]: this.experienceVariantIndexes[curr] || 0
|
|
3204
|
+
});
|
|
3205
|
+
}, {}));
|
|
3202
3206
|
this.onChange();
|
|
3203
3207
|
}
|
|
3204
3208
|
deactivateAudience(id) {
|
|
@@ -3206,16 +3210,19 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
3206
3210
|
console.log(`You cannot deactivate an unkown audience (id: ${id}). How did you get it in the first place?`);
|
|
3207
3211
|
return;
|
|
3208
3212
|
}
|
|
3209
|
-
// When a audience is deactivated, the normal state will be that the experience goes into the control
|
|
3210
|
-
this.experiences
|
|
3213
|
+
// // When a audience is deactivated, the normal state will be that the experience goes into the control
|
|
3214
|
+
// this.experiences
|
|
3215
|
+
// .filter((experience) => experience.audience?.id === id)
|
|
3216
|
+
// .forEach((experience) => {
|
|
3217
|
+
// this.setExperienceVariant({
|
|
3218
|
+
// experienceId: experience.id,
|
|
3219
|
+
// variantIndex: 0,
|
|
3220
|
+
// });
|
|
3221
|
+
// });
|
|
3222
|
+
this.experienceVariantIndexOverwrites = omit__default["default"](this.experienceVariantIndexOverwrites, this.experiences.filter(experience => {
|
|
3211
3223
|
var _b;
|
|
3212
3224
|
return ((_b = experience.audience) === null || _b === void 0 ? void 0 : _b.id) === id;
|
|
3213
|
-
}).
|
|
3214
|
-
this.setExperienceVariant({
|
|
3215
|
-
experienceId: experience.id,
|
|
3216
|
-
variantIndex: 0
|
|
3217
|
-
});
|
|
3218
|
-
});
|
|
3225
|
+
}).map(experience => experience.id));
|
|
3219
3226
|
this.audienceOverwrites = Object.assign(Object.assign({}, this.audienceOverwrites), {
|
|
3220
3227
|
[id]: false
|
|
3221
3228
|
});
|
package/index.js
CHANGED
|
@@ -2282,6 +2282,79 @@ $$4({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }
|
|
|
2282
2282
|
assign: assign
|
|
2283
2283
|
});
|
|
2284
2284
|
|
|
2285
|
+
var aCallable = aCallable$8;
|
|
2286
|
+
var toObject$1 = toObject$4;
|
|
2287
|
+
var IndexedObject = indexedObject;
|
|
2288
|
+
var lengthOfArrayLike = lengthOfArrayLike$3;
|
|
2289
|
+
|
|
2290
|
+
var $TypeError$1 = TypeError;
|
|
2291
|
+
|
|
2292
|
+
// `Array.prototype.{ reduce, reduceRight }` methods implementation
|
|
2293
|
+
var createMethod = function (IS_RIGHT) {
|
|
2294
|
+
return function (that, callbackfn, argumentsLength, memo) {
|
|
2295
|
+
aCallable(callbackfn);
|
|
2296
|
+
var O = toObject$1(that);
|
|
2297
|
+
var self = IndexedObject(O);
|
|
2298
|
+
var length = lengthOfArrayLike(O);
|
|
2299
|
+
var index = IS_RIGHT ? length - 1 : 0;
|
|
2300
|
+
var i = IS_RIGHT ? -1 : 1;
|
|
2301
|
+
if (argumentsLength < 2) while (true) {
|
|
2302
|
+
if (index in self) {
|
|
2303
|
+
memo = self[index];
|
|
2304
|
+
index += i;
|
|
2305
|
+
break;
|
|
2306
|
+
}
|
|
2307
|
+
index += i;
|
|
2308
|
+
if (IS_RIGHT ? index < 0 : length <= index) {
|
|
2309
|
+
throw $TypeError$1('Reduce of empty array with no initial value');
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
|
|
2313
|
+
memo = callbackfn(memo, self[index], index, O);
|
|
2314
|
+
}
|
|
2315
|
+
return memo;
|
|
2316
|
+
};
|
|
2317
|
+
};
|
|
2318
|
+
|
|
2319
|
+
var arrayReduce = {
|
|
2320
|
+
// `Array.prototype.reduce` method
|
|
2321
|
+
// https://tc39.es/ecma262/#sec-array.prototype.reduce
|
|
2322
|
+
left: createMethod(false),
|
|
2323
|
+
// `Array.prototype.reduceRight` method
|
|
2324
|
+
// https://tc39.es/ecma262/#sec-array.prototype.reduceright
|
|
2325
|
+
right: createMethod(true)
|
|
2326
|
+
};
|
|
2327
|
+
|
|
2328
|
+
var fails$3 = fails$f;
|
|
2329
|
+
|
|
2330
|
+
var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
|
|
2331
|
+
var method = [][METHOD_NAME];
|
|
2332
|
+
return !!method && fails$3(function () {
|
|
2333
|
+
// eslint-disable-next-line no-useless-call -- required for testing
|
|
2334
|
+
method.call(null, argument || function () { return 1; }, 1);
|
|
2335
|
+
});
|
|
2336
|
+
};
|
|
2337
|
+
|
|
2338
|
+
var $$3 = _export;
|
|
2339
|
+
var $reduce = arrayReduce.left;
|
|
2340
|
+
var arrayMethodIsStrict = arrayMethodIsStrict$1;
|
|
2341
|
+
var CHROME_VERSION = engineV8Version;
|
|
2342
|
+
var IS_NODE = engineIsNode;
|
|
2343
|
+
|
|
2344
|
+
var STRICT_METHOD = arrayMethodIsStrict('reduce');
|
|
2345
|
+
// Chrome 80-82 has a critical bug
|
|
2346
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
|
|
2347
|
+
var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
|
|
2348
|
+
|
|
2349
|
+
// `Array.prototype.reduce` method
|
|
2350
|
+
// https://tc39.es/ecma262/#sec-array.prototype.reduce
|
|
2351
|
+
$$3({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
|
|
2352
|
+
reduce: function reduce(callbackfn /* , initialValue */) {
|
|
2353
|
+
var length = arguments.length;
|
|
2354
|
+
return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
|
|
2355
|
+
}
|
|
2356
|
+
});
|
|
2357
|
+
|
|
2285
2358
|
var objectDefineProperties = {};
|
|
2286
2359
|
|
|
2287
2360
|
var DESCRIPTORS$1 = descriptors;
|
|
@@ -2411,9 +2484,9 @@ var addToUnscopables$2 = function (key) {
|
|
|
2411
2484
|
ArrayPrototype[UNSCOPABLES][key] = true;
|
|
2412
2485
|
};
|
|
2413
2486
|
|
|
2414
|
-
var fails$
|
|
2487
|
+
var fails$2 = fails$f;
|
|
2415
2488
|
|
|
2416
|
-
var correctPrototypeGetter = !fails$
|
|
2489
|
+
var correctPrototypeGetter = !fails$2(function () {
|
|
2417
2490
|
function F() { /* empty */ }
|
|
2418
2491
|
F.prototype.constructor = null;
|
|
2419
2492
|
// eslint-disable-next-line es/no-object-getprototypeof -- required for testing
|
|
@@ -2422,7 +2495,7 @@ var correctPrototypeGetter = !fails$3(function () {
|
|
|
2422
2495
|
|
|
2423
2496
|
var hasOwn = hasOwnProperty_1;
|
|
2424
2497
|
var isCallable$2 = isCallable$k;
|
|
2425
|
-
var toObject
|
|
2498
|
+
var toObject = toObject$4;
|
|
2426
2499
|
var sharedKey = sharedKey$3;
|
|
2427
2500
|
var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
|
|
2428
2501
|
|
|
@@ -2434,7 +2507,7 @@ var ObjectPrototype = $Object.prototype;
|
|
|
2434
2507
|
// https://tc39.es/ecma262/#sec-object.getprototypeof
|
|
2435
2508
|
// eslint-disable-next-line es/no-object-getprototypeof -- safe
|
|
2436
2509
|
var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
|
|
2437
|
-
var object = toObject
|
|
2510
|
+
var object = toObject(O);
|
|
2438
2511
|
if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
|
|
2439
2512
|
var constructor = object.constructor;
|
|
2440
2513
|
if (isCallable$2(constructor) && object instanceof constructor) {
|
|
@@ -2442,7 +2515,7 @@ var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : f
|
|
|
2442
2515
|
} return object instanceof $Object ? ObjectPrototype : null;
|
|
2443
2516
|
};
|
|
2444
2517
|
|
|
2445
|
-
var fails$
|
|
2518
|
+
var fails$1 = fails$f;
|
|
2446
2519
|
var isCallable$1 = isCallable$k;
|
|
2447
2520
|
var isObject$1 = isObject$9;
|
|
2448
2521
|
var getPrototypeOf$1 = objectGetPrototypeOf;
|
|
@@ -2467,7 +2540,7 @@ if ([].keys) {
|
|
|
2467
2540
|
}
|
|
2468
2541
|
}
|
|
2469
2542
|
|
|
2470
|
-
var NEW_ITERATOR_PROTOTYPE = !isObject$1(IteratorPrototype$2) || fails$
|
|
2543
|
+
var NEW_ITERATOR_PROTOTYPE = !isObject$1(IteratorPrototype$2) || fails$1(function () {
|
|
2471
2544
|
var test = {};
|
|
2472
2545
|
// FF44- legacy iterators case
|
|
2473
2546
|
return IteratorPrototype$2[ITERATOR$2].call(test) !== test;
|
|
@@ -2504,7 +2577,7 @@ var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUME
|
|
|
2504
2577
|
return IteratorConstructor;
|
|
2505
2578
|
};
|
|
2506
2579
|
|
|
2507
|
-
var $$
|
|
2580
|
+
var $$2 = _export;
|
|
2508
2581
|
var call = functionCall;
|
|
2509
2582
|
var FunctionName = functionName;
|
|
2510
2583
|
var isCallable = isCallable$k;
|
|
@@ -2589,7 +2662,7 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
|
|
|
2589
2662
|
if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
|
|
2590
2663
|
defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
|
|
2591
2664
|
}
|
|
2592
|
-
} else $$
|
|
2665
|
+
} else $$2({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
|
|
2593
2666
|
}
|
|
2594
2667
|
|
|
2595
2668
|
// define iterator
|
|
@@ -2751,19 +2824,19 @@ for (var COLLECTION_NAME in DOMIterables) {
|
|
|
2751
2824
|
|
|
2752
2825
|
handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
|
|
2753
2826
|
|
|
2754
|
-
var $$
|
|
2827
|
+
var $$1 = _export;
|
|
2755
2828
|
var $includes = arrayIncludes.includes;
|
|
2756
|
-
var fails
|
|
2829
|
+
var fails = fails$f;
|
|
2757
2830
|
var addToUnscopables = addToUnscopables$2;
|
|
2758
2831
|
|
|
2759
2832
|
// FF99+ bug
|
|
2760
|
-
var BROKEN_ON_SPARSE = fails
|
|
2833
|
+
var BROKEN_ON_SPARSE = fails(function () {
|
|
2761
2834
|
return !Array(1).includes();
|
|
2762
2835
|
});
|
|
2763
2836
|
|
|
2764
2837
|
// `Array.prototype.includes` method
|
|
2765
2838
|
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
2766
|
-
$$
|
|
2839
|
+
$$1({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
|
|
2767
2840
|
includes: function includes(el /* , fromIndex = 0 */) {
|
|
2768
2841
|
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
|
2769
2842
|
}
|
|
@@ -2787,11 +2860,11 @@ var isRegexp = function (it) {
|
|
|
2787
2860
|
|
|
2788
2861
|
var isRegExp = isRegexp;
|
|
2789
2862
|
|
|
2790
|
-
var $TypeError
|
|
2863
|
+
var $TypeError = TypeError;
|
|
2791
2864
|
|
|
2792
2865
|
var notARegexp = function (it) {
|
|
2793
2866
|
if (isRegExp(it)) {
|
|
2794
|
-
throw $TypeError
|
|
2867
|
+
throw $TypeError("The method doesn't accept regular expressions");
|
|
2795
2868
|
} return it;
|
|
2796
2869
|
};
|
|
2797
2870
|
|
|
@@ -2820,7 +2893,7 @@ var correctIsRegexpLogic = function (METHOD_NAME) {
|
|
|
2820
2893
|
} return false;
|
|
2821
2894
|
};
|
|
2822
2895
|
|
|
2823
|
-
var
|
|
2896
|
+
var $ = _export;
|
|
2824
2897
|
var uncurryThis = functionUncurryThis;
|
|
2825
2898
|
var notARegExp = notARegexp;
|
|
2826
2899
|
var requireObjectCoercible = requireObjectCoercible$3;
|
|
@@ -2831,7 +2904,7 @@ var stringIndexOf = uncurryThis(''.indexOf);
|
|
|
2831
2904
|
|
|
2832
2905
|
// `String.prototype.includes` method
|
|
2833
2906
|
// https://tc39.es/ecma262/#sec-string.prototype.includes
|
|
2834
|
-
|
|
2907
|
+
$({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
|
|
2835
2908
|
includes: function includes(searchString /* , position = 0 */) {
|
|
2836
2909
|
return !!~stringIndexOf(
|
|
2837
2910
|
toString(requireObjectCoercible(this)),
|
|
@@ -2841,79 +2914,6 @@ $$1({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }
|
|
|
2841
2914
|
}
|
|
2842
2915
|
});
|
|
2843
2916
|
|
|
2844
|
-
var aCallable = aCallable$8;
|
|
2845
|
-
var toObject = toObject$4;
|
|
2846
|
-
var IndexedObject = indexedObject;
|
|
2847
|
-
var lengthOfArrayLike = lengthOfArrayLike$3;
|
|
2848
|
-
|
|
2849
|
-
var $TypeError = TypeError;
|
|
2850
|
-
|
|
2851
|
-
// `Array.prototype.{ reduce, reduceRight }` methods implementation
|
|
2852
|
-
var createMethod = function (IS_RIGHT) {
|
|
2853
|
-
return function (that, callbackfn, argumentsLength, memo) {
|
|
2854
|
-
aCallable(callbackfn);
|
|
2855
|
-
var O = toObject(that);
|
|
2856
|
-
var self = IndexedObject(O);
|
|
2857
|
-
var length = lengthOfArrayLike(O);
|
|
2858
|
-
var index = IS_RIGHT ? length - 1 : 0;
|
|
2859
|
-
var i = IS_RIGHT ? -1 : 1;
|
|
2860
|
-
if (argumentsLength < 2) while (true) {
|
|
2861
|
-
if (index in self) {
|
|
2862
|
-
memo = self[index];
|
|
2863
|
-
index += i;
|
|
2864
|
-
break;
|
|
2865
|
-
}
|
|
2866
|
-
index += i;
|
|
2867
|
-
if (IS_RIGHT ? index < 0 : length <= index) {
|
|
2868
|
-
throw $TypeError('Reduce of empty array with no initial value');
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
|
|
2872
|
-
memo = callbackfn(memo, self[index], index, O);
|
|
2873
|
-
}
|
|
2874
|
-
return memo;
|
|
2875
|
-
};
|
|
2876
|
-
};
|
|
2877
|
-
|
|
2878
|
-
var arrayReduce = {
|
|
2879
|
-
// `Array.prototype.reduce` method
|
|
2880
|
-
// https://tc39.es/ecma262/#sec-array.prototype.reduce
|
|
2881
|
-
left: createMethod(false),
|
|
2882
|
-
// `Array.prototype.reduceRight` method
|
|
2883
|
-
// https://tc39.es/ecma262/#sec-array.prototype.reduceright
|
|
2884
|
-
right: createMethod(true)
|
|
2885
|
-
};
|
|
2886
|
-
|
|
2887
|
-
var fails = fails$f;
|
|
2888
|
-
|
|
2889
|
-
var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
|
|
2890
|
-
var method = [][METHOD_NAME];
|
|
2891
|
-
return !!method && fails(function () {
|
|
2892
|
-
// eslint-disable-next-line no-useless-call -- required for testing
|
|
2893
|
-
method.call(null, argument || function () { return 1; }, 1);
|
|
2894
|
-
});
|
|
2895
|
-
};
|
|
2896
|
-
|
|
2897
|
-
var $ = _export;
|
|
2898
|
-
var $reduce = arrayReduce.left;
|
|
2899
|
-
var arrayMethodIsStrict = arrayMethodIsStrict$1;
|
|
2900
|
-
var CHROME_VERSION = engineV8Version;
|
|
2901
|
-
var IS_NODE = engineIsNode;
|
|
2902
|
-
|
|
2903
|
-
var STRICT_METHOD = arrayMethodIsStrict('reduce');
|
|
2904
|
-
// Chrome 80-82 has a critical bug
|
|
2905
|
-
// https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
|
|
2906
|
-
var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
|
|
2907
|
-
|
|
2908
|
-
// `Array.prototype.reduce` method
|
|
2909
|
-
// https://tc39.es/ecma262/#sec-array.prototype.reduce
|
|
2910
|
-
$({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
|
|
2911
|
-
reduce: function reduce(callbackfn /* , initialValue */) {
|
|
2912
|
-
var length = arguments.length;
|
|
2913
|
-
return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
|
|
2914
|
-
}
|
|
2915
|
-
});
|
|
2916
|
-
|
|
2917
2917
|
/******************************************************************************
|
|
2918
2918
|
Copyright (c) Microsoft Corporation.
|
|
2919
2919
|
|
|
@@ -3020,21 +3020,21 @@ const PreviewRenderPlugin = ctx => {
|
|
|
3020
3020
|
};
|
|
3021
3021
|
}, [id]);
|
|
3022
3022
|
useEffect(() => {
|
|
3023
|
-
const
|
|
3024
|
-
const
|
|
3025
|
-
return
|
|
3023
|
+
const experienceIds = Object.keys(pluginApi.experienceVariantIndexes);
|
|
3024
|
+
const experience = experiences.find(experience => {
|
|
3025
|
+
return experienceIds.includes(experience.id);
|
|
3026
3026
|
});
|
|
3027
|
-
if (!
|
|
3027
|
+
if (!experience) {
|
|
3028
3028
|
setComponentProps({});
|
|
3029
3029
|
return;
|
|
3030
3030
|
}
|
|
3031
|
-
const baselineComponent =
|
|
3031
|
+
const baselineComponent = experience.components.find(component => component.baseline.id === baseline.id);
|
|
3032
3032
|
if (!baselineComponent) {
|
|
3033
3033
|
setComponentProps({});
|
|
3034
3034
|
return;
|
|
3035
3035
|
}
|
|
3036
3036
|
const allVariants = [baseline, ...baselineComponent.variants];
|
|
3037
|
-
const variantIndex = pluginApi.
|
|
3037
|
+
const variantIndex = pluginApi.experienceVariantIndexes[experience.id];
|
|
3038
3038
|
if (allVariants.length <= variantIndex) {
|
|
3039
3039
|
setComponentProps({});
|
|
3040
3040
|
return;
|
|
@@ -3045,7 +3045,7 @@ const PreviewRenderPlugin = ctx => {
|
|
|
3045
3045
|
return;
|
|
3046
3046
|
}
|
|
3047
3047
|
setComponentProps(Object.assign({}, variant));
|
|
3048
|
-
}, [experiences, baseline, setComponentProps, pluginApi.
|
|
3048
|
+
}, [experiences, baseline, setComponentProps, pluginApi.experienceVariantIndexes]);
|
|
3049
3049
|
return jsx(Fragment, {
|
|
3050
3050
|
children: children
|
|
3051
3051
|
});
|
|
@@ -3169,10 +3169,14 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3169
3169
|
this.audienceOverwrites = Object.assign(Object.assign({}, this.audienceOverwrites), {
|
|
3170
3170
|
[id]: true
|
|
3171
3171
|
});
|
|
3172
|
-
this.experienceVariantIndexOverwrites =
|
|
3172
|
+
this.experienceVariantIndexOverwrites = Object.assign(Object.assign({}, this.experienceVariantIndexOverwrites), this.experiences.filter(experience => {
|
|
3173
3173
|
var _b;
|
|
3174
3174
|
return ((_b = experience.audience) === null || _b === void 0 ? void 0 : _b.id) === id;
|
|
3175
|
-
}).map(experience => experience.id))
|
|
3175
|
+
}).map(experience => experience.id).reduce((acc, curr) => {
|
|
3176
|
+
return Object.assign(Object.assign({}, acc), {
|
|
3177
|
+
[curr]: this.experienceVariantIndexes[curr] || 0
|
|
3178
|
+
});
|
|
3179
|
+
}, {}));
|
|
3176
3180
|
this.onChange();
|
|
3177
3181
|
}
|
|
3178
3182
|
deactivateAudience(id) {
|
|
@@ -3180,16 +3184,19 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3180
3184
|
console.log(`You cannot deactivate an unkown audience (id: ${id}). How did you get it in the first place?`);
|
|
3181
3185
|
return;
|
|
3182
3186
|
}
|
|
3183
|
-
// When a audience is deactivated, the normal state will be that the experience goes into the control
|
|
3184
|
-
this.experiences
|
|
3187
|
+
// // When a audience is deactivated, the normal state will be that the experience goes into the control
|
|
3188
|
+
// this.experiences
|
|
3189
|
+
// .filter((experience) => experience.audience?.id === id)
|
|
3190
|
+
// .forEach((experience) => {
|
|
3191
|
+
// this.setExperienceVariant({
|
|
3192
|
+
// experienceId: experience.id,
|
|
3193
|
+
// variantIndex: 0,
|
|
3194
|
+
// });
|
|
3195
|
+
// });
|
|
3196
|
+
this.experienceVariantIndexOverwrites = omit(this.experienceVariantIndexOverwrites, this.experiences.filter(experience => {
|
|
3185
3197
|
var _b;
|
|
3186
3198
|
return ((_b = experience.audience) === null || _b === void 0 ? void 0 : _b.id) === id;
|
|
3187
|
-
}).
|
|
3188
|
-
this.setExperienceVariant({
|
|
3189
|
-
experienceId: experience.id,
|
|
3190
|
-
variantIndex: 0
|
|
3191
|
-
});
|
|
3192
|
-
});
|
|
3199
|
+
}).map(experience => experience.id));
|
|
3193
3200
|
this.audienceOverwrites = Object.assign(Object.assign({}, this.audienceOverwrites), {
|
|
3194
3201
|
[id]: false
|
|
3195
3202
|
});
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-plugin-preview",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.13",
|
|
4
4
|
"module": "./index.js",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"lodash": "4.17.21",
|
|
10
|
-
"@ninetailed/experience.js-shared": "4.0.0-beta.
|
|
11
|
-
"@ninetailed/experience.js": "4.0.0-beta.
|
|
12
|
-
"@ninetailed/experience.js-plugin-analytics": "4.0.0-beta.
|
|
13
|
-
"@ninetailed/experience.js-utils": "4.0.0-beta.
|
|
14
|
-
"@ninetailed/experience.js-react": "4.0.0-beta.
|
|
15
|
-
"@ninetailed/experience.js-preview-bridge": "4.0.0-beta.
|
|
10
|
+
"@ninetailed/experience.js-shared": "4.0.0-beta.13",
|
|
11
|
+
"@ninetailed/experience.js": "4.0.0-beta.13",
|
|
12
|
+
"@ninetailed/experience.js-plugin-analytics": "4.0.0-beta.13",
|
|
13
|
+
"@ninetailed/experience.js-utils": "4.0.0-beta.11",
|
|
14
|
+
"@ninetailed/experience.js-react": "4.0.0-beta.13",
|
|
15
|
+
"@ninetailed/experience.js-preview-bridge": "4.0.0-beta.13",
|
|
16
16
|
"react": "18.2.0",
|
|
17
17
|
"uuid": "9.0.0"
|
|
18
18
|
},
|