@absmartly/sdk-plugins 1.1.2 → 1.2.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/dist/absmartly-cookie.min.js +1 -1
- package/dist/absmartly-dom-changes-core.min.js +1 -1
- package/dist/absmartly-dom-changes-lite.min.js +1 -1
- package/dist/absmartly-overrides-full.min.js +1 -1
- package/dist/absmartly-overrides-lite.min.js +1 -1
- package/dist/absmartly-sdk-plugins.min.js +1 -1
- package/dist/absmartly-vitals.min.js +1 -1
- package/es/cookies/cookieUtils.js +2 -1
- package/es/cookies/cookieUtils.js.map +1 -1
- package/es/core/DOMChangesPluginLite.js +195 -221
- package/es/core/DOMChangesPluginLite.js.map +1 -1
- package/es/core/DOMManipulatorLite.js +76 -10
- package/es/core/DOMManipulatorLite.js.map +1 -1
- package/es/core/ExposureTracker.js +136 -11
- package/es/core/ExposureTracker.js.map +1 -1
- package/es/core/PendingChangeManager.js +14 -14
- package/es/core/PendingChangeManager.js.map +1 -1
- package/es/entries/dom-with-overrides-lite.js +3 -0
- package/es/entries/dom-with-overrides-lite.js.map +1 -1
- package/es/generated/buildInfo.js +3 -0
- package/es/generated/buildInfo.js.map +1 -0
- package/es/index.js +9 -2
- package/es/index.js.map +1 -1
- package/es/overrides/OverridesPlugin.js +2 -2
- package/es/overrides/OverridesPlugin.js.map +1 -1
- package/es/overrides/OverridesPluginLite.js +29 -1
- package/es/overrides/OverridesPluginLite.js.map +1 -1
- package/es/overrides/overridesUtils.js +27 -18
- package/es/overrides/overridesUtils.js.map +1 -1
- package/es/parsers/VariantExtractor.js +14 -7
- package/es/parsers/VariantExtractor.js.map +1 -1
- package/es/url-redirect/URLRedirectExtractor.js +185 -0
- package/es/url-redirect/URLRedirectExtractor.js.map +1 -0
- package/es/url-redirect/URLRedirectMatcher.js +116 -0
- package/es/url-redirect/URLRedirectMatcher.js.map +1 -0
- package/es/url-redirect/URLRedirectPlugin.js +351 -0
- package/es/url-redirect/URLRedirectPlugin.js.map +1 -0
- package/es/url-redirect/index.js +5 -0
- package/es/url-redirect/index.js.map +1 -0
- package/es/url-redirect/types.js +2 -0
- package/es/url-redirect/types.js.map +1 -0
- package/es/utils/URLMatcher.js +4 -3
- package/es/utils/URLMatcher.js.map +1 -1
- package/es/utils/debug.js +4 -3
- package/es/utils/debug.js.map +1 -1
- package/es/utils/persistence.js +278 -0
- package/es/utils/persistence.js.map +1 -0
- package/es/utils/plugin-registry.js +47 -0
- package/es/utils/plugin-registry.js.map +1 -0
- package/lib/cookies/cookieUtils.d.ts +0 -4
- package/lib/cookies/cookieUtils.js +6 -5
- package/lib/cookies/cookieUtils.js.map +1 -1
- package/lib/core/DOMChangesPluginLite.d.ts +10 -7
- package/lib/core/DOMChangesPluginLite.js +195 -221
- package/lib/core/DOMChangesPluginLite.js.map +1 -1
- package/lib/core/DOMManipulatorLite.js +76 -10
- package/lib/core/DOMManipulatorLite.js.map +1 -1
- package/lib/core/ExposureTracker.d.ts +6 -0
- package/lib/core/ExposureTracker.js +136 -11
- package/lib/core/ExposureTracker.js.map +1 -1
- package/lib/core/PendingChangeManager.d.ts +0 -1
- package/lib/core/PendingChangeManager.js +14 -14
- package/lib/core/PendingChangeManager.js.map +1 -1
- package/lib/entries/dom-with-overrides-lite.d.ts +2 -0
- package/lib/entries/dom-with-overrides-lite.js +3 -1
- package/lib/entries/dom-with-overrides-lite.js.map +1 -1
- package/lib/generated/buildInfo.d.ts +2 -0
- package/lib/generated/buildInfo.js +6 -0
- package/lib/generated/buildInfo.js.map +1 -0
- package/lib/index.d.ts +8 -2
- package/lib/index.js +17 -1
- package/lib/index.js.map +1 -1
- package/lib/overrides/OverridesPlugin.js +2 -2
- package/lib/overrides/OverridesPlugin.js.map +1 -1
- package/lib/overrides/OverridesPluginLite.d.ts +8 -0
- package/lib/overrides/OverridesPluginLite.js +29 -1
- package/lib/overrides/OverridesPluginLite.js.map +1 -1
- package/lib/overrides/overridesUtils.d.ts +10 -5
- package/lib/overrides/overridesUtils.js +28 -18
- package/lib/overrides/overridesUtils.js.map +1 -1
- package/lib/parsers/VariantExtractor.js +14 -7
- package/lib/parsers/VariantExtractor.js.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/url-redirect/URLRedirectExtractor.d.ts +16 -0
- package/lib/url-redirect/URLRedirectExtractor.js +188 -0
- package/lib/url-redirect/URLRedirectExtractor.js.map +1 -0
- package/lib/url-redirect/URLRedirectMatcher.d.ts +8 -0
- package/lib/url-redirect/URLRedirectMatcher.js +119 -0
- package/lib/url-redirect/URLRedirectMatcher.js.map +1 -0
- package/lib/url-redirect/URLRedirectPlugin.d.ts +21 -0
- package/lib/url-redirect/URLRedirectPlugin.js +354 -0
- package/lib/url-redirect/URLRedirectPlugin.js.map +1 -0
- package/lib/url-redirect/index.d.ts +4 -0
- package/lib/url-redirect/index.js +25 -0
- package/lib/url-redirect/index.js.map +1 -0
- package/lib/url-redirect/types.d.ts +29 -0
- package/lib/url-redirect/types.js +3 -0
- package/lib/url-redirect/types.js.map +1 -0
- package/lib/utils/URLMatcher.js +4 -3
- package/lib/utils/URLMatcher.js.map +1 -1
- package/lib/utils/debug.d.ts +1 -1
- package/lib/utils/debug.js +4 -3
- package/lib/utils/debug.js.map +1 -1
- package/lib/utils/persistence.d.ts +23 -0
- package/lib/utils/persistence.js +281 -0
- package/lib/utils/persistence.js.map +1 -0
- package/lib/utils/plugin-registry.d.ts +40 -0
- package/lib/utils/plugin-registry.js +53 -0
- package/lib/utils/plugin-registry.js.map +1 -0
- package/package.json +64 -6
- package/types/cookies/cookieUtils.d.ts +0 -4
- package/types/core/DOMChangesPluginLite.d.ts +10 -7
- package/types/core/ExposureTracker.d.ts +6 -0
- package/types/core/PendingChangeManager.d.ts +0 -1
- package/types/entries/dom-with-overrides-lite.d.ts +2 -0
- package/types/generated/buildInfo.d.ts +2 -0
- package/types/index.d.ts +8 -2
- package/types/overrides/OverridesPluginLite.d.ts +8 -0
- package/types/overrides/overridesUtils.d.ts +10 -5
- package/types/types/index.d.ts +1 -0
- package/types/url-redirect/URLRedirectExtractor.d.ts +16 -0
- package/types/url-redirect/URLRedirectMatcher.d.ts +8 -0
- package/types/url-redirect/URLRedirectPlugin.d.ts +21 -0
- package/types/url-redirect/index.d.ts +4 -0
- package/types/url-redirect/types.d.ts +29 -0
- package/types/utils/debug.d.ts +1 -1
- package/types/utils/persistence.d.ts +23 -0
- package/types/utils/plugin-registry.d.ts +40 -0
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* These can be used independently for lightweight override operations
|
|
4
4
|
* without requiring the full OverridesPlugin class
|
|
5
5
|
*/
|
|
6
|
+
export declare const DEFAULT_OVERRIDE_COOKIE_NAME = "absmartly_overrides";
|
|
7
|
+
export declare const DEFAULT_OVERRIDE_QUERY_PREFIX = "exp_";
|
|
6
8
|
export interface SimpleOverride {
|
|
7
9
|
variant: number;
|
|
8
10
|
env?: number;
|
|
@@ -15,7 +17,7 @@ export interface OverrideOptions {
|
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Parse query string parameters for experiment overrides
|
|
18
|
-
* @param queryPrefix - Prefix for experiment parameters (
|
|
20
|
+
* @param queryPrefix - Prefix for experiment parameters (default: DEFAULT_OVERRIDE_QUERY_PREFIX)
|
|
19
21
|
* @param searchParams - Optional URLSearchParams instance (defaults to window.location.search)
|
|
20
22
|
*/
|
|
21
23
|
export declare function getQueryStringOverrides(queryPrefix?: string, searchParams?: URLSearchParams): Record<string, number | SimpleOverride>;
|
|
@@ -26,8 +28,10 @@ export declare function getQueryStringOverrides(queryPrefix?: string, searchPara
|
|
|
26
28
|
export declare function parseOverrideCookie(value: string): Record<string, number | SimpleOverride>;
|
|
27
29
|
/**
|
|
28
30
|
* Get experiment overrides from cookie
|
|
31
|
+
* @param cookieName - Name of the cookie to read (default: DEFAULT_OVERRIDE_COOKIE_NAME)
|
|
32
|
+
* @param cookieHeader - Optional cookie header string (for server-side use). If not provided, uses document.cookie
|
|
29
33
|
*/
|
|
30
|
-
export declare function getCookieOverrides(cookieName?: string): Record<string, number | SimpleOverride>;
|
|
34
|
+
export declare function getCookieOverrides(cookieName?: string, cookieHeader?: string): Record<string, number | SimpleOverride>;
|
|
31
35
|
/**
|
|
32
36
|
* Serialize overrides to cookie value format
|
|
33
37
|
*/
|
|
@@ -40,9 +44,10 @@ export declare function persistOverridesToCookie(overrides: Record<string, numbe
|
|
|
40
44
|
* Get experiment overrides from query string or cookie
|
|
41
45
|
* Returns normalized Record<string, number> for use with SDK createContext
|
|
42
46
|
*
|
|
43
|
-
* @param cookieName - Name of the cookie to read/write (default:
|
|
44
|
-
* @param queryPrefix - Prefix for query string parameters (default:
|
|
47
|
+
* @param cookieName - Name of the cookie to read/write (default: DEFAULT_OVERRIDE_COOKIE_NAME)
|
|
48
|
+
* @param queryPrefix - Prefix for query string parameters (default: DEFAULT_OVERRIDE_QUERY_PREFIX)
|
|
45
49
|
* @param searchParams - Optional URLSearchParams instance (defaults to window.location.search)
|
|
50
|
+
* @param cookieHeader - Optional cookie header string (for server-side use). If not provided, uses document.cookie
|
|
46
51
|
* @returns Normalized overrides as Record<string, number>
|
|
47
52
|
*/
|
|
48
|
-
export declare function getOverrides(cookieName?: string, queryPrefix?: string, searchParams?: URLSearchParams): Record<string, number>;
|
|
53
|
+
export declare function getOverrides(cookieName?: string, queryPrefix?: string, searchParams?: URLSearchParams, cookieHeader?: string): Record<string, number>;
|
package/types/types/index.d.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ABsmartlyContext } from '../types';
|
|
2
|
+
import { URLRedirectConfig } from './types';
|
|
3
|
+
export declare class URLRedirectExtractor {
|
|
4
|
+
private context;
|
|
5
|
+
private variableName;
|
|
6
|
+
private debug;
|
|
7
|
+
private cachedConfigs;
|
|
8
|
+
constructor(context: ABsmartlyContext, variableName?: string, debug?: boolean);
|
|
9
|
+
clearCache(): void;
|
|
10
|
+
extractAllConfigs(): Map<string, Map<number, URLRedirectConfig>>;
|
|
11
|
+
private extractConfigsForExperiment;
|
|
12
|
+
private parseConfig;
|
|
13
|
+
private isValidRedirect;
|
|
14
|
+
getConfigForExperiment(experimentName: string): URLRedirectConfig | null;
|
|
15
|
+
getAllVariantConfigs(experimentName: string): Map<number, URLRedirectConfig>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { URLRedirect, RedirectMatch } from './types';
|
|
2
|
+
export declare class URLRedirectMatcher {
|
|
3
|
+
static findMatch(currentUrl: string, redirects: URLRedirect[], experimentName: string, variant: number): RedirectMatch | null;
|
|
4
|
+
private static matchRedirect;
|
|
5
|
+
private static matchDomainRedirect;
|
|
6
|
+
private static matchPageRedirect;
|
|
7
|
+
static buildTargetUrl(currentUrl: string, redirect: URLRedirect): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { URLRedirectPluginConfig, RedirectMatch } from './types';
|
|
2
|
+
import { URLRedirectExtractor } from './URLRedirectExtractor';
|
|
3
|
+
export declare class URLRedirectPlugin {
|
|
4
|
+
static readonly VERSION: string;
|
|
5
|
+
private config;
|
|
6
|
+
private extractor;
|
|
7
|
+
private initialized;
|
|
8
|
+
private readyPromise;
|
|
9
|
+
constructor(config: URLRedirectPluginConfig);
|
|
10
|
+
ready(): Promise<RedirectMatch | null>;
|
|
11
|
+
private initialize;
|
|
12
|
+
findRedirectMatch(url?: string): RedirectMatch | null;
|
|
13
|
+
private getAnyConfig;
|
|
14
|
+
executeRedirect(match: RedirectMatch): Promise<void>;
|
|
15
|
+
private publishViaBeacon;
|
|
16
|
+
getExtractor(): URLRedirectExtractor;
|
|
17
|
+
refreshExperiments(): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
private registerWithContext;
|
|
20
|
+
private unregisterFromContext;
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { URLFilter } from '../types';
|
|
2
|
+
export type RedirectType = 'domain' | 'page';
|
|
3
|
+
export type ControlBehavior = 'redirect-same' | 'no-redirect';
|
|
4
|
+
export interface URLRedirect {
|
|
5
|
+
from: string;
|
|
6
|
+
to: string;
|
|
7
|
+
preservePath?: boolean;
|
|
8
|
+
type: RedirectType;
|
|
9
|
+
}
|
|
10
|
+
export interface URLRedirectConfig {
|
|
11
|
+
redirects: URLRedirect[];
|
|
12
|
+
urlFilter?: URLFilter;
|
|
13
|
+
controlBehavior?: ControlBehavior;
|
|
14
|
+
}
|
|
15
|
+
export interface RedirectMatch {
|
|
16
|
+
redirect: URLRedirect;
|
|
17
|
+
targetUrl: string;
|
|
18
|
+
experimentName: string;
|
|
19
|
+
variant: number;
|
|
20
|
+
isControl: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface URLRedirectPluginConfig {
|
|
23
|
+
context: import('../types').ABsmartlyContext;
|
|
24
|
+
variableName?: string;
|
|
25
|
+
debug?: boolean;
|
|
26
|
+
autoApply?: boolean;
|
|
27
|
+
useBeacon?: boolean;
|
|
28
|
+
onBeforeRedirect?: (match: RedirectMatch) => void | Promise<void>;
|
|
29
|
+
}
|
package/types/utils/debug.d.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DOMChange } from '../types';
|
|
2
|
+
export interface PersistenceConfig {
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
onReapply: (change: DOMChange, experimentName: string) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class DOMPersistenceManager {
|
|
7
|
+
private watchedElements;
|
|
8
|
+
private persistenceObserver;
|
|
9
|
+
private reapplyingElements;
|
|
10
|
+
private reapplyLogThrottle;
|
|
11
|
+
private appliedChanges;
|
|
12
|
+
private config;
|
|
13
|
+
constructor(config: PersistenceConfig);
|
|
14
|
+
watchElement(element: Element, experimentName: string, change: DOMChange): void;
|
|
15
|
+
unwatchElement(element: Element, experimentName: string): void;
|
|
16
|
+
unwatchExperiment(experimentName: string): void;
|
|
17
|
+
getAppliedChanges(): Map<string, DOMChange[]>;
|
|
18
|
+
clearAll(): void;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
private setupPersistenceObserver;
|
|
21
|
+
private checkStyleOverwritten;
|
|
22
|
+
private checkAttributeOverwritten;
|
|
23
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global plugin registry for ABsmartly plugins
|
|
3
|
+
* Allows detection and inspection of loaded plugins
|
|
4
|
+
*/
|
|
5
|
+
export interface PluginRegistryEntry {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
initialized: boolean;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
capabilities?: string[];
|
|
11
|
+
instance?: any;
|
|
12
|
+
}
|
|
13
|
+
export interface PluginRegistry {
|
|
14
|
+
dom?: PluginRegistryEntry;
|
|
15
|
+
overrides?: PluginRegistryEntry;
|
|
16
|
+
cookie?: PluginRegistryEntry;
|
|
17
|
+
vitals?: PluginRegistryEntry;
|
|
18
|
+
urlRedirect?: PluginRegistryEntry;
|
|
19
|
+
}
|
|
20
|
+
declare global {
|
|
21
|
+
interface Window {
|
|
22
|
+
__ABSMARTLY_PLUGINS__?: PluginRegistry;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Register a plugin in the global registry
|
|
27
|
+
*/
|
|
28
|
+
export declare function registerPlugin(pluginType: keyof PluginRegistry, entry: PluginRegistryEntry): void;
|
|
29
|
+
/**
|
|
30
|
+
* Unregister a plugin from the global registry
|
|
31
|
+
*/
|
|
32
|
+
export declare function unregisterPlugin(pluginType: keyof PluginRegistry): void;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a plugin is registered
|
|
35
|
+
*/
|
|
36
|
+
export declare function isPluginRegistered(pluginType: keyof PluginRegistry): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get all registered plugins
|
|
39
|
+
*/
|
|
40
|
+
export declare function getRegisteredPlugins(): PluginRegistry;
|