react-native-plasma 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,40 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
6
+
7
+ Pod::Spec.new do |s|
8
+ s.name = "RNPlasma"
9
+ s.version = package["version"]
10
+ s.summary = package["description"]
11
+ s.homepage = package["homepage"]
12
+ s.license = package["license"]
13
+ s.authors = package["author"]
14
+
15
+ s.platforms = { :ios => "13.0" }
16
+ s.source = { :git => "https://github.com/nammayatri/react-native-plasma.git", :tag => "#{s.version}" }
17
+
18
+ s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
19
+ s.public_header_files = "ios/**/*.h"
20
+ s.swift_version = "5.0"
21
+ s.pod_target_xcconfig = {
22
+ 'DEFINES_MODULE' => 'YES',
23
+ 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++20',
24
+ 'CLANG_CXX_LIBRARY' => 'libc++',
25
+ 'OTHER_CPLUSPLUSFLAGS' => '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1'
26
+ }
27
+ s.user_target_xcconfig = {
28
+ 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++20'
29
+ }
30
+
31
+ # PlasmaSDK iOS SDK
32
+ s.dependency "PlasmaSDK", "~> 1.0.1"
33
+
34
+ # Use install_modules_dependencies if available (provided by react_native_pods.rb via Podfile)
35
+ if defined?(install_modules_dependencies)
36
+ install_modules_dependencies(s)
37
+ else
38
+ s.dependency "React-Core"
39
+ end
40
+ end
@@ -0,0 +1,80 @@
1
+ buildscript {
2
+ ext.getExtOrDefault = {name ->
3
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['PlasmaBridge_' + name]
4
+ }
5
+
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ }
10
+
11
+ dependencies {
12
+ classpath "com.android.tools.build:gradle:8.7.2"
13
+ // noinspection DifferentKotlinGradleVersion
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15
+ }
16
+ }
17
+
18
+
19
+ apply plugin: "com.android.library"
20
+ apply plugin: "kotlin-android"
21
+
22
+ apply plugin: "com.facebook.react"
23
+
24
+ def getExtOrIntegerDefault(name) {
25
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["PlasmaBridge_" + name]).toInteger()
26
+ }
27
+
28
+ android {
29
+ namespace "com.plasmareactnative"
30
+
31
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
32
+
33
+ defaultConfig {
34
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
35
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
36
+ }
37
+
38
+ buildFeatures {
39
+ buildConfig true
40
+ }
41
+
42
+ buildTypes {
43
+ release {
44
+ minifyEnabled false
45
+ }
46
+ }
47
+
48
+ lintOptions {
49
+ disable "GradleCompatible"
50
+ }
51
+
52
+ compileOptions {
53
+ sourceCompatibility JavaVersion.VERSION_1_8
54
+ targetCompatibility JavaVersion.VERSION_1_8
55
+ }
56
+
57
+ sourceSets {
58
+ main {
59
+ java.srcDirs += [
60
+ "generated/java",
61
+ "generated/jni"
62
+ ]
63
+ }
64
+ }
65
+ }
66
+
67
+ repositories {
68
+ mavenCentral()
69
+ google()
70
+ }
71
+
72
+ def kotlin_version = getExtOrDefault("kotlinVersion")
73
+
74
+ dependencies {
75
+ implementation "com.facebook.react:react-android"
76
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
77
+
78
+ // Plasma Android SDK
79
+ implementation("com.movingtech:plasma-sdk:1.0.11")
80
+ }
@@ -0,0 +1,5 @@
1
+ PlasmaBridge_kotlinVersion=2.0.21
2
+ PlasmaBridge_minSdkVersion=24
3
+ PlasmaBridge_targetSdkVersion=34
4
+ PlasmaBridge_compileSdkVersion=35
5
+ PlasmaBridge_ndkVersion=27.1.12297006
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,77 @@
1
+ package com.plasmareactnative
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReadableMap
5
+ import com.facebook.react.module.annotations.ReactModule
6
+ import com.plasma.sdk.PlasmaInstance
7
+ import com.plasma.sdk.Plasma
8
+ import com.plasma.sdk.config.PlasmaConfig
9
+
10
+ @ReactModule(name = PlasmaBridgeModule.NAME)
11
+ class PlasmaBridgeModule(reactContext: ReactApplicationContext) :
12
+ NativePlasmaBridgeSpec(reactContext) {
13
+
14
+ override fun getName(): String {
15
+ return NAME
16
+ }
17
+
18
+ override fun initializePlasma(baseUrl: String, apiKey: String) {
19
+ if (!Plasma.isInitialized()) {
20
+ val plasmaConfig = PlasmaConfig(
21
+ apiKey = apiKey,
22
+ baseUrl = baseUrl
23
+ )
24
+ Plasma.initialize(reactApplicationContext, plasmaConfig)
25
+ }
26
+ }
27
+
28
+ override fun plasmaLogin(userId: String, deviceToken: String) {
29
+ if (Plasma.isInitialized()) {
30
+ Plasma.getInstance().login(userId, deviceToken)
31
+ }
32
+ }
33
+
34
+ override fun plasmaLogout() {
35
+ if (Plasma.isInitialized()) {
36
+ Plasma.getInstance().logout()
37
+ }
38
+ }
39
+
40
+ override fun setDeviceToken(token: String) {
41
+ if (Plasma.isInitialized()) {
42
+ Plasma.getInstance().updateDeviceToken(token)
43
+ }
44
+ }
45
+
46
+ override fun setUserId(userId: String) {
47
+ if (Plasma.isInitialized()) {
48
+ Plasma.getInstance().setUserId(userId)
49
+ }
50
+ }
51
+
52
+ override fun setTags(tags: ReadableMap?) {
53
+ if (tags != null && Plasma.isInitialized()) {
54
+ val mapTags = tags.toHashMap()
55
+ val buildTags: MutableMap<String, String> = mutableMapOf()
56
+ for (tag in mapTags.entries) {
57
+ buildTags[tag.key] = tag.value.toString()
58
+ }
59
+ Plasma.getInstance().setTags(buildTags)
60
+ }
61
+ }
62
+
63
+ override fun setUserProps(props: ReadableMap?) {
64
+ if (props != null && Plasma.isInitialized()) {
65
+ val mapProps = props.toHashMap()
66
+ val buildProps: MutableMap<String, String> = mutableMapOf()
67
+ for (prop in mapProps.entries) {
68
+ buildProps[prop.key] = prop.value.toString()
69
+ }
70
+ Plasma.getInstance().setUserProperties(buildProps)
71
+ }
72
+ }
73
+
74
+ companion object {
75
+ const val NAME = "PlasmaBridge"
76
+ }
77
+ }
@@ -0,0 +1,33 @@
1
+ package com.plasmareactnative
2
+
3
+ import com.facebook.react.BaseReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.model.ReactModuleInfo
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
8
+ import java.util.HashMap
9
+
10
+ class PlasmaBridgePackage : BaseReactPackage() {
11
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
+ return if (name == PlasmaBridgeModule.NAME) {
13
+ PlasmaBridgeModule(reactContext)
14
+ } else {
15
+ null
16
+ }
17
+ }
18
+
19
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
20
+ return ReactModuleInfoProvider {
21
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
22
+ moduleInfos[PlasmaBridgeModule.NAME] = ReactModuleInfo(
23
+ PlasmaBridgeModule.NAME,
24
+ PlasmaBridgeModule.NAME,
25
+ false, // canOverrideExistingModule
26
+ false, // needsEagerInit
27
+ false, // isCxxModule
28
+ true // isTurboModule
29
+ )
30
+ moduleInfos
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,13 @@
1
+ #ifdef __cplusplus
2
+ #import <PlasmaBridgeSpec/PlasmaBridgeSpec.h>
3
+ #endif
4
+
5
+ #import <React/RCTBridgeModule.h>
6
+
7
+ #ifdef __cplusplus
8
+ @interface PlasmaBridge : NSObject <NativePlasmaBridgeSpec>
9
+ #else
10
+ @interface PlasmaBridge : NSObject <RCTBridgeModule>
11
+ #endif
12
+
13
+ @end
@@ -0,0 +1,58 @@
1
+ #import "PlasmaBridge.h"
2
+
3
+ #if __has_include(<RNPlasma/RNPlasma-Swift.h>)
4
+ #import <RNPlasma/RNPlasma-Swift.h>
5
+ #else
6
+ #import "RNPlasma-Swift.h"
7
+ #endif
8
+
9
+ @implementation PlasmaBridge {
10
+ RNPlasmaBridge *_bridge;
11
+ }
12
+
13
+ - (instancetype)init {
14
+ self = [super init];
15
+ if (self) {
16
+ _bridge = [RNPlasmaBridge getInstance];
17
+ }
18
+ return self;
19
+ }
20
+
21
+ - (void)initializePlasma:(NSString *)baseUrl apiKey:(NSString *)apiKey {
22
+ [_bridge initializePlasma:baseUrl apiKey:apiKey];
23
+ }
24
+
25
+ - (void)plasmaLogin:(NSString *)userId deviceToken:(NSString *)deviceToken {
26
+ [_bridge plasmaLogin:userId deviceToken:deviceToken];
27
+ }
28
+
29
+ - (void)plasmaLogout {
30
+ [_bridge plasmaLogout];
31
+ }
32
+
33
+ - (void)setDeviceToken:(NSString *)token {
34
+ [_bridge setDeviceToken:token];
35
+ }
36
+
37
+ - (void)setUserId:(NSString *)userId {
38
+ [_bridge setUserId:userId];
39
+ }
40
+
41
+ - (void)setTags:(NSDictionary *)tags {
42
+ [_bridge setTags:tags];
43
+ }
44
+
45
+ - (void)setUserProps:(NSDictionary *)props {
46
+ [_bridge setUserProps:props];
47
+ }
48
+
49
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
50
+ (const facebook::react::ObjCTurboModule::InitParams &)params {
51
+ return std::make_shared<facebook::react::NativePlasmaBridgeSpecJSI>(params);
52
+ }
53
+
54
+ + (NSString *)moduleName {
55
+ return @"PlasmaBridge";
56
+ }
57
+
58
+ @end
@@ -0,0 +1,71 @@
1
+ import Foundation
2
+ import PlasmaSDK
3
+
4
+ @objc(RNPlasmaBridge)
5
+ public class RNPlasmaBridge: NSObject {
6
+
7
+ @objc
8
+ public static func getInstance() -> RNPlasmaBridge {
9
+ return RNPlasmaBridge()
10
+ }
11
+
12
+ @objc
13
+ public func initializePlasma(_ baseUrl: String, apiKey: String) {
14
+ let config = PlasmaConfig(apiKey: apiKey, baseUrl: baseUrl)
15
+ Plasma.initialize(config: config)
16
+ }
17
+
18
+ @objc
19
+ public func plasmaLogin(_ userId: String, deviceToken: String) {
20
+ if Plasma.isInitialized() {
21
+ Plasma.getInstance().login(userId: userId, deviceToken: deviceToken)
22
+ }
23
+ }
24
+
25
+ @objc
26
+ public func plasmaLogout() {
27
+ if Plasma.isInitialized() {
28
+ Plasma.getInstance().logout()
29
+ }
30
+ }
31
+
32
+ @objc
33
+ public func setDeviceToken(_ token: String) {
34
+ if Plasma.isInitialized() {
35
+ Plasma.getInstance().updateDeviceToken(token)
36
+ }
37
+ }
38
+
39
+ @objc
40
+ public func setUserId(_ userId: String) {
41
+ if Plasma.isInitialized() {
42
+ Plasma.getInstance().setUserId(userId)
43
+ }
44
+ }
45
+
46
+ @objc
47
+ public func setTags(_ tags: NSDictionary) {
48
+ if Plasma.isInitialized() {
49
+ var buildTags: [String: String] = [:]
50
+ for (key, value) in tags {
51
+ if let k = key as? String {
52
+ buildTags[k] = "\(value)"
53
+ }
54
+ }
55
+ Plasma.getInstance().setTags(buildTags)
56
+ }
57
+ }
58
+
59
+ @objc
60
+ public func setUserProps(_ props: NSDictionary) {
61
+ if Plasma.isInitialized() {
62
+ var buildProps: [String: String] = [:]
63
+ for (key, value) in props {
64
+ if let k = key as? String {
65
+ buildProps[k] = "\(value)"
66
+ }
67
+ }
68
+ Plasma.getInstance().setUserProperties(buildProps)
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,13 @@
1
+ import { TurboModuleRegistry, type TurboModule } from 'react-native';
2
+
3
+ export interface Spec extends TurboModule {
4
+ initializePlasma(baseUrl: string, apiKey: string): void;
5
+ plasmaLogin(userId: string, deviceToken: string): void;
6
+ plasmaLogout(): void;
7
+ setDeviceToken(token: string): void;
8
+ setUserId(userId: string): void;
9
+ setTags(tags: { [key: string]: string | number }): void;
10
+ setUserProps(props: { [key: string]: string | number }): void;
11
+ }
12
+
13
+ export default TurboModuleRegistry.getEnforcing<Spec>('PlasmaBridge');
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ import PlasmaBridge from './NativePlasmaBridge';
4
+ export class PlasmaAPI {
5
+ static initializePlasma(baseUrl, apiKey) {
6
+ PlasmaBridge.initializePlasma(baseUrl, apiKey);
7
+ }
8
+ static plasmaLogin(userId, deviceToken) {
9
+ PlasmaBridge.plasmaLogin(userId, deviceToken);
10
+ }
11
+ static plasmaLogout() {
12
+ PlasmaBridge.plasmaLogout();
13
+ }
14
+ static setDeviceToken(token) {
15
+ PlasmaBridge.setDeviceToken(token);
16
+ }
17
+ static setUserId(userId) {
18
+ PlasmaBridge.setUserId(userId);
19
+ }
20
+ static setTags(tags) {
21
+ PlasmaBridge.setTags(tags);
22
+ }
23
+ static setUserProps(props) {
24
+ PlasmaBridge.setUserProps(props);
25
+ }
26
+ }
27
+ export default PlasmaAPI;
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PlasmaBridge","PlasmaAPI","initializePlasma","baseUrl","apiKey","plasmaLogin","userId","deviceToken","plasmaLogout","setDeviceToken","token","setUserId","setTags","tags","setUserProps","props"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,YAAY,MAAM,sBAAsB;AAU/C,OAAO,MAAMC,SAAS,CAAC;EACrB,OAAOC,gBAAgBA,CAACC,OAAe,EAAEC,MAAc,EAAQ;IAC7DJ,YAAY,CAACE,gBAAgB,CAACC,OAAO,EAAEC,MAAM,CAAC;EAChD;EAEA,OAAOC,WAAWA,CAACC,MAAc,EAAEC,WAAmB,EAAQ;IAC5DP,YAAY,CAACK,WAAW,CAACC,MAAM,EAAEC,WAAW,CAAC;EAC/C;EAEA,OAAOC,YAAYA,CAAA,EAAS;IAC1BR,YAAY,CAACQ,YAAY,CAAC,CAAC;EAC7B;EAEA,OAAOC,cAAcA,CAACC,KAAa,EAAQ;IACzCV,YAAY,CAACS,cAAc,CAACC,KAAK,CAAC;EACpC;EAEA,OAAOC,SAASA,CAACL,MAAc,EAAQ;IACrCN,YAAY,CAACW,SAAS,CAACL,MAAM,CAAC;EAChC;EAEA,OAAOM,OAAOA,CAACC,IAAU,EAAQ;IAC/Bb,YAAY,CAACY,OAAO,CAACC,IAAI,CAAC;EAC5B;EAEA,OAAOC,YAAYA,CAACC,KAAgB,EAAQ;IAC1Cf,YAAY,CAACc,YAAY,CAACC,KAAK,CAAC;EAClC;AACF;AAEA,eAAed,SAAS","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,17 @@
1
+ import { type TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ initializePlasma(baseUrl: string, apiKey: string): void;
4
+ plasmaLogin(userId: string, deviceToken: string): void;
5
+ plasmaLogout(): void;
6
+ setDeviceToken(token: string): void;
7
+ setUserId(userId: string): void;
8
+ setTags(tags: {
9
+ [key: string]: string | number;
10
+ }): void;
11
+ setUserProps(props: {
12
+ [key: string]: string | number;
13
+ }): void;
14
+ }
15
+ declare const _default: Spec;
16
+ export default _default;
17
+ //# sourceMappingURL=NativePlasmaBridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativePlasmaBridge.d.ts","sourceRoot":"","sources":["../../../src/NativePlasmaBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACxD,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACvD,YAAY,IAAI,IAAI,CAAC;IACrB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACxD,YAAY,CAAC,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC/D;;AAED,wBAAsE"}
@@ -0,0 +1,17 @@
1
+ export interface Tags {
2
+ [key: string]: string | number;
3
+ }
4
+ export interface UserProps {
5
+ [key: string]: string | number;
6
+ }
7
+ export declare class PlasmaAPI {
8
+ static initializePlasma(baseUrl: string, apiKey: string): void;
9
+ static plasmaLogin(userId: string, deviceToken: string): void;
10
+ static plasmaLogout(): void;
11
+ static setDeviceToken(token: string): void;
12
+ static setUserId(userId: string): void;
13
+ static setTags(tags: Tags): void;
14
+ static setUserProps(props: UserProps): void;
15
+ }
16
+ export default PlasmaAPI;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAChC;AAED,qBAAa,SAAS;IACpB,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAI9D,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAI7D,MAAM,CAAC,YAAY,IAAI,IAAI;IAI3B,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI1C,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAItC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAIhC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;CAG5C;AAED,eAAe,SAAS,CAAC"}
package/package.json ADDED
@@ -0,0 +1,184 @@
1
+ {
2
+ "name": "react-native-plasma",
3
+ "version": "0.1.0",
4
+ "description": "React Native bridge for the Plasma SDK",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "react-native": "./src/index.tsx",
8
+ "exports": {
9
+ ".": {
10
+ "source": "./src/index.tsx",
11
+ "types": "./lib/typescript/src/index.d.ts",
12
+ "default": "./lib/module/index.js"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "src",
18
+ "lib",
19
+ "android",
20
+ "ios",
21
+ "cpp",
22
+ "*.podspec",
23
+ "react-native.config.js",
24
+ "!ios/build",
25
+ "!android/build",
26
+ "!android/gradle",
27
+ "!android/gradlew",
28
+ "!android/gradlew.bat",
29
+ "!android/local.properties",
30
+ "!**/__tests__",
31
+ "!**/__fixtures__",
32
+ "!**/__mocks__",
33
+ "!**/.*"
34
+ ],
35
+ "scripts": {
36
+ "clean": "del-cli android/build ios/build lib",
37
+ "build": "NODE_OPTIONS='--experimental-require-module' bob build",
38
+ "prepack": "NODE_OPTIONS='--experimental-require-module' bob build",
39
+ "typecheck": "tsc",
40
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
41
+ "release": "release-it --only-version",
42
+ "test": "jest --passWithNoTests"
43
+ },
44
+ "keywords": [
45
+ "react-native",
46
+ "ios",
47
+ "android",
48
+ "plasma"
49
+ ],
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/nammayatri/react-native-plasma.git"
53
+ },
54
+ "author": "Nammayatri <sdk@nammayatri.in> (https://github.com/nammayatri/react-native-plasma)",
55
+ "license": "MIT",
56
+ "bugs": {
57
+ "url": "https://github.com/nammayatri/react-native-plasma/issues"
58
+ },
59
+ "homepage": "https://github.com/nammayatri/react-native-plasma#readme",
60
+ "publishConfig": {
61
+ "registry": "https://registry.npmjs.org/"
62
+ },
63
+ "devDependencies": {
64
+ "@commitlint/config-conventional": "^19.8.1",
65
+ "@eslint/compat": "^1.3.2",
66
+ "@eslint/eslintrc": "^3.3.1",
67
+ "@eslint/js": "^9.35.0",
68
+ "@react-native-community/cli": "20.0.1",
69
+ "@react-native/babel-preset": "0.81.1",
70
+ "@react-native/eslint-config": "^0.81.1",
71
+ "@release-it/conventional-changelog": "^10.0.1",
72
+ "@types/jest": "^29.5.14",
73
+ "@types/react": "^19.1.0",
74
+ "commitlint": "^19.8.1",
75
+ "del-cli": "^6.0.0",
76
+ "eslint": "^9.35.0",
77
+ "eslint-config-prettier": "^10.1.8",
78
+ "eslint-plugin-prettier": "^5.5.4",
79
+ "jest": "^29.7.0",
80
+ "lefthook": "^2.0.3",
81
+ "prettier": "^2.8.8",
82
+ "react": "19.1.0",
83
+ "react-native": "0.81.1",
84
+ "react-native-builder-bob": "0.40.0",
85
+ "release-it": "^19.0.4",
86
+ "turbo": "^2.5.6",
87
+ "typescript": "^5.9.2",
88
+ "typescript-eslint": "^8.57.1"
89
+ },
90
+ "peerDependencies": {
91
+ "react": "*",
92
+ "react-native": "*"
93
+ },
94
+ "peerDependenciesMeta": {
95
+ "react": {
96
+ "optional": false
97
+ },
98
+ "react-native": {
99
+ "optional": false
100
+ }
101
+ },
102
+ "engines": {
103
+ "node": ">=20.19.0"
104
+ },
105
+ "packageManager": "yarn@4.11.0",
106
+ "react-native-builder-bob": {
107
+ "source": "src",
108
+ "output": "lib",
109
+ "targets": [
110
+ [
111
+ "module",
112
+ {
113
+ "esm": true
114
+ }
115
+ ],
116
+ [
117
+ "typescript",
118
+ {
119
+ "project": "tsconfig.build.json"
120
+ }
121
+ ]
122
+ ]
123
+ },
124
+ "codegenConfig": {
125
+ "name": "PlasmaBridgeSpec",
126
+ "type": "modules",
127
+ "jsSrcsDir": "src",
128
+ "android": {
129
+ "javaPackageName": "com.plasmareactnative"
130
+ },
131
+ "ios": {
132
+ "moduleName": "PlasmaBridge"
133
+ }
134
+ },
135
+ "prettier": {
136
+ "quoteProps": "consistent",
137
+ "singleQuote": true,
138
+ "tabWidth": 2,
139
+ "trailingComma": "es5",
140
+ "useTabs": false
141
+ },
142
+ "commitlint": {
143
+ "extends": [
144
+ "@commitlint/config-conventional"
145
+ ]
146
+ },
147
+ "release-it": {
148
+ "git": {
149
+ "commitMessage": "chore: release ${version}",
150
+ "tagName": "v${version}"
151
+ },
152
+ "npm": {
153
+ "publish": true
154
+ },
155
+ "github": {
156
+ "release": true
157
+ },
158
+ "plugins": {
159
+ "@release-it/conventional-changelog": {
160
+ "preset": {
161
+ "name": "angular"
162
+ }
163
+ }
164
+ }
165
+ },
166
+ "jest": {
167
+ "preset": "react-native",
168
+ "modulePathIgnorePatterns": [
169
+ "<rootDir>/example/node_modules",
170
+ "<rootDir>/lib/"
171
+ ]
172
+ },
173
+ "create-react-native-library": {
174
+ "languages": "kotlin-objc",
175
+ "type": "turbo-module",
176
+ "tools": [
177
+ "eslint",
178
+ "lefthook",
179
+ "release-it",
180
+ "jest"
181
+ ],
182
+ "version": "0.55.1"
183
+ }
184
+ }
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ android: {
5
+ sourceDir: './android',
6
+ packageImportPath: 'import com.plasmareactnative.PlasmaBridgePackage;',
7
+ packageInstance: 'new PlasmaBridgePackage()',
8
+ },
9
+ ios: {
10
+ podspecPath: './RNPlasma.podspec',
11
+ },
12
+ },
13
+ },
14
+ };
@@ -0,0 +1,13 @@
1
+ import { TurboModuleRegistry, type TurboModule } from 'react-native';
2
+
3
+ export interface Spec extends TurboModule {
4
+ initializePlasma(baseUrl: string, apiKey: string): void;
5
+ plasmaLogin(userId: string, deviceToken: string): void;
6
+ plasmaLogout(): void;
7
+ setDeviceToken(token: string): void;
8
+ setUserId(userId: string): void;
9
+ setTags(tags: { [key: string]: string | number }): void;
10
+ setUserProps(props: { [key: string]: string | number }): void;
11
+ }
12
+
13
+ export default TurboModuleRegistry.getEnforcing<Spec>('PlasmaBridge');
package/src/index.tsx ADDED
@@ -0,0 +1,41 @@
1
+ import PlasmaBridge from './NativePlasmaBridge';
2
+
3
+ export interface Tags {
4
+ [key: string]: string | number;
5
+ }
6
+
7
+ export interface UserProps {
8
+ [key: string]: string | number;
9
+ }
10
+
11
+ export class PlasmaAPI {
12
+ static initializePlasma(baseUrl: string, apiKey: string): void {
13
+ PlasmaBridge.initializePlasma(baseUrl, apiKey);
14
+ }
15
+
16
+ static plasmaLogin(userId: string, deviceToken: string): void {
17
+ PlasmaBridge.plasmaLogin(userId, deviceToken);
18
+ }
19
+
20
+ static plasmaLogout(): void {
21
+ PlasmaBridge.plasmaLogout();
22
+ }
23
+
24
+ static setDeviceToken(token: string): void {
25
+ PlasmaBridge.setDeviceToken(token);
26
+ }
27
+
28
+ static setUserId(userId: string): void {
29
+ PlasmaBridge.setUserId(userId);
30
+ }
31
+
32
+ static setTags(tags: Tags): void {
33
+ PlasmaBridge.setTags(tags);
34
+ }
35
+
36
+ static setUserProps(props: UserProps): void {
37
+ PlasmaBridge.setUserProps(props);
38
+ }
39
+ }
40
+
41
+ export default PlasmaAPI;