@encorekit/capacitor 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,23 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "EncorekitCapacitor"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => "15.0" }
14
+ s.source = { :git => "https://github.com/EncoreKit/capacitor-sdk.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/Sources/**/*.{swift,h,m}"
17
+
18
+ ios_version = package["sdkVersions"]["ios"]["EncoreKit"]
19
+ s.dependency "Capacitor"
20
+ s.dependency "EncoreKit", ios_version
21
+
22
+ s.swift_version = "5.9"
23
+ end
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # @encorekit/capacitor
2
+
3
+ Encore Capacitor bridge — thin native plugin layer delegating to encore-swift-sdk (iOS) and encore-android-sdk (Android).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @encorekit/capacitor
9
+ npx cap sync
10
+ ```
11
+
12
+ Both SPM (default) and CocoaPods are supported for iOS. No additional configuration needed.
13
+
14
+ ## Usage
15
+
16
+ ```typescript
17
+ import Encore from '@encorekit/capacitor';
18
+
19
+ // 1. Configure (once, early in app lifecycle)
20
+ await Encore.configure('your-api-key', { logLevel: 'debug' });
21
+
22
+ // 2. Register callbacks (before showing placements)
23
+ await Encore.registerCallbacks();
24
+
25
+ Encore.onPurchaseRequest(async (event) => {
26
+ console.log('Purchase requested:', event.productId);
27
+ // Handle purchase with your billing provider...
28
+ await Encore.completePurchaseRequest(true);
29
+ });
30
+
31
+ Encore.onPurchaseComplete((event) => {
32
+ console.log('Purchase complete:', event);
33
+ });
34
+
35
+ Encore.onPassthrough((event) => {
36
+ console.log('Passthrough:', event);
37
+ });
38
+
39
+ // 3. Identify user
40
+ await Encore.identify('user-123', {
41
+ email: 'user@example.com',
42
+ subscriptionTier: 'free',
43
+ });
44
+
45
+ // 4. Show placement
46
+ const result = await Encore.placement('onboarding').show();
47
+ if (result.status === 'granted') {
48
+ console.log('Offer granted!');
49
+ }
50
+
51
+ // 5. Reset on logout
52
+ await Encore.reset();
53
+ ```
54
+
55
+ ## API Reference
56
+
57
+ | Method | Description |
58
+ |:-------|:------------|
59
+ | `configure(apiKey, options?)` | Initialize SDK with API key |
60
+ | `identify(userId, attributes?)` | Associate user identity |
61
+ | `setUserAttributes(attributes)` | Update user attributes |
62
+ | `reset()` | Clear user data (logout) |
63
+ | `placement(id).show()` | Present offer placement |
64
+ | `placements.setClaimEnabled(enabled)` | Control claim button |
65
+ | `registerCallbacks()` | Register native event handlers |
66
+ | `completePurchaseRequest(success)` | Complete pending purchase |
67
+ | `onPurchaseRequest(handler)` | Listen for purchase requests |
68
+ | `onPurchaseComplete(handler)` | Listen for purchase completions |
69
+ | `onPassthrough(handler)` | Listen for passthrough events |
70
+
71
+ ## Types
72
+
73
+ ```typescript
74
+ interface UserAttributes {
75
+ email?: string;
76
+ firstName?: string;
77
+ lastName?: string;
78
+ // ... 16 more optional fields
79
+ custom?: Record<string, string>;
80
+ }
81
+
82
+ interface PlacementResult {
83
+ status: 'granted' | 'not_granted' | 'completed' | 'dismissed' | 'no_offers';
84
+ reason?: string;
85
+ entitlement?: string;
86
+ offerId?: string;
87
+ campaignId?: string;
88
+ }
89
+ ```
90
+
91
+ ## Platform Support
92
+
93
+ | Platform | Min Version | Native SDK |
94
+ |:---------|:-----------|:-----------|
95
+ | iOS | 14.0 | EncoreKit (CocoaPods) |
96
+ | Android | API 22 | com.encorekit:encore (Maven Central) |
97
+ | Web | N/A | Noop fallback with warnings |
@@ -0,0 +1,85 @@
1
+ import groovy.json.JsonSlurper
2
+
3
+ def packageJson = new JsonSlurper().parseText(file("$projectDir/../package.json").text)
4
+ def encoreAndroidVersion = packageJson.sdkVersions.android["com.encorekit:encore"]
5
+
6
+ ext {
7
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
8
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
9
+ }
10
+
11
+ buildscript {
12
+ repositories {
13
+ google()
14
+ mavenCentral()
15
+ }
16
+
17
+ dependencies {
18
+ classpath "com.android.tools.build:gradle:8.2.2"
19
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24"
20
+ }
21
+ }
22
+
23
+ repositories {
24
+ google()
25
+ mavenCentral()
26
+ }
27
+
28
+ apply plugin: "com.android.library"
29
+ apply plugin: "kotlin-android"
30
+
31
+ android {
32
+ namespace "com.encorekit.capacitor"
33
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
34
+
35
+ defaultConfig {
36
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 26
37
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
38
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
39
+ }
40
+
41
+ buildTypes {
42
+ release {
43
+ minifyEnabled false
44
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
45
+ }
46
+ }
47
+
48
+ compileOptions {
49
+ sourceCompatibility JavaVersion.VERSION_17
50
+ targetCompatibility JavaVersion.VERSION_17
51
+ }
52
+
53
+ kotlinOptions {
54
+ jvmTarget = "17"
55
+ }
56
+ }
57
+
58
+ dependencies {
59
+ // Capacitor core — host app provides at runtime
60
+ implementation project(':capacitor-android')
61
+
62
+ // AppCompatActivity — required by Capacitor Plugin base class.
63
+ // compileOnly: host app provides at runtime (avoid version conflict).
64
+ compileOnly "androidx.appcompat:appcompat:$androidxAppCompatVersion"
65
+
66
+ // Encore native Android SDK — we own this version.
67
+ // Exclude kotlin-stdlib to avoid conflicts with the host app's Kotlin version.
68
+ // Keep kotlin-reflect — Moshi needs it at runtime for JSON parsing.
69
+ implementation("com.encorekit:encore:${encoreAndroidVersion}") {
70
+ exclude module: 'kotlin-stdlib'
71
+ exclude module: 'kotlin-stdlib-jdk7'
72
+ exclude module: 'kotlin-stdlib-jdk8'
73
+ }
74
+
75
+ // Bridge uses coroutines for async calls to native SDK.
76
+ // Exclude the entire org.jetbrains.kotlin group so the host app's
77
+ // Kotlin version always wins.
78
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1") {
79
+ exclude group: 'org.jetbrains.kotlin'
80
+ }
81
+
82
+ // Test
83
+ testImplementation "junit:junit:$junitVersion"
84
+ androidTestImplementation "androidx.test.ext:junit:1.1.5"
85
+ }
@@ -0,0 +1 @@
1
+ EncoreCapacitorPlugin_kotlinVersion=1.9.24
@@ -0,0 +1 @@
1
+ rootProject.name = 'encore-capacitor'
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.encorekit.capacitor">
3
+ </manifest>
@@ -0,0 +1,225 @@
1
+ // EncoreCapacitorPlugin.kt
2
+ // Android bridge — delegates all calls to the native encore-android-sdk.
3
+
4
+ package com.encorekit.capacitor
5
+
6
+ import com.encorekit.encore.Encore
7
+ import com.encorekit.encore.core.canonical.user.UserAttributes
8
+ import com.encorekit.encore.core.infrastructure.logging.LogLevel
9
+ import com.getcapacitor.JSObject
10
+ import com.getcapacitor.Plugin
11
+ import com.getcapacitor.PluginCall
12
+ import com.getcapacitor.PluginMethod
13
+ import com.getcapacitor.annotation.CapacitorPlugin
14
+ import kotlinx.coroutines.CompletableDeferred
15
+ import kotlinx.coroutines.CoroutineScope
16
+ import kotlinx.coroutines.Dispatchers
17
+ import kotlinx.coroutines.SupervisorJob
18
+ import kotlinx.coroutines.launch
19
+
20
+ @CapacitorPlugin(name = "EncoreCapacitorPlugin")
21
+ class EncoreCapacitorPlugin : Plugin() {
22
+
23
+ private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
24
+ @Volatile private var currentDeferred: CompletableDeferred<Boolean>? = null
25
+
26
+ // -- Configuration --
27
+
28
+ @PluginMethod
29
+ fun configure(call: PluginCall) {
30
+ val apiKey = call.getString("apiKey")
31
+ if (apiKey == null) {
32
+ call.reject("Missing required parameter: apiKey")
33
+ return
34
+ }
35
+
36
+ val logLevel = when (call.getString("logLevel")) {
37
+ "error" -> LogLevel.ERROR
38
+ "warn" -> LogLevel.WARN
39
+ "info" -> LogLevel.INFO
40
+ "debug" -> LogLevel.DEBUG
41
+ else -> LogLevel.NONE
42
+ }
43
+
44
+ Encore.shared.configure(context, apiKey = apiKey, logLevel = logLevel)
45
+ call.resolve(JSObject().put("success", true))
46
+ }
47
+
48
+ // -- User Identity --
49
+
50
+ @PluginMethod
51
+ fun identify(call: PluginCall) {
52
+ val userId = call.getString("userId")
53
+ if (userId == null) {
54
+ call.reject("Missing required parameter: userId")
55
+ return
56
+ }
57
+
58
+ Encore.shared.identify(userId = userId, attributes = parseAttributes(call))
59
+ call.resolve(JSObject().put("success", true))
60
+ }
61
+
62
+ @PluginMethod
63
+ fun setUserAttributes(call: PluginCall) {
64
+ parseAttributes(call)?.let { Encore.shared.setUserAttributes(it) }
65
+ call.resolve(JSObject().put("success", true))
66
+ }
67
+
68
+ @PluginMethod
69
+ fun reset(call: PluginCall) {
70
+ Encore.shared.reset()
71
+ call.resolve(JSObject().put("success", true))
72
+ }
73
+
74
+ // -- Claim Control --
75
+
76
+ @PluginMethod
77
+ fun setClaimEnabled(call: PluginCall) {
78
+ val enabled = call.getBoolean("enabled")
79
+ if (enabled == null) {
80
+ call.reject("Missing required parameter: enabled")
81
+ return
82
+ }
83
+
84
+ Encore.shared.placements.isClaimEnabled = enabled
85
+ call.resolve(JSObject().put("success", true))
86
+ }
87
+
88
+ // -- Offers --
89
+
90
+ @PluginMethod
91
+ fun show(call: PluginCall) {
92
+ val placementId = call.getString("placementId") ?: ""
93
+ val activity = activity
94
+ if (activity == null) {
95
+ call.reject("NO_ACTIVITY", "No current activity available")
96
+ return
97
+ }
98
+
99
+ scope.launch {
100
+ try {
101
+ val result = Encore.shared.placement(placementId).show(activity)
102
+ val obj = JSObject()
103
+ when (result) {
104
+ is com.encorekit.encore.features.offers.PresentationResult.Completed -> {
105
+ obj.put("status", "completed")
106
+ obj.put("offerId", result.offerId)
107
+ obj.put("campaignId", result.campaignId)
108
+ }
109
+ is com.encorekit.encore.features.offers.PresentationResult.Dismissed -> {
110
+ obj.put("status", "dismissed")
111
+ obj.put("reason", result.reason.value)
112
+ }
113
+ is com.encorekit.encore.features.offers.PresentationResult.NoOffers -> {
114
+ obj.put("status", "no_offers")
115
+ }
116
+ }
117
+ call.resolve(obj)
118
+ } catch (e: Exception) {
119
+ call.reject("SHOW_FAILED", e.message, e)
120
+ }
121
+ }
122
+ }
123
+
124
+ // -- Callbacks --
125
+
126
+ @PluginMethod
127
+ fun registerCallbacks(call: PluginCall) {
128
+ Encore.shared
129
+ .onPurchaseRequest { request ->
130
+ // Fail stale deferred so the previous purchase flow resolves
131
+ currentDeferred?.complete(false)
132
+
133
+ val deferred = CompletableDeferred<Boolean>()
134
+ currentDeferred = deferred
135
+
136
+ try {
137
+ notifyListeners("onPurchaseRequest", JSObject().apply {
138
+ put("productId", request.productId)
139
+ put("placementId", request.placementId)
140
+ put("promoOfferId", request.promoOfferId)
141
+ })
142
+ } catch (_: Exception) {
143
+ // notifyListeners can throw during context teardown — safe to ignore
144
+ }
145
+
146
+ val success = deferred.await()
147
+ currentDeferred = null
148
+
149
+ if (!success) {
150
+ throw Exception("Purchase failed by JS handler")
151
+ }
152
+ }
153
+ .onPurchaseComplete { result, productId ->
154
+ notifyListeners("onPurchaseComplete", JSObject().apply {
155
+ put("productId", productId)
156
+ put("purchaseToken", result.purchaseToken)
157
+ put("orderId", result.orderId)
158
+ })
159
+ }
160
+ .onPassthrough { placementId ->
161
+ notifyListeners("onPassthrough", JSObject().apply {
162
+ put("placementId", placementId)
163
+ })
164
+ }
165
+
166
+ call.resolve(JSObject().put("success", true))
167
+ }
168
+
169
+ @PluginMethod
170
+ fun completePurchaseRequest(call: PluginCall) {
171
+ val success = call.getBoolean("success") ?: false
172
+ val deferred = currentDeferred
173
+ if (deferred != null) {
174
+ deferred.complete(success)
175
+ call.resolve(JSObject().put("success", true))
176
+ } else {
177
+ call.resolve(JSObject().apply {
178
+ put("success", false)
179
+ put("error", "No pending purchase request")
180
+ })
181
+ }
182
+ }
183
+
184
+ // -- Helpers --
185
+
186
+ private fun parseAttributes(call: PluginCall): UserAttributes? {
187
+ val obj = call.getObject("attributes") ?: return null
188
+ return UserAttributes(
189
+ email = obj.optString("email", null),
190
+ firstName = obj.optString("firstName", null),
191
+ lastName = obj.optString("lastName", null),
192
+ phoneNumber = obj.optString("phoneNumber", null),
193
+ postalCode = obj.optString("postalCode", null),
194
+ city = obj.optString("city", null),
195
+ state = obj.optString("state", null),
196
+ countryCode = obj.optString("countryCode", null),
197
+ latitude = obj.optString("latitude", null),
198
+ longitude = obj.optString("longitude", null),
199
+ dateOfBirth = obj.optString("dateOfBirth", null),
200
+ gender = obj.optString("gender", null),
201
+ language = obj.optString("language", null),
202
+ subscriptionTier = obj.optString("subscriptionTier", null),
203
+ monthsSubscribed = obj.optString("monthsSubscribed", null),
204
+ billingCycle = obj.optString("billingCycle", null),
205
+ lastPaymentAmount = obj.optString("lastPaymentAmount", null),
206
+ lastActiveDate = obj.optString("lastActiveDate", null),
207
+ totalSessions = obj.optString("totalSessions", null),
208
+ custom = parseCustomMap(obj),
209
+ )
210
+ }
211
+
212
+ private fun parseCustomMap(obj: org.json.JSONObject): Map<String, String> {
213
+ val customObj = obj.optJSONObject("custom") ?: return emptyMap()
214
+ val result = mutableMapOf<String, String>()
215
+ val keys = customObj.keys()
216
+ while (keys.hasNext()) {
217
+ val key = keys.next()
218
+ val value = customObj.optString(key, null)
219
+ if (value != null) {
220
+ result[key] = value
221
+ }
222
+ }
223
+ return result
224
+ }
225
+ }
@@ -0,0 +1,126 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
3
+ export interface UserAttributes {
4
+ email?: string;
5
+ firstName?: string;
6
+ lastName?: string;
7
+ phoneNumber?: string;
8
+ postalCode?: string;
9
+ city?: string;
10
+ state?: string;
11
+ countryCode?: string;
12
+ latitude?: string;
13
+ longitude?: string;
14
+ dateOfBirth?: string;
15
+ gender?: string;
16
+ language?: string;
17
+ subscriptionTier?: string;
18
+ monthsSubscribed?: string;
19
+ billingCycle?: string;
20
+ lastPaymentAmount?: string;
21
+ lastActiveDate?: string;
22
+ totalSessions?: string;
23
+ custom?: Record<string, string>;
24
+ }
25
+ export interface PlacementResult {
26
+ status: 'granted' | 'not_granted' | 'completed' | 'dismissed' | 'no_offers';
27
+ reason?: string;
28
+ entitlement?: string;
29
+ offerId?: string;
30
+ campaignId?: string;
31
+ }
32
+ export interface PurchaseRequestEvent {
33
+ productId: string;
34
+ placementId?: string;
35
+ promoOfferId?: string;
36
+ }
37
+ export interface PurchaseCompleteEvent {
38
+ productId: string;
39
+ transactionId?: string;
40
+ purchaseToken?: string;
41
+ orderId?: string;
42
+ }
43
+ export interface PassthroughEvent {
44
+ placementId?: string;
45
+ }
46
+ export interface EncorePlugin {
47
+ configure(options: {
48
+ apiKey: string;
49
+ logLevel?: LogLevel;
50
+ }): Promise<{
51
+ success: boolean;
52
+ }>;
53
+ identify(options: {
54
+ userId: string;
55
+ attributes?: UserAttributes;
56
+ }): Promise<{
57
+ success: boolean;
58
+ }>;
59
+ setUserAttributes(options: {
60
+ attributes: UserAttributes;
61
+ }): Promise<{
62
+ success: boolean;
63
+ }>;
64
+ reset(): Promise<{
65
+ success: boolean;
66
+ }>;
67
+ show(options: {
68
+ placementId: string;
69
+ }): Promise<PlacementResult>;
70
+ setClaimEnabled(options: {
71
+ enabled: boolean;
72
+ }): Promise<{
73
+ success: boolean;
74
+ }>;
75
+ registerCallbacks(): Promise<{
76
+ success: boolean;
77
+ }>;
78
+ completePurchaseRequest(options: {
79
+ success: boolean;
80
+ }): Promise<{
81
+ success: boolean;
82
+ }>;
83
+ addListener(eventName: 'onPurchaseRequest', handler: (event: PurchaseRequestEvent) => void): Promise<PluginListenerHandle>;
84
+ addListener(eventName: 'onPurchaseComplete', handler: (event: PurchaseCompleteEvent) => void): Promise<PluginListenerHandle>;
85
+ addListener(eventName: 'onPassthrough', handler: (event: PassthroughEvent) => void): Promise<PluginListenerHandle>;
86
+ removeAllListeners(): Promise<void>;
87
+ }
88
+ export interface ConfigureOptions {
89
+ logLevel?: LogLevel;
90
+ }
91
+ export interface PlacementBuilder {
92
+ show(): Promise<PlacementResult>;
93
+ }
94
+ export interface EncorePlacements {
95
+ setClaimEnabled(enabled: boolean): Promise<{
96
+ success: boolean;
97
+ }>;
98
+ }
99
+ export interface EncoreSDK {
100
+ configure(apiKey: string, options?: ConfigureOptions): Promise<{
101
+ success: boolean;
102
+ }>;
103
+ identify(userId: string, attributes?: UserAttributes): Promise<{
104
+ success: boolean;
105
+ }>;
106
+ setUserAttributes(attributes: UserAttributes): Promise<{
107
+ success: boolean;
108
+ }>;
109
+ reset(): Promise<{
110
+ success: boolean;
111
+ }>;
112
+ placement(placementId: string): PlacementBuilder;
113
+ /** @deprecated Use `Encore.placement(placementId).show()` instead. */
114
+ show(placementId: string): Promise<PlacementResult>;
115
+ placements: EncorePlacements;
116
+ registerCallbacks(): Promise<{
117
+ success: boolean;
118
+ }>;
119
+ completePurchaseRequest(success: boolean): Promise<{
120
+ success: boolean;
121
+ }>;
122
+ onPurchaseRequest(handler: (event: PurchaseRequestEvent) => void): () => void;
123
+ onPurchaseComplete(handler: (event: PurchaseCompleteEvent) => void): () => void;
124
+ onPassthrough(handler: (event: PassthroughEvent) => void): () => void;
125
+ }
126
+ //# sourceMappingURL=definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definit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;IACrF,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC7E,KAAK,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACvC,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,gBAAgB,CAAC;IACjD,sEAAsE;IACtE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACpD,UAAU,EAAE,gBAAgB,CAAC;IAC7B,iBAAiB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACnD,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACzE,iBAAiB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC9E,kBAAkB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChF,aAAa,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACvE"}
@@ -0,0 +1,4 @@
1
+ // Encore Capacitor Plugin — type definitions.
2
+ // All types mirror the React Native SDK for cross-platform parity.
3
+ export {};
4
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,mEAAmE"}
@@ -0,0 +1,7 @@
1
+ import type { EncorePlugin, PlacementResult, UserAttributes, ConfigureOptions, PurchaseRequestEvent, PurchaseCompleteEvent, PassthroughEvent, PlacementBuilder, EncorePlacements, EncoreSDK } from './definitions';
2
+ declare const EncoreCapacitorPlugin: EncorePlugin;
3
+ declare const Encore: EncoreSDK;
4
+ export default Encore;
5
+ export { EncoreCapacitorPlugin };
6
+ export type { EncorePlugin, PlacementResult, UserAttributes, ConfigureOptions, PurchaseRequestEvent, PurchaseCompleteEvent, PassthroughEvent, PlacementBuilder, EncorePlacements, EncoreSDK, };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACV,MAAM,eAAe,CAAC;AAEvB,QAAA,MAAM,qBAAqB,cAK1B,CAAC;AAiBF,QAAA,MAAM,MAAM,EAAE,SAsFb,CAAC;AAEF,eAAe,MAAM,CAAC;AACtB,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,YAAY,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,GACV,CAAC"}
@@ -0,0 +1,55 @@
1
+ // Encore Capacitor SDK
2
+ // Bridge-only layer — delegates to native SDKs on each platform.
3
+ // iOS: encore-swift-sdk | Android: encore-android-sdk
4
+ import { registerPlugin } from '@capacitor/core';
5
+ const EncoreCapacitorPlugin = registerPlugin('EncoreCapacitorPlugin', {
6
+ web: () => import('./web').then((m) => new m.EncorePluginWeb()),
7
+ });
8
+ async function safeBridgeCall(method, call, fallback) {
9
+ try {
10
+ return await call();
11
+ }
12
+ catch (error) {
13
+ console.warn(`[Encore] ${method} failed:`, error);
14
+ return fallback;
15
+ }
16
+ }
17
+ // -- Typed Export --
18
+ const Encore = {
19
+ configure: (apiKey, options = {}) => safeBridgeCall('configure', () => EncoreCapacitorPlugin.configure({ apiKey, logLevel: options.logLevel }), { success: false }),
20
+ identify: (userId, attributes) => safeBridgeCall('identify', () => EncoreCapacitorPlugin.identify({ userId, attributes }), { success: false }),
21
+ setUserAttributes: (attributes) => safeBridgeCall('setUserAttributes', () => EncoreCapacitorPlugin.setUserAttributes({ attributes }), { success: false }),
22
+ reset: () => safeBridgeCall('reset', () => EncoreCapacitorPlugin.reset(), {
23
+ success: false,
24
+ }),
25
+ placement: (placementId) => ({
26
+ show: () => safeBridgeCall('show', () => EncoreCapacitorPlugin.show({ placementId }), { status: 'not_granted', reason: 'sdk_error' }),
27
+ }),
28
+ show: (placementId) => safeBridgeCall('show', () => EncoreCapacitorPlugin.show({ placementId }), { status: 'not_granted', reason: 'sdk_error' }),
29
+ placements: {
30
+ setClaimEnabled: (enabled) => safeBridgeCall('setClaimEnabled', () => EncoreCapacitorPlugin.setClaimEnabled({ enabled }), { success: false }),
31
+ },
32
+ registerCallbacks: () => safeBridgeCall('registerCallbacks', () => EncoreCapacitorPlugin.registerCallbacks(), { success: false }),
33
+ completePurchaseRequest: (success) => safeBridgeCall('completePurchaseRequest', () => EncoreCapacitorPlugin.completePurchaseRequest({ success }), { success: false }),
34
+ onPurchaseRequest: (handler) => {
35
+ const handle = EncoreCapacitorPlugin.addListener('onPurchaseRequest', handler);
36
+ return () => {
37
+ handle.then((h) => h.remove());
38
+ };
39
+ },
40
+ onPurchaseComplete: (handler) => {
41
+ const handle = EncoreCapacitorPlugin.addListener('onPurchaseComplete', handler);
42
+ return () => {
43
+ handle.then((h) => h.remove());
44
+ };
45
+ },
46
+ onPassthrough: (handler) => {
47
+ const handle = EncoreCapacitorPlugin.addListener('onPassthrough', handler);
48
+ return () => {
49
+ handle.then((h) => h.remove());
50
+ };
51
+ },
52
+ };
53
+ export default Encore;
54
+ export { EncoreCapacitorPlugin };
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src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