@ninetailed/experience.js-plugin-preview 4.0.0-beta.2 → 4.0.0-beta.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/index.cjs +12 -6
- package/index.js +12 -6
- package/lib/plugin/NinetailedPreviewPlugin.d.ts +1 -1
- package/package.json +7 -7
package/index.cjs
CHANGED
|
@@ -3056,6 +3056,10 @@ const PreviewRenderPlugin = ctx => {
|
|
|
3056
3056
|
}
|
|
3057
3057
|
const allVariants = [baseline, ...baselineComponent.variants];
|
|
3058
3058
|
const variantIndex = pluginApi.experienceVariantIndexOverwrites[overWrittenExperience.id];
|
|
3059
|
+
if (allVariants.length <= variantIndex) {
|
|
3060
|
+
setComponentProps({});
|
|
3061
|
+
return;
|
|
3062
|
+
}
|
|
3059
3063
|
const variant = allVariants[variantIndex];
|
|
3060
3064
|
if (!variant) {
|
|
3061
3065
|
setComponentProps({});
|
|
@@ -3201,7 +3205,10 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
3201
3205
|
var _b;
|
|
3202
3206
|
return ((_b = experience.audience) === null || _b === void 0 ? void 0 : _b.id) === id;
|
|
3203
3207
|
}).forEach(experience => {
|
|
3204
|
-
this.
|
|
3208
|
+
this.setExperienceVariant({
|
|
3209
|
+
experienceId: experience.id,
|
|
3210
|
+
variantIndex: 0
|
|
3211
|
+
});
|
|
3205
3212
|
});
|
|
3206
3213
|
}
|
|
3207
3214
|
resetAudience(id) {
|
|
@@ -3216,7 +3223,7 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
3216
3223
|
this.audienceOverwrites = audienceOverwrites;
|
|
3217
3224
|
this.onChange();
|
|
3218
3225
|
}
|
|
3219
|
-
|
|
3226
|
+
setExperienceVariant({
|
|
3220
3227
|
experienceId,
|
|
3221
3228
|
variantIndex
|
|
3222
3229
|
}) {
|
|
@@ -3236,8 +3243,7 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
3236
3243
|
}
|
|
3237
3244
|
const isValidIndex = experience.components.map(component => component.variants.length + 1).every(length => length > variantIndex);
|
|
3238
3245
|
if (!isValidIndex) {
|
|
3239
|
-
console.
|
|
3240
|
-
return;
|
|
3246
|
+
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.`);
|
|
3241
3247
|
}
|
|
3242
3248
|
this.experienceVariantIndexOverwrites = Object.assign(Object.assign({}, this.experienceVariantIndexOverwrites), {
|
|
3243
3249
|
[experienceId]: variantIndex
|
|
@@ -3271,7 +3277,7 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
3271
3277
|
apiAudiences: ((_b = this.profile) === null || _b === void 0 ? void 0 : _b.audiences) || [],
|
|
3272
3278
|
audienceOverwrites: this.audienceOverwrites,
|
|
3273
3279
|
activeAudiences: this.activeAudiences,
|
|
3274
|
-
setExperienceVariant: this.
|
|
3280
|
+
setExperienceVariant: this.setExperienceVariant.bind(this),
|
|
3275
3281
|
resetExperience: this.resetExperience.bind(this),
|
|
3276
3282
|
experienceVariantIndexes: Object.assign(Object.assign({}, this.experienceVariantIndexes), this.experienceVariantIndexOverwrites),
|
|
3277
3283
|
experienceVariantIndexOverwrites: this.experienceVariantIndexOverwrites,
|
|
@@ -3289,7 +3295,7 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
3289
3295
|
deactivateAudience: this.deactivateAudience.bind(this),
|
|
3290
3296
|
resetAudience: this.resetAudience.bind(this),
|
|
3291
3297
|
activeAudiences: this.activeAudiences,
|
|
3292
|
-
setExperienceVariant: this.
|
|
3298
|
+
setExperienceVariant: this.setExperienceVariant.bind(this),
|
|
3293
3299
|
resetExperience: this.resetExperience.bind(this),
|
|
3294
3300
|
experienceVariantIndexes: Object.assign(Object.assign({}, this.experienceVariantIndexes), this.experienceVariantIndexOverwrites)
|
|
3295
3301
|
};
|
package/index.js
CHANGED
|
@@ -3034,6 +3034,10 @@ const PreviewRenderPlugin = ctx => {
|
|
|
3034
3034
|
}
|
|
3035
3035
|
const allVariants = [baseline, ...baselineComponent.variants];
|
|
3036
3036
|
const variantIndex = pluginApi.experienceVariantIndexOverwrites[overWrittenExperience.id];
|
|
3037
|
+
if (allVariants.length <= variantIndex) {
|
|
3038
|
+
setComponentProps({});
|
|
3039
|
+
return;
|
|
3040
|
+
}
|
|
3037
3041
|
const variant = allVariants[variantIndex];
|
|
3038
3042
|
if (!variant) {
|
|
3039
3043
|
setComponentProps({});
|
|
@@ -3179,7 +3183,10 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3179
3183
|
var _b;
|
|
3180
3184
|
return ((_b = experience.audience) === null || _b === void 0 ? void 0 : _b.id) === id;
|
|
3181
3185
|
}).forEach(experience => {
|
|
3182
|
-
this.
|
|
3186
|
+
this.setExperienceVariant({
|
|
3187
|
+
experienceId: experience.id,
|
|
3188
|
+
variantIndex: 0
|
|
3189
|
+
});
|
|
3183
3190
|
});
|
|
3184
3191
|
}
|
|
3185
3192
|
resetAudience(id) {
|
|
@@ -3194,7 +3201,7 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3194
3201
|
this.audienceOverwrites = audienceOverwrites;
|
|
3195
3202
|
this.onChange();
|
|
3196
3203
|
}
|
|
3197
|
-
|
|
3204
|
+
setExperienceVariant({
|
|
3198
3205
|
experienceId,
|
|
3199
3206
|
variantIndex
|
|
3200
3207
|
}) {
|
|
@@ -3214,8 +3221,7 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3214
3221
|
}
|
|
3215
3222
|
const isValidIndex = experience.components.map(component => component.variants.length + 1).every(length => length > variantIndex);
|
|
3216
3223
|
if (!isValidIndex) {
|
|
3217
|
-
console.
|
|
3218
|
-
return;
|
|
3224
|
+
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.`);
|
|
3219
3225
|
}
|
|
3220
3226
|
this.experienceVariantIndexOverwrites = Object.assign(Object.assign({}, this.experienceVariantIndexOverwrites), {
|
|
3221
3227
|
[experienceId]: variantIndex
|
|
@@ -3249,7 +3255,7 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3249
3255
|
apiAudiences: ((_b = this.profile) === null || _b === void 0 ? void 0 : _b.audiences) || [],
|
|
3250
3256
|
audienceOverwrites: this.audienceOverwrites,
|
|
3251
3257
|
activeAudiences: this.activeAudiences,
|
|
3252
|
-
setExperienceVariant: this.
|
|
3258
|
+
setExperienceVariant: this.setExperienceVariant.bind(this),
|
|
3253
3259
|
resetExperience: this.resetExperience.bind(this),
|
|
3254
3260
|
experienceVariantIndexes: Object.assign(Object.assign({}, this.experienceVariantIndexes), this.experienceVariantIndexOverwrites),
|
|
3255
3261
|
experienceVariantIndexOverwrites: this.experienceVariantIndexOverwrites,
|
|
@@ -3267,7 +3273,7 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3267
3273
|
deactivateAudience: this.deactivateAudience.bind(this),
|
|
3268
3274
|
resetAudience: this.resetAudience.bind(this),
|
|
3269
3275
|
activeAudiences: this.activeAudiences,
|
|
3270
|
-
setExperienceVariant: this.
|
|
3276
|
+
setExperienceVariant: this.setExperienceVariant.bind(this),
|
|
3271
3277
|
resetExperience: this.resetExperience.bind(this),
|
|
3272
3278
|
experienceVariantIndexes: Object.assign(Object.assign({}, this.experienceVariantIndexes), this.experienceVariantIndexOverwrites)
|
|
3273
3279
|
};
|
|
@@ -40,7 +40,7 @@ export declare class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
40
40
|
activateAudience(id: string): void;
|
|
41
41
|
deactivateAudience(id: string): void;
|
|
42
42
|
resetAudience(id: string): void;
|
|
43
|
-
|
|
43
|
+
setExperienceVariant({ experienceId, variantIndex, }: {
|
|
44
44
|
experienceId: string;
|
|
45
45
|
variantIndex: number;
|
|
46
46
|
}): void;
|
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.4",
|
|
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": "4.0.0-beta.
|
|
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.4",
|
|
10
|
+
"@ninetailed/experience.js": "4.0.0-beta.4",
|
|
11
|
+
"@ninetailed/experience.js-plugin-analytics": "4.0.0-beta.4",
|
|
12
|
+
"@ninetailed/experience.js-utils": "4.0.0-beta.3",
|
|
13
|
+
"@ninetailed/experience.js-react": "4.0.0-beta.4",
|
|
14
|
+
"@ninetailed/experience.js-preview-bridge": "4.0.0-beta.4",
|
|
15
15
|
"react": "18.2.0",
|
|
16
16
|
"uuid": "9.0.0"
|
|
17
17
|
},
|