@ninetailed/experience.js-plugin-preview 4.1.0-beta.1 → 4.1.0-beta.2
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 +7 -1
- package/index.js +6 -1
- package/lib/plugin/NinetailedPreviewPlugin.d.ts +3 -0
- package/package.json +6 -6
package/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ var experience_js = require('@ninetailed/experience.js');
|
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var react = require('react');
|
|
9
9
|
var uuid = require('uuid');
|
|
10
|
+
var unionBy = require('lodash/unionBy');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
13
|
|
|
@@ -29,6 +30,7 @@ function _interopNamespace(e) {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
33
|
+
var unionBy__default = /*#__PURE__*/_interopDefaultLegacy(unionBy);
|
|
32
34
|
|
|
33
35
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
34
36
|
|
|
@@ -3107,6 +3109,7 @@ class NinetailedPreviewPlugin extends experience_js.NinetailedPlugin {
|
|
|
3107
3109
|
this.name = 'ninetailed:preview' + Math.random();
|
|
3108
3110
|
this.isOpen = false;
|
|
3109
3111
|
this.experiences = [];
|
|
3112
|
+
this.audienceDefinitions = [];
|
|
3110
3113
|
this.audienceOverwrites = {};
|
|
3111
3114
|
this.experienceVariantIndexOverwrites = {};
|
|
3112
3115
|
this.profile = null;
|
|
@@ -3213,6 +3216,7 @@ class NinetailedPreviewPlugin extends experience_js.NinetailedPlugin {
|
|
|
3213
3216
|
this.onChange();
|
|
3214
3217
|
};
|
|
3215
3218
|
this.experiences = options.experiences || [];
|
|
3219
|
+
this.audienceDefinitions = options.audiences || [];
|
|
3216
3220
|
this.renderPluginComponent = PreviewRenderPlugin(this.renderPluginContext);
|
|
3217
3221
|
}
|
|
3218
3222
|
open() {
|
|
@@ -3343,6 +3347,7 @@ class NinetailedPreviewPlugin extends experience_js.NinetailedPlugin {
|
|
|
3343
3347
|
apiAudiences: ((_b = this.profile) === null || _b === void 0 ? void 0 : _b.audiences) || [],
|
|
3344
3348
|
audienceOverwrites: this.audienceOverwrites,
|
|
3345
3349
|
activeAudiences: this.activeAudiences,
|
|
3350
|
+
audienceDefinitions: this.audienceDefinitions,
|
|
3346
3351
|
setExperienceVariant: this.setExperienceVariant.bind(this),
|
|
3347
3352
|
resetExperience: this.resetExperience.bind(this),
|
|
3348
3353
|
experienceVariantIndexes: Object.assign(Object.assign({}, this.experienceVariantIndexes), this.experienceVariantIndexOverwrites),
|
|
@@ -3370,7 +3375,8 @@ class NinetailedPreviewPlugin extends experience_js.NinetailedPlugin {
|
|
|
3370
3375
|
return this.potentialAudiences.some(audience => audience.id === id);
|
|
3371
3376
|
}
|
|
3372
3377
|
get potentialAudiences() {
|
|
3373
|
-
|
|
3378
|
+
const audiencesFromExperiences = this.experiences.map(experience => experience.audience).filter(audience => !!audience);
|
|
3379
|
+
return unionBy__default["default"](this.audienceDefinitions, audiencesFromExperiences, 'id');
|
|
3374
3380
|
}
|
|
3375
3381
|
get activeAudiences() {
|
|
3376
3382
|
var _b;
|
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { NinetailedPlugin, OnChangeEmitter, selectActiveExperiments, selectEligi
|
|
|
3
3
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useState, useRef, useEffect } from 'react';
|
|
5
5
|
import { v4 } from 'uuid';
|
|
6
|
+
import unionBy from 'lodash/unionBy';
|
|
6
7
|
|
|
7
8
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
8
9
|
|
|
@@ -3081,6 +3082,7 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3081
3082
|
this.name = 'ninetailed:preview' + Math.random();
|
|
3082
3083
|
this.isOpen = false;
|
|
3083
3084
|
this.experiences = [];
|
|
3085
|
+
this.audienceDefinitions = [];
|
|
3084
3086
|
this.audienceOverwrites = {};
|
|
3085
3087
|
this.experienceVariantIndexOverwrites = {};
|
|
3086
3088
|
this.profile = null;
|
|
@@ -3187,6 +3189,7 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3187
3189
|
this.onChange();
|
|
3188
3190
|
};
|
|
3189
3191
|
this.experiences = options.experiences || [];
|
|
3192
|
+
this.audienceDefinitions = options.audiences || [];
|
|
3190
3193
|
this.renderPluginComponent = PreviewRenderPlugin(this.renderPluginContext);
|
|
3191
3194
|
}
|
|
3192
3195
|
open() {
|
|
@@ -3317,6 +3320,7 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3317
3320
|
apiAudiences: ((_b = this.profile) === null || _b === void 0 ? void 0 : _b.audiences) || [],
|
|
3318
3321
|
audienceOverwrites: this.audienceOverwrites,
|
|
3319
3322
|
activeAudiences: this.activeAudiences,
|
|
3323
|
+
audienceDefinitions: this.audienceDefinitions,
|
|
3320
3324
|
setExperienceVariant: this.setExperienceVariant.bind(this),
|
|
3321
3325
|
resetExperience: this.resetExperience.bind(this),
|
|
3322
3326
|
experienceVariantIndexes: Object.assign(Object.assign({}, this.experienceVariantIndexes), this.experienceVariantIndexOverwrites),
|
|
@@ -3344,7 +3348,8 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
3344
3348
|
return this.potentialAudiences.some(audience => audience.id === id);
|
|
3345
3349
|
}
|
|
3346
3350
|
get potentialAudiences() {
|
|
3347
|
-
|
|
3351
|
+
const audiencesFromExperiences = this.experiences.map(experience => experience.audience).filter(audience => !!audience);
|
|
3352
|
+
return unionBy(this.audienceDefinitions, audiencesFromExperiences, 'id');
|
|
3348
3353
|
}
|
|
3349
3354
|
get activeAudiences() {
|
|
3350
3355
|
var _b;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Reference } from '@ninetailed/experience.js-shared';
|
|
2
2
|
import { ExperienceConfiguration, PROFILE_CHANGE, NinetailedPlugin, HasExperienceSelectionMiddleware, ExperienceSelectionMiddleware } from '@ninetailed/experience.js';
|
|
3
|
+
import { Audience } from '@ninetailed/experience.js-utils';
|
|
3
4
|
import { RenderPluginWrapperComponent } from '@ninetailed/experience.js-react';
|
|
4
5
|
export declare const NINETAILED_PREVIEW_EVENTS: {
|
|
5
6
|
previewAudiences: string;
|
|
@@ -9,6 +10,7 @@ type NinetailedPreviewPluginOptions = {
|
|
|
9
10
|
url?: string;
|
|
10
11
|
environment?: string;
|
|
11
12
|
experiences: ExperienceConfiguration[];
|
|
13
|
+
audiences: Audience[];
|
|
12
14
|
ui?: {
|
|
13
15
|
opener?: {
|
|
14
16
|
hide: boolean;
|
|
@@ -20,6 +22,7 @@ export declare class NinetailedPreviewPlugin extends NinetailedPlugin implements
|
|
|
20
22
|
name: string;
|
|
21
23
|
private isOpen;
|
|
22
24
|
private readonly experiences;
|
|
25
|
+
private readonly audienceDefinitions;
|
|
23
26
|
private audienceOverwrites;
|
|
24
27
|
private experienceVariantIndexOverwrites;
|
|
25
28
|
private profile;
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-plugin-preview",
|
|
3
|
-
"version": "4.1.0-beta.
|
|
3
|
+
"version": "4.1.0-beta.2",
|
|
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.1.0-beta.
|
|
11
|
-
"@ninetailed/experience.js": "4.1.0-beta.
|
|
12
|
-
"@ninetailed/experience.js-utils": "4.
|
|
13
|
-
"@ninetailed/experience.js-react": "4.1.0-beta.
|
|
14
|
-
"@ninetailed/experience.js-preview-bridge": "4.1.0-beta.
|
|
10
|
+
"@ninetailed/experience.js-shared": "4.1.0-beta.2",
|
|
11
|
+
"@ninetailed/experience.js": "4.1.0-beta.2",
|
|
12
|
+
"@ninetailed/experience.js-utils": "4.1.0-beta.1",
|
|
13
|
+
"@ninetailed/experience.js-react": "4.1.0-beta.2",
|
|
14
|
+
"@ninetailed/experience.js-preview-bridge": "4.1.0-beta.2",
|
|
15
15
|
"react": "18.2.0",
|
|
16
16
|
"uuid": "9.0.0",
|
|
17
17
|
"ts-toolbelt": "9.6.0"
|