@ninetailed/experience.js-plugin-preview 4.0.0-beta.1 → 4.0.0-beta.3
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 +15 -2
- package/index.js +15 -2
- package/package.json +7 -7
package/index.cjs
CHANGED
|
@@ -3046,16 +3046,23 @@ const PreviewRenderPlugin = ctx => {
|
|
|
3046
3046
|
return overWrittenExperienceIds.includes(experience.id);
|
|
3047
3047
|
});
|
|
3048
3048
|
if (!overWrittenExperience) {
|
|
3049
|
+
setComponentProps({});
|
|
3049
3050
|
return;
|
|
3050
3051
|
}
|
|
3051
3052
|
const baselineComponent = overWrittenExperience.components.find(component => component.baseline.id === baseline.id);
|
|
3052
3053
|
if (!baselineComponent) {
|
|
3054
|
+
setComponentProps({});
|
|
3053
3055
|
return;
|
|
3054
3056
|
}
|
|
3055
3057
|
const allVariants = [baseline, ...baselineComponent.variants];
|
|
3056
3058
|
const variantIndex = pluginApi.experienceVariantIndexOverwrites[overWrittenExperience.id];
|
|
3059
|
+
if (allVariants.length <= variantIndex) {
|
|
3060
|
+
setComponentProps({});
|
|
3061
|
+
return;
|
|
3062
|
+
}
|
|
3057
3063
|
const variant = allVariants[variantIndex];
|
|
3058
3064
|
if (!variant) {
|
|
3065
|
+
setComponentProps({});
|
|
3059
3066
|
return;
|
|
3060
3067
|
}
|
|
3061
3068
|
setComponentProps(Object.assign({}, variant));
|
|
@@ -3193,6 +3200,13 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
3193
3200
|
[id]: false
|
|
3194
3201
|
});
|
|
3195
3202
|
this.onChange();
|
|
3203
|
+
// When a audience is deactivated, the normal state will be that the experience goes into the control
|
|
3204
|
+
this.experiences.filter(experience => {
|
|
3205
|
+
var _b;
|
|
3206
|
+
return ((_b = experience.audience) === null || _b === void 0 ? void 0 : _b.id) === id;
|
|
3207
|
+
}).forEach(experience => {
|
|
3208
|
+
this.resetExperience(experience.id);
|
|
3209
|
+
});
|
|
3196
3210
|
}
|
|
3197
3211
|
resetAudience(id) {
|
|
3198
3212
|
if (!this.isKnownAudience(id)) {
|
|
@@ -3226,8 +3240,7 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
3226
3240
|
}
|
|
3227
3241
|
const isValidIndex = experience.components.map(component => component.variants.length + 1).every(length => length > variantIndex);
|
|
3228
3242
|
if (!isValidIndex) {
|
|
3229
|
-
console.
|
|
3230
|
-
return;
|
|
3243
|
+
console.warn(`You activated a variant at index ${variantIndex} for the experience (id: ${experienceId}). Not all components have that many variants, you may see the baseline for some.`);
|
|
3231
3244
|
}
|
|
3232
3245
|
this.experienceVariantIndexOverwrites = Object.assign(Object.assign({}, this.experienceVariantIndexOverwrites), {
|
|
3233
3246
|
[experienceId]: variantIndex
|
package/index.js
CHANGED
|
@@ -3024,16 +3024,23 @@ const PreviewRenderPlugin = ctx => {
|
|
|
3024
3024
|
return overWrittenExperienceIds.includes(experience.id);
|
|
3025
3025
|
});
|
|
3026
3026
|
if (!overWrittenExperience) {
|
|
3027
|
+
setComponentProps({});
|
|
3027
3028
|
return;
|
|
3028
3029
|
}
|
|
3029
3030
|
const baselineComponent = overWrittenExperience.components.find(component => component.baseline.id === baseline.id);
|
|
3030
3031
|
if (!baselineComponent) {
|
|
3032
|
+
setComponentProps({});
|
|
3031
3033
|
return;
|
|
3032
3034
|
}
|
|
3033
3035
|
const allVariants = [baseline, ...baselineComponent.variants];
|
|
3034
3036
|
const variantIndex = pluginApi.experienceVariantIndexOverwrites[overWrittenExperience.id];
|
|
3037
|
+
if (allVariants.length <= variantIndex) {
|
|
3038
|
+
setComponentProps({});
|
|
3039
|
+
return;
|
|
3040
|
+
}
|
|
3035
3041
|
const variant = allVariants[variantIndex];
|
|
3036
3042
|
if (!variant) {
|
|
3043
|
+
setComponentProps({});
|
|
3037
3044
|
return;
|
|
3038
3045
|
}
|
|
3039
3046
|
setComponentProps(Object.assign({}, variant));
|
|
@@ -3171,6 +3178,13 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3171
3178
|
[id]: false
|
|
3172
3179
|
});
|
|
3173
3180
|
this.onChange();
|
|
3181
|
+
// When a audience is deactivated, the normal state will be that the experience goes into the control
|
|
3182
|
+
this.experiences.filter(experience => {
|
|
3183
|
+
var _b;
|
|
3184
|
+
return ((_b = experience.audience) === null || _b === void 0 ? void 0 : _b.id) === id;
|
|
3185
|
+
}).forEach(experience => {
|
|
3186
|
+
this.resetExperience(experience.id);
|
|
3187
|
+
});
|
|
3174
3188
|
}
|
|
3175
3189
|
resetAudience(id) {
|
|
3176
3190
|
if (!this.isKnownAudience(id)) {
|
|
@@ -3204,8 +3218,7 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3204
3218
|
}
|
|
3205
3219
|
const isValidIndex = experience.components.map(component => component.variants.length + 1).every(length => length > variantIndex);
|
|
3206
3220
|
if (!isValidIndex) {
|
|
3207
|
-
console.
|
|
3208
|
-
return;
|
|
3221
|
+
console.warn(`You activated a variant at index ${variantIndex} for the experience (id: ${experienceId}). Not all components have that many variants, you may see the baseline for some.`);
|
|
3209
3222
|
}
|
|
3210
3223
|
this.experienceVariantIndexOverwrites = Object.assign(Object.assign({}, this.experienceVariantIndexOverwrites), {
|
|
3211
3224
|
[experienceId]: variantIndex
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-plugin-preview",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.3",
|
|
4
4
|
"module": "./index.js",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@ninetailed/experience.js-shared": "4.0.0-beta.
|
|
10
|
-
"@ninetailed/experience.js": "4.0.0-beta.
|
|
11
|
-
"@ninetailed/experience.js-plugin-analytics": "4.0.0-beta.
|
|
12
|
-
"@ninetailed/experience.js-utils": "
|
|
13
|
-
"@ninetailed/experience.js-react": "4.0.0-beta.
|
|
14
|
-
"@ninetailed/experience.js-preview-bridge": "4.0.0-beta.
|
|
9
|
+
"@ninetailed/experience.js-shared": "4.0.0-beta.3",
|
|
10
|
+
"@ninetailed/experience.js": "4.0.0-beta.3",
|
|
11
|
+
"@ninetailed/experience.js-plugin-analytics": "4.0.0-beta.3",
|
|
12
|
+
"@ninetailed/experience.js-utils": "4.0.0-beta.2",
|
|
13
|
+
"@ninetailed/experience.js-react": "4.0.0-beta.3",
|
|
14
|
+
"@ninetailed/experience.js-preview-bridge": "4.0.0-beta.3",
|
|
15
15
|
"react": "18.2.0",
|
|
16
16
|
"uuid": "9.0.0"
|
|
17
17
|
},
|