@cuby-ui/ar 0.0.1

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/CubyAr.podspec ADDED
@@ -0,0 +1,17 @@
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 = 'CubyAr'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '14.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CubyAr",
6
+ platforms: [.iOS(.v14)],
7
+ products: [
8
+ .library(
9
+ name: "CubyAr",
10
+ targets: ["ExamplePlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "ExamplePlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/ExamplePlugin"),
23
+ .testTarget(
24
+ name: "ExamplePluginTests",
25
+ dependencies: ["ExamplePlugin"],
26
+ path: "ios/Tests/ExamplePluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # cuby-ar
2
+
3
+ Ar/Vr plugin
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install cuby-ar
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`startAR(...)`](#startar)
17
+ * [`logMessage(...)`](#logmessage)
18
+
19
+ </docgen-index>
20
+
21
+ <docgen-api>
22
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
23
+
24
+ ### startAR(...)
25
+
26
+ ```typescript
27
+ startAR(options?: { message?: string | undefined; } | undefined) => Promise<void>
28
+ ```
29
+
30
+ Launches the native AR activity.
31
+
32
+ | Param | Type |
33
+ | ------------- | ---------------------------------- |
34
+ | **`options`** | <code>{ message?: string; }</code> |
35
+
36
+ --------------------
37
+
38
+
39
+ ### logMessage(...)
40
+
41
+ ```typescript
42
+ logMessage(options: { message: string; }) => Promise<void>
43
+ ```
44
+
45
+ Sends a message to native code to be logged. Returns a small status
46
+ object on success.
47
+
48
+ | Param | Type |
49
+ | ------------- | --------------------------------- |
50
+ | **`options`** | <code>{ message: string; }</code> |
51
+
52
+ --------------------
53
+
54
+ </docgen-api>
@@ -0,0 +1,61 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.6.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace "com.cuby.plugins.cubyar"
22
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_21
41
+ targetCompatibility JavaVersion.VERSION_21
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ flatDir {
49
+ dirs 'libs'
50
+ }
51
+ }
52
+
53
+
54
+ dependencies {
55
+ implementation fileTree(dir: 'libs', include: ['*.aar'])
56
+ implementation project(':capacitor-android')
57
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
58
+ testImplementation "junit:junit:$junitVersion"
59
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
60
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
61
+ }
@@ -0,0 +1,5 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+
3
+ <uses-permission android:name="android.permission.CAMERA" />
4
+
5
+ </manifest>
@@ -0,0 +1,97 @@
1
+ package com.cuby.plugins.cubyar;
2
+
3
+ import static com.cuby.cubyar.NativeLogger.LogMessage;
4
+
5
+ import android.Manifest;
6
+ import android.annotation.SuppressLint;
7
+ import android.app.Activity;
8
+ import android.content.Intent;
9
+ import android.content.pm.PackageManager;
10
+ import android.os.Handler;
11
+ import android.os.Looper;
12
+ import android.util.Log;
13
+ import android.widget.Toast;
14
+
15
+ import androidx.core.app.ActivityCompat;
16
+ import androidx.core.content.ContextCompat;
17
+
18
+ import com.getcapacitor.Plugin;
19
+ import com.getcapacitor.PluginCall;
20
+ import com.getcapacitor.PluginMethod;
21
+ import com.getcapacitor.annotation.CapacitorPlugin;
22
+ import com.getcapacitor.JSObject;
23
+
24
+ @CapacitorPlugin(name = "NativeBridge")
25
+ public class NativeBridge extends Plugin {
26
+
27
+ private static final int CAMERA_REQUEST_CODE = 1234;
28
+ private PluginCall savedCall;
29
+
30
+ @PluginMethod
31
+ public void startAR(PluginCall call) {
32
+ Activity activity = getActivity();
33
+
34
+ if (ContextCompat.checkSelfPermission(activity,
35
+ Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
36
+ savedCall = call;
37
+ ActivityCompat.requestPermissions(activity,
38
+ new String[] { Manifest.permission.CAMERA },
39
+ CAMERA_REQUEST_CODE);
40
+ return;
41
+ }
42
+
43
+ launchUnrealAR();
44
+ }
45
+
46
+ @SuppressLint("QueryPermissionsNeeded")
47
+ private void launchUnrealAR(PluginCall call) {
48
+ Activity activity = getActivity();
49
+
50
+ String message = call.getString("message");
51
+ try {
52
+ Intent intent = new Intent();
53
+ intent.setClassName(activity.getPackageName(), "com.epicgames.unreal.GameActivity");
54
+
55
+ if (intent.resolveActivity(activity.getPackageManager()) != null) {
56
+ activity.startActivity(intent);
57
+ Log.i("ArLauncherPlugin", "Unreal AR activity launched successfully");
58
+
59
+ // Delay calling LogMessage by 10 seconds so we don't block the UI thread
60
+ // and allow the launched activity to settle first.
61
+ new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
62
+ @Override
63
+ public void run() {
64
+ LogMessage(message);
65
+ Log.i("ArLauncherPlugin", message);
66
+ }
67
+ }, 10_000);
68
+
69
+ } else {
70
+ Log.e("ArLauncherPlugin", "GameActivity not found in package");
71
+ }
72
+
73
+ } catch (Exception e) {
74
+ Log.e("ArLauncherPlugin", "Failed to launch AR", e);
75
+ }
76
+ }
77
+
78
+ @PluginMethod
79
+ public void logMessage(PluginCall call) {
80
+ String message = call.getString("message");
81
+
82
+ if (message == null) {
83
+ call.reject("Missing 'message' parameter");
84
+ return;
85
+ }
86
+
87
+ try {
88
+ LogMessage(message);
89
+
90
+ JSObject ret = new JSObject();
91
+ ret.put("status", "logged");
92
+ call.resolve(ret);
93
+ } catch (Exception e) {
94
+ call.reject("Failed to log message via native code", e);
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,19 @@
1
+ package com.google.vr.sdk.samples.permission;
2
+
3
+ import android.app.Activity;
4
+
5
+ public class PermissionHelper {
6
+ public static boolean hasPermissions(Activity activity) {
7
+ return true;
8
+ }
9
+
10
+ public static void requestPermissions(Activity activity) {
11
+ }
12
+
13
+ public static boolean checkPermission(String permission) {
14
+ return true;
15
+ }
16
+
17
+ public static void acquirePermissions(String[] permissions) {
18
+ }
19
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "api": {
3
+ "name": "NativeBridgePlugin",
4
+ "slug": "nativebridgeplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "startAR",
10
+ "signature": "(options?: { message?: string | undefined; } | undefined) => Promise<void>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "",
15
+ "type": "{ message?: string | undefined; } | undefined"
16
+ }
17
+ ],
18
+ "returns": "Promise<void>",
19
+ "tags": [],
20
+ "docs": "Launches the native AR activity.",
21
+ "complexTypes": [],
22
+ "slug": "startar"
23
+ },
24
+ {
25
+ "name": "logMessage",
26
+ "signature": "(options: { message: string; }) => Promise<void>",
27
+ "parameters": [
28
+ {
29
+ "name": "options",
30
+ "docs": "",
31
+ "type": "{ message: string; }"
32
+ }
33
+ ],
34
+ "returns": "Promise<void>",
35
+ "tags": [],
36
+ "docs": "Sends a message to native code to be logged. Returns a small status\nobject on success.",
37
+ "complexTypes": [],
38
+ "slug": "logmessage"
39
+ }
40
+ ],
41
+ "properties": []
42
+ },
43
+ "interfaces": [],
44
+ "enums": [],
45
+ "typeAliases": [],
46
+ "pluginConfigs": []
47
+ }
@@ -0,0 +1,15 @@
1
+ export interface NativeBridgePlugin {
2
+ /**
3
+ * Launches the native AR activity.
4
+ */
5
+ startAR(options?: {
6
+ message?: string;
7
+ }): Promise<void>;
8
+ /**
9
+ * Sends a message to native code to be logged. Returns a small status
10
+ * object on success.
11
+ */
12
+ logMessage(options: {
13
+ message: string;
14
+ }): Promise<void>;
15
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface NativeBridgePlugin {\n /**\n * Launches the native AR activity.\n */\n startAR(options?: { message?: string }): Promise<void>;\n\n /**\n * Sends a message to native code to be logged. Returns a small status\n * object on success.\n */\n logMessage(options: { message: string }): Promise<void>;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { NativeBridgePlugin } from './definitions';
2
+ declare const NativeBridge: NativeBridgePlugin;
3
+ export * from './definitions';
4
+ export { NativeBridge };
@@ -0,0 +1,5 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const NativeBridge = registerPlugin('NativeBridge');
3
+ export * from './definitions';
4
+ export { NativeBridge };
5
+ //# 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,YAAY,GAAG,cAAc,CAAqB,cAAc,CAAC,CAAC;AAExE,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { NativeBridgePlugin } from './definitions';\n\nconst NativeBridge = registerPlugin<NativeBridgePlugin>('NativeBridge');\n\nexport * from './definitions';\nexport { NativeBridge };\n"]}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ const NativeBridge = core.registerPlugin('NativeBridge');
6
+
7
+ exports.NativeBridge = NativeBridge;
8
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst NativeBridge = registerPlugin('NativeBridge');\nexport * from './definitions';\nexport { NativeBridge };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,11 @@
1
+ var capacitorExample = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const NativeBridge = core.registerPlugin('NativeBridge');
5
+
6
+ exports.NativeBridge = NativeBridge;
7
+
8
+ return exports;
9
+
10
+ })({}, capacitorExports);
11
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst NativeBridge = registerPlugin('NativeBridge');\nexport * from './definitions';\nexport { NativeBridge };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;AACK,OAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import Foundation
2
+
3
+ @objc public class Example: NSObject {
4
+ @objc public func echo(_ value: String) -> String {
5
+ print(value)
6
+ return value
7
+ }
8
+ }
@@ -0,0 +1,23 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(ExamplePlugin)
9
+ public class ExamplePlugin: CAPPlugin, CAPBridgedPlugin {
10
+ public let identifier = "ExamplePlugin"
11
+ public let jsName = "Example"
12
+ public let pluginMethods: [CAPPluginMethod] = [
13
+ CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise)
14
+ ]
15
+ private let implementation = Example()
16
+
17
+ @objc func echo(_ call: CAPPluginCall) {
18
+ let value = call.getString("value") ?? ""
19
+ call.resolve([
20
+ "value": implementation.echo(value)
21
+ ])
22
+ }
23
+ }
@@ -0,0 +1,15 @@
1
+ import XCTest
2
+ @testable import ExamplePlugin
3
+
4
+ class ExampleTests: XCTestCase {
5
+ func testEcho() {
6
+ // This is an example of a functional test case for a plugin.
7
+ // Use XCTAssert and related functions to verify your tests produce the correct results.
8
+
9
+ let implementation = Example()
10
+ let value = "Hello, World!"
11
+ let result = implementation.echo(value)
12
+
13
+ XCTAssertEqual(value, result)
14
+ }
15
+ }
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@cuby-ui/ar",
3
+ "version": "0.0.1",
4
+ "description": "Ar/Vr plugin",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/",
13
+ "ios/Sources",
14
+ "ios/Tests",
15
+ "Package.swift",
16
+ "CubyAr.podspec"
17
+ ],
18
+ "author": "",
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Cuby-Technologies/cuby-vr-ar.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/Cuby-Technologies/cuby-vr-ar/issues"
26
+ },
27
+ "keywords": [
28
+ "capacitor",
29
+ "plugin",
30
+ "native"
31
+ ],
32
+ "scripts": {
33
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
34
+ "verify:ios": "xcodebuild -scheme CubyAr -destination generic/platform=iOS",
35
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
36
+ "verify:web": "npm run build",
37
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
38
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
39
+ "eslint": "eslint . --ext ts",
40
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
41
+ "swiftlint": "node-swiftlint",
42
+ "docgen": "docgen --api NativeBridgePlugin --output-readme README.md --output-json dist/docs.json",
43
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
44
+ "clean": "rimraf ./dist",
45
+ "watch": "tsc --watch",
46
+ "prepublishOnly": "npm run build"
47
+ },
48
+ "devDependencies": {
49
+ "@capacitor/android": "^7.0.0",
50
+ "@capacitor/core": "^7.0.0",
51
+ "@capacitor/docgen": "^0.3.0",
52
+ "@capacitor/ios": "^7.0.0",
53
+ "@ionic/eslint-config": "^0.4.0",
54
+ "@ionic/prettier-config": "^4.0.0",
55
+ "@ionic/swiftlint-config": "^2.0.0",
56
+ "eslint": "^8.57.0",
57
+ "prettier": "^3.4.2",
58
+ "prettier-plugin-java": "^2.6.6",
59
+ "rimraf": "^6.0.1",
60
+ "rollup": "^4.30.1",
61
+ "swiftlint": "^2.0.0",
62
+ "typescript": "~4.1.5"
63
+ },
64
+ "peerDependencies": {
65
+ "@capacitor/core": ">=7.0.0"
66
+ },
67
+ "prettier": "@ionic/prettier-config",
68
+ "swiftlint": "@ionic/swiftlint-config",
69
+ "eslintConfig": {
70
+ "extends": "@ionic/eslint-config/recommended"
71
+ },
72
+ "capacitor": {
73
+ "ios": {
74
+ "src": "ios"
75
+ },
76
+ "android": {
77
+ "src": "android"
78
+ }
79
+ }
80
+ }