@appboxo/capacitor-boxo-sdk 0.0.3 → 0.0.5

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/README.md CHANGED
@@ -21,6 +21,9 @@ npx cap sync
21
21
  * [`sendPaymentEvent(...)`](#sendpaymentevent)
22
22
  * [`getMiniapps()`](#getminiapps)
23
23
  * [`hideMiniapps()`](#hideminiapps)
24
+ * [`addListener('custom_event', ...)`](#addlistenercustom_event-)
25
+ * [`addListener('payment_event', ...)`](#addlistenerpayment_event-)
26
+ * [`addListener('miniapp_lifecycle', ...)`](#addlistenerminiapp_lifecycle-)
24
27
  * [`logout()`](#logout)
25
28
  * [Interfaces](#interfaces)
26
29
 
@@ -144,14 +147,62 @@ To use this function need to enable 'enableMultitaskMode: true' in Appboxo.setCo
144
147
  --------------------
145
148
 
146
149
 
147
- ### logout()
150
+ ### addListener('custom_event', ...)
148
151
 
149
152
  ```typescript
150
- logout() => Promise<void>
153
+ addListener(eventName: 'custom_event', listenerFunc: (customEvent: CustomEvent) => void) => Promise<PluginListenerHandle>
151
154
  ```
152
155
 
153
156
  When host app user logs out, it is highly important to clear all miniapp storage data.
154
157
 
158
+ | Param | Type |
159
+ | ------------------ | ----------------------------------------------------------------------------- |
160
+ | **`eventName`** | <code>'custom_event'</code> |
161
+ | **`listenerFunc`** | <code>(customEvent: <a href="#customevent">CustomEvent</a>) =&gt; void</code> |
162
+
163
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
164
+
165
+ --------------------
166
+
167
+
168
+ ### addListener('payment_event', ...)
169
+
170
+ ```typescript
171
+ addListener(eventName: 'payment_event', listenerFunc: (paymentEvent: PaymentEvent) => void) => Promise<PluginListenerHandle>
172
+ ```
173
+
174
+ | Param | Type |
175
+ | ------------------ | -------------------------------------------------------------------------------- |
176
+ | **`eventName`** | <code>'payment_event'</code> |
177
+ | **`listenerFunc`** | <code>(paymentEvent: <a href="#paymentevent">PaymentEvent</a>) =&gt; void</code> |
178
+
179
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
180
+
181
+ --------------------
182
+
183
+
184
+ ### addListener('miniapp_lifecycle', ...)
185
+
186
+ ```typescript
187
+ addListener(eventName: 'miniapp_lifecycle', listenerFunc: (lifecycle: LifecycleEvent) => void) => Promise<PluginListenerHandle>
188
+ ```
189
+
190
+ | Param | Type |
191
+ | ------------------ | --------------------------------------------------------------------------------- |
192
+ | **`eventName`** | <code>'miniapp_lifecycle'</code> |
193
+ | **`listenerFunc`** | <code>(lifecycle: <a href="#lifecycleevent">LifecycleEvent</a>) =&gt; void</code> |
194
+
195
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
196
+
197
+ --------------------
198
+
199
+
200
+ ### logout()
201
+
202
+ ```typescript
203
+ logout() => Promise<void>
204
+ ```
205
+
155
206
  --------------------
156
207
 
157
208
 
@@ -237,4 +288,20 @@ When host app user logs out, it is highly important to clear all miniapp storage
237
288
  | **`description`** | <code>string</code> |
238
289
  | **`logo`** | <code>string</code> |
239
290
 
291
+
292
+ #### PluginListenerHandle
293
+
294
+ | Prop | Type |
295
+ | ------------ | ----------------------------------------- |
296
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
297
+
298
+
299
+ #### LifecycleEvent
300
+
301
+ | Prop | Type | Description |
302
+ | --------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
303
+ | **`appId`** | <code>string</code> | |
304
+ | **`lifecycle`** | <code>string</code> | onLaunch - Called when the miniapp will launch with Appboxo.open(...) onResume - Called when the miniapp will start interacting with the user onPause - Called when the miniapp loses foreground state onClose - Called when clicked close button in miniapp or when destroyed miniapp page onError - Called when miniapp fails to launch due to internet connection issues onUserInteraction - Called whenever touch event is dispatched to the miniapp page. onAuth - Called when the miniapp starts login and user allows it |
305
+ | **`error`** | <code>string</code> | |
306
+
240
307
  </docgen-api>
package/dist/docs.json CHANGED
@@ -131,13 +131,85 @@
131
131
  "complexTypes": [],
132
132
  "slug": "hideminiapps"
133
133
  },
134
+ {
135
+ "name": "addListener",
136
+ "signature": "(eventName: 'custom_event', listenerFunc: (customEvent: CustomEvent) => void) => Promise<PluginListenerHandle>",
137
+ "parameters": [
138
+ {
139
+ "name": "eventName",
140
+ "docs": "",
141
+ "type": "'custom_event'"
142
+ },
143
+ {
144
+ "name": "listenerFunc",
145
+ "docs": "",
146
+ "type": "(customEvent: CustomEvent) => void"
147
+ }
148
+ ],
149
+ "returns": "Promise<PluginListenerHandle>",
150
+ "tags": [],
151
+ "docs": "When host app user logs out, it is highly important to clear all miniapp storage data.",
152
+ "complexTypes": [
153
+ "PluginListenerHandle",
154
+ "CustomEvent"
155
+ ],
156
+ "slug": "addlistenercustom_event-"
157
+ },
158
+ {
159
+ "name": "addListener",
160
+ "signature": "(eventName: 'payment_event', listenerFunc: (paymentEvent: PaymentEvent) => void) => Promise<PluginListenerHandle>",
161
+ "parameters": [
162
+ {
163
+ "name": "eventName",
164
+ "docs": "",
165
+ "type": "'payment_event'"
166
+ },
167
+ {
168
+ "name": "listenerFunc",
169
+ "docs": "",
170
+ "type": "(paymentEvent: PaymentEvent) => void"
171
+ }
172
+ ],
173
+ "returns": "Promise<PluginListenerHandle>",
174
+ "tags": [],
175
+ "docs": "",
176
+ "complexTypes": [
177
+ "PluginListenerHandle",
178
+ "PaymentEvent"
179
+ ],
180
+ "slug": "addlistenerpayment_event-"
181
+ },
182
+ {
183
+ "name": "addListener",
184
+ "signature": "(eventName: 'miniapp_lifecycle', listenerFunc: (lifecycle: LifecycleEvent) => void) => Promise<PluginListenerHandle>",
185
+ "parameters": [
186
+ {
187
+ "name": "eventName",
188
+ "docs": "",
189
+ "type": "'miniapp_lifecycle'"
190
+ },
191
+ {
192
+ "name": "listenerFunc",
193
+ "docs": "",
194
+ "type": "(lifecycle: LifecycleEvent) => void"
195
+ }
196
+ ],
197
+ "returns": "Promise<PluginListenerHandle>",
198
+ "tags": [],
199
+ "docs": "",
200
+ "complexTypes": [
201
+ "PluginListenerHandle",
202
+ "LifecycleEvent"
203
+ ],
204
+ "slug": "addlistenerminiapp_lifecycle-"
205
+ },
134
206
  {
135
207
  "name": "logout",
136
208
  "signature": "() => Promise<void>",
137
209
  "parameters": [],
138
210
  "returns": "Promise<void>",
139
211
  "tags": [],
140
- "docs": "When host app user logs out, it is highly important to clear all miniapp storage data.",
212
+ "docs": "",
141
213
  "complexTypes": [],
142
214
  "slug": "logout"
143
215
  }
@@ -477,6 +549,52 @@
477
549
  "type": "string"
478
550
  }
479
551
  ]
552
+ },
553
+ {
554
+ "name": "PluginListenerHandle",
555
+ "slug": "pluginlistenerhandle",
556
+ "docs": "",
557
+ "tags": [],
558
+ "methods": [],
559
+ "properties": [
560
+ {
561
+ "name": "remove",
562
+ "tags": [],
563
+ "docs": "",
564
+ "complexTypes": [],
565
+ "type": "() => Promise<void>"
566
+ }
567
+ ]
568
+ },
569
+ {
570
+ "name": "LifecycleEvent",
571
+ "slug": "lifecycleevent",
572
+ "docs": "",
573
+ "tags": [],
574
+ "methods": [],
575
+ "properties": [
576
+ {
577
+ "name": "appId",
578
+ "tags": [],
579
+ "docs": "",
580
+ "complexTypes": [],
581
+ "type": "string"
582
+ },
583
+ {
584
+ "name": "lifecycle",
585
+ "tags": [],
586
+ "docs": "onLaunch - Called when the miniapp will launch with Appboxo.open(...)\nonResume - Called when the miniapp will start interacting with the user\nonPause - Called when the miniapp loses foreground state\nonClose - Called when clicked close button in miniapp or when destroyed miniapp page\nonError - Called when miniapp fails to launch due to internet connection issues\nonUserInteraction - Called whenever touch event is dispatched to the miniapp page.\nonAuth - Called when the miniapp starts login and user allows it",
587
+ "complexTypes": [],
588
+ "type": "string"
589
+ },
590
+ {
591
+ "name": "error",
592
+ "tags": [],
593
+ "docs": "",
594
+ "complexTypes": [],
595
+ "type": "string | undefined"
596
+ }
597
+ ]
480
598
  }
481
599
  ],
482
600
  "enums": [],
@@ -1,3 +1,4 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
1
2
  export interface AppboxoPlugin {
2
3
  /**
3
4
  * Set global configs
@@ -40,6 +41,9 @@ export interface AppboxoPlugin {
40
41
  /**
41
42
  * When host app user logs out, it is highly important to clear all miniapp storage data.
42
43
  */
44
+ addListener(eventName: 'custom_event', listenerFunc: (customEvent: CustomEvent) => void): Promise<PluginListenerHandle>;
45
+ addListener(eventName: 'payment_event', listenerFunc: (paymentEvent: PaymentEvent) => void): Promise<PluginListenerHandle>;
46
+ addListener(eventName: 'miniapp_lifecycle', listenerFunc: (lifecycle: LifecycleEvent) => void): Promise<PluginListenerHandle>;
43
47
  logout(): Promise<void>;
44
48
  }
45
49
  export interface ConfigOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface AppboxoPlugin {\n /**\n * Set global configs\n */\n setConfig(options: ConfigOptions): Promise<void>;\n /**\n * Open miniapp with options\n */\n openMiniapp(options: OpenMiniappOptions): Promise<void>;\n /**\n * get AuthCode from hostapp backend and send it to miniapp\n */\n setAuthCode(options: { appId: string; authCode: string }): Promise<void>;\n /**\n * close miniapp by appId\n */\n closeMiniapp(options: { appId: string }): Promise<void>;\n /**\n * send custom event to miniapp\n */\n sendCustomEvent(customEvent: CustomEvent): Promise<void>;\n /**\n * send payment event to miniapp\n */\n sendPaymentEvent(paymentEvent: PaymentEvent): Promise<void>;\n /**\n * Get list of miniapps\n */\n getMiniapps(): Promise<MiniappListResult>;\n /**\n * Miniapp opens on a native screen. To show payment processing page need to hide miniapp screen.\n * To use this function need to enable 'enableMultitaskMode: true' in Appboxo.setConfigs()\n */\n hideMiniapps(): Promise<void>;\n /**\n * When host app user logs out, it is highly important to clear all miniapp storage data.\n */\n logout(): Promise<void>;\n}\n\nexport interface ConfigOptions {\n /**\n * your client id from dashboard\n */\n clientId: string;\n /**\n * hostapp userId, will be used for the Consent Management\n */\n userId?: string;\n /**\n * switch to sandbox mode\n */\n sandboxMode?: boolean;\n /**\n * Each miniapp appears as a task in the Recents screen.\n * !It works only on android devices.\n */\n enableMultitaskMode?: boolean;\n /**\n * theme for splash screen and other native components used inside miniapp.\n */\n theme?: 'light' | 'dark' | 'system';\n /**\n * enables webview debugging\n */\n isDebug?: boolean;\n /**\n * use it to hide \"Settings\" from Miniapp menu\n */\n showPermissionsPage?: boolean;\n /**\n * use it to hide \"Clear cache\" from Miniapp menu\n */\n showClearCache?: boolean;\n}\n\nexport interface OpenMiniappOptions {\n /**\n * miniapp id\n */\n appId: string;\n /**\n * (optional) data as Map that is sent to miniapp\n */\n data?: object;\n /**\n * (optional) miniapp theme \"dark\" | \"light\" (by default is system theme)\n */\n theme?: 'light' | 'dark' | 'system';\n /**\n * (optional) extra query params to append to miniapp URL (like: http://miniapp-url.com/?param=test)\n */\n extraUrlParams?: object;\n /**\n * (optional) suffix to append to miniapp URL (like: http://miniapp-url.com/?param=test)\n */\n urlSuffix?: string;\n /**\n * (optional) provide colors to miniapp if miniapp supports\n */\n colors?: ColorOptions;\n /**\n * (optional) use to skip miniapp splash screen\n */\n enableSplash?: boolean;\n}\n\nexport interface ColorOptions {\n primaryColor?: string;\n secondaryColor?: string;\n tertiaryColor?: string;\n}\n\nexport interface CustomEvent {\n appId: string;\n requestId: number;\n type: string;\n errorType?: string;\n payload?: object;\n}\n\nexport interface PaymentEvent {\n appId: string;\n transactionToken?: string;\n miniappOrderId?: string;\n amount: number;\n currency?: string;\n status?: string;\n hostappOrderId?: string;\n extraParams?: object;\n}\n\nexport interface LifecycleEvent {\n appId: string;\n /**\n * onLaunch - Called when the miniapp will launch with Appboxo.open(...)\n * onResume - Called when the miniapp will start interacting with the user\n * onPause - Called when the miniapp loses foreground state\n * onClose - Called when clicked close button in miniapp or when destroyed miniapp page\n * onError - Called when miniapp fails to launch due to internet connection issues\n * onUserInteraction - Called whenever touch event is dispatched to the miniapp page.\n * onAuth - Called when the miniapp starts login and user allows it\n */\n lifecycle: string;\n error?: string;\n}\n\nexport interface MiniappListResult {\n miniapps?: [MiniappData];\n error?: string;\n}\n\nexport interface MiniappData {\n appId: string;\n name: string;\n category: string;\n description: string;\n logo: string;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface AppboxoPlugin {\n /**\n * Set global configs\n */\n setConfig(options: ConfigOptions): Promise<void>;\n /**\n * Open miniapp with options\n */\n openMiniapp(options: OpenMiniappOptions): Promise<void>;\n /**\n * get AuthCode from hostapp backend and send it to miniapp\n */\n setAuthCode(options: { appId: string; authCode: string }): Promise<void>;\n /**\n * close miniapp by appId\n */\n closeMiniapp(options: { appId: string }): Promise<void>;\n /**\n * send custom event to miniapp\n */\n sendCustomEvent(customEvent: CustomEvent): Promise<void>;\n /**\n * send payment event to miniapp\n */\n sendPaymentEvent(paymentEvent: PaymentEvent): Promise<void>;\n /**\n * Get list of miniapps\n */\n getMiniapps(): Promise<MiniappListResult>;\n /**\n * Miniapp opens on a native screen. To show payment processing page need to hide miniapp screen.\n * To use this function need to enable 'enableMultitaskMode: true' in Appboxo.setConfigs()\n */\n hideMiniapps(): Promise<void>;\n /**\n * When host app user logs out, it is highly important to clear all miniapp storage data.\n */\n addListener(\n eventName: 'custom_event',\n listenerFunc: (customEvent: CustomEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n addListener(\n eventName: 'payment_event',\n listenerFunc: (paymentEvent: PaymentEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n addListener(\n eventName: 'miniapp_lifecycle',\n listenerFunc: (lifecycle: LifecycleEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n logout(): Promise<void>;\n}\n\nexport interface ConfigOptions {\n /**\n * your client id from dashboard\n */\n clientId: string;\n /**\n * hostapp userId, will be used for the Consent Management\n */\n userId?: string;\n /**\n * switch to sandbox mode\n */\n sandboxMode?: boolean;\n /**\n * Each miniapp appears as a task in the Recents screen.\n * !It works only on android devices.\n */\n enableMultitaskMode?: boolean;\n /**\n * theme for splash screen and other native components used inside miniapp.\n */\n theme?: 'light' | 'dark' | 'system';\n /**\n * enables webview debugging\n */\n isDebug?: boolean;\n /**\n * use it to hide \"Settings\" from Miniapp menu\n */\n showPermissionsPage?: boolean;\n /**\n * use it to hide \"Clear cache\" from Miniapp menu\n */\n showClearCache?: boolean;\n}\n\nexport interface OpenMiniappOptions {\n /**\n * miniapp id\n */\n appId: string;\n /**\n * (optional) data as Map that is sent to miniapp\n */\n data?: object;\n /**\n * (optional) miniapp theme \"dark\" | \"light\" (by default is system theme)\n */\n theme?: 'light' | 'dark' | 'system';\n /**\n * (optional) extra query params to append to miniapp URL (like: http://miniapp-url.com/?param=test)\n */\n extraUrlParams?: object;\n /**\n * (optional) suffix to append to miniapp URL (like: http://miniapp-url.com/?param=test)\n */\n urlSuffix?: string;\n /**\n * (optional) provide colors to miniapp if miniapp supports\n */\n colors?: ColorOptions;\n /**\n * (optional) use to skip miniapp splash screen\n */\n enableSplash?: boolean;\n}\n\nexport interface ColorOptions {\n primaryColor?: string;\n secondaryColor?: string;\n tertiaryColor?: string;\n}\n\nexport interface CustomEvent {\n appId: string;\n requestId: number;\n type: string;\n errorType?: string;\n payload?: object;\n}\n\nexport interface PaymentEvent {\n appId: string;\n transactionToken?: string;\n miniappOrderId?: string;\n amount: number;\n currency?: string;\n status?: string;\n hostappOrderId?: string;\n extraParams?: object;\n}\n\nexport interface LifecycleEvent {\n appId: string;\n /**\n * onLaunch - Called when the miniapp will launch with Appboxo.open(...)\n * onResume - Called when the miniapp will start interacting with the user\n * onPause - Called when the miniapp loses foreground state\n * onClose - Called when clicked close button in miniapp or when destroyed miniapp page\n * onError - Called when miniapp fails to launch due to internet connection issues\n * onUserInteraction - Called whenever touch event is dispatched to the miniapp page.\n * onAuth - Called when the miniapp starts login and user allows it\n */\n lifecycle: string;\n error?: string;\n}\n\nexport interface MiniappListResult {\n miniapps?: [MiniappData];\n error?: string;\n}\n\nexport interface MiniappData {\n appId: string;\n name: string;\n category: string;\n description: string;\n logo: string;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appboxo/capacitor-boxo-sdk",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "A capacitor wrapper over Appboxo SDK for IOS and Android.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -46,10 +46,10 @@
46
46
  "prepublishOnly": "npm run build"
47
47
  },
48
48
  "devDependencies": {
49
- "@capacitor/android": "^5.7.7",
50
- "@capacitor/core": "^5.7.7",
49
+ "@capacitor/android": "^5.2.2",
50
+ "@capacitor/core": "^5.2.2",
51
51
  "@capacitor/docgen": "^0.2.2",
52
- "@capacitor/ios": "^5.7.7",
52
+ "@capacitor/ios": "^5.2.2",
53
53
  "@ionic/eslint-config": "^0.4.0",
54
54
  "@ionic/prettier-config": "^1.0.1",
55
55
  "@ionic/swiftlint-config": "^1.1.2",
@@ -62,7 +62,7 @@
62
62
  "typescript": "~4.1.5"
63
63
  },
64
64
  "peerDependencies": {
65
- "@capacitor/core": "^5.7.7"
65
+ "@capacitor/core": "^5.2.2"
66
66
  },
67
67
  "prettier": "@ionic/prettier-config",
68
68
  "swiftlint": "@ionic/swiftlint-config",