@active-reach/web-sdk 1.4.0 → 1.5.0

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.
Files changed (34) hide show
  1. package/dist/aegis.min.js +1 -1
  2. package/dist/aegis.min.js.map +1 -1
  3. package/dist/{analytics-D9BAnJAu.mjs → analytics-C00PJUSy.mjs} +7 -2
  4. package/dist/{analytics-D9BAnJAu.mjs.map → analytics-C00PJUSy.mjs.map} +1 -1
  5. package/dist/core/prefetch-bundle-client.d.ts +150 -0
  6. package/dist/core/prefetch-bundle-client.d.ts.map +1 -0
  7. package/dist/governance/name-governor.d.ts +10 -0
  8. package/dist/governance/name-governor.d.ts.map +1 -1
  9. package/dist/inapp/AegisInAppManager.d.ts +26 -1
  10. package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
  11. package/dist/inapp/renderers/carousel-cards.d.ts +15 -0
  12. package/dist/inapp/renderers/carousel-cards.d.ts.map +1 -0
  13. package/dist/inapp/renderers/coachmark-tour.d.ts +24 -0
  14. package/dist/inapp/renderers/coachmark-tour.d.ts.map +1 -0
  15. package/dist/inapp/renderers/index.d.ts +12 -0
  16. package/dist/inapp/renderers/index.d.ts.map +1 -0
  17. package/dist/inapp/renderers/product-recommendation.d.ts +23 -0
  18. package/dist/inapp/renderers/product-recommendation.d.ts.map +1 -0
  19. package/dist/inapp/renderers/progress-bar.d.ts +24 -0
  20. package/dist/inapp/renderers/progress-bar.d.ts.map +1 -0
  21. package/dist/inapp/renderers/sticky-bar.d.ts +14 -0
  22. package/dist/inapp/renderers/sticky-bar.d.ts.map +1 -0
  23. package/dist/inapp/renderers/types.d.ts +27 -0
  24. package/dist/inapp/renderers/types.d.ts.map +1 -0
  25. package/dist/inbox/AegisInbox.d.ts +103 -0
  26. package/dist/inbox/AegisInbox.d.ts.map +1 -0
  27. package/dist/inbox/index.d.ts +3 -0
  28. package/dist/inbox/index.d.ts.map +1 -0
  29. package/dist/index.d.ts +4 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +1304 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/react.js +1 -1
  34. package/package.json +1 -1
@@ -0,0 +1,150 @@
1
+ /**
2
+ * PrefetchBundleClient — unified init-time resolver for in-app state.
3
+ *
4
+ * Fetches /v1/sdk/prefetch-bundle at SDK init and on a 5-minute ETag
5
+ * refresh cadence. The bundle payload carries:
6
+ * • `campaigns[]` — eligible, property-scoped, A/B-assigned campaigns
7
+ * armed for this contact. EVERY in-app type is in
8
+ * here (modal, banner, spin_wheel, carousel_cards,
9
+ * sticky_bar, progress_bar, coachmark_tour, etc.).
10
+ * • `inbox` — first page + unread count for the notification
11
+ * drawer; lets AegisInbox hydrate without a second
12
+ * round-trip.
13
+ * • `etag` — content-hashed, stable when state is unchanged;
14
+ * 304 responses cost ~50ms and consume no body.
15
+ * • `invalidation_topic` — SSE channel name the cell-plane publishes
16
+ * to when a playbook arms a campaign mid-session.
17
+ * The SDK does NOT open SSE on that topic today —
18
+ * we rely on the 5-minute poll + an explicit
19
+ * `refresh()` hook that app code (AegisInAppManager,
20
+ * AegisInbox) call on relevant user actions.
21
+ *
22
+ * This is the cornerstone of the preload-first contract from
23
+ * docs/architecture/IN_APP_MESSAGES_EXPANSION_PLAN.md §1. The render
24
+ * path must NEVER hit the network at trigger time — the bundle is
25
+ * populated at init, and everything renders from memory.
26
+ */
27
+ export interface PrefetchBundleCampaign {
28
+ id: string;
29
+ type: string;
30
+ sub_type?: string;
31
+ title: string;
32
+ body: string;
33
+ image_url?: string;
34
+ action_url?: string;
35
+ button_text?: string;
36
+ background_color?: string;
37
+ text_color?: string;
38
+ priority: number;
39
+ expires_at?: string | null;
40
+ frequency?: {
41
+ max_impressions?: number;
42
+ max_impressions_per_day?: number;
43
+ cooldown_seconds?: number;
44
+ };
45
+ interactive_config?: Record<string, unknown>;
46
+ client_trigger?: {
47
+ type: string;
48
+ config?: Record<string, unknown>;
49
+ };
50
+ assigned_variant_id?: string;
51
+ inbox_enabled?: boolean;
52
+ }
53
+ export interface PrefetchBundleInboxEntry {
54
+ id: string;
55
+ source: string;
56
+ campaign_id: string | null;
57
+ title: string;
58
+ body: string;
59
+ media_url: string | null;
60
+ cta_url: string | null;
61
+ metadata: Record<string, unknown> | null;
62
+ read: boolean;
63
+ read_at: string | null;
64
+ created_at: string | null;
65
+ expires_at: string | null;
66
+ }
67
+ export interface PrefetchBundleInbox {
68
+ unread_count: number;
69
+ page: PrefetchBundleInboxEntry[];
70
+ cursor: string | null;
71
+ }
72
+ export interface PrefetchBundle {
73
+ etag: string;
74
+ generated_at: string;
75
+ ttl_seconds: number;
76
+ invalidation_topic: string;
77
+ campaigns: PrefetchBundleCampaign[];
78
+ inbox: PrefetchBundleInbox;
79
+ }
80
+ export interface PrefetchBundleContext {
81
+ device_type?: string;
82
+ page_url?: string;
83
+ geo?: string;
84
+ is_new_user?: boolean;
85
+ }
86
+ export interface PrefetchBundleClientOptions {
87
+ apiHost: string;
88
+ writeKey: string;
89
+ organizationId?: string;
90
+ contactId?: string;
91
+ userId?: string;
92
+ propertyId?: string;
93
+ /** Cached AB assignments from localStorage, base64-json. */
94
+ abAssignments?: Record<string, string>;
95
+ /** Polling cadence; defaults to the bundle's own `ttl_seconds` (300s). */
96
+ pollIntervalMs?: number;
97
+ /** Factory for client context — re-evaluated on each fetch so device/page
98
+ * state stays fresh without forcing callers to re-instantiate the client. */
99
+ contextProvider?: () => PrefetchBundleContext;
100
+ }
101
+ export type PrefetchBundleListener = (bundle: PrefetchBundle) => void;
102
+ export declare class PrefetchBundleClient {
103
+ private apiHost;
104
+ private writeKey;
105
+ private organizationId?;
106
+ private contactId?;
107
+ private userId?;
108
+ private propertyId?;
109
+ private abAssignments;
110
+ private pollIntervalMs;
111
+ private contextProvider;
112
+ private currentETag;
113
+ private currentBundle;
114
+ private pollTimer;
115
+ private listeners;
116
+ private inflightRefetch;
117
+ constructor(options: PrefetchBundleClientOptions);
118
+ /**
119
+ * Initial fetch + start the background ETag poll. Resolves to the bundle
120
+ * (or `null` if the first fetch failed — callers should fall back to an
121
+ * empty campaign list, not abort SDK init).
122
+ */
123
+ start(): Promise<PrefetchBundle | null>;
124
+ stop(): void;
125
+ getBundle(): PrefetchBundle | null;
126
+ getCampaigns(): PrefetchBundleCampaign[];
127
+ getInbox(): PrefetchBundleInbox;
128
+ /** Force a refresh (dedupes concurrent calls). Exposed so inbox mutations
129
+ * and campaign-activation SSE messages can trigger a refetch on demand. */
130
+ refresh(): Promise<PrefetchBundle | null>;
131
+ /** Subscribe to bundle changes (emits on first fetch + on any content
132
+ * change — ETag 304 does NOT fire the listener). Returns an unsubscribe. */
133
+ onChange(listener: PrefetchBundleListener): () => void;
134
+ /**
135
+ * Update the identity tuple — called by AegisInAppManager when the host
136
+ * app resolves a contactId post-init (e.g., after login). Triggers an
137
+ * immediate refresh since the eligible campaigns + inbox will differ.
138
+ */
139
+ updateIdentity(partial: {
140
+ contactId?: string;
141
+ userId?: string;
142
+ organizationId?: string;
143
+ propertyId?: string;
144
+ }): void;
145
+ /** Update cached AB assignments. Called by downstream renderers after
146
+ * they display a variant. Persisted to localStorage by higher layers. */
147
+ setAbAssignments(assignments: Record<string, string>): void;
148
+ private fetch;
149
+ }
150
+ //# sourceMappingURL=prefetch-bundle-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefetch-bundle-client.d.ts","sourceRoot":"","sources":["../../src/core/prefetch-bundle-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAA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e,CAA8B;IAErD,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,aAAa,CAA+B;IACpD,OAAO,CAAC,SAAS,CAA+C;IAChE,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,eAAe,CAA+C;gBAE1D,OAAO,EAAE,2BAA2B;IAYhD;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAQ7C,IAAI,IAAI,IAAI;IAOZ,SAAS,IAAI,cAAc,GAAG,IAAI;IAIlC,YAAY,IAAI,sBAAsB,EAAE;IAIxC,QAAQ,IAAI,mBAAmB;IAI/B;gFAC4E;IACtE,OAAO,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAU/C;iFAC6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,IAAI;IAQtD;;;;OAIG;IACH,cAAc,CAAC,OAAO,EAAE;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI;IA+BR;8EAC0E;IAC1E,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;YAM7C,KAAK;CAmEpB"}
@@ -37,6 +37,14 @@ export interface EventGovernanceHint {
37
37
  m: number;
38
38
  bloom_b64: string;
39
39
  remaining_new_names: number | null;
40
+ /**
41
+ * When true, the server is in its 7-day soft-cap grace window: it accepts
42
+ * novel event names past the cap. SDK must NOT drop locally in this mode —
43
+ * doing so would enforce harder than the server. See
44
+ * apps/control-plane/app/schemas/event_governance_hint.py for the canonical
45
+ * contract.
46
+ */
47
+ grace_active?: boolean;
40
48
  ttl_seconds: number;
41
49
  }
42
50
  export interface DropReport {
@@ -50,6 +58,7 @@ export interface DropReport {
50
58
  export declare class NameGovernor {
51
59
  private bloom;
52
60
  private remainingNewNames;
61
+ private graceActive;
53
62
  /**
54
63
  * Names this SDK instance has seen AS NOVEL and already charged against
55
64
  * `remainingNewNames`. Reset on every `ingestHint()` so we don't leak
@@ -83,6 +92,7 @@ export declare class NameGovernor {
83
92
  hasBloom: boolean;
84
93
  remaining: number;
85
94
  localNovel: number;
95
+ graceActive: boolean;
86
96
  };
87
97
  }
88
98
  //# sourceMappingURL=name-governor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"name-governor.d.ts","sourceRoot":"","sources":["../../src/governance/name-governor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,0DAA0D;AAC1D,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AAeD,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,iBAAiB,CAAoB;IAE7C;;;;OAIG;IACH,OAAO,CAAC,eAAe,CAA0B;IAEjD,4EAA4E;IAC5E,OAAO,CAAC,sBAAsB,CAAkC;IAChE,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,oBAAoB,CAAS;IAErC;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,GAAG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ACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,GAAG,IAAI;IA4BlD;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAqCtC;;;;OAIG;IACH,eAAe,IAAI,UAAU,GAAG,IAAI;IAkBpC,gBAAgB;IAChB,WAAW,IAAI;QACb,QAAQ,EAAE,OAAO,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,OAAO,CAAC;KACtB;CAQF"}
@@ -21,7 +21,7 @@
21
21
  */
22
22
  export interface InAppCampaign {
23
23
  id: string;
24
- type: 'modal' | 'banner' | 'tooltip' | 'full_screen' | 'half_interstitial' | 'alert' | 'pip';
24
+ type: 'modal' | 'banner' | 'tooltip' | 'full_screen' | 'half_interstitial' | 'alert' | 'pip' | 'carousel_cards' | 'sticky_bar' | 'progress_bar' | 'coachmark_tour' | 'product_recommendation';
25
25
  sub_type?: string;
26
26
  title: string;
27
27
  body: string;
@@ -84,7 +84,32 @@ export declare class AegisInAppManager {
84
84
  private processABAssignments;
85
85
  private getVariantId;
86
86
  private tryDisplayNextCampaign;
87
+ /**
88
+ * Evaluate the currently armed campaigns against a client-side event
89
+ * and render any that match their `client_trigger`.
90
+ *
91
+ * Called by the host app (e.g., the EcommerceTracker on product_viewed),
92
+ * or by future TriggerEngine bridges. Safe to call repeatedly for the
93
+ * same event — dedup happens via `displayedCampaigns`.
94
+ *
95
+ * Supported trigger types (align with the cell-plane server-side
96
+ * `display_rules.trigger_type`):
97
+ * - `custom_event` : fire when eventName matches config.event
98
+ * - `product_match` : fire on `product_viewed` when eventData.product_id
99
+ * matches config.product_id (string or string[])
100
+ * - `delay` : client-side setTimeout — evaluated at armeng
101
+ * time (kicked off from `displayCampaign`), not here.
102
+ */
103
+ onClientEvent(eventName: string, eventData?: Record<string, unknown>): void;
104
+ private matchesClientTrigger;
87
105
  private displayCampaign;
106
+ /**
107
+ * Build the shared context passed into the preload-first renderers.
108
+ * Matches the interface in `./renderers/types.ts`. Kept as a private
109
+ * method (rather than inlined at each call-site) so future renderer
110
+ * additions stay consistent and easy to audit.
111
+ */
112
+ private buildRenderContext;
88
113
  /**
89
114
  * Renders interactive sub-type campaigns (spin wheel, NPS, quiz, etc.)
90
115
  * using DOM-safe rendering. These sub-types use the campaign's
@@ -1 +1 @@
1
- {"version":3,"file":"AegisInAppManager.d.ts","sourceRoot":"","sources":["../../src/inapp/AegisInAppManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa,GAAG,mBAAmB,GAAG,OAAO,GAAG,KAAK,CAAC;IAC7F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE;QACV,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,cAAc,CAAC,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OA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AO,CAAC,YAAY;IAiHpB,OAAO,CAAC,WAAW;IAkHnB,OAAO,CAAC,gBAAgB;IA6GxB,OAAO,CAAC,sBAAsB;IAyH9B,OAAO,CAAC,WAAW;IAwGnB,OAAO,CAAC,SAAS;IAiHjB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,aAAa;IA8IrB,OAAO,CAAC,kBAAkB;IA6C1B,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,aAAa;IAqBrB;;;;;;;;;;;OAWG;YACW,UAAU;IA+CxB,OAAO,CAAC,GAAG;IAMX,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;CA2BpD"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * CarouselCards renderer — a swipeable / autoplaying sequence of product
3
+ * cards. Used for post-purchase upsells, cross-sell, and "recently viewed"
4
+ * surfaces. The entire card list is pre-bundled — no network call on
5
+ * trigger; slide advance is pure client state.
6
+ *
7
+ * Data shape (interactive_config, populated at campaign create time and
8
+ * validated server-side):
9
+ * cards: Array<{ image_url?, title, body?, cta_text?, cta_url? }>
10
+ * autoplay_ms?: number // 0 = manual advance only
11
+ * loop?: boolean // wrap to card 0 on last-next
12
+ */
13
+ import type { RenderContext } from './types';
14
+ export declare function renderCarouselCards(ctx: RenderContext): void;
15
+ //# sourceMappingURL=carousel-cards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carousel-cards.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/carousel-cards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAY7C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CA4L5D"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * CoachmarkTour renderer — a guided, multi-step walkthrough anchored to
3
+ * DOM elements via CSS selectors. One tooltip appears at a time with
4
+ * next/back navigation; completion + skip are persisted per contact via
5
+ * localStorage under the `resume_key`, so an abandoned tour resumes on
6
+ * the next visit instead of restarting or re-bothering the user.
7
+ *
8
+ * interactive_config:
9
+ * steps: Array<{
10
+ * anchor_web?: string, // CSS selector for THIS platform
11
+ * anchor_android?: string, // ignored on web
12
+ * anchor_ios?: string, // ignored on web
13
+ * title: string,
14
+ * body: string,
15
+ * placement?: 'top' | 'bottom' | 'left' | 'right',
16
+ * cta_text?: string,
17
+ * }>
18
+ * resume_key: string,
19
+ * allow_skip?: boolean,
20
+ * show_progress_dots?: boolean,
21
+ */
22
+ import type { RenderContext } from './types';
23
+ export declare function renderCoachmarkTour(ctx: RenderContext): void;
24
+ //# sourceMappingURL=coachmark-tour.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coachmark-tour.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/coachmark-tour.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA6C7C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CA0M5D"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Barrel for the 5 preload-first renderers. These are pure DOM-mutation
3
+ * functions that operate on a shared `RenderContext` — they never do
4
+ * network I/O at render time, consistent with the preload-first contract.
5
+ */
6
+ export type { RenderContext, Renderer } from './types';
7
+ export { renderCarouselCards } from './carousel-cards';
8
+ export { renderStickyBar } from './sticky-bar';
9
+ export { renderProgressBar } from './progress-bar';
10
+ export { renderCoachmarkTour } from './coachmark-tour';
11
+ export { renderProductRecommendation } from './product-recommendation';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * ProductRecommendation renderer — personalized product grid/row rendered
3
+ * from `interactive_config.cards[]` that the cell-plane populated at
4
+ * bundle-assembly time. The SDK never calls a product-API at render
5
+ * time — the preload contract is that the recommended products are
6
+ * already in the bundle.
7
+ *
8
+ * The layout is narrower than the generic carousel because product recs
9
+ * should feel like a first-class product grid, not a marketing slider.
10
+ * Three layouts: grid (2-col / 3-col responsive), row (horizontal-scroll),
11
+ * carousel (same as carousel_cards but different framing copy).
12
+ *
13
+ * interactive_config:
14
+ * rec_source?: 'viewed' | 'abandoned' | 'cross_sell' | 'trending' | 'personalized'
15
+ * (metadata only — the actual product list is in `cards[]`)
16
+ * rec_count?: number (display hint; rendering is driven by cards.length)
17
+ * rec_layout?: 'grid' | 'row' | 'carousel' default 'grid'
18
+ * rec_cta_text?: string default 'Shop now'
19
+ * cards: Array<{ image_url?, title?, body?, cta_url?, metadata? }>
20
+ */
21
+ import type { RenderContext } from './types';
22
+ export declare function renderProductRecommendation(ctx: RenderContext): void;
23
+ //# sourceMappingURL=product-recommendation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-recommendation.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/product-recommendation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAa7C,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAyKpE"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * ProgressBar renderer — a persistent bar that shows the user's progress
3
+ * toward a reward threshold (free shipping, loyalty tier, referral bonus).
4
+ *
5
+ * Two sources of the current value:
6
+ * 'client' — cheap: read from window.Shopify / WooCommerce / Magento
7
+ * cart globals. Untrusted; fine for visual-only hints.
8
+ * 'sse' — trusted: cell-plane pushes current_value via SSE to the
9
+ * already-shipped realtime server. For cart-gated rewards
10
+ * (must agree with server-side checkout guard), prefer SSE.
11
+ *
12
+ * For Phase 1 we implement CLIENT mode end-to-end. SSE mode reads
13
+ * `window.__aegisProgressSSE[campaign.id]` if populated by a parent app
14
+ * — higher-level integration (the SSE bridge) can push values there.
15
+ *
16
+ * interactive_config:
17
+ * progress_goal_type: 'cart_total' | 'items_in_cart' | 'loyalty_points' | 'referrals'
18
+ * progress_threshold: number
19
+ * progress_reward_text?: string
20
+ * progress_source?: 'client' | 'sse' default 'client'
21
+ */
22
+ import type { RenderContext } from './types';
23
+ export declare function renderProgressBar(ctx: RenderContext): void;
24
+ //# sourceMappingURL=progress-bar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-bar.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/progress-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAgJ1D"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * StickyBar renderer — a pinned notification strip at the top or bottom
3
+ * of the viewport. Used for free-shipping hints, flash-sale banners,
4
+ * cart-reminder strips. Dismissible, optionally auto-hiding.
5
+ *
6
+ * interactive_config:
7
+ * sticky_position: 'top' | 'bottom' (required)
8
+ * sticky_bg_color?: string
9
+ * sticky_dismissible?: boolean default true
10
+ * sticky_auto_hide_ms?: number 0 = never
11
+ */
12
+ import type { RenderContext } from './types';
13
+ export declare function renderStickyBar(ctx: RenderContext): void;
14
+ //# sourceMappingURL=sticky-bar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sticky-bar.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/sticky-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAO7C,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CA2GxD"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Preload-first renderer types — the 5 display types added in Phase 0
3
+ * of the In-App Messages Expansion Plan (carousel_cards, sticky_bar,
4
+ * progress_bar, coachmark_tour, product_recommendation).
5
+ *
6
+ * Each renderer is a pure function over a `RenderContext` so that the
7
+ * main `AegisInAppManager` class does not grow unbounded. Render paths
8
+ * never do network I/O — everything they need is already in the
9
+ * campaign payload from the prefetch bundle.
10
+ */
11
+ import type { InAppCampaign } from '../AegisInAppManager';
12
+ export interface RenderContext {
13
+ campaign: InAppCampaign;
14
+ /** Track impression/click/dismiss via navigator.sendBeacon-capable writer. */
15
+ trackEvent: (campaignId: string, eventType: 'impression' | 'clicked' | 'dismissed') => void;
16
+ /** Null-safe URL hardener — rejects javascript:/data: */
17
+ sanitizeUrl: (url: string) => string | null;
18
+ /** Only accept #hex / rgb() / rgba() / named tokens — everything else returns the default. */
19
+ sanitizeColor: (color: string) => string;
20
+ /** Debug logger — forwarded to the manager's logger. */
21
+ log: (msg: string, level?: 'log' | 'warn' | 'error') => void;
22
+ /** Lazily inject the shared keyframes. */
23
+ addAnimationStyles: () => void;
24
+ }
25
+ /** Renderer signature — side-effectful DOM mutation, no return. */
26
+ export type Renderer = (ctx: RenderContext) => void;
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/inapp/renderers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,aAAa,CAAC;IACxB,8EAA8E;IAC9E,UAAU,EAAE,CACV,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,YAAY,GAAG,SAAS,GAAG,WAAW,KAC9C,IAAI,CAAC;IACV,yDAAyD;IACzD,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC5C,8FAA8F;IAC9F,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,wDAAwD;IACxD,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,KAAK,IAAI,CAAC;IAC7D,0CAA0C;IAC1C,kBAAkB,EAAE,MAAM,IAAI,CAAC;CAChC;AAED,mEAAmE;AACnE,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * AegisInbox — client-side App Inbox (Message Center).
3
+ *
4
+ * Backs the notification drawer on actii.me WebView and every tenant
5
+ * storefront that embeds the Web SDK. Operates against cell-plane's
6
+ * /v1/in-app/inbox family of endpoints (list, unread-count, read,
7
+ * dismiss, read-all).
8
+ *
9
+ * Design choices:
10
+ * • Hydrate from the prefetch bundle at init — no extra HTTP on first
11
+ * paint. PrefetchBundleClient seeds us; we then own the live copy.
12
+ * • Mutations are optimistic + beacon-backed. Read / dismiss writes to
13
+ * local state immediately, then POSTs with `keepalive: true` so an
14
+ * in-flight dismiss survives page unload.
15
+ * • Badge polling uses the tiny `/unread-count` endpoint on a 60-second
16
+ * cadence — matches the `inbox_poll_interval_ms` from sdk_config's
17
+ * TransportConfig.hybrid mode.
18
+ * • No external dependencies; IndexedDB is optional (we gracefully fall
19
+ * back to in-memory when unavailable, e.g., in private browsing).
20
+ */
21
+ import type { PrefetchBundleClient } from '../core/prefetch-bundle-client';
22
+ export interface AegisInboxEntry {
23
+ id: string;
24
+ source: string;
25
+ campaign_id: string | null;
26
+ title: string;
27
+ body: string;
28
+ media_url: string | null;
29
+ cta_url: string | null;
30
+ metadata: Record<string, unknown> | null;
31
+ read: boolean;
32
+ read_at: string | null;
33
+ dismissed_at?: string | null;
34
+ created_at: string | null;
35
+ expires_at: string | null;
36
+ }
37
+ export interface AegisInboxConfig {
38
+ apiHost: string;
39
+ writeKey: string;
40
+ organizationId?: string;
41
+ contactId?: string;
42
+ propertyId?: string;
43
+ bundleClient?: PrefetchBundleClient;
44
+ unreadPollIntervalMs?: number;
45
+ }
46
+ export type InboxListener = (state: {
47
+ entries: AegisInboxEntry[];
48
+ unreadCount: number;
49
+ }) => void;
50
+ export declare class AegisInbox {
51
+ private apiHost;
52
+ private writeKey;
53
+ private organizationId?;
54
+ private contactId?;
55
+ private propertyId?;
56
+ private bundleClient?;
57
+ private unreadPollIntervalMs;
58
+ private entries;
59
+ private unreadCount;
60
+ private cursor;
61
+ private listeners;
62
+ private pollTimer;
63
+ private bundleUnsub;
64
+ constructor(config: AegisInboxConfig);
65
+ /** Hydrate from bundle (if available), restore the IDB cache (if any),
66
+ * then start the background unread-count poll. */
67
+ initialize(): Promise<void>;
68
+ stop(): void;
69
+ /** Update identity after login / property switch. Clears the local
70
+ * inbox since it's intrinsically contact+property scoped. */
71
+ setIdentity(partial: {
72
+ contactId?: string;
73
+ propertyId?: string;
74
+ organizationId?: string;
75
+ }): void;
76
+ getEntries(): AegisInboxEntry[];
77
+ getUnreadCount(): number;
78
+ /** Pagination cursor (ISO-8601 timestamp of the oldest entry currently
79
+ * held). Pass it back via `loadMore()` to fetch older history. */
80
+ getCursor(): string | null;
81
+ /** Append one more page of older entries using the current cursor. */
82
+ loadMore(): Promise<void>;
83
+ onChange(l: InboxListener): () => void;
84
+ refreshList(): Promise<void>;
85
+ refreshUnreadCount(): Promise<void>;
86
+ markRead(messageId: string): Promise<void>;
87
+ dismiss(messageId: string): Promise<void>;
88
+ markAllRead(): Promise<void>;
89
+ private seedFromBundle;
90
+ private recomputeUnread;
91
+ private emit;
92
+ private headers;
93
+ /** Best-effort beacon-style POST. Uses `keepalive: true` so it survives
94
+ * a navigation away from the current page (e.g., user taps the CTA
95
+ * which takes them to another URL right after dismiss). */
96
+ private postBeacon;
97
+ private openDb;
98
+ private cacheKey;
99
+ private writeCache;
100
+ private readCache;
101
+ private clearCache;
102
+ }
103
+ //# sourceMappingURL=AegisInbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AegisInbox.d.ts","sourceRoot":"","sources":["../../src/inbox/AegisInbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAG3E,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAA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AAO,CAAC,IAAI,CAAC;IAuB/B,QAAQ,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,IAAI;IAQhC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B5B,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBnC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW1C,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYzC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBlC,OAAO,CAAC,cAAc;IAuBtB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,IAAI;IAWZ,OAAO,CAAC,OAAO;IAWf;;gEAE4D;YAC9C,UAAU;YAiBV,MAAM;IAmBpB,OAAO,CAAC,QAAQ;YAKF,UAAU;YAmBV,SAAS;YAmBT,UAAU;CAkBzB"}
@@ -0,0 +1,3 @@
1
+ export { AegisInbox } from './AegisInbox';
2
+ export type { AegisInboxConfig, AegisInboxEntry, InboxListener } from './AegisInbox';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/inbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.d.ts CHANGED
@@ -18,6 +18,10 @@ export { TriggerEngine } from './triggers';
18
18
  export type { TriggerRule, ScrollDepthConfig, TimeOnPageConfig, ExitIntentConfig, InactivityConfig, TriggerEvent, } from './triggers';
19
19
  export { SdkConfigPoller } from './core/sdk-config-poller';
20
20
  export type { SdkConfig, SdkConfigPollerOptions, ConfigChangeCallback } from './core/sdk-config-poller';
21
+ export { PrefetchBundleClient } from './core/prefetch-bundle-client';
22
+ export type { PrefetchBundle, PrefetchBundleCampaign, PrefetchBundleInbox, PrefetchBundleInboxEntry, PrefetchBundleClientOptions, PrefetchBundleContext, PrefetchBundleListener, } from './core/prefetch-bundle-client';
23
+ export { AegisInbox } from './inbox';
24
+ export type { AegisInboxConfig, AegisInboxEntry, InboxListener } from './inbox';
21
25
  export { AegisWebPush } from './push/AegisWebPush';
22
26
  export type { AegisWebPushConfig, AegisAPIClient, ContactIdentity, PushEventTracker, } from './push/AegisWebPush';
23
27
  export { bootstrap, readFirstPartyCookie, writeFirstPartyCookie, deriveDeviceFingerprint, BootstrapError, } from './core/bootstrap';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,QAAA,MAAM,KAAK,OAAc,CAAC;AAE1B,eAAe,KAAK,CAAC;AAErB,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5E,YAAY,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;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