@ninetailed/experience.js-plugin-preview 7.20.5 → 7.20.6
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 +23 -28
- package/index.esm.js +23 -28
- package/package.json +5 -5
- package/src/index.d.ts +2 -2
- package/src/lib/plugin/NinetailedPreviewPlugin.d.ts +105 -105
- package/src/lib/plugin/WidgetContainer.d.ts +17 -17
- package/src/lib/plugin/index.d.ts +2 -2
- package/src/lib/plugin/types.d.ts +7 -7
package/index.cjs.js
CHANGED
|
@@ -21,7 +21,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
21
21
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
22
|
PERFORMANCE OF THIS SOFTWARE.
|
|
23
23
|
***************************************************************************** */
|
|
24
|
-
/* global Reflect, Promise
|
|
24
|
+
/* global Reflect, Promise */
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
function __rest(s, e) {
|
|
@@ -42,14 +42,9 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
42
42
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
43
43
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
44
44
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
45
|
-
step((generator = generator.apply(thisArg,
|
|
45
|
+
step((generator = generator.apply(thisArg, [])).next());
|
|
46
46
|
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
};
|
|
47
|
+
}
|
|
53
48
|
|
|
54
49
|
const CONTAINER_WIDTH = 432;
|
|
55
50
|
const BUTTON_WIDTH = 48;
|
|
@@ -124,8 +119,8 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
124
119
|
this.container = null;
|
|
125
120
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
126
121
|
this.bridge = null;
|
|
127
|
-
/**
|
|
128
|
-
* Since several instances of the plugin can be created, we need to make sure only one is marked as active.
|
|
122
|
+
/**
|
|
123
|
+
* Since several instances of the plugin can be created, we need to make sure only one is marked as active.
|
|
129
124
|
*/
|
|
130
125
|
this.isActiveInstance = false;
|
|
131
126
|
this.onChangeEmitter = new experience_js.OnChangeEmitter();
|
|
@@ -175,9 +170,9 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
175
170
|
this.onProfileChange(payload.profile, payload.changes || []);
|
|
176
171
|
}
|
|
177
172
|
};
|
|
178
|
-
/**
|
|
179
|
-
* Implements the HasChangesModificationMiddleware interface
|
|
180
|
-
* Returns a middleware function that applies variable overwrites to changes
|
|
173
|
+
/**
|
|
174
|
+
* Implements the HasChangesModificationMiddleware interface
|
|
175
|
+
* Returns a middleware function that applies variable overwrites to changes
|
|
181
176
|
*/
|
|
182
177
|
this.getChangesModificationMiddleware = () => {
|
|
183
178
|
if (!this.isActiveInstance || Object.keys(this.variableOverwrites).length === 0 && Object.keys(this.audienceOverwrites).length === 0) {
|
|
@@ -285,9 +280,9 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
285
280
|
}
|
|
286
281
|
this.onChange();
|
|
287
282
|
};
|
|
288
|
-
/**
|
|
289
|
-
* Handles changes from the SDK and applies any variable overrides.
|
|
290
|
-
* This should be called whenever the original changes are updated.
|
|
283
|
+
/**
|
|
284
|
+
* Handles changes from the SDK and applies any variable overrides.
|
|
285
|
+
* This should be called whenever the original changes are updated.
|
|
291
286
|
*/
|
|
292
287
|
this.onChangesChange = incomingChanges => {
|
|
293
288
|
if (!this.isActiveInstance) {
|
|
@@ -465,8 +460,8 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
465
460
|
window.ninetailed.reset();
|
|
466
461
|
}
|
|
467
462
|
}
|
|
468
|
-
/**
|
|
469
|
-
* Sets a variable value override for preview
|
|
463
|
+
/**
|
|
464
|
+
* Sets a variable value override for preview
|
|
470
465
|
*/
|
|
471
466
|
setVariableValue({
|
|
472
467
|
experienceId,
|
|
@@ -503,8 +498,8 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
503
498
|
openExperienceEditor(experience) {
|
|
504
499
|
if (this.onOpenExperienceEditor && typeof this.onOpenExperienceEditor === 'function') return this.onOpenExperienceEditor(experience);
|
|
505
500
|
}
|
|
506
|
-
/**
|
|
507
|
-
* @deprecated This method will be removed in a future release. Use `openExperienceEditor` instead to see the experience insights.
|
|
501
|
+
/**
|
|
502
|
+
* @deprecated This method will be removed in a future release. Use `openExperienceEditor` instead to see the experience insights.
|
|
508
503
|
*/
|
|
509
504
|
openExperienceAnalytics(experience) {
|
|
510
505
|
experience_jsShared.logger.warn('The `openExperienceAnalytics` method is deprecated and will be removed in a future release. Use `openExperienceEditor` instead to see the experience insights.');
|
|
@@ -516,7 +511,7 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
516
511
|
get pluginApi() {
|
|
517
512
|
var _b;
|
|
518
513
|
return {
|
|
519
|
-
version: "7.20.
|
|
514
|
+
version: "7.20.6",
|
|
520
515
|
open: this.open.bind(this),
|
|
521
516
|
close: this.close.bind(this),
|
|
522
517
|
toggle: this.toggle.bind(this),
|
|
@@ -601,15 +596,15 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
601
596
|
audiences: this.activeAudiences
|
|
602
597
|
}));
|
|
603
598
|
}
|
|
604
|
-
/**
|
|
605
|
-
* Get the override key for a variable
|
|
599
|
+
/**
|
|
600
|
+
* Get the override key for a variable
|
|
606
601
|
*/
|
|
607
602
|
getOverrideKey(experienceId, key) {
|
|
608
603
|
return `${experienceId}:${key}`;
|
|
609
604
|
}
|
|
610
|
-
/**
|
|
611
|
-
* Ensure inline variables for a given experience reflect the selected variant
|
|
612
|
-
* without triggering multiple onChange calls. Keeps custom flags in sync with forced variants.
|
|
605
|
+
/**
|
|
606
|
+
* Ensure inline variables for a given experience reflect the selected variant
|
|
607
|
+
* without triggering multiple onChange calls. Keeps custom flags in sync with forced variants.
|
|
613
608
|
*/
|
|
614
609
|
applyInlineVariableOverridesForExperience(experience, variantIndex) {
|
|
615
610
|
const {
|
|
@@ -649,8 +644,8 @@ class NinetailedPreviewPlugin extends experience_jsPluginAnalytics.NinetailedPlu
|
|
|
649
644
|
this.variableOverwrites = overrides;
|
|
650
645
|
}
|
|
651
646
|
}
|
|
652
|
-
/**
|
|
653
|
-
* Get effective changes by applying overwrites - compute on demand
|
|
647
|
+
/**
|
|
648
|
+
* Get effective changes by applying overwrites - compute on demand
|
|
654
649
|
*/
|
|
655
650
|
getEffectiveChanges(inputChanges = this.changes) {
|
|
656
651
|
if (!inputChanges || Object.keys(this.variableOverwrites).length === 0) {
|
package/index.esm.js
CHANGED
|
@@ -17,7 +17,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
17
17
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
18
|
PERFORMANCE OF THIS SOFTWARE.
|
|
19
19
|
***************************************************************************** */
|
|
20
|
-
/* global Reflect, Promise
|
|
20
|
+
/* global Reflect, Promise */
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
function __rest(s, e) {
|
|
@@ -38,14 +38,9 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
38
38
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
39
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
40
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg,
|
|
41
|
+
step((generator = generator.apply(thisArg, [])).next());
|
|
42
42
|
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
46
|
-
var e = new Error(message);
|
|
47
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
48
|
-
};
|
|
43
|
+
}
|
|
49
44
|
|
|
50
45
|
const CONTAINER_WIDTH = 432;
|
|
51
46
|
const BUTTON_WIDTH = 48;
|
|
@@ -120,8 +115,8 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
120
115
|
this.container = null;
|
|
121
116
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
117
|
this.bridge = null;
|
|
123
|
-
/**
|
|
124
|
-
* Since several instances of the plugin can be created, we need to make sure only one is marked as active.
|
|
118
|
+
/**
|
|
119
|
+
* Since several instances of the plugin can be created, we need to make sure only one is marked as active.
|
|
125
120
|
*/
|
|
126
121
|
this.isActiveInstance = false;
|
|
127
122
|
this.onChangeEmitter = new OnChangeEmitter();
|
|
@@ -171,9 +166,9 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
171
166
|
this.onProfileChange(payload.profile, payload.changes || []);
|
|
172
167
|
}
|
|
173
168
|
};
|
|
174
|
-
/**
|
|
175
|
-
* Implements the HasChangesModificationMiddleware interface
|
|
176
|
-
* Returns a middleware function that applies variable overwrites to changes
|
|
169
|
+
/**
|
|
170
|
+
* Implements the HasChangesModificationMiddleware interface
|
|
171
|
+
* Returns a middleware function that applies variable overwrites to changes
|
|
177
172
|
*/
|
|
178
173
|
this.getChangesModificationMiddleware = () => {
|
|
179
174
|
if (!this.isActiveInstance || Object.keys(this.variableOverwrites).length === 0 && Object.keys(this.audienceOverwrites).length === 0) {
|
|
@@ -281,9 +276,9 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
281
276
|
}
|
|
282
277
|
this.onChange();
|
|
283
278
|
};
|
|
284
|
-
/**
|
|
285
|
-
* Handles changes from the SDK and applies any variable overrides.
|
|
286
|
-
* This should be called whenever the original changes are updated.
|
|
279
|
+
/**
|
|
280
|
+
* Handles changes from the SDK and applies any variable overrides.
|
|
281
|
+
* This should be called whenever the original changes are updated.
|
|
287
282
|
*/
|
|
288
283
|
this.onChangesChange = incomingChanges => {
|
|
289
284
|
if (!this.isActiveInstance) {
|
|
@@ -461,8 +456,8 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
461
456
|
window.ninetailed.reset();
|
|
462
457
|
}
|
|
463
458
|
}
|
|
464
|
-
/**
|
|
465
|
-
* Sets a variable value override for preview
|
|
459
|
+
/**
|
|
460
|
+
* Sets a variable value override for preview
|
|
466
461
|
*/
|
|
467
462
|
setVariableValue({
|
|
468
463
|
experienceId,
|
|
@@ -499,8 +494,8 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
499
494
|
openExperienceEditor(experience) {
|
|
500
495
|
if (this.onOpenExperienceEditor && typeof this.onOpenExperienceEditor === 'function') return this.onOpenExperienceEditor(experience);
|
|
501
496
|
}
|
|
502
|
-
/**
|
|
503
|
-
* @deprecated This method will be removed in a future release. Use `openExperienceEditor` instead to see the experience insights.
|
|
497
|
+
/**
|
|
498
|
+
* @deprecated This method will be removed in a future release. Use `openExperienceEditor` instead to see the experience insights.
|
|
504
499
|
*/
|
|
505
500
|
openExperienceAnalytics(experience) {
|
|
506
501
|
logger.warn('The `openExperienceAnalytics` method is deprecated and will be removed in a future release. Use `openExperienceEditor` instead to see the experience insights.');
|
|
@@ -512,7 +507,7 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
512
507
|
get pluginApi() {
|
|
513
508
|
var _b;
|
|
514
509
|
return {
|
|
515
|
-
version: "7.20.
|
|
510
|
+
version: "7.20.6",
|
|
516
511
|
open: this.open.bind(this),
|
|
517
512
|
close: this.close.bind(this),
|
|
518
513
|
toggle: this.toggle.bind(this),
|
|
@@ -597,15 +592,15 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
597
592
|
audiences: this.activeAudiences
|
|
598
593
|
}));
|
|
599
594
|
}
|
|
600
|
-
/**
|
|
601
|
-
* Get the override key for a variable
|
|
595
|
+
/**
|
|
596
|
+
* Get the override key for a variable
|
|
602
597
|
*/
|
|
603
598
|
getOverrideKey(experienceId, key) {
|
|
604
599
|
return `${experienceId}:${key}`;
|
|
605
600
|
}
|
|
606
|
-
/**
|
|
607
|
-
* Ensure inline variables for a given experience reflect the selected variant
|
|
608
|
-
* without triggering multiple onChange calls. Keeps custom flags in sync with forced variants.
|
|
601
|
+
/**
|
|
602
|
+
* Ensure inline variables for a given experience reflect the selected variant
|
|
603
|
+
* without triggering multiple onChange calls. Keeps custom flags in sync with forced variants.
|
|
609
604
|
*/
|
|
610
605
|
applyInlineVariableOverridesForExperience(experience, variantIndex) {
|
|
611
606
|
const {
|
|
@@ -645,8 +640,8 @@ class NinetailedPreviewPlugin extends NinetailedPlugin {
|
|
|
645
640
|
this.variableOverwrites = overrides;
|
|
646
641
|
}
|
|
647
642
|
}
|
|
648
|
-
/**
|
|
649
|
-
* Get effective changes by applying overwrites - compute on demand
|
|
643
|
+
/**
|
|
644
|
+
* Get effective changes by applying overwrites - compute on demand
|
|
650
645
|
*/
|
|
651
646
|
getEffectiveChanges(inputChanges = this.changes) {
|
|
652
647
|
if (!inputChanges || Object.keys(this.variableOverwrites).length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-plugin-preview",
|
|
3
|
-
"version": "7.20.
|
|
3
|
+
"version": "7.20.6",
|
|
4
4
|
"description": "Ninetailed SDK plugin for preview",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"sideEffects": false,
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ninetailed/experience.js-shared": "7.20.
|
|
32
|
-
"@ninetailed/experience.js": "7.20.
|
|
33
|
-
"@ninetailed/experience.js-preview-bridge": "7.20.
|
|
34
|
-
"@ninetailed/experience.js-plugin-analytics": "7.20.
|
|
31
|
+
"@ninetailed/experience.js-shared": "7.20.6",
|
|
32
|
+
"@ninetailed/experience.js": "7.20.6",
|
|
33
|
+
"@ninetailed/experience.js-preview-bridge": "7.20.6",
|
|
34
|
+
"@ninetailed/experience.js-plugin-analytics": "7.20.6",
|
|
35
35
|
"radash": "10.9.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { NinetailedPreviewPlugin } from './lib/plugin';
|
|
2
|
-
export { NinetailedPreviewPlugin as default } from './lib/plugin';
|
|
1
|
+
export { NinetailedPreviewPlugin } from './lib/plugin';
|
|
2
|
+
export { NinetailedPreviewPlugin as default } from './lib/plugin';
|
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
import { Reference, AllowedVariableType } from '@ninetailed/experience.js-shared';
|
|
2
|
-
import { ExperienceConfiguration, PROFILE_CHANGE, HasExperienceSelectionMiddleware, BuildExperienceSelectionMiddleware, HasChangesModificationMiddleware, BuildChangesModificationMiddleware, type ProfileChangedPayload, type InterestedInProfileChange } from '@ninetailed/experience.js';
|
|
3
|
-
import type { ExposedAudienceDefinition, PreviewBridgeOptions } from '@ninetailed/experience.js-preview-bridge';
|
|
4
|
-
import { type EventHandler, NinetailedPlugin } from '@ninetailed/experience.js-plugin-analytics';
|
|
5
|
-
import { WidgetContainerOptions } from './WidgetContainer';
|
|
6
|
-
export declare const NINETAILED_PREVIEW_EVENTS: {
|
|
7
|
-
previewAudiences: string;
|
|
8
|
-
previewTraits: string;
|
|
9
|
-
};
|
|
10
|
-
type NinetailedPreviewPluginOptions = {
|
|
11
|
-
experiences: ExperienceConfiguration[];
|
|
12
|
-
audiences: ExposedAudienceDefinition[];
|
|
13
|
-
onOpenExperienceEditor?: (experience: ExperienceConfiguration) => void;
|
|
14
|
-
onOpenAudienceEditor?: (audience: ExposedAudienceDefinition) => void;
|
|
15
|
-
} & PreviewBridgeOptions & WidgetContainerOptions;
|
|
16
|
-
export declare class NinetailedPreviewPlugin extends NinetailedPlugin implements HasExperienceSelectionMiddleware<Reference, Reference>, HasChangesModificationMiddleware, InterestedInProfileChange {
|
|
17
|
-
private readonly options;
|
|
18
|
-
name: string;
|
|
19
|
-
private isOpen;
|
|
20
|
-
private readonly experiences;
|
|
21
|
-
private readonly audienceDefinitions;
|
|
22
|
-
private audienceOverwrites;
|
|
23
|
-
private experienceVariantIndexOverwrites;
|
|
24
|
-
private variableOverwrites;
|
|
25
|
-
private profile;
|
|
26
|
-
private changes;
|
|
27
|
-
private container;
|
|
28
|
-
private bridge;
|
|
29
|
-
/**
|
|
30
|
-
* Since several instances of the plugin can be created, we need to make sure only one is marked as active.
|
|
31
|
-
*/
|
|
32
|
-
private isActiveInstance;
|
|
33
|
-
private onChangeEmitter;
|
|
34
|
-
private readonly onOpenExperienceEditor;
|
|
35
|
-
private readonly onOpenAudienceEditor;
|
|
36
|
-
private clientId;
|
|
37
|
-
private environment;
|
|
38
|
-
constructor(options: NinetailedPreviewPluginOptions);
|
|
39
|
-
initialize: () => Promise<void>;
|
|
40
|
-
loaded: () => boolean;
|
|
41
|
-
[PROFILE_CHANGE]: EventHandler<ProfileChangedPayload>;
|
|
42
|
-
open(): void;
|
|
43
|
-
close(): void;
|
|
44
|
-
toggle(): void;
|
|
45
|
-
activateAudience(id: string): void;
|
|
46
|
-
deactivateAudience(id: string): void;
|
|
47
|
-
resetAudience(id: string): void;
|
|
48
|
-
setExperienceVariant({ experienceId, variantIndex, }: {
|
|
49
|
-
experienceId: string;
|
|
50
|
-
variantIndex: number;
|
|
51
|
-
}): void;
|
|
52
|
-
resetExperience(experienceId: string): void;
|
|
53
|
-
reset(): void;
|
|
54
|
-
/**
|
|
55
|
-
* Implements the HasChangesModificationMiddleware interface
|
|
56
|
-
* Returns a middleware function that applies variable overwrites to changes
|
|
57
|
-
*/
|
|
58
|
-
getChangesModificationMiddleware: BuildChangesModificationMiddleware;
|
|
59
|
-
/**
|
|
60
|
-
* Sets a variable value override for preview
|
|
61
|
-
*/
|
|
62
|
-
setVariableValue({ experienceId, key, value, variantIndex, }: {
|
|
63
|
-
experienceId: string;
|
|
64
|
-
key: string;
|
|
65
|
-
value: AllowedVariableType;
|
|
66
|
-
variantIndex: number;
|
|
67
|
-
}): void;
|
|
68
|
-
getExperienceSelectionMiddleware: BuildExperienceSelectionMiddleware<Reference, Reference>;
|
|
69
|
-
openExperienceEditor(experience: ExperienceConfiguration): void;
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated This method will be removed in a future release. Use `openExperienceEditor` instead to see the experience insights.
|
|
72
|
-
*/
|
|
73
|
-
openExperienceAnalytics(experience: ExperienceConfiguration): void;
|
|
74
|
-
openAudienceEditor(audience: ExposedAudienceDefinition): void;
|
|
75
|
-
private get pluginApi();
|
|
76
|
-
private get windowApi();
|
|
77
|
-
private isKnownAudience;
|
|
78
|
-
private get potentialAudiences();
|
|
79
|
-
private get activeAudiences();
|
|
80
|
-
private calculateExperienceVariantIndexes;
|
|
81
|
-
private get apiExperienceVariantIndexes();
|
|
82
|
-
private get experienceVariantIndexes();
|
|
83
|
-
/**
|
|
84
|
-
* Get the override key for a variable
|
|
85
|
-
*/
|
|
86
|
-
private getOverrideKey;
|
|
87
|
-
/**
|
|
88
|
-
* Ensure inline variables for a given experience reflect the selected variant
|
|
89
|
-
* without triggering multiple onChange calls. Keeps custom flags in sync with forced variants.
|
|
90
|
-
*/
|
|
91
|
-
private applyInlineVariableOverridesForExperience;
|
|
92
|
-
/**
|
|
93
|
-
* Get effective changes by applying overwrites - compute on demand
|
|
94
|
-
*/
|
|
95
|
-
private getEffectiveChanges;
|
|
96
|
-
private onChange;
|
|
97
|
-
private onProfileChange;
|
|
98
|
-
/**
|
|
99
|
-
* Handles changes from the SDK and applies any variable overrides.
|
|
100
|
-
* This should be called whenever the original changes are updated.
|
|
101
|
-
*/
|
|
102
|
-
private onChangesChange;
|
|
103
|
-
private setCredentials;
|
|
104
|
-
}
|
|
105
|
-
export {};
|
|
1
|
+
import { Reference, AllowedVariableType } from '@ninetailed/experience.js-shared';
|
|
2
|
+
import { ExperienceConfiguration, PROFILE_CHANGE, HasExperienceSelectionMiddleware, BuildExperienceSelectionMiddleware, HasChangesModificationMiddleware, BuildChangesModificationMiddleware, type ProfileChangedPayload, type InterestedInProfileChange } from '@ninetailed/experience.js';
|
|
3
|
+
import type { ExposedAudienceDefinition, PreviewBridgeOptions } from '@ninetailed/experience.js-preview-bridge';
|
|
4
|
+
import { type EventHandler, NinetailedPlugin } from '@ninetailed/experience.js-plugin-analytics';
|
|
5
|
+
import { WidgetContainerOptions } from './WidgetContainer';
|
|
6
|
+
export declare const NINETAILED_PREVIEW_EVENTS: {
|
|
7
|
+
previewAudiences: string;
|
|
8
|
+
previewTraits: string;
|
|
9
|
+
};
|
|
10
|
+
type NinetailedPreviewPluginOptions = {
|
|
11
|
+
experiences: ExperienceConfiguration[];
|
|
12
|
+
audiences: ExposedAudienceDefinition[];
|
|
13
|
+
onOpenExperienceEditor?: (experience: ExperienceConfiguration) => void;
|
|
14
|
+
onOpenAudienceEditor?: (audience: ExposedAudienceDefinition) => void;
|
|
15
|
+
} & PreviewBridgeOptions & WidgetContainerOptions;
|
|
16
|
+
export declare class NinetailedPreviewPlugin extends NinetailedPlugin implements HasExperienceSelectionMiddleware<Reference, Reference>, HasChangesModificationMiddleware, InterestedInProfileChange {
|
|
17
|
+
private readonly options;
|
|
18
|
+
name: string;
|
|
19
|
+
private isOpen;
|
|
20
|
+
private readonly experiences;
|
|
21
|
+
private readonly audienceDefinitions;
|
|
22
|
+
private audienceOverwrites;
|
|
23
|
+
private experienceVariantIndexOverwrites;
|
|
24
|
+
private variableOverwrites;
|
|
25
|
+
private profile;
|
|
26
|
+
private changes;
|
|
27
|
+
private container;
|
|
28
|
+
private bridge;
|
|
29
|
+
/**
|
|
30
|
+
* Since several instances of the plugin can be created, we need to make sure only one is marked as active.
|
|
31
|
+
*/
|
|
32
|
+
private isActiveInstance;
|
|
33
|
+
private onChangeEmitter;
|
|
34
|
+
private readonly onOpenExperienceEditor;
|
|
35
|
+
private readonly onOpenAudienceEditor;
|
|
36
|
+
private clientId;
|
|
37
|
+
private environment;
|
|
38
|
+
constructor(options: NinetailedPreviewPluginOptions);
|
|
39
|
+
initialize: () => Promise<void>;
|
|
40
|
+
loaded: () => boolean;
|
|
41
|
+
[PROFILE_CHANGE]: EventHandler<ProfileChangedPayload>;
|
|
42
|
+
open(): void;
|
|
43
|
+
close(): void;
|
|
44
|
+
toggle(): void;
|
|
45
|
+
activateAudience(id: string): void;
|
|
46
|
+
deactivateAudience(id: string): void;
|
|
47
|
+
resetAudience(id: string): void;
|
|
48
|
+
setExperienceVariant({ experienceId, variantIndex, }: {
|
|
49
|
+
experienceId: string;
|
|
50
|
+
variantIndex: number;
|
|
51
|
+
}): void;
|
|
52
|
+
resetExperience(experienceId: string): void;
|
|
53
|
+
reset(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Implements the HasChangesModificationMiddleware interface
|
|
56
|
+
* Returns a middleware function that applies variable overwrites to changes
|
|
57
|
+
*/
|
|
58
|
+
getChangesModificationMiddleware: BuildChangesModificationMiddleware;
|
|
59
|
+
/**
|
|
60
|
+
* Sets a variable value override for preview
|
|
61
|
+
*/
|
|
62
|
+
setVariableValue({ experienceId, key, value, variantIndex, }: {
|
|
63
|
+
experienceId: string;
|
|
64
|
+
key: string;
|
|
65
|
+
value: AllowedVariableType;
|
|
66
|
+
variantIndex: number;
|
|
67
|
+
}): void;
|
|
68
|
+
getExperienceSelectionMiddleware: BuildExperienceSelectionMiddleware<Reference, Reference>;
|
|
69
|
+
openExperienceEditor(experience: ExperienceConfiguration): void;
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated This method will be removed in a future release. Use `openExperienceEditor` instead to see the experience insights.
|
|
72
|
+
*/
|
|
73
|
+
openExperienceAnalytics(experience: ExperienceConfiguration): void;
|
|
74
|
+
openAudienceEditor(audience: ExposedAudienceDefinition): void;
|
|
75
|
+
private get pluginApi();
|
|
76
|
+
private get windowApi();
|
|
77
|
+
private isKnownAudience;
|
|
78
|
+
private get potentialAudiences();
|
|
79
|
+
private get activeAudiences();
|
|
80
|
+
private calculateExperienceVariantIndexes;
|
|
81
|
+
private get apiExperienceVariantIndexes();
|
|
82
|
+
private get experienceVariantIndexes();
|
|
83
|
+
/**
|
|
84
|
+
* Get the override key for a variable
|
|
85
|
+
*/
|
|
86
|
+
private getOverrideKey;
|
|
87
|
+
/**
|
|
88
|
+
* Ensure inline variables for a given experience reflect the selected variant
|
|
89
|
+
* without triggering multiple onChange calls. Keeps custom flags in sync with forced variants.
|
|
90
|
+
*/
|
|
91
|
+
private applyInlineVariableOverridesForExperience;
|
|
92
|
+
/**
|
|
93
|
+
* Get effective changes by applying overwrites - compute on demand
|
|
94
|
+
*/
|
|
95
|
+
private getEffectiveChanges;
|
|
96
|
+
private onChange;
|
|
97
|
+
private onProfileChange;
|
|
98
|
+
/**
|
|
99
|
+
* Handles changes from the SDK and applies any variable overrides.
|
|
100
|
+
* This should be called whenever the original changes are updated.
|
|
101
|
+
*/
|
|
102
|
+
private onChangesChange;
|
|
103
|
+
private setCredentials;
|
|
104
|
+
}
|
|
105
|
+
export {};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export type WidgetContainerOptions = {
|
|
2
|
-
ui?: {
|
|
3
|
-
opener?: {
|
|
4
|
-
hide: boolean;
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare class WidgetContainer {
|
|
9
|
-
private readonly options;
|
|
10
|
-
private static CONTAINER_CLASS;
|
|
11
|
-
private readonly container;
|
|
12
|
-
constructor(options: WidgetContainerOptions);
|
|
13
|
-
open(): void;
|
|
14
|
-
close(): void;
|
|
15
|
-
get element(): HTMLDivElement;
|
|
16
|
-
static isContainerAttached(): boolean;
|
|
17
|
-
}
|
|
1
|
+
export type WidgetContainerOptions = {
|
|
2
|
+
ui?: {
|
|
3
|
+
opener?: {
|
|
4
|
+
hide: boolean;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare class WidgetContainer {
|
|
9
|
+
private readonly options;
|
|
10
|
+
private static CONTAINER_CLASS;
|
|
11
|
+
private readonly container;
|
|
12
|
+
constructor(options: WidgetContainerOptions);
|
|
13
|
+
open(): void;
|
|
14
|
+
close(): void;
|
|
15
|
+
get element(): HTMLDivElement;
|
|
16
|
+
static isContainerAttached(): boolean;
|
|
17
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './NinetailedPreviewPlugin';
|
|
2
|
-
export * from './types';
|
|
1
|
+
export * from './NinetailedPreviewPlugin';
|
|
2
|
+
export * from './types';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type Credentials = {
|
|
2
|
-
clientId: string;
|
|
3
|
-
secret: string;
|
|
4
|
-
};
|
|
5
|
-
export type Connection = {
|
|
6
|
-
environment?: string;
|
|
7
|
-
};
|
|
1
|
+
export type Credentials = {
|
|
2
|
+
clientId: string;
|
|
3
|
+
secret: string;
|
|
4
|
+
};
|
|
5
|
+
export type Connection = {
|
|
6
|
+
environment?: string;
|
|
7
|
+
};
|