@appfunnel-dev/sdk 0.5.0 → 0.7.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.
- package/dist/chunk-EVUYCLVY.cjs +1326 -0
- package/dist/chunk-EVUYCLVY.cjs.map +1 -0
- package/dist/chunk-H3KHXZSI.js +1321 -0
- package/dist/chunk-H3KHXZSI.js.map +1 -0
- package/dist/chunk-P4SLDMWY.js +104 -0
- package/dist/chunk-P4SLDMWY.js.map +1 -0
- package/dist/chunk-XP44I2MU.cjs +108 -0
- package/dist/chunk-XP44I2MU.cjs.map +1 -0
- package/dist/elements/index.cjs +12172 -0
- package/dist/elements/index.cjs.map +1 -0
- package/dist/elements/index.d.cts +602 -0
- package/dist/elements/index.d.ts +602 -0
- package/dist/elements/index.js +12137 -0
- package/dist/elements/index.js.map +1 -0
- package/dist/index.cjs +590 -371
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +132 -14
- package/dist/index.d.ts +132 -14
- package/dist/index.js +555 -355
- package/dist/index.js.map +1 -1
- package/dist/internal-C7seLJBr.d.cts +516 -0
- package/dist/internal-C7seLJBr.d.ts +516 -0
- package/dist/internal.cjs +5 -1196
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +2 -204
- package/dist/internal.d.ts +2 -204
- package/dist/internal.js +1 -1199
- package/dist/internal.js.map +1 -1
- package/package.json +17 -2
- package/dist/types-ChorYUCl.d.cts +0 -255
- package/dist/types-ChorYUCl.d.ts +0 -255
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type VariableType = 'string' | 'number' | 'boolean' | 'stringArray';
|
|
4
|
+
type VariableValue = string | number | boolean | string[] | null | undefined;
|
|
5
|
+
interface AppFunnelConfig {
|
|
6
|
+
projectId?: string;
|
|
7
|
+
/** Funnel ID — set automatically on first publish. */
|
|
8
|
+
funnelId?: string;
|
|
9
|
+
name: string;
|
|
10
|
+
/** Page key to start on. Defaults to first entry in `pages`. */
|
|
11
|
+
initialPageKey?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Response variables — user answers to quiz/survey questions.
|
|
14
|
+
* Stored internally as `answers.<key>`.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* responses: {
|
|
18
|
+
* goal: { type: 'string', default: '' },
|
|
19
|
+
* age_range: { type: 'string' },
|
|
20
|
+
* interests: { type: 'stringArray', default: [] },
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
responses?: Record<string, VariableConfig>;
|
|
25
|
+
/**
|
|
26
|
+
* Query param variables — captured from the URL at runtime.
|
|
27
|
+
* Stored internally as `query.<key>`.
|
|
28
|
+
* Listed here so the CLI build can emit them for analytics/database.
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* queryParams: {
|
|
32
|
+
* utm_source: { type: 'string' },
|
|
33
|
+
* utm_medium: { type: 'string' },
|
|
34
|
+
* ref: { type: 'string' },
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
queryParams?: Record<string, VariableConfig>;
|
|
39
|
+
/**
|
|
40
|
+
* Data variables — arbitrary runtime state (not user answers or query params).
|
|
41
|
+
* Stored internally as `data.<key>`.
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* data: {
|
|
45
|
+
* selectedPlanTier: { type: 'string', default: 'free' },
|
|
46
|
+
* hasSeenOnboarding: { type: 'boolean', default: false },
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
data?: Record<string, VariableConfig>;
|
|
51
|
+
/** Default locale for translations. Defaults to 'en'. */
|
|
52
|
+
defaultLocale?: string;
|
|
53
|
+
products?: ProductsConfig;
|
|
54
|
+
settings?: FunnelSettings;
|
|
55
|
+
/**
|
|
56
|
+
* Integration configs (Meta Pixel, GTM, Clarity, etc.).
|
|
57
|
+
* Loaded from the API at runtime — the CLI build injects these
|
|
58
|
+
* from the project's dashboard settings.
|
|
59
|
+
*/
|
|
60
|
+
integrations?: Record<string, Record<string, unknown>>;
|
|
61
|
+
/**
|
|
62
|
+
* Pages and routes can be defined here OR via `definePage()` in each page file.
|
|
63
|
+
* When using `definePage()`, the CLI build collects page definitions from the
|
|
64
|
+
* filesystem and merges them into the final config. These fields are populated
|
|
65
|
+
* by the build step — you don't need to set them manually.
|
|
66
|
+
*/
|
|
67
|
+
pages?: Record<string, PageConfig>;
|
|
68
|
+
routes?: Record<string, RouteConfig[]>;
|
|
69
|
+
}
|
|
70
|
+
type PageType = 'default' | 'checkout' | 'finish' | 'auth' | 'paywall' | 'upsell';
|
|
71
|
+
interface PageConfig {
|
|
72
|
+
name: string;
|
|
73
|
+
type: PageType;
|
|
74
|
+
/** URL slug for this page. Used for deep links, browser history, and reload persistence.
|
|
75
|
+
* Defaults to the page key (filename) if not specified. */
|
|
76
|
+
slug?: string;
|
|
77
|
+
}
|
|
78
|
+
interface RouteConfig {
|
|
79
|
+
to: string;
|
|
80
|
+
when?: ConditionConfig | ConditionGroupConfig;
|
|
81
|
+
}
|
|
82
|
+
interface PageDefinition {
|
|
83
|
+
/** Display name shown in analytics and dashboard */
|
|
84
|
+
name: string;
|
|
85
|
+
/** Page type — determines behavior (e.g. checkout pages trigger payment flow) */
|
|
86
|
+
type?: PageType;
|
|
87
|
+
/** URL slug for this page. Defaults to the page key (filename) if not specified.
|
|
88
|
+
* Used for deep links, browser history (pushState), and reload persistence. */
|
|
89
|
+
slug?: string;
|
|
90
|
+
/** Routes from this page. Evaluated in order; first match wins. */
|
|
91
|
+
routes?: RouteConfig[];
|
|
92
|
+
}
|
|
93
|
+
interface ConditionConfig {
|
|
94
|
+
variable: string;
|
|
95
|
+
equals?: VariableValue;
|
|
96
|
+
notEquals?: VariableValue;
|
|
97
|
+
contains?: string;
|
|
98
|
+
greaterThan?: number;
|
|
99
|
+
lessThan?: number;
|
|
100
|
+
exists?: boolean;
|
|
101
|
+
isEmpty?: boolean;
|
|
102
|
+
includes?: string;
|
|
103
|
+
}
|
|
104
|
+
interface ConditionGroupConfig {
|
|
105
|
+
operator: 'AND' | 'OR';
|
|
106
|
+
rules: (ConditionConfig | ConditionGroupConfig)[];
|
|
107
|
+
}
|
|
108
|
+
interface VariableConfig {
|
|
109
|
+
type: VariableType;
|
|
110
|
+
default?: VariableValue;
|
|
111
|
+
persist?: boolean;
|
|
112
|
+
}
|
|
113
|
+
interface ProductsConfig {
|
|
114
|
+
items: ProductConfig[];
|
|
115
|
+
defaultId?: string;
|
|
116
|
+
}
|
|
117
|
+
interface ProductConfig {
|
|
118
|
+
id: string;
|
|
119
|
+
name: string;
|
|
120
|
+
storePriceId: string;
|
|
121
|
+
trialDays?: number;
|
|
122
|
+
trialStorePriceId?: string;
|
|
123
|
+
}
|
|
124
|
+
interface FunnelSettings {
|
|
125
|
+
[key: string]: unknown;
|
|
126
|
+
}
|
|
127
|
+
interface RuntimeProduct {
|
|
128
|
+
id: string;
|
|
129
|
+
name: string;
|
|
130
|
+
price: string;
|
|
131
|
+
rawPrice: number;
|
|
132
|
+
monthlyPrice: string;
|
|
133
|
+
dailyPrice: string;
|
|
134
|
+
weeklyPrice: string;
|
|
135
|
+
yearlyPrice: string;
|
|
136
|
+
period: string;
|
|
137
|
+
periodly: string;
|
|
138
|
+
currencyCode: string;
|
|
139
|
+
currencySymbol: string;
|
|
140
|
+
hasTrial: boolean;
|
|
141
|
+
trialDays: number;
|
|
142
|
+
trialPrice: string;
|
|
143
|
+
paidTrial: boolean;
|
|
144
|
+
trialRawPrice: number;
|
|
145
|
+
trialDailyPrice: string;
|
|
146
|
+
trialCurrencyCode: string;
|
|
147
|
+
trialStorePriceId: string;
|
|
148
|
+
storePriceId: string;
|
|
149
|
+
stripePriceId: string;
|
|
150
|
+
stripeProductId: string;
|
|
151
|
+
paddlePriceId: string;
|
|
152
|
+
paddleProductId: string;
|
|
153
|
+
displayName: string;
|
|
154
|
+
periodDays: number;
|
|
155
|
+
periodMonths: number;
|
|
156
|
+
periodWeeks: number;
|
|
157
|
+
}
|
|
158
|
+
interface PageState {
|
|
159
|
+
key: string;
|
|
160
|
+
name: string;
|
|
161
|
+
type: string;
|
|
162
|
+
slug: string;
|
|
163
|
+
index: number;
|
|
164
|
+
}
|
|
165
|
+
interface Progress {
|
|
166
|
+
current: number;
|
|
167
|
+
total: number;
|
|
168
|
+
percentage: number;
|
|
169
|
+
}
|
|
170
|
+
/** Enriched price data from API (matches getFunnelByIdentifier response) */
|
|
171
|
+
interface EnrichedPriceData {
|
|
172
|
+
amount: number;
|
|
173
|
+
currency: string;
|
|
174
|
+
interval: string | null;
|
|
175
|
+
intervalCount: number | null;
|
|
176
|
+
stripePriceId?: string;
|
|
177
|
+
stripeProductId?: string;
|
|
178
|
+
paddlePriceId?: string;
|
|
179
|
+
paddleProductId?: string;
|
|
180
|
+
displayName?: string;
|
|
181
|
+
priceName?: string;
|
|
182
|
+
name?: string;
|
|
183
|
+
}
|
|
184
|
+
/** Hook return types */
|
|
185
|
+
interface TranslationState {
|
|
186
|
+
/** Translate a key, with optional interpolation: t('welcome', { name: 'John' }) */
|
|
187
|
+
t: (key: string, params?: Record<string, string | number>) => string;
|
|
188
|
+
/** Current locale code */
|
|
189
|
+
locale: string;
|
|
190
|
+
/** Switch locale at runtime */
|
|
191
|
+
setLocale: (locale: string) => void;
|
|
192
|
+
/** List of locales that have translations loaded */
|
|
193
|
+
availableLocales: string[];
|
|
194
|
+
}
|
|
195
|
+
interface LocaleState {
|
|
196
|
+
/** Full locale string, e.g. 'en-US' */
|
|
197
|
+
locale: string;
|
|
198
|
+
/** Language code, e.g. 'en' */
|
|
199
|
+
language: string;
|
|
200
|
+
/** Region code, e.g. 'US' */
|
|
201
|
+
region: string;
|
|
202
|
+
/** All preferred languages from navigator.languages */
|
|
203
|
+
languages: string[];
|
|
204
|
+
/** IANA timezone, e.g. 'America/New_York' */
|
|
205
|
+
timeZone: string;
|
|
206
|
+
/** Whether the locale uses 24-hour clock */
|
|
207
|
+
is24Hour: boolean;
|
|
208
|
+
}
|
|
209
|
+
interface UserState {
|
|
210
|
+
email: string;
|
|
211
|
+
name: string;
|
|
212
|
+
stripeCustomerId: string;
|
|
213
|
+
paddleCustomerId: string;
|
|
214
|
+
dateOfBirth: string;
|
|
215
|
+
/** Set email (does NOT fire identify — use tracking.identify() explicitly) */
|
|
216
|
+
setEmail: (email: string) => void;
|
|
217
|
+
setName: (name: string) => void;
|
|
218
|
+
setDateOfBirth: (dateOfBirth: string) => void;
|
|
219
|
+
}
|
|
220
|
+
interface NavigationState {
|
|
221
|
+
goToNextPage: () => void;
|
|
222
|
+
goBack: () => void;
|
|
223
|
+
goToPage: (pageKey: string) => void;
|
|
224
|
+
currentPage: PageState | null;
|
|
225
|
+
pageHistory: string[];
|
|
226
|
+
progress: Progress;
|
|
227
|
+
}
|
|
228
|
+
interface ProductsState {
|
|
229
|
+
products: RuntimeProduct[];
|
|
230
|
+
selected: RuntimeProduct | null;
|
|
231
|
+
select: (productId: string) => void;
|
|
232
|
+
}
|
|
233
|
+
interface TrackingState {
|
|
234
|
+
track: (eventName: string, data?: Record<string, unknown>) => void;
|
|
235
|
+
identify: (email: string) => void;
|
|
236
|
+
}
|
|
237
|
+
interface PaymentState {
|
|
238
|
+
customerId: string | null;
|
|
239
|
+
isAuthorized: boolean;
|
|
240
|
+
loading: boolean;
|
|
241
|
+
error: string | null;
|
|
242
|
+
cardDetails: {
|
|
243
|
+
last4: string;
|
|
244
|
+
brand: string;
|
|
245
|
+
expMonth: number;
|
|
246
|
+
expYear: number;
|
|
247
|
+
} | null;
|
|
248
|
+
}
|
|
249
|
+
interface DeviceInfo {
|
|
250
|
+
os: {
|
|
251
|
+
name: string;
|
|
252
|
+
timezone: string;
|
|
253
|
+
};
|
|
254
|
+
device: {
|
|
255
|
+
type: string;
|
|
256
|
+
isMobile: boolean;
|
|
257
|
+
isTablet: boolean;
|
|
258
|
+
screenWidth: number;
|
|
259
|
+
screenHeight: number;
|
|
260
|
+
viewportWidth: number;
|
|
261
|
+
viewportHeight: number;
|
|
262
|
+
colorDepth: number;
|
|
263
|
+
pixelRatio: number;
|
|
264
|
+
};
|
|
265
|
+
browser: {
|
|
266
|
+
name: string;
|
|
267
|
+
version: string;
|
|
268
|
+
userAgent: string;
|
|
269
|
+
cookieEnabled: boolean;
|
|
270
|
+
online: boolean;
|
|
271
|
+
language: string;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
interface PageData {
|
|
275
|
+
currentId: string;
|
|
276
|
+
currentIndex: number;
|
|
277
|
+
current: number;
|
|
278
|
+
total: number;
|
|
279
|
+
progressPercentage: number;
|
|
280
|
+
startedAt: number;
|
|
281
|
+
}
|
|
282
|
+
interface FunnelState {
|
|
283
|
+
funnelId: string;
|
|
284
|
+
campaignId: string;
|
|
285
|
+
sessionId: string | null;
|
|
286
|
+
variables: Record<string, VariableValue>;
|
|
287
|
+
user: UserState;
|
|
288
|
+
responses: Record<string, VariableValue>;
|
|
289
|
+
queryParams: Record<string, string>;
|
|
290
|
+
navigation: NavigationState;
|
|
291
|
+
products: ProductsState;
|
|
292
|
+
tracking: TrackingState;
|
|
293
|
+
payment: PaymentState;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
declare class VariableStore {
|
|
297
|
+
private state;
|
|
298
|
+
private listeners;
|
|
299
|
+
/** Tracks which keys changed in the last mutation — used by scoped notify */
|
|
300
|
+
private changedKeys;
|
|
301
|
+
constructor(initial: Record<string, VariableValue>);
|
|
302
|
+
getState(): Record<string, VariableValue>;
|
|
303
|
+
get(key: string): VariableValue;
|
|
304
|
+
set(key: string, value: VariableValue): void;
|
|
305
|
+
setState(updater: (prev: Record<string, VariableValue>) => Record<string, VariableValue>): void;
|
|
306
|
+
/** Batch set multiple variables at once */
|
|
307
|
+
setMany(updates: Record<string, VariableValue>): void;
|
|
308
|
+
/**
|
|
309
|
+
* Subscribe to store changes.
|
|
310
|
+
*
|
|
311
|
+
* @param listener - callback fired when relevant keys change
|
|
312
|
+
* @param scope - optional scope to limit notifications:
|
|
313
|
+
* - `{ keys: ['data.x', 'user.email'] }` — only fire when these exact keys change
|
|
314
|
+
* - `{ prefix: 'answers.' }` — only fire when any key starting with this prefix changes
|
|
315
|
+
* - omit or `{}` — fire on every change (global listener)
|
|
316
|
+
*/
|
|
317
|
+
subscribe(listener: () => void, scope?: {
|
|
318
|
+
keys?: string[];
|
|
319
|
+
prefix?: string;
|
|
320
|
+
}): () => void;
|
|
321
|
+
private notify;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
interface RouterOptions {
|
|
325
|
+
config: AppFunnelConfig;
|
|
326
|
+
/** Override the initial page (from URL deep link or config) */
|
|
327
|
+
initialPage?: string;
|
|
328
|
+
/** Base path for URL updates, e.g. '/f/my-campaign' */
|
|
329
|
+
basePath?: string;
|
|
330
|
+
/** Campaign slug — used to check session cookies for deep-link gating */
|
|
331
|
+
campaignSlug?: string;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Router — observable page state machine for funnel navigation.
|
|
335
|
+
*
|
|
336
|
+
* Subscribable so React components can re-render on page changes
|
|
337
|
+
* via useSyncExternalStore.
|
|
338
|
+
*/
|
|
339
|
+
declare class Router {
|
|
340
|
+
private config;
|
|
341
|
+
private pageKeys;
|
|
342
|
+
private history;
|
|
343
|
+
private currentKey;
|
|
344
|
+
private initialKey;
|
|
345
|
+
private listeners;
|
|
346
|
+
readonly basePath: string;
|
|
347
|
+
constructor(options: RouterOptions);
|
|
348
|
+
private hasSessionCookie;
|
|
349
|
+
subscribe(listener: () => void): () => void;
|
|
350
|
+
private notify;
|
|
351
|
+
/** Snapshot key for useSyncExternalStore — changes on every navigation. */
|
|
352
|
+
getSnapshot(): string;
|
|
353
|
+
getCurrentPage(): PageState | null;
|
|
354
|
+
/** Build the full URL path for a page key. */
|
|
355
|
+
getPageUrl(pageKey: string): string;
|
|
356
|
+
/** Resolve a page key from a URL slug. */
|
|
357
|
+
resolveSlug(slug: string): string | null;
|
|
358
|
+
getPageHistory(): string[];
|
|
359
|
+
getProgress(): Progress;
|
|
360
|
+
/**
|
|
361
|
+
* Evaluate routes for the current page and navigate to the first matching target.
|
|
362
|
+
* Returns the new page key, or null if no route matched.
|
|
363
|
+
*/
|
|
364
|
+
goToNextPage(variables: Record<string, VariableValue>): string | null;
|
|
365
|
+
/** Navigate to a specific page by key. */
|
|
366
|
+
goToPage(pageKey: string): string | null;
|
|
367
|
+
/** Go back to the previous page in history. */
|
|
368
|
+
goBack(): string | null;
|
|
369
|
+
/** Set the current page directly (used for deep-link/reload restore). */
|
|
370
|
+
setCurrentPage(pageKey: string): void;
|
|
371
|
+
private navigateTo;
|
|
372
|
+
private calculateExpectedPathLength;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Funnel Tracker — handles event tracking, session management, and attribution.
|
|
377
|
+
* Forked from admin/lib/funnel/tracking.ts — simplified for headless SDK.
|
|
378
|
+
*/
|
|
379
|
+
interface FunnelEventDataMap {
|
|
380
|
+
'funnel.start': Record<string, never>;
|
|
381
|
+
'page.view': {
|
|
382
|
+
pageId: string;
|
|
383
|
+
pageKey?: string;
|
|
384
|
+
pageName?: string;
|
|
385
|
+
isInitial?: boolean;
|
|
386
|
+
};
|
|
387
|
+
'page.exit': {
|
|
388
|
+
pageId: string;
|
|
389
|
+
durationMs: number;
|
|
390
|
+
activeMs: number;
|
|
391
|
+
};
|
|
392
|
+
'user.registered': {
|
|
393
|
+
email: string;
|
|
394
|
+
};
|
|
395
|
+
'checkout.start': {
|
|
396
|
+
productId?: string;
|
|
397
|
+
priceId: string;
|
|
398
|
+
productName?: string;
|
|
399
|
+
};
|
|
400
|
+
'checkout.payment_added': Record<string, never>;
|
|
401
|
+
'purchase.complete': {
|
|
402
|
+
amount?: number;
|
|
403
|
+
currency?: string;
|
|
404
|
+
email?: string;
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
type KnownFunnelEvent = keyof FunnelEventDataMap;
|
|
408
|
+
declare class FunnelTracker {
|
|
409
|
+
private campaignId;
|
|
410
|
+
private funnelId;
|
|
411
|
+
private campaignSlug;
|
|
412
|
+
private sessionId;
|
|
413
|
+
private experimentId;
|
|
414
|
+
private initialized;
|
|
415
|
+
private customerId;
|
|
416
|
+
private adAttribution;
|
|
417
|
+
private currentPageId;
|
|
418
|
+
private pageStartTime;
|
|
419
|
+
private pageActiveTime;
|
|
420
|
+
private lastActiveStart;
|
|
421
|
+
private isPageVisible;
|
|
422
|
+
private variablePersistence;
|
|
423
|
+
constructor();
|
|
424
|
+
init(campaignId: string, funnelId: string, campaignSlug?: string, experimentId?: string | null): void;
|
|
425
|
+
getSessionId(): string | null;
|
|
426
|
+
getCustomerId(): string | null;
|
|
427
|
+
setSessionId(sessionId: string): void;
|
|
428
|
+
private persistSessionId;
|
|
429
|
+
track<E extends KnownFunnelEvent>(event: E, data?: FunnelEventDataMap[E], userData?: Record<string, unknown>): Promise<string>;
|
|
430
|
+
track(event: string, data?: Record<string, unknown>, userData?: Record<string, unknown>): Promise<string>;
|
|
431
|
+
/** Identify a user by email — fires user.registered event */
|
|
432
|
+
identify(email: string): Promise<void>;
|
|
433
|
+
updateUserData(userData: Record<string, unknown>): Promise<void>;
|
|
434
|
+
setCurrentVariables(variables: Record<string, unknown>): void;
|
|
435
|
+
flushVariables(): Promise<void>;
|
|
436
|
+
startPageTracking(pageId: string): void;
|
|
437
|
+
stopPageTracking(): void;
|
|
438
|
+
private calculateActiveTime;
|
|
439
|
+
private handleVisibilityChange;
|
|
440
|
+
private handleBeforeUnload;
|
|
441
|
+
private cleanupPageTracking;
|
|
442
|
+
reset(): void;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Lightweight i18n runtime.
|
|
447
|
+
*
|
|
448
|
+
* Translations are flat or nested JSON objects per locale:
|
|
449
|
+
* { "en": { "welcome": "Hello, {{name}}" }, "de": { "welcome": "Hallo, {{name}}" } }
|
|
450
|
+
*
|
|
451
|
+
* The CLI build reads `locales/*.json` and passes them to FunnelProvider.
|
|
452
|
+
*/
|
|
453
|
+
type TranslationMap = Record<string, Record<string, string>>;
|
|
454
|
+
declare class I18n {
|
|
455
|
+
private translations;
|
|
456
|
+
private locale;
|
|
457
|
+
private fallbackLocale;
|
|
458
|
+
private listeners;
|
|
459
|
+
constructor(defaultLocale?: string);
|
|
460
|
+
/** Load all translations at once */
|
|
461
|
+
load(translations: TranslationMap): void;
|
|
462
|
+
getLocale(): string;
|
|
463
|
+
setLocale(locale: string): void;
|
|
464
|
+
getAvailableLocales(): string[];
|
|
465
|
+
/**
|
|
466
|
+
* Translate a key with optional interpolation.
|
|
467
|
+
*
|
|
468
|
+
* Supports dot notation for nested keys and `{{var}}` interpolation:
|
|
469
|
+
* t('checkout.title')
|
|
470
|
+
* t('welcome', { name: 'John' }) → "Hello, John"
|
|
471
|
+
*/
|
|
472
|
+
t(key: string, params?: Record<string, string | number>): string;
|
|
473
|
+
subscribe(listener: () => void): () => void;
|
|
474
|
+
private resolve;
|
|
475
|
+
private notify;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
interface FunnelContextValue {
|
|
479
|
+
config: AppFunnelConfig;
|
|
480
|
+
variableStore: VariableStore;
|
|
481
|
+
router: Router;
|
|
482
|
+
tracker: FunnelTracker;
|
|
483
|
+
i18n: I18n;
|
|
484
|
+
products: RuntimeProduct[];
|
|
485
|
+
selectedProductId: string | null;
|
|
486
|
+
selectProduct: (productId: string) => void;
|
|
487
|
+
funnelId: string;
|
|
488
|
+
campaignId: string;
|
|
489
|
+
sessionId: string | null;
|
|
490
|
+
}
|
|
491
|
+
interface FunnelProviderProps {
|
|
492
|
+
config: AppFunnelConfig;
|
|
493
|
+
children: React.ReactNode;
|
|
494
|
+
/** Pre-fetched session data (from API) */
|
|
495
|
+
sessionData?: {
|
|
496
|
+
sessionId?: string;
|
|
497
|
+
campaignId: string;
|
|
498
|
+
funnelId: string;
|
|
499
|
+
variables?: Record<string, VariableValue>;
|
|
500
|
+
customerId?: string;
|
|
501
|
+
experimentId?: string | null;
|
|
502
|
+
};
|
|
503
|
+
/** Pre-fetched enriched price data map: storePriceId → price data */
|
|
504
|
+
priceData?: Map<string, EnrichedPriceData>;
|
|
505
|
+
/** Campaign slug for session cookies and URL routing */
|
|
506
|
+
campaignSlug?: string;
|
|
507
|
+
/** Base path for URL updates, e.g. '/f/my-campaign' */
|
|
508
|
+
basePath?: string;
|
|
509
|
+
/** Override the initial page (e.g. from URL slug on reload/deep link) */
|
|
510
|
+
initialPage?: string;
|
|
511
|
+
/** Translations map: { "en": { "key": "value" }, "de": { "key": "wert" } } */
|
|
512
|
+
translations?: TranslationMap;
|
|
513
|
+
}
|
|
514
|
+
declare function FunnelProvider({ config, children, sessionData, priceData, campaignSlug, basePath, initialPage, translations, }: FunnelProviderProps): react_jsx_runtime.JSX.Element;
|
|
515
|
+
|
|
516
|
+
export { type AppFunnelConfig as A, type ConditionConfig as C, type DeviceInfo as D, type FunnelState as F, type LocaleState as L, type NavigationState as N, type PageDefinition as P, type RouteConfig as R, type TranslationState as T, type UserState as U, type VariableValue as V, type ProductsState as a, type TrackingState as b, type PaymentState as c, type PageData as d, type ConditionGroupConfig as e, FunnelProvider as f, type FunnelProviderProps as g, type FunnelSettings as h, type PageConfig as i, type PageState as j, type PageType as k, type ProductConfig as l, type ProductsConfig as m, type Progress as n, type RuntimeProduct as o, type VariableConfig as p, type VariableType as q, type FunnelContextValue as r, type TranslationMap as s };
|