@ninetailed/experience.js-plugin-preview 7.7.4-beta.0 → 7.7.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.js CHANGED
@@ -73,7 +73,6 @@ class WidgetContainer {
73
73
  var _a, _b;
74
74
  this.options = options;
75
75
  this.container = document.createElement('div');
76
- this.container.classList.add(WidgetContainer.CONTAINER_CLASS);
77
76
  this.container.style.position = 'fixed';
78
77
  this.container.style.zIndex = '999999';
79
78
  this.container.style.right = '0px';
@@ -110,11 +109,7 @@ class WidgetContainer {
110
109
  get element() {
111
110
  return this.container;
112
111
  }
113
- static isContainerAttached() {
114
- return document.querySelector(`.${WidgetContainer.CONTAINER_CLASS}`) !== null;
115
- }
116
112
  }
117
- WidgetContainer.CONTAINER_CLASS = 'nt-preview-widget-container';
118
113
 
119
114
  var _a;
120
115
  class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlugin {
@@ -130,25 +125,15 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
130
125
  this.profile = null;
131
126
  this.container = null;
132
127
  this.bridge = null;
133
- /**
134
- * Since several instances of the plugin can be created, we need to make sure only one is marked as active.
135
- */
136
- this.isActiveInstance = false;
137
128
  this.onChangeEmitter = new experience_js.OnChangeEmitter();
138
129
  this.clientId = null;
139
130
  this.environment = null;
140
131
  this.initialize = () => __awaiter(this, void 0, void 0, function* () {
141
132
  var _b;
142
133
  if (typeof window !== 'undefined') {
143
- if (WidgetContainer.isContainerAttached()) {
144
- experience_jsShared.logger.warn('Preview plugin is already attached.');
145
- this.isActiveInstance = false;
146
- return;
147
- }
148
134
  const {
149
135
  PreviewBridge
150
136
  } = yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@ninetailed/experience.js-preview-bridge')); });
151
- this.isActiveInstance = true;
152
137
  this.container = new WidgetContainer({
153
138
  ui: this.options.ui
154
139
  });
@@ -170,9 +155,6 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
170
155
  this[_a] = ({
171
156
  payload
172
157
  }) => {
173
- if (!this.isActiveInstance) {
174
- return;
175
- }
176
158
  if (payload === null || payload === void 0 ? void 0 : payload.profile) {
177
159
  this.onProfileChange(payload.profile);
178
160
  }
@@ -181,9 +163,6 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
181
163
  baseline,
182
164
  experiences
183
165
  }) => {
184
- if (!this.isActiveInstance) {
185
- return;
186
- }
187
166
  return () => {
188
167
  const experienceIds = Object.keys(this.pluginApi.experienceVariantIndexes);
189
168
  const experience = experiences.find(experience => {
@@ -259,18 +238,12 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
259
238
  }
260
239
  open() {
261
240
  var _b;
262
- if (!this.isActiveInstance) {
263
- return;
264
- }
265
241
  (_b = this.container) === null || _b === void 0 ? void 0 : _b.open();
266
242
  this.isOpen = true;
267
243
  this.onChange();
268
244
  }
269
245
  close() {
270
246
  var _b;
271
- if (!this.isActiveInstance) {
272
- return;
273
- }
274
247
  (_b = this.container) === null || _b === void 0 ? void 0 : _b.close();
275
248
  setTimeout(() => {
276
249
  this.isOpen = false;
@@ -278,9 +251,6 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
278
251
  }, 700);
279
252
  }
280
253
  toggle() {
281
- if (!this.isActiveInstance) {
282
- return;
283
- }
284
254
  if (this.isOpen) {
285
255
  this.close();
286
256
  } else {
@@ -288,9 +258,6 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
288
258
  }
289
259
  }
290
260
  activateAudience(id) {
291
- if (!this.isActiveInstance) {
292
- return;
293
- }
294
261
  if (!this.isKnownAudience(id)) {
295
262
  experience_jsShared.logger.warn(`You cannot activate an unknown audience (id: ${id}).`);
296
263
  return;
@@ -309,9 +276,6 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
309
276
  this.onChange();
310
277
  }
311
278
  deactivateAudience(id) {
312
- if (!this.isActiveInstance) {
313
- return;
314
- }
315
279
  if (!this.isKnownAudience(id)) {
316
280
  experience_jsShared.logger.warn(`You cannot deactivate an unkown audience (id: ${id}). How did you get it in the first place?`);
317
281
  return;
@@ -345,9 +309,6 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
345
309
  this.onChange();
346
310
  }
347
311
  resetAudience(id) {
348
- if (!this.isActiveInstance) {
349
- return;
350
- }
351
312
  if (!this.isKnownAudience(id)) {
352
313
  experience_jsShared.logger.warn(`You cannot reset an unknown audience (id: ${id}). How did you get it in the first place?`);
353
314
  return;
@@ -363,9 +324,6 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
363
324
  experienceId,
364
325
  variantIndex
365
326
  }) {
366
- if (!this.isActiveInstance) {
367
- return;
368
- }
369
327
  const experience = this.experiences.find(experience => experience.id === experienceId);
370
328
  if (!experience) {
371
329
  experience_jsShared.logger.warn(`You cannot active a variant for an unknown experience (id: ${experienceId})`);
@@ -388,9 +346,6 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
388
346
  this.onChange();
389
347
  }
390
348
  resetExperience(experienceId) {
391
- if (!this.isActiveInstance) {
392
- return;
393
- }
394
349
  const _b = this.experienceVariantIndexOverwrites,
395
350
  _c = experienceId;
396
351
  _b[_c];
@@ -399,9 +354,6 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
399
354
  this.onChange();
400
355
  }
401
356
  reset() {
402
- if (!this.isActiveInstance) {
403
- return;
404
- }
405
357
  if (typeof window !== 'undefined' && window.ninetailed && typeof window.ninetailed.reset === 'function') {
406
358
  window.ninetailed.reset();
407
359
  }
@@ -418,7 +370,7 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
418
370
  get pluginApi() {
419
371
  var _b;
420
372
  return {
421
- version: "7.7.4-beta.0" ,
373
+ version: "7.7.4" ,
422
374
  open: this.open.bind(this),
423
375
  close: this.close.bind(this),
424
376
  toggle: this.toggle.bind(this),
package/index.esm.js CHANGED
@@ -42,7 +42,6 @@ class WidgetContainer {
42
42
  this.container = void 0;
43
43
  this.options = options;
44
44
  this.container = document.createElement('div');
45
- this.container.classList.add(WidgetContainer.CONTAINER_CLASS);
46
45
  this.container.style.position = 'fixed';
47
46
  this.container.style.zIndex = '999999';
48
47
  this.container.style.right = '0px';
@@ -79,11 +78,7 @@ class WidgetContainer {
79
78
  get element() {
80
79
  return this.container;
81
80
  }
82
- static isContainerAttached() {
83
- return document.querySelector(`.${WidgetContainer.CONTAINER_CLASS}`) !== null;
84
- }
85
81
  }
86
- WidgetContainer.CONTAINER_CLASS = 'nt-preview-widget-container';
87
82
 
88
83
  class NinetailedPreviewPlugin extends NinetailedPlugin {
89
84
  constructor(options) {
@@ -99,10 +94,6 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
99
94
  this.profile = null;
100
95
  this.container = null;
101
96
  this.bridge = null;
102
- /**
103
- * Since several instances of the plugin can be created, we need to make sure only one is marked as active.
104
- */
105
- this.isActiveInstance = false;
106
97
  this.onChangeEmitter = new OnChangeEmitter();
107
98
  this.onOpenExperienceEditor = void 0;
108
99
  this.onOpenAudienceEditor = void 0;
@@ -111,15 +102,9 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
111
102
  this.initialize = async function () {
112
103
  if (typeof window !== 'undefined') {
113
104
  var _window$ninetailed;
114
- if (WidgetContainer.isContainerAttached()) {
115
- logger.warn('Preview plugin is already attached.');
116
- _this.isActiveInstance = false;
117
- return;
118
- }
119
105
  const {
120
106
  PreviewBridge
121
107
  } = await import('@ninetailed/experience.js-preview-bridge');
122
- _this.isActiveInstance = true;
123
108
  _this.container = new WidgetContainer({
124
109
  ui: _this.options.ui
125
110
  });
@@ -141,9 +126,6 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
141
126
  this[PROFILE_CHANGE] = ({
142
127
  payload
143
128
  }) => {
144
- if (!this.isActiveInstance) {
145
- return;
146
- }
147
129
  if (payload != null && payload.profile) {
148
130
  this.onProfileChange(payload.profile);
149
131
  }
@@ -152,9 +134,6 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
152
134
  baseline,
153
135
  experiences
154
136
  }) => {
155
- if (!this.isActiveInstance) {
156
- return;
157
- }
158
137
  return () => {
159
138
  const experienceIds = Object.keys(this.pluginApi.experienceVariantIndexes);
160
139
  const experience = experiences.find(experience => {
@@ -231,18 +210,12 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
231
210
  }
232
211
  open() {
233
212
  var _this$container;
234
- if (!this.isActiveInstance) {
235
- return;
236
- }
237
213
  (_this$container = this.container) == null || _this$container.open();
238
214
  this.isOpen = true;
239
215
  this.onChange();
240
216
  }
241
217
  close() {
242
218
  var _this$container2;
243
- if (!this.isActiveInstance) {
244
- return;
245
- }
246
219
  (_this$container2 = this.container) == null || _this$container2.close();
247
220
  setTimeout(() => {
248
221
  this.isOpen = false;
@@ -250,9 +223,6 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
250
223
  }, 700);
251
224
  }
252
225
  toggle() {
253
- if (!this.isActiveInstance) {
254
- return;
255
- }
256
226
  if (this.isOpen) {
257
227
  this.close();
258
228
  } else {
@@ -260,9 +230,6 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
260
230
  }
261
231
  }
262
232
  activateAudience(id) {
263
- if (!this.isActiveInstance) {
264
- return;
265
- }
266
233
  if (!this.isKnownAudience(id)) {
267
234
  logger.warn(`You cannot activate an unknown audience (id: ${id}).`);
268
235
  return;
@@ -281,9 +248,6 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
281
248
  this.onChange();
282
249
  }
283
250
  deactivateAudience(id) {
284
- if (!this.isActiveInstance) {
285
- return;
286
- }
287
251
  if (!this.isKnownAudience(id)) {
288
252
  logger.warn(`You cannot deactivate an unkown audience (id: ${id}). How did you get it in the first place?`);
289
253
  return;
@@ -317,9 +281,6 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
317
281
  this.onChange();
318
282
  }
319
283
  resetAudience(id) {
320
- if (!this.isActiveInstance) {
321
- return;
322
- }
323
284
  if (!this.isKnownAudience(id)) {
324
285
  logger.warn(`You cannot reset an unknown audience (id: ${id}). How did you get it in the first place?`);
325
286
  return;
@@ -333,9 +294,6 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
333
294
  experienceId,
334
295
  variantIndex
335
296
  }) {
336
- if (!this.isActiveInstance) {
337
- return;
338
- }
339
297
  const experience = this.experiences.find(experience => experience.id === experienceId);
340
298
  if (!experience) {
341
299
  logger.warn(`You cannot active a variant for an unknown experience (id: ${experienceId})`);
@@ -358,18 +316,12 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
358
316
  this.onChange();
359
317
  }
360
318
  resetExperience(experienceId) {
361
- if (!this.isActiveInstance) {
362
- return;
363
- }
364
319
  const _this$experienceVaria = this.experienceVariantIndexOverwrites,
365
320
  experienceVariantIndexOverwrites = _objectWithoutPropertiesLoose(_this$experienceVaria, [experienceId].map(_toPropertyKey));
366
321
  this.experienceVariantIndexOverwrites = experienceVariantIndexOverwrites;
367
322
  this.onChange();
368
323
  }
369
324
  reset() {
370
- if (!this.isActiveInstance) {
371
- return;
372
- }
373
325
  if (typeof window !== 'undefined' && window.ninetailed && typeof window.ninetailed.reset === 'function') {
374
326
  window.ninetailed.reset();
375
327
  }
@@ -386,7 +338,7 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
386
338
  get pluginApi() {
387
339
  var _this$profile;
388
340
  return {
389
- version: "7.7.4-beta.0" ,
341
+ version: "7.7.4" ,
390
342
  open: this.open.bind(this),
391
343
  close: this.close.bind(this),
392
344
  toggle: this.toggle.bind(this),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-plugin-preview",
3
- "version": "7.7.4-beta.0",
3
+ "version": "7.7.4",
4
4
  "description": "Ninetailed SDK plugin for preview",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,10 +15,10 @@
15
15
  "a/b testing"
16
16
  ],
17
17
  "dependencies": {
18
- "@ninetailed/experience.js-shared": "7.7.4-beta.0",
19
- "@ninetailed/experience.js": "7.7.4-beta.0",
20
- "@ninetailed/experience.js-preview-bridge": "7.7.4-beta.0",
21
- "@ninetailed/experience.js-plugin-analytics": "7.7.4-beta.0"
18
+ "@ninetailed/experience.js-shared": "7.7.4",
19
+ "@ninetailed/experience.js": "7.7.4",
20
+ "@ninetailed/experience.js-preview-bridge": "7.7.4",
21
+ "@ninetailed/experience.js-plugin-analytics": "7.7.4"
22
22
  },
23
23
  "module": "./index.esm.js",
24
24
  "main": "./index.cjs.js"
@@ -29,10 +29,6 @@ export declare class NinetailedPreviewPlugin extends NinetailedPlugin implements
29
29
  private profile;
30
30
  private container;
31
31
  private bridge;
32
- /**
33
- * Since several instances of the plugin can be created, we need to make sure only one is marked as active.
34
- */
35
- private isActiveInstance;
36
32
  private onChangeEmitter;
37
33
  private readonly onOpenExperienceEditor;
38
34
  private readonly onOpenAudienceEditor;
@@ -7,12 +7,10 @@ type WidgetContainerOptions = {
7
7
  };
8
8
  export declare class WidgetContainer {
9
9
  private readonly options;
10
- private static CONTAINER_CLASS;
11
10
  private container;
12
11
  constructor(options: WidgetContainerOptions);
13
12
  open(): void;
14
13
  close(): void;
15
14
  get element(): HTMLDivElement;
16
- static isContainerAttached(): boolean;
17
15
  }
18
16
  export {};