@capivv/capacitor-sdk 0.1.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.
@@ -0,0 +1,9 @@
1
+ // Framework-specific components for Ionic
2
+ // These components require their respective framework dependencies
3
+ // and are distributed separately.
4
+ //
5
+ // For React: @capivv/capacitor-react
6
+ // For Angular: @capivv/capacitor-angular
7
+ // For Vue: @capivv/capacitor-vue
8
+ export {};
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,mEAAmE;AACnE,kCAAkC;AAClC,EAAE;AACF,qCAAqC;AACrC,yCAAyC;AACzC,iCAAiC"}
@@ -0,0 +1,327 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ /**
3
+ * Product type for purchases
4
+ */
5
+ export declare enum ProductType {
6
+ /** One-time purchase */
7
+ INAPP = "INAPP",
8
+ /** Subscription */
9
+ SUBSCRIPTION = "SUBSCRIPTION"
10
+ }
11
+ /**
12
+ * Purchase state
13
+ */
14
+ export declare enum PurchaseState {
15
+ PENDING = "PENDING",
16
+ PURCHASED = "PURCHASED",
17
+ FAILED = "FAILED"
18
+ }
19
+ /**
20
+ * Configuration options for initializing the SDK
21
+ */
22
+ export interface CapivvConfig {
23
+ /** Your Capivv public API key */
24
+ apiKey: string;
25
+ /** API endpoint URL (optional, defaults to production) */
26
+ apiUrl?: string;
27
+ /** Enable debug logging */
28
+ debug?: boolean;
29
+ }
30
+ /**
31
+ * User attributes for identification
32
+ */
33
+ export interface UserAttributes {
34
+ email?: string;
35
+ name?: string;
36
+ [key: string]: string | number | boolean | undefined;
37
+ }
38
+ /**
39
+ * A product available for purchase
40
+ */
41
+ export interface Product {
42
+ /** Product identifier */
43
+ identifier: string;
44
+ /** Display name */
45
+ title: string;
46
+ /** Product description */
47
+ description: string;
48
+ /** Formatted price string (e.g., "$9.99") */
49
+ priceString: string;
50
+ /** Price in minor units (cents) */
51
+ priceAmountMicros: number;
52
+ /** Currency code (e.g., "USD") */
53
+ currencyCode: string;
54
+ /** Product type */
55
+ productType: ProductType;
56
+ /** Subscription period (for subscriptions) */
57
+ subscriptionPeriod?: string;
58
+ /** Trial period (for subscriptions) */
59
+ trialPeriod?: string;
60
+ }
61
+ /**
62
+ * An entitlement granted to the user
63
+ */
64
+ export interface Entitlement {
65
+ /** Entitlement identifier */
66
+ identifier: string;
67
+ /** Whether the entitlement is currently active */
68
+ isActive: boolean;
69
+ /** When the entitlement expires (ISO date string) */
70
+ expiresAt?: string;
71
+ /** Product that granted this entitlement */
72
+ productIdentifier?: string;
73
+ }
74
+ /**
75
+ * A completed purchase transaction
76
+ */
77
+ export interface Transaction {
78
+ /** Transaction identifier */
79
+ transactionId: string;
80
+ /** Product identifier */
81
+ productIdentifier: string;
82
+ /** Purchase date (ISO string) */
83
+ purchaseDate: string;
84
+ /** Expiration date for subscriptions (ISO string) */
85
+ expirationDate?: string;
86
+ /** Current state of the purchase */
87
+ state: PurchaseState;
88
+ /** Whether the purchase is acknowledged */
89
+ isAcknowledged: boolean;
90
+ /** Receipt data (iOS) */
91
+ receipt?: string;
92
+ /** Purchase token (Android) */
93
+ purchaseToken?: string;
94
+ }
95
+ /**
96
+ * Offering containing products grouped for presentation
97
+ */
98
+ export interface Offering {
99
+ /** Offering identifier */
100
+ identifier: string;
101
+ /** Display description */
102
+ description?: string;
103
+ /** Products in this offering */
104
+ products: Product[];
105
+ /** Metadata from dashboard */
106
+ metadata?: Record<string, unknown>;
107
+ }
108
+ /**
109
+ * User information including entitlements
110
+ */
111
+ export interface UserInfo {
112
+ /** User identifier */
113
+ userId: string;
114
+ /** User's active entitlements */
115
+ entitlements: Entitlement[];
116
+ /** Original purchase date (subscriber since) */
117
+ originalPurchaseDate?: string;
118
+ /** Latest purchase date */
119
+ latestPurchaseDate?: string;
120
+ }
121
+ /**
122
+ * Result of checking if a feature is unlocked
123
+ */
124
+ export interface EntitlementCheckResult {
125
+ /** Whether the user has access */
126
+ hasAccess: boolean;
127
+ /** The entitlement if found */
128
+ entitlement?: Entitlement;
129
+ }
130
+ /**
131
+ * Result of a purchase operation
132
+ */
133
+ export interface PurchaseResult {
134
+ /** Whether the purchase succeeded */
135
+ success: boolean;
136
+ /** The transaction details */
137
+ transaction?: Transaction;
138
+ /** Error message if failed */
139
+ error?: string;
140
+ }
141
+ /**
142
+ * Event emitted when entitlements change
143
+ */
144
+ export interface EntitlementsUpdatedEvent {
145
+ entitlements: Entitlement[];
146
+ }
147
+ /**
148
+ * Event emitted when a purchase completes
149
+ */
150
+ export interface PurchaseCompletedEvent {
151
+ transaction: Transaction;
152
+ }
153
+ /**
154
+ * Event emitted when a purchase fails
155
+ */
156
+ export interface PurchaseFailedEvent {
157
+ productIdentifier: string;
158
+ error: string;
159
+ }
160
+ /**
161
+ * Capivv Plugin Interface
162
+ *
163
+ * The Capivv Capacitor plugin provides subscription management
164
+ * and in-app purchase functionality for iOS and Android.
165
+ */
166
+ export interface CapivvPlugin {
167
+ /**
168
+ * Configure and initialize the SDK.
169
+ * Must be called before any other methods.
170
+ *
171
+ * @param config - Configuration options
172
+ * @returns Promise that resolves when initialization is complete
173
+ */
174
+ configure(config: CapivvConfig): Promise<void>;
175
+ /**
176
+ * Identify the current user.
177
+ * Creates the user in Capivv if they don't exist.
178
+ *
179
+ * @param options - User identification options
180
+ * @returns Promise with user information
181
+ */
182
+ identify(options: {
183
+ userId: string;
184
+ attributes?: UserAttributes;
185
+ }): Promise<UserInfo>;
186
+ /**
187
+ * Log out the current user.
188
+ * Clears cached data and resets to anonymous state.
189
+ *
190
+ * @returns Promise that resolves when logout is complete
191
+ */
192
+ logout(): Promise<void>;
193
+ /**
194
+ * Get the current user's information.
195
+ *
196
+ * @returns Promise with user information
197
+ */
198
+ getUserInfo(): Promise<UserInfo>;
199
+ /**
200
+ * Check if billing is supported on this device.
201
+ *
202
+ * @returns Promise with billing support status
203
+ */
204
+ isBillingSupported(): Promise<{
205
+ isSupported: boolean;
206
+ }>;
207
+ /**
208
+ * Get available offerings.
209
+ * Offerings group products for presentation.
210
+ *
211
+ * @returns Promise with list of offerings
212
+ */
213
+ getOfferings(): Promise<{
214
+ offerings: Offering[];
215
+ }>;
216
+ /**
217
+ * Get a specific product by identifier.
218
+ *
219
+ * @param options - Product query options
220
+ * @returns Promise with product details
221
+ */
222
+ getProduct(options: {
223
+ productIdentifier: string;
224
+ productType?: ProductType;
225
+ }): Promise<{
226
+ product: Product;
227
+ }>;
228
+ /**
229
+ * Get multiple products by identifier.
230
+ *
231
+ * @param options - Products query options
232
+ * @returns Promise with product list
233
+ */
234
+ getProducts(options: {
235
+ productIdentifiers: string[];
236
+ productType?: ProductType;
237
+ }): Promise<{
238
+ products: Product[];
239
+ }>;
240
+ /**
241
+ * Purchase a product.
242
+ *
243
+ * @param options - Purchase options
244
+ * @returns Promise with purchase result
245
+ */
246
+ purchase(options: {
247
+ productIdentifier: string;
248
+ productType?: ProductType;
249
+ /** For subscription plan selection (Android) */
250
+ planIdentifier?: string;
251
+ /** Quantity for consumables */
252
+ quantity?: number;
253
+ }): Promise<PurchaseResult>;
254
+ /**
255
+ * Restore previous purchases.
256
+ * Useful for users who reinstall the app or switch devices.
257
+ *
258
+ * @returns Promise with restored entitlements
259
+ */
260
+ restorePurchases(): Promise<{
261
+ entitlements: Entitlement[];
262
+ }>;
263
+ /**
264
+ * Check if the user has access to a specific entitlement.
265
+ *
266
+ * @param options - Entitlement check options
267
+ * @returns Promise with access status
268
+ */
269
+ checkEntitlement(options: {
270
+ entitlementIdentifier: string;
271
+ }): Promise<EntitlementCheckResult>;
272
+ /**
273
+ * Get all active entitlements for the current user.
274
+ *
275
+ * @returns Promise with active entitlements
276
+ */
277
+ getEntitlements(): Promise<{
278
+ entitlements: Entitlement[];
279
+ }>;
280
+ /**
281
+ * Sync purchases with the server.
282
+ * Call this after app launch to ensure entitlements are up to date.
283
+ *
284
+ * @returns Promise with synced entitlements
285
+ */
286
+ syncPurchases(): Promise<{
287
+ entitlements: Entitlement[];
288
+ }>;
289
+ /**
290
+ * Present the platform-specific subscription management UI.
291
+ * On iOS, opens the App Store subscription management.
292
+ * On Android, opens Google Play subscription management.
293
+ *
294
+ * @returns Promise that resolves when management UI is shown
295
+ */
296
+ manageSubscriptions(): Promise<void>;
297
+ /**
298
+ * Listen for entitlement updates.
299
+ *
300
+ * @param eventName - Event name
301
+ * @param listenerFunc - Callback function
302
+ * @returns Promise with listener handle for removal
303
+ */
304
+ addListener(eventName: 'entitlementsUpdated', listenerFunc: (event: EntitlementsUpdatedEvent) => void): Promise<PluginListenerHandle>;
305
+ /**
306
+ * Listen for purchase completion.
307
+ *
308
+ * @param eventName - Event name
309
+ * @param listenerFunc - Callback function
310
+ * @returns Promise with listener handle for removal
311
+ */
312
+ addListener(eventName: 'purchaseCompleted', listenerFunc: (event: PurchaseCompletedEvent) => void): Promise<PluginListenerHandle>;
313
+ /**
314
+ * Listen for purchase failures.
315
+ *
316
+ * @param eventName - Event name
317
+ * @param listenerFunc - Callback function
318
+ * @returns Promise with listener handle for removal
319
+ */
320
+ addListener(eventName: 'purchaseFailed', listenerFunc: (event: PurchaseFailedEvent) => void): Promise<PluginListenerHandle>;
321
+ /**
322
+ * Remove all listeners for this plugin.
323
+ *
324
+ * @returns Promise that resolves when listeners are removed
325
+ */
326
+ removeAllListeners(): Promise<void>;
327
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Product type for purchases
3
+ */
4
+ export var ProductType;
5
+ (function (ProductType) {
6
+ /** One-time purchase */
7
+ ProductType["INAPP"] = "INAPP";
8
+ /** Subscription */
9
+ ProductType["SUBSCRIPTION"] = "SUBSCRIPTION";
10
+ })(ProductType || (ProductType = {}));
11
+ /**
12
+ * Purchase state
13
+ */
14
+ export var PurchaseState;
15
+ (function (PurchaseState) {
16
+ PurchaseState["PENDING"] = "PENDING";
17
+ PurchaseState["PURCHASED"] = "PURCHASED";
18
+ PurchaseState["FAILED"] = "FAILED";
19
+ })(PurchaseState || (PurchaseState = {}));
20
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,wBAAwB;IACxB,8BAAe,CAAA;IACf,mBAAmB;IACnB,4CAA6B,CAAA;AAC/B,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,wCAAuB,CAAA;IACvB,kCAAiB,CAAA;AACnB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB"}
@@ -0,0 +1,7 @@
1
+ import type { CapivvPlugin } from './definitions';
2
+ declare const Capivv: CapivvPlugin;
3
+ export * from './definitions';
4
+ export { Capivv };
5
+ export type { TemplateDefinition, TemplateSettings, TemplateComponent, ComponentType, ComponentProps, BackgroundStyle, FeatureItem, FAQItem, CarouselItem, TemplateLoadResult, } from './templates/types';
6
+ export { l10n, CapivvL10n } from './l10n/translations';
7
+ export type { SupportedLocale, CapivvStrings } from './l10n/translations';
@@ -0,0 +1,10 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const Capivv = registerPlugin('Capivv', {
3
+ web: () => import('./web').then((m) => new m.CapivvWeb()),
4
+ });
5
+ // Core exports
6
+ export * from './definitions';
7
+ export { Capivv };
8
+ // Localization
9
+ export { l10n, CapivvL10n } from './l10n/translations';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,MAAM,GAAG,cAAc,CAAe,QAAQ,EAAE;IACpD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;CAC1D,CAAC,CAAC;AAEH,eAAe;AACf,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC;AAgBlB,eAAe;AACf,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Capivv SDK Localization
3
+ *
4
+ * Provides localized strings for the Capivv SDK UI components.
5
+ */
6
+ export type SupportedLocale = 'en' | 'es' | 'fr' | 'de' | 'ja' | 'zh' | 'pt' | 'it';
7
+ export interface CapivvStrings {
8
+ 'common.continue': string;
9
+ 'common.cancel': string;
10
+ 'common.close': string;
11
+ 'common.done': string;
12
+ 'common.loading': string;
13
+ 'common.processing': string;
14
+ 'common.error': string;
15
+ 'common.success': string;
16
+ 'common.tryAgain': string;
17
+ 'paywall.restore': string;
18
+ 'paywall.restoring': string;
19
+ 'paywall.purchasing': string;
20
+ 'paywall.startTrial': string;
21
+ 'paywall.then': string;
22
+ 'paywall.perMonth': string;
23
+ 'paywall.perYear': string;
24
+ 'paywall.perWeek': string;
25
+ 'paywall.bestValue': string;
26
+ 'paywall.mostPopular': string;
27
+ 'paywall.save': string;
28
+ 'paywall.freeTrialIncluded': string;
29
+ 'paywall.termsAndPrivacy': string;
30
+ 'paywall.legalDisclaimer': string;
31
+ 'paywall.unlockPremium': string;
32
+ 'paywall.noProductsAvailable': string;
33
+ 'error.unableToLoad': string;
34
+ 'error.purchaseFailed': string;
35
+ 'error.restoreFailed': string;
36
+ 'error.networkError': string;
37
+ 'error.somethingWentWrong': string;
38
+ 'error.dismiss': string;
39
+ 'error.failedToLoadOfferings': string;
40
+ 'faq.title': string;
41
+ 'socialProof.rating': string;
42
+ 'socialProof.reviews': string;
43
+ 'socialProof.downloads': string;
44
+ 'countdown.days': string;
45
+ 'countdown.hours': string;
46
+ 'countdown.minutes': string;
47
+ 'countdown.seconds': string;
48
+ }
49
+ /**
50
+ * Capivv L10n helper
51
+ */
52
+ declare class CapivvL10n {
53
+ private locale;
54
+ constructor(locale?: SupportedLocale);
55
+ /**
56
+ * Get a localized string by key
57
+ */
58
+ get(key: keyof CapivvStrings): string;
59
+ /**
60
+ * Get a formatted string with placeholder replacement
61
+ */
62
+ format(key: keyof CapivvStrings, ...args: (string | number)[]): string;
63
+ /**
64
+ * Set the locale
65
+ */
66
+ setLocale(locale: SupportedLocale): void;
67
+ /**
68
+ * Get the current locale
69
+ */
70
+ getLocale(): SupportedLocale;
71
+ }
72
+ export declare const l10n: CapivvL10n;
73
+ export { CapivvL10n };