@cuby-ui/ar 0.0.10 → 0.0.12

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
@@ -15,6 +15,8 @@ npx cap sync
15
15
 
16
16
  * [`startAR()`](#startar)
17
17
  * [`logMessage(...)`](#logmessage)
18
+ * [`addListener('click', ...)`](#addlistenerclick-)
19
+ * [Interfaces](#interfaces)
18
20
 
19
21
  </docgen-index>
20
22
 
@@ -47,4 +49,32 @@ object on success.
47
49
 
48
50
  --------------------
49
51
 
52
+
53
+ ### addListener('click', ...)
54
+
55
+ ```typescript
56
+ addListener(eventName: 'click', listenerFunc: (event: { data: string; }) => void) => PluginListenerHandle
57
+ ```
58
+
59
+ Listens for click events from the native AR view.
60
+
61
+ | Param | Type | Description |
62
+ | ------------------ | -------------------------------------------------- | -------------------------------------------------------------------------------- |
63
+ | **`eventName`** | <code>'click'</code> | The name of the event to listen for (should be 'click'). |
64
+ | **`listenerFunc`** | <code>(event: { data: string; }) =&gt; void</code> | The function to call when the event occurs, receiving an event object with data. |
65
+
66
+ **Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
67
+
68
+ --------------------
69
+
70
+
71
+ ### Interfaces
72
+
73
+
74
+ #### PluginListenerHandle
75
+
76
+ | Prop | Type |
77
+ | ------------ | ----------------------------------------- |
78
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
79
+
50
80
  </docgen-api>
@@ -53,9 +53,9 @@ repositories {
53
53
  }
54
54
  }
55
55
 
56
-
57
56
  dependencies {
58
- implementation fileTree(dir: 'libs', include: ['*.aar'])
57
+ compileOnly files('libs/app-release.aar')
58
+
59
59
  implementation project(':capacitor-android')
60
60
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
61
61
  implementation ("com.google.ar:core:1.37.0")
Binary file
@@ -23,6 +23,15 @@ public class NativeBridge extends Plugin {
23
23
  private static final String LOG_TAG = "CubyARPlugin";
24
24
  private boolean isPermissionDenied = false;
25
25
 
26
+ public static NativeBridge instance;
27
+
28
+ @Override
29
+ public void load() {
30
+ super.load();
31
+ instance = this;
32
+ Log.i(LOG_TAG, "NativeBridge instance stored");
33
+ }
34
+
26
35
  @PluginMethod
27
36
  public void startAR(PluginCall call) {
28
37
  PermissionState state = getPermissionState("camera");
@@ -102,7 +111,8 @@ public class NativeBridge extends Plugin {
102
111
 
103
112
  try {
104
113
  NativeLogger.logMessage(message, (float) duration);
105
-
114
+ String data = NativeLogger.returnData();
115
+ Log.i(LOG_TAG, "Native data: " + data);
106
116
  JSObject ret = new JSObject();
107
117
  ret.put("status", "logged");
108
118
  call.resolve(ret);
@@ -110,4 +120,16 @@ public class NativeBridge extends Plugin {
110
120
  call.reject("Failed to log message via native code", e);
111
121
  }
112
122
  }
123
+
124
+ public String getNativeData() {
125
+ try {
126
+ String data = NativeLogger.returnData();
127
+ JSObject ret = new JSObject();
128
+ ret.put("data", data);
129
+ notifyListeners("click", ret);
130
+ } catch (Exception e) {
131
+ // call.reject("Failed to get native data", e);
132
+ }
133
+ return "";
134
+ }
113
135
  }
package/dist/docs.json CHANGED
@@ -35,11 +35,64 @@
35
35
  "docs": "Sends a message to native code to be logged. Returns a small status\nobject on success.",
36
36
  "complexTypes": [],
37
37
  "slug": "logmessage"
38
+ },
39
+ {
40
+ "name": "addListener",
41
+ "signature": "(eventName: 'click', listenerFunc: (event: { data: string; }) => void) => PluginListenerHandle",
42
+ "parameters": [
43
+ {
44
+ "name": "eventName",
45
+ "docs": "The name of the event to listen for (should be 'click').",
46
+ "type": "'click'"
47
+ },
48
+ {
49
+ "name": "listenerFunc",
50
+ "docs": "The function to call when the event occurs, receiving an event object with data.",
51
+ "type": "(event: { data: string; }) => void"
52
+ }
53
+ ],
54
+ "returns": "PluginListenerHandle",
55
+ "tags": [
56
+ {
57
+ "name": "param",
58
+ "text": "eventName The name of the event to listen for (should be 'click')."
59
+ },
60
+ {
61
+ "name": "param",
62
+ "text": "listenerFunc The function to call when the event occurs, receiving an event object with data."
63
+ },
64
+ {
65
+ "name": "returns",
66
+ "text": "A handle to remove the listener when no longer needed."
67
+ }
68
+ ],
69
+ "docs": "Listens for click events from the native AR view.",
70
+ "complexTypes": [
71
+ "PluginListenerHandle"
72
+ ],
73
+ "slug": "addlistenerclick-"
38
74
  }
39
75
  ],
40
76
  "properties": []
41
77
  },
42
- "interfaces": [],
78
+ "interfaces": [
79
+ {
80
+ "name": "PluginListenerHandle",
81
+ "slug": "pluginlistenerhandle",
82
+ "docs": "",
83
+ "tags": [],
84
+ "methods": [],
85
+ "properties": [
86
+ {
87
+ "name": "remove",
88
+ "tags": [],
89
+ "docs": "",
90
+ "complexTypes": [],
91
+ "type": "() => Promise<void>"
92
+ }
93
+ ]
94
+ }
95
+ ],
43
96
  "enums": [],
44
97
  "typeAliases": [],
45
98
  "pluginConfigs": []
@@ -1,3 +1,4 @@
1
+ import { PluginListenerHandle } from '@capacitor/core';
1
2
  export interface NativeBridgePlugin {
2
3
  /**
3
4
  * Launches the AR activity.
@@ -12,4 +13,13 @@ export interface NativeBridgePlugin {
12
13
  message: string;
13
14
  duration?: number;
14
15
  }): void;
16
+ /**
17
+ * Listens for click events from the native AR view.
18
+ * @param eventName The name of the event to listen for (should be 'click').
19
+ * @param listenerFunc The function to call when the event occurs, receiving an event object with data.
20
+ * @returns A handle to remove the listener when no longer needed.
21
+ */
22
+ addListener(eventName: 'click', listenerFunc: (event: {
23
+ data: string;
24
+ }) => void): PluginListenerHandle;
15
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface NativeBridgePlugin {\n /**\n * Launches the AR activity.\n */\n startAR(): void;\n\n /**\n * Sends a message to native code to be logged. Returns a small status\n * object on success.\n * @param options The message to log and optional duration in seconds (default is 5).\n */\n logMessage(options: { message: string; duration?: number; }): void;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import { PluginListenerHandle } from '@capacitor/core';\n\nexport interface NativeBridgePlugin {\n /**\n * Launches the AR activity.\n */\n startAR(): void;\n\n /**\n * Sends a message to native code to be logged. Returns a small status\n * object on success.\n * @param options The message to log and optional duration in seconds (default is 5).\n */\n logMessage(options: { message: string; duration?: number; }): void;\n\n /**\n * Listens for click events from the native AR view.\n * @param eventName The name of the event to listen for (should be 'click').\n * @param listenerFunc The function to call when the event occurs, receiving an event object with data.\n * @returns A handle to remove the listener when no longer needed.\n */\n addListener(\n eventName: 'click',\n listenerFunc: (event: { data: string }) => void\n ): PluginListenerHandle;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuby-ui/ar",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Ar/Vr plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",