@syntropika/tembra-react-native 0.0.0-stage → 0.2.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.
- package/LICENSE +202 -0
- package/README.md +8 -2
- package/Tembra.podspec +21 -0
- package/android/build.gradle +47 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/tembra/TembraModule.kt +52 -0
- package/android/src/main/java/com/tembra/TembraPackage.kt +26 -0
- package/ios/RCTTembra.h +10 -0
- package/ios/RCTTembra.mm +58 -0
- package/ios/Tembra.swift +55 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0-sources.jar +0 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0-sources.jar.md5 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0-sources.jar.sha1 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0-sources.jar.sha256 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0-sources.jar.sha512 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.aar +0 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.aar.md5 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.aar.sha1 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.aar.sha256 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.aar.sha512 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.module +116 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.module.md5 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.module.sha1 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.module.sha256 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.module.sha512 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.pom +35 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.pom.md5 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.pom.sha1 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.pom.sha256 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/0.2.0/tembra-kotlin-0.2.0.pom.sha512 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/maven-metadata.xml +13 -0
- package/native/maven/dev/tembra/tembra-kotlin/maven-metadata.xml.md5 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/maven-metadata.xml.sha1 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/maven-metadata.xml.sha256 +1 -0
- package/native/maven/dev/tembra/tembra-kotlin/maven-metadata.xml.sha512 +1 -0
- package/native/swift/Sources/TembraNative/Generated/TembraNative.swift +780 -0
- package/native/swift/Sources/TembraNative/TembraKernel.swift +24 -0
- package/native/swift/TembraFFI.xcframework/Info.plist +65 -0
- package/native/swift/TembraFFI.xcframework/ios-arm64/Headers/TembraFFI.h +556 -0
- package/native/swift/TembraFFI.xcframework/ios-arm64/Headers/module.modulemap +7 -0
- package/native/swift/TembraFFI.xcframework/ios-arm64/libtembra_mobile.a +0 -0
- package/native/swift/TembraFFI.xcframework/ios-arm64_x86_64-simulator/Headers/TembraFFI.h +556 -0
- package/native/swift/TembraFFI.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap +7 -0
- package/native/swift/TembraFFI.xcframework/ios-arm64_x86_64-simulator/libtembra_mobile.a +4 -0
- package/native/swift/TembraFFI.xcframework/macos-arm64_x86_64/Headers/TembraFFI.h +556 -0
- package/native/swift/TembraFFI.xcframework/macos-arm64_x86_64/Headers/module.modulemap +7 -0
- package/native/swift/TembraFFI.xcframework/macos-arm64_x86_64/libtembra_mobile.a +4 -0
- package/package.json +49 -4
- package/react-native.config.js +12 -0
- package/src/NativeTembra.ts +13 -0
- package/src/index.ts +22 -0
- package/src/kernel.ts +25 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Tembra for React Native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@syntropika/tembra-react-native` runs TypeScript orbs on iOS and Android.
|
|
4
|
+
Swift and Kotlin bindings connect the SDK to the shared Rust kernel.
|
|
5
|
+
The package requires React Native 0.82 or newer with the New Architecture.
|
|
6
|
+
|
|
7
|
+
See the [React Native guide](../../../docs/react-native.md) for installation, use and cleanup.
|
|
8
|
+
See [Native builds](../../../DEVELOP.md#native-builds) to generate bindings and package native libraries.
|
|
9
|
+
See [Architecture](../../../docs/architecture.md) for the crate and package boundaries.
|
package/Tembra.podspec
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
3
|
+
|
|
4
|
+
Pod::Spec.new do |s|
|
|
5
|
+
s.name = 'Tembra'
|
|
6
|
+
s.version = package['version']
|
|
7
|
+
s.summary = package['description']
|
|
8
|
+
s.homepage = 'https://github.com/syntropika/tembra'
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.authors = 'Tembra contributors'
|
|
11
|
+
s.source = { :git => 'https://github.com/syntropika/tembra.git', :tag => "v#{s.version}" }
|
|
12
|
+
s.platforms = { :ios => '15.1' }
|
|
13
|
+
s.swift_version = '5.9'
|
|
14
|
+
s.source_files = 'ios/**/*.{h,mm,swift}', 'native/swift/Sources/**/*.swift'
|
|
15
|
+
s.public_header_files = 'ios/RCTTembra.h'
|
|
16
|
+
s.vendored_frameworks = 'native/swift/TembraFFI.xcframework'
|
|
17
|
+
s.frameworks = 'Security', 'SystemConfiguration'
|
|
18
|
+
s.libraries = 'c++', 'resolv'
|
|
19
|
+
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
|
20
|
+
install_modules_dependencies(s)
|
|
21
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
dependencies {
|
|
7
|
+
classpath("com.android.tools.build:gradle:8.9.2")
|
|
8
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.20")
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
apply plugin: "com.android.library"
|
|
13
|
+
apply plugin: "org.jetbrains.kotlin.android"
|
|
14
|
+
apply plugin: "com.facebook.react"
|
|
15
|
+
|
|
16
|
+
react {
|
|
17
|
+
jsRootDir = file("../src")
|
|
18
|
+
libraryName = "TembraSpec"
|
|
19
|
+
codegenJavaPackageName = "com.tembra"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
android {
|
|
23
|
+
namespace "com.tembra"
|
|
24
|
+
compileSdkVersion rootProject.ext.has("compileSdkVersion") ? rootProject.ext.compileSdkVersion : 36
|
|
25
|
+
defaultConfig {
|
|
26
|
+
minSdkVersion 24
|
|
27
|
+
targetSdkVersion 36
|
|
28
|
+
}
|
|
29
|
+
compileOptions {
|
|
30
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
31
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
32
|
+
}
|
|
33
|
+
kotlinOptions { jvmTarget = "17" }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
repositories {
|
|
37
|
+
maven { url = uri("../native/maven") }
|
|
38
|
+
google()
|
|
39
|
+
mavenCentral()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
def tembraVersion = new groovy.json.JsonSlurper().parse(file("../package.json")).version
|
|
43
|
+
|
|
44
|
+
dependencies {
|
|
45
|
+
implementation("com.facebook.react:react-android")
|
|
46
|
+
implementation("dev.tembra:tembra-kotlin:${tembraVersion}")
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
package com.tembra
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import java.util.UUID
|
|
5
|
+
|
|
6
|
+
/** Own kernels for one React Native module, including reload cleanup. */
|
|
7
|
+
class TembraModule(context: ReactApplicationContext) : NativeTembraSpec(context) {
|
|
8
|
+
private val kernels = mutableMapOf<String, TembraKernel>()
|
|
9
|
+
private var invalidated = false
|
|
10
|
+
|
|
11
|
+
/** Return the name used by the generated JavaScript specification. */
|
|
12
|
+
override fun getName() = NAME
|
|
13
|
+
|
|
14
|
+
/** Allocate an isolated Rust worker for one host. */
|
|
15
|
+
@Synchronized
|
|
16
|
+
override fun createKernel(): String {
|
|
17
|
+
check(!invalidated) { "The native module has been invalidated" }
|
|
18
|
+
val handle = UUID.randomUUID().toString()
|
|
19
|
+
kernels[handle] = TembraKernel()
|
|
20
|
+
return handle
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Exchange metadata synchronously without retaining application values. */
|
|
24
|
+
@Synchronized
|
|
25
|
+
override fun request(handle: String, metadata: String): String {
|
|
26
|
+
val kernel = checkNotNull(kernels[handle]) { "The native kernel has been released" }
|
|
27
|
+
return kernel.request(metadata)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Release native storage after JavaScript lifecycle cleanup. */
|
|
31
|
+
@Synchronized
|
|
32
|
+
override fun releaseKernel(handle: String): Boolean {
|
|
33
|
+
val kernel = kernels.remove(handle) ?: return false
|
|
34
|
+
kernel.close()
|
|
35
|
+
return true
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Stop all workers when the React Native instance is destroyed. */
|
|
39
|
+
@Synchronized
|
|
40
|
+
override fun invalidate() {
|
|
41
|
+
invalidated = true
|
|
42
|
+
kernels.values.forEach { kernel ->
|
|
43
|
+
kernel.close()
|
|
44
|
+
}
|
|
45
|
+
kernels.clear()
|
|
46
|
+
super.invalidate()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
companion object {
|
|
50
|
+
const val NAME = "NativeTembra"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.tembra
|
|
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
|
+
|
|
9
|
+
/** Register the generated TurboModule with React Native autolinking. */
|
|
10
|
+
class TembraPackage : BaseReactPackage() {
|
|
11
|
+
/** Create the module only when React Native requests it. */
|
|
12
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? =
|
|
13
|
+
if (name == TembraModule.NAME) TembraModule(reactContext) else null
|
|
14
|
+
|
|
15
|
+
/** Advertise synchronous TurboModule support to the runtime. */
|
|
16
|
+
override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
|
|
17
|
+
mapOf(TembraModule.NAME to ReactModuleInfo(
|
|
18
|
+
TembraModule.NAME,
|
|
19
|
+
TembraModule.NAME,
|
|
20
|
+
false,
|
|
21
|
+
false,
|
|
22
|
+
false,
|
|
23
|
+
true,
|
|
24
|
+
))
|
|
25
|
+
}
|
|
26
|
+
}
|
package/ios/RCTTembra.h
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
// Swift imports the pod's public headers without C++ interoperability enabled.
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
#import <TembraSpec/TembraSpec.h>
|
|
6
|
+
#import <React/RCTInvalidating.h>
|
|
7
|
+
|
|
8
|
+
@interface RCTTembra : NSObject <NativeTembraSpec, RCTInvalidating>
|
|
9
|
+
@end
|
|
10
|
+
#endif
|
package/ios/RCTTembra.mm
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#import "RCTTembra.h"
|
|
2
|
+
#import "Tembra-Swift.h"
|
|
3
|
+
|
|
4
|
+
@implementation RCTTembra {
|
|
5
|
+
Tembra *_storage;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
RCT_EXPORT_MODULE(NativeTembra)
|
|
9
|
+
|
|
10
|
+
/** Construct the Swift owner without allocating a kernel until requested. */
|
|
11
|
+
- (instancetype)init {
|
|
12
|
+
if (self = [super init]) {
|
|
13
|
+
_storage = [Tembra new];
|
|
14
|
+
}
|
|
15
|
+
return self;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Allow module creation outside the main queue. */
|
|
19
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
20
|
+
return NO;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Allocate one kernel and translate transport errors into JavaScript exceptions. */
|
|
24
|
+
- (NSString *)createKernel {
|
|
25
|
+
NSError *error = nil;
|
|
26
|
+
NSString *handle = [_storage createKernelAndReturnError:&error];
|
|
27
|
+
if (error) {
|
|
28
|
+
@throw [NSException exceptionWithName:@"TembraError" reason:error.localizedDescription userInfo:nil];
|
|
29
|
+
}
|
|
30
|
+
return handle;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Preserve the kernel response envelope across the Swift adapter. */
|
|
34
|
+
- (NSString *)request:(NSString *)handle metadata:(NSString *)metadata {
|
|
35
|
+
NSError *error = nil;
|
|
36
|
+
NSString *response = [_storage request:handle metadata:metadata error:&error];
|
|
37
|
+
if (error) {
|
|
38
|
+
@throw [NSException exceptionWithName:@"TembraError" reason:error.localizedDescription userInfo:nil];
|
|
39
|
+
}
|
|
40
|
+
return response;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Release storage after JavaScript host cleanup. */
|
|
44
|
+
- (NSNumber *)releaseKernel:(NSString *)handle {
|
|
45
|
+
return @([_storage releaseKernel:handle]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Tear down all remaining kernels during React Native invalidation. */
|
|
49
|
+
- (void)invalidate {
|
|
50
|
+
[_storage invalidate];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Connect the generated synchronous methods to JSI. */
|
|
54
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
55
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
56
|
+
return std::make_shared<facebook::react::NativeTembraSpecJSI>(params);
|
|
57
|
+
}
|
|
58
|
+
@end
|
package/ios/Tembra.swift
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/** Own native kernels independently of the React Native calling thread. */
|
|
4
|
+
@objc(Tembra) public final class Tembra: NSObject {
|
|
5
|
+
private let lock = NSLock()
|
|
6
|
+
private var kernels: [String: TembraKernel] = [:]
|
|
7
|
+
private var invalidated = false
|
|
8
|
+
|
|
9
|
+
/** Allocate an isolated native kernel for one JavaScript host. */
|
|
10
|
+
@objc public func createKernel() throws -> String {
|
|
11
|
+
lock.lock()
|
|
12
|
+
defer { lock.unlock() }
|
|
13
|
+
guard !invalidated else {
|
|
14
|
+
throw NSError(domain: "NativeTembra", code: 1, userInfo: [
|
|
15
|
+
NSLocalizedDescriptionKey: "The native module has been invalidated"
|
|
16
|
+
])
|
|
17
|
+
}
|
|
18
|
+
let handle = UUID().uuidString
|
|
19
|
+
kernels[handle] = try TembraKernel()
|
|
20
|
+
return handle
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Forward metadata while excluding concurrent invalidation. */
|
|
24
|
+
@objc public func request(_ handle: String, metadata: String) throws -> String {
|
|
25
|
+
lock.lock()
|
|
26
|
+
defer { lock.unlock() }
|
|
27
|
+
guard let kernel = kernels[handle] else {
|
|
28
|
+
throw NSError(domain: "NativeTembra", code: 1, userInfo: [
|
|
29
|
+
NSLocalizedDescriptionKey: "The native kernel has been released"
|
|
30
|
+
])
|
|
31
|
+
}
|
|
32
|
+
return try kernel.request(metadata)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Release one kernel after the host has drained its lifecycle. */
|
|
36
|
+
@objc public func releaseKernel(_ handle: String) -> Bool {
|
|
37
|
+
lock.lock()
|
|
38
|
+
defer { lock.unlock() }
|
|
39
|
+
guard let kernel = kernels.removeValue(forKey: handle) else { return false }
|
|
40
|
+
kernel.close()
|
|
41
|
+
return true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Release every worker when React Native destroys the module. */
|
|
45
|
+
@objc public func invalidate() {
|
|
46
|
+
lock.lock()
|
|
47
|
+
defer { lock.unlock() }
|
|
48
|
+
invalidated = true
|
|
49
|
+
for kernel in kernels.values { kernel.close() }
|
|
50
|
+
kernels.removeAll()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Stop workers when the module is deallocated without explicit invalidation. */
|
|
54
|
+
deinit { invalidate() }
|
|
55
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
16cc016503aa4f490073091ba4cc95f3
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
330c40e17d67f65e26ab7303e6e1a5f8fa30f813
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
6820483e95b767d9a4ae50ab1c6c0e148fde7a9862b441fd5c3279b8c1e0f852
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ee0affce17966e01b480d9e6d41500712b670bd2949d2a43aca6ae8edd95e58daff3f7a83c6cf476dc0d9c5b94bffa63fbf69d7715133983dc3b7543a2f6e3ba
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
19d949a143225c60fdec63afd4a8aeed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3ac0ead04dbdd7232f5a3ab667d397414308126a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f09d59de211cc506611a20d657e64cdc49b6b5d81e2a8152b73c3688e45a1b0c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7921e6ed861ad55a0a66e1f26d5ee7f10424652c786dac4211c68de14c0ee38876f9a904fc38a9b33d36dc167276ef17c6562a022017052dcac24d149c14a906
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
{
|
|
2
|
+
"formatVersion": "1.1",
|
|
3
|
+
"component": {
|
|
4
|
+
"group": "dev.tembra",
|
|
5
|
+
"module": "tembra-kotlin",
|
|
6
|
+
"version": "0.2.0",
|
|
7
|
+
"attributes": {
|
|
8
|
+
"org.gradle.status": "release"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"createdBy": {
|
|
12
|
+
"gradle": {
|
|
13
|
+
"version": "8.11.1"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"variants": [
|
|
17
|
+
{
|
|
18
|
+
"name": "releaseVariantReleaseApiPublication",
|
|
19
|
+
"attributes": {
|
|
20
|
+
"org.gradle.category": "library",
|
|
21
|
+
"org.gradle.dependency.bundling": "external",
|
|
22
|
+
"org.gradle.libraryelements": "aar",
|
|
23
|
+
"org.gradle.usage": "java-api"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": [
|
|
26
|
+
{
|
|
27
|
+
"group": "org.jetbrains.kotlin",
|
|
28
|
+
"module": "kotlin-stdlib",
|
|
29
|
+
"version": {
|
|
30
|
+
"requires": "2.1.20"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"files": [
|
|
35
|
+
{
|
|
36
|
+
"name": "tembra-kotlin-0.2.0.aar",
|
|
37
|
+
"url": "tembra-kotlin-0.2.0.aar",
|
|
38
|
+
"size": 1862737,
|
|
39
|
+
"sha512": "7921e6ed861ad55a0a66e1f26d5ee7f10424652c786dac4211c68de14c0ee38876f9a904fc38a9b33d36dc167276ef17c6562a022017052dcac24d149c14a906",
|
|
40
|
+
"sha256": "f09d59de211cc506611a20d657e64cdc49b6b5d81e2a8152b73c3688e45a1b0c",
|
|
41
|
+
"sha1": "3ac0ead04dbdd7232f5a3ab667d397414308126a",
|
|
42
|
+
"md5": "19d949a143225c60fdec63afd4a8aeed"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "releaseVariantReleaseRuntimePublication",
|
|
48
|
+
"attributes": {
|
|
49
|
+
"org.gradle.category": "library",
|
|
50
|
+
"org.gradle.dependency.bundling": "external",
|
|
51
|
+
"org.gradle.libraryelements": "aar",
|
|
52
|
+
"org.gradle.usage": "java-runtime"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": [
|
|
55
|
+
{
|
|
56
|
+
"group": "net.java.dev.jna",
|
|
57
|
+
"module": "jna",
|
|
58
|
+
"version": {
|
|
59
|
+
"requires": "5.17.0"
|
|
60
|
+
},
|
|
61
|
+
"excludes": [
|
|
62
|
+
{
|
|
63
|
+
"group": "*",
|
|
64
|
+
"module": "*"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"thirdPartyCompatibility": {
|
|
68
|
+
"artifactSelector": {
|
|
69
|
+
"name": "jna",
|
|
70
|
+
"type": "aar",
|
|
71
|
+
"extension": "aar"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"group": "org.jetbrains.kotlin",
|
|
77
|
+
"module": "kotlin-stdlib",
|
|
78
|
+
"version": {
|
|
79
|
+
"requires": "2.1.20"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"files": [
|
|
84
|
+
{
|
|
85
|
+
"name": "tembra-kotlin-0.2.0.aar",
|
|
86
|
+
"url": "tembra-kotlin-0.2.0.aar",
|
|
87
|
+
"size": 1862737,
|
|
88
|
+
"sha512": "7921e6ed861ad55a0a66e1f26d5ee7f10424652c786dac4211c68de14c0ee38876f9a904fc38a9b33d36dc167276ef17c6562a022017052dcac24d149c14a906",
|
|
89
|
+
"sha256": "f09d59de211cc506611a20d657e64cdc49b6b5d81e2a8152b73c3688e45a1b0c",
|
|
90
|
+
"sha1": "3ac0ead04dbdd7232f5a3ab667d397414308126a",
|
|
91
|
+
"md5": "19d949a143225c60fdec63afd4a8aeed"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "releaseVariantReleaseSourcePublication",
|
|
97
|
+
"attributes": {
|
|
98
|
+
"org.gradle.category": "documentation",
|
|
99
|
+
"org.gradle.dependency.bundling": "external",
|
|
100
|
+
"org.gradle.docstype": "sources",
|
|
101
|
+
"org.gradle.usage": "java-runtime"
|
|
102
|
+
},
|
|
103
|
+
"files": [
|
|
104
|
+
{
|
|
105
|
+
"name": "tembra-kotlin-0.2.0-sources.jar",
|
|
106
|
+
"url": "tembra-kotlin-0.2.0-sources.jar",
|
|
107
|
+
"size": 13954,
|
|
108
|
+
"sha512": "ee0affce17966e01b480d9e6d41500712b670bd2949d2a43aca6ae8edd95e58daff3f7a83c6cf476dc0d9c5b94bffa63fbf69d7715133983dc3b7543a2f6e3ba",
|
|
109
|
+
"sha256": "6820483e95b767d9a4ae50ab1c6c0e148fde7a9862b441fd5c3279b8c1e0f852",
|
|
110
|
+
"sha1": "330c40e17d67f65e26ab7303e6e1a5f8fa30f813",
|
|
111
|
+
"md5": "16cc016503aa4f490073091ba4cc95f3"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
6e55b46e02b8b4648f8224ecbf84eae0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5e5d3f4ac420e7c3395a236360dc567bfd38651e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f30a4140ed374793052d8ecf70981906fe102c1a7f4250a9fb147790e5af5725
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
33232edfdbf52cf65a67d9cc5707e8e59a1d1415b566ef1e7016f03a8d4044016d0d41488a788e98cf8a1d1b9c14e9b0db009ac6adbb9f453cc7b533eb7a5f87
|