react-native-ariel 0.1.0-dev.41 → 0.1.0-dev.50
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/Ariel.podspec +1 -1
- package/README.md +8 -63
- package/android/CMakeLists.txt +5 -4
- package/android/build.gradle +6 -0
- package/android/generated/jni/CMakeLists.txt +9 -1
- package/android/generated/jni/react/renderer/components/ArielSpec/ArielSpecJSI-generated.cpp +32 -0
- package/android/generated/jni/react/renderer/components/ArielSpec/ArielSpecJSI.h +52 -17
- package/android/src/main/java/com/ariel/ArielModule.kt +53 -0
- package/android/src/main/java/com/ariel/ArielPackage.kt +34 -0
- package/cpp/generated/mermaid_wrapper.cpp +1 -0
- package/cpp/mermaid_wrapper.cpp +1 -0
- package/ios/generated/ArielSpecJSI-generated.cpp +32 -0
- package/ios/generated/ArielSpecJSI.h +80 -0
- package/package.json +14 -20
- package/react-native.config.js +2 -3
- package/ios/generated/ReactCodegen/ArielSpecJSI.h +0 -45
- package/src/generated/web/wasm-bindgen/package.json +0 -15
- /package/ios/generated/{ReactCodegen/ArielSpec → ArielSpec}/ArielSpec-generated.mm +0 -0
- /package/ios/generated/{ReactCodegen/ArielSpec → ArielSpec}/ArielSpec.h +0 -0
package/Ariel.podspec
CHANGED
|
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.platforms = { :ios => min_ios_version_supported }
|
|
16
16
|
s.source = { :git => "https://github.com/rinfimate/ariel.git", :tag => "#{s.version}" }
|
|
17
17
|
|
|
18
|
-
s.source_files = "ios/**/*.{h,m,mm,swift}", "
|
|
18
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}", "cpp/**/*.{hpp,cpp,c,h}"
|
|
19
19
|
s.vendored_frameworks = "ArielFramework.xcframework"
|
|
20
20
|
s.dependency "uniffi-bindgen-react-native", "0.31.0-2"
|
|
21
21
|
|
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Every other Mermaid solution for React Native requires a DOM, a WebView, or a he
|
|
|
29
29
|
yarn add react-native-ariel react-native-svg
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
> **
|
|
32
|
+
> **Requirements:** React Native **≥ 0.73** with **New Architecture enabled**. On RN 0.73–0.75 you must set `newArchEnabled=true` in `android/gradle.properties` and enable it in your iOS Podfile — New Architecture became the default in RN 0.76.
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
@@ -269,72 +269,17 @@ yarn ubrn:clean
|
|
|
269
269
|
|
|
270
270
|
---
|
|
271
271
|
|
|
272
|
-
## Running the example app
|
|
273
|
-
|
|
274
|
-
The `example/` directory is an Expo app with a live Mermaid editor — type a diagram, see the SVG update in real time with timing stats.
|
|
275
|
-
|
|
276
|
-
### Step 1 — Generate bindings (all platforms, run once)
|
|
277
|
-
|
|
278
|
-
```sh
|
|
279
|
-
yarn ubrn:generate
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Step 2 — Build native libs for your target platform
|
|
283
|
-
|
|
284
|
-
```sh
|
|
285
|
-
# Android
|
|
286
|
-
yarn ubrn:android
|
|
287
|
-
|
|
288
|
-
# iOS (macOS only)
|
|
289
|
-
yarn ubrn:ios
|
|
290
|
-
|
|
291
|
-
# Web — compile WASM bundle
|
|
292
|
-
yarn ubrn:web
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
### Step 3 — Run the example
|
|
296
|
-
|
|
297
|
-
**Web** (no emulator needed — opens in your browser):
|
|
298
|
-
```sh
|
|
299
|
-
yarn example:web
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
**Android** (emulator or USB device with debugging enabled):
|
|
303
|
-
```sh
|
|
304
|
-
yarn example:android
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
**iOS** (macOS only):
|
|
308
|
-
```sh
|
|
309
|
-
yarn example:ios
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
### With Expo Dev Client (install on device)
|
|
313
|
-
|
|
314
|
-
For a shareable installable build that includes the Ariel native module:
|
|
315
|
-
|
|
316
|
-
```sh
|
|
317
|
-
# Install EAS CLI
|
|
318
|
-
npm install -g eas-cli
|
|
319
|
-
|
|
320
|
-
# Build dev client (free for public repos)
|
|
321
|
-
eas build --profile development
|
|
322
|
-
|
|
323
|
-
# Install the .apk / .ipa on your device, then run:
|
|
324
|
-
yarn example:android # or example:ios
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
---
|
|
328
|
-
|
|
329
272
|
## CI
|
|
330
273
|
|
|
331
|
-
|
|
274
|
+
On every push to `main` and on pull requests, `ci.yml` runs:
|
|
332
275
|
|
|
333
|
-
|
|
|
276
|
+
| Job | Runner | What it does |
|
|
334
277
|
|---|---|---|
|
|
335
|
-
| `
|
|
336
|
-
| `build-
|
|
337
|
-
| `build-
|
|
278
|
+
| `test-rust` | `ubuntu-latest` | Rust unit tests |
|
|
279
|
+
| `build-android` | `ubuntu-latest` | Cross-compiles Rust for all Android ABIs |
|
|
280
|
+
| `build-ios` | `macos-latest` | Builds iOS xcframework |
|
|
281
|
+
| `build-web` | `ubuntu-latest` | Builds WASM bundle |
|
|
282
|
+
| `publish` | `ubuntu-latest` | Publishes to npm (push to main or release only) |
|
|
338
283
|
|
|
339
284
|
iOS uses GitHub's free `macos-latest` runner (unlimited minutes on public repos).
|
|
340
285
|
|
package/android/CMakeLists.txt
CHANGED
|
@@ -16,7 +16,6 @@ else()
|
|
|
16
16
|
cmake_path(SET UNIFFI_INCLUDES "${_UNIFFI_HOISTED}" NORMALIZE)
|
|
17
17
|
endif()
|
|
18
18
|
|
|
19
|
-
# Specifies a path to native header files.
|
|
20
19
|
include_directories(
|
|
21
20
|
../cpp
|
|
22
21
|
../cpp/generated
|
|
@@ -41,9 +40,11 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
|
41
40
|
# Set linker flags for 16KB page size alignment (required for Android 15+)
|
|
42
41
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size=16384")
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
cmake_path(
|
|
44
|
+
SET MY_RUST_LIB
|
|
45
|
+
${CMAKE_CURRENT_LIST_DIR}/src/main/jniLibs/${ANDROID_ABI}/libmermaid_wrapper.a
|
|
46
|
+
NORMALIZE
|
|
47
|
+
)
|
|
47
48
|
add_library(my_rust_lib STATIC IMPORTED)
|
|
48
49
|
set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB})
|
|
49
50
|
|
package/android/build.gradle
CHANGED
|
@@ -25,4 +25,12 @@ target_link_libraries(
|
|
|
25
25
|
reactnative
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
target_compile_options(
|
|
29
|
+
react_codegen_ArielSpec
|
|
30
|
+
PRIVATE
|
|
31
|
+
-DLOG_TAG=\"ReactNative\"
|
|
32
|
+
-fexceptions
|
|
33
|
+
-frtti
|
|
34
|
+
-std=c++20
|
|
35
|
+
-Wall
|
|
36
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "ArielSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeArielCxxSpecJSI_installRustCrate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeArielCxxSpecJSI *>(&turboModule)->installRustCrate(
|
|
16
|
+
rt
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
static jsi::Value __hostFunction_NativeArielCxxSpecJSI_cleanupRustCrate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
20
|
+
return static_cast<NativeArielCxxSpecJSI *>(&turboModule)->cleanupRustCrate(
|
|
21
|
+
rt
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
NativeArielCxxSpecJSI::NativeArielCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
26
|
+
: TurboModule("Ariel", jsInvoker) {
|
|
27
|
+
methodMap_["installRustCrate"] = MethodMetadata {0, __hostFunction_NativeArielCxxSpecJSI_installRustCrate};
|
|
28
|
+
methodMap_["cleanupRustCrate"] = MethodMetadata {0, __hostFunction_NativeArielCxxSpecJSI_cleanupRustCrate};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
} // namespace facebook::react
|
|
@@ -15,31 +15,66 @@
|
|
|
15
15
|
namespace facebook::react {
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
class JSI_EXPORT NativeArielCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeArielCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual bool installRustCrate(jsi::Runtime &rt) = 0;
|
|
24
|
+
virtual bool cleanupRustCrate(jsi::Runtime &rt) = 0;
|
|
25
|
+
|
|
26
|
+
};
|
|
27
|
+
|
|
18
28
|
template <typename T>
|
|
19
29
|
class JSI_EXPORT NativeArielCxxSpec : public TurboModule {
|
|
20
30
|
public:
|
|
31
|
+
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
32
|
+
return delegate_.create(rt, propName);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
36
|
+
return delegate_.getPropertyNames(runtime);
|
|
37
|
+
}
|
|
38
|
+
|
|
21
39
|
static constexpr std::string_view kModuleName = "Ariel";
|
|
22
40
|
|
|
23
41
|
protected:
|
|
24
|
-
NativeArielCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
NativeArielCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
43
|
+
: TurboModule(std::string{NativeArielCxxSpec::kModuleName}, jsInvoker),
|
|
44
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
45
|
+
|
|
46
|
+
|
|
29
47
|
private:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return bridging::callFromJs<bool>(rt, &T::installRustCrate, static_cast<NativeArielCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
|
|
35
|
-
}
|
|
48
|
+
class Delegate : public NativeArielCxxSpecJSI {
|
|
49
|
+
public:
|
|
50
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
51
|
+
NativeArielCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
36
52
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
bool installRustCrate(jsi::Runtime &rt) override {
|
|
56
|
+
static_assert(
|
|
57
|
+
bridging::getParameterCount(&T::installRustCrate) == 1,
|
|
58
|
+
"Expected installRustCrate(...) to have 1 parameters");
|
|
59
|
+
|
|
60
|
+
return bridging::callFromJs<bool>(
|
|
61
|
+
rt, &T::installRustCrate, jsInvoker_, instance_);
|
|
62
|
+
}
|
|
63
|
+
bool cleanupRustCrate(jsi::Runtime &rt) override {
|
|
64
|
+
static_assert(
|
|
65
|
+
bridging::getParameterCount(&T::cleanupRustCrate) == 1,
|
|
66
|
+
"Expected cleanupRustCrate(...) to have 1 parameters");
|
|
67
|
+
|
|
68
|
+
return bridging::callFromJs<bool>(
|
|
69
|
+
rt, &T::cleanupRustCrate, jsInvoker_, instance_);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
friend class NativeArielCxxSpec;
|
|
74
|
+
T *instance_;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
Delegate delegate_;
|
|
43
78
|
};
|
|
44
79
|
|
|
45
80
|
} // namespace facebook::react
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
package com.ariel
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
6
|
+
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
|
|
7
|
+
|
|
8
|
+
@ReactModule(name = ArielModule.NAME)
|
|
9
|
+
class ArielModule(reactContext: ReactApplicationContext) :
|
|
10
|
+
NativeArielSpec(reactContext) {
|
|
11
|
+
|
|
12
|
+
override fun getName(): String {
|
|
13
|
+
return NAME
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Two native methods implemented in cpp-adapter.cpp, and ultimately
|
|
17
|
+
// react-native-ariel.cpp
|
|
18
|
+
|
|
19
|
+
external fun nativeInstallRustCrate(runtimePointer: Long, callInvoker: CallInvokerHolder): Boolean
|
|
20
|
+
external fun nativeCleanupRustCrate(runtimePointer: Long): Boolean
|
|
21
|
+
|
|
22
|
+
override fun installRustCrate(): Boolean {
|
|
23
|
+
val context = this.reactApplicationContext
|
|
24
|
+
return nativeInstallRustCrate(
|
|
25
|
+
context.javaScriptContextHolder!!.get(),
|
|
26
|
+
resolveCallInvokerHolder(context)
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private fun resolveCallInvokerHolder(context: ReactApplicationContext): CallInvokerHolder {
|
|
31
|
+
// RN 0.74+ exposes getJSCallInvokerHolder() on ReactContext directly.
|
|
32
|
+
// RN 0.73 only has it on CatalystInstance — use reflection to handle both.
|
|
33
|
+
val direct = context.javaClass.methods.firstOrNull { it.name == "getJSCallInvokerHolder" }
|
|
34
|
+
if (direct != null) return direct.invoke(context) as CallInvokerHolder
|
|
35
|
+
@Suppress("DEPRECATION")
|
|
36
|
+
val ci = checkNotNull(context.catalystInstance) { "No CatalystInstance" }
|
|
37
|
+
return ci.javaClass.methods.first { it.name == "getJSCallInvokerHolder" }.invoke(ci) as CallInvokerHolder
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override fun cleanupRustCrate(): Boolean {
|
|
41
|
+
return nativeCleanupRustCrate(
|
|
42
|
+
this.reactApplicationContext.javaScriptContextHolder!!.get()
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
companion object {
|
|
47
|
+
const val NAME = "Ariel"
|
|
48
|
+
|
|
49
|
+
init {
|
|
50
|
+
System.loadLibrary("react-native-ariel")
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
package com.ariel
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.TurboReactPackage
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
9
|
+
import java.util.HashMap
|
|
10
|
+
|
|
11
|
+
class ArielPackage : TurboReactPackage() {
|
|
12
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
13
|
+
return if (name == ArielModule.NAME) {
|
|
14
|
+
ArielModule(reactContext)
|
|
15
|
+
} else {
|
|
16
|
+
null
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
21
|
+
return ReactModuleInfoProvider {
|
|
22
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
23
|
+
moduleInfos[ArielModule.NAME] = ReactModuleInfo(
|
|
24
|
+
ArielModule.NAME,
|
|
25
|
+
ArielModule.NAME,
|
|
26
|
+
false, // canOverrideExistingModule
|
|
27
|
+
false, // needsEagerInit
|
|
28
|
+
false, // isCxxModule
|
|
29
|
+
true // isTurboModule
|
|
30
|
+
)
|
|
31
|
+
moduleInfos
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/cpp/mermaid_wrapper.cpp
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "ArielSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeArielCxxSpecJSI_installRustCrate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeArielCxxSpecJSI *>(&turboModule)->installRustCrate(
|
|
16
|
+
rt
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
static jsi::Value __hostFunction_NativeArielCxxSpecJSI_cleanupRustCrate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
20
|
+
return static_cast<NativeArielCxxSpecJSI *>(&turboModule)->cleanupRustCrate(
|
|
21
|
+
rt
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
NativeArielCxxSpecJSI::NativeArielCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
26
|
+
: TurboModule("Ariel", jsInvoker) {
|
|
27
|
+
methodMap_["installRustCrate"] = MethodMetadata {0, __hostFunction_NativeArielCxxSpecJSI_installRustCrate};
|
|
28
|
+
methodMap_["cleanupRustCrate"] = MethodMetadata {0, __hostFunction_NativeArielCxxSpecJSI_cleanupRustCrate};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSI_EXPORT NativeArielCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeArielCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual bool installRustCrate(jsi::Runtime &rt) = 0;
|
|
24
|
+
virtual bool cleanupRustCrate(jsi::Runtime &rt) = 0;
|
|
25
|
+
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
template <typename T>
|
|
29
|
+
class JSI_EXPORT NativeArielCxxSpec : public TurboModule {
|
|
30
|
+
public:
|
|
31
|
+
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
32
|
+
return delegate_.create(rt, propName);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
36
|
+
return delegate_.getPropertyNames(runtime);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static constexpr std::string_view kModuleName = "Ariel";
|
|
40
|
+
|
|
41
|
+
protected:
|
|
42
|
+
NativeArielCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
43
|
+
: TurboModule(std::string{NativeArielCxxSpec::kModuleName}, jsInvoker),
|
|
44
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
private:
|
|
48
|
+
class Delegate : public NativeArielCxxSpecJSI {
|
|
49
|
+
public:
|
|
50
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
51
|
+
NativeArielCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
bool installRustCrate(jsi::Runtime &rt) override {
|
|
56
|
+
static_assert(
|
|
57
|
+
bridging::getParameterCount(&T::installRustCrate) == 1,
|
|
58
|
+
"Expected installRustCrate(...) to have 1 parameters");
|
|
59
|
+
|
|
60
|
+
return bridging::callFromJs<bool>(
|
|
61
|
+
rt, &T::installRustCrate, jsInvoker_, instance_);
|
|
62
|
+
}
|
|
63
|
+
bool cleanupRustCrate(jsi::Runtime &rt) override {
|
|
64
|
+
static_assert(
|
|
65
|
+
bridging::getParameterCount(&T::cleanupRustCrate) == 1,
|
|
66
|
+
"Expected cleanupRustCrate(...) to have 1 parameters");
|
|
67
|
+
|
|
68
|
+
return bridging::callFromJs<bool>(
|
|
69
|
+
rt, &T::cleanupRustCrate, jsInvoker_, instance_);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
friend class NativeArielCxxSpec;
|
|
74
|
+
T *instance_;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
Delegate delegate_;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace facebook::react
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-ariel",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.50",
|
|
4
4
|
"description": "Mermaid diagrams for React Native and React Native Web. No DOM. No WebView. Pure Rust.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"source": "./src/index.tsx",
|
|
7
7
|
"types": "./lib/typescript/src/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"browser": "./
|
|
10
|
+
"browser": "./lib/module/index.web.js",
|
|
11
11
|
"source": "./src/index.tsx",
|
|
12
12
|
"types": "./lib/typescript/src/index.d.ts",
|
|
13
13
|
"default": "./lib/module/index.js"
|
|
@@ -34,15 +34,11 @@
|
|
|
34
34
|
"!**/.*"
|
|
35
35
|
],
|
|
36
36
|
"scripts": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"example:ios": "yarn workspace react-native-ariel-example ios",
|
|
40
|
-
"example:web": "yarn workspace react-native-ariel-example web",
|
|
41
|
-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
42
|
-
"prepare": "bob build",
|
|
37
|
+
"clean": "del-cli android/build lib",
|
|
38
|
+
"prepare": "bob build && node scripts/copy-wasm-to-lib.js",
|
|
43
39
|
"typecheck": "tsc",
|
|
44
40
|
"test": "jest",
|
|
45
|
-
"ubrn:ios": "ubrn build ios
|
|
41
|
+
"ubrn:ios": "ubrn build ios",
|
|
46
42
|
"ubrn:ios-ci": "ubrn build ios",
|
|
47
43
|
"ubrn:android": "ubrn build android",
|
|
48
44
|
"ubrn:web": "wasm-pack build rust_modules/wasm --target web --out-dir ../../src/generated/web/wasm-bindgen && node scripts/patch-wasm.js",
|
|
@@ -83,26 +79,22 @@
|
|
|
83
79
|
"devDependencies": {
|
|
84
80
|
"@jest/globals": "^30.0.0",
|
|
85
81
|
"@react-native-community/cli": "20.1.0",
|
|
86
|
-
"@react-native/babel-preset": "0.
|
|
87
|
-
"@react
|
|
88
|
-
"@types/react": "^19.2.0",
|
|
82
|
+
"@react-native/babel-preset": "0.77.0",
|
|
83
|
+
"@types/react": "^18.3.0",
|
|
89
84
|
"del-cli": "^7.0.0",
|
|
90
85
|
"jest": "^30.3.0",
|
|
91
86
|
"prettier": "^3.8.3",
|
|
92
|
-
"react": "
|
|
93
|
-
"react-native": "0.
|
|
87
|
+
"react": "18.3.1",
|
|
88
|
+
"react-native": "0.77.0",
|
|
94
89
|
"react-native-builder-bob": "^0.41.0",
|
|
95
90
|
"turbo": "^2.8.21",
|
|
96
91
|
"typescript": "^6.0.2"
|
|
97
92
|
},
|
|
98
93
|
"peerDependencies": {
|
|
99
94
|
"react": "*",
|
|
100
|
-
"react-native": "
|
|
95
|
+
"react-native": ">=0.73.0",
|
|
101
96
|
"react-native-svg": ">=13.0.0"
|
|
102
97
|
},
|
|
103
|
-
"workspaces": [
|
|
104
|
-
"example"
|
|
105
|
-
],
|
|
106
98
|
"packageManager": "yarn@4.11.0",
|
|
107
99
|
"react-native-builder-bob": {
|
|
108
100
|
"source": "src",
|
|
@@ -138,9 +130,11 @@
|
|
|
138
130
|
"includesGeneratedCode": true
|
|
139
131
|
},
|
|
140
132
|
"jest": {
|
|
141
|
-
"
|
|
133
|
+
"testEnvironment": "node",
|
|
134
|
+
"transform": {
|
|
135
|
+
"^.+\\.(ts|tsx|js|jsx)$": "babel-jest"
|
|
136
|
+
},
|
|
142
137
|
"modulePathIgnorePatterns": [
|
|
143
|
-
"<rootDir>/example/node_modules",
|
|
144
138
|
"<rootDir>/lib/"
|
|
145
139
|
]
|
|
146
140
|
},
|
package/react-native.config.js
CHANGED
|
@@ -5,10 +5,9 @@ module.exports = {
|
|
|
5
5
|
dependency: {
|
|
6
6
|
platforms: {
|
|
7
7
|
android: {
|
|
8
|
-
cmakeListsPath: 'CMakeLists.txt',
|
|
8
|
+
cmakeListsPath: 'generated/jni/CMakeLists.txt',
|
|
9
9
|
cxxModuleCMakeListsModuleName: 'react-native-ariel',
|
|
10
|
-
cxxModuleCMakeListsPath: '
|
|
11
|
-
cxxModuleHeaderName: 'ArielImpl',
|
|
10
|
+
cxxModuleCMakeListsPath: 'CMakeLists.txt',
|
|
12
11
|
},
|
|
13
12
|
},
|
|
14
13
|
},
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
-
*
|
|
4
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
-
* once the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
#pragma once
|
|
11
|
-
|
|
12
|
-
#include <ReactCommon/TurboModule.h>
|
|
13
|
-
#include <react/bridging/Bridging.h>
|
|
14
|
-
|
|
15
|
-
namespace facebook::react {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
template <typename T>
|
|
19
|
-
class JSI_EXPORT NativeArielCxxSpec : public TurboModule {
|
|
20
|
-
public:
|
|
21
|
-
static constexpr std::string_view kModuleName = "Ariel";
|
|
22
|
-
|
|
23
|
-
protected:
|
|
24
|
-
NativeArielCxxSpec(std::shared_ptr<CallInvoker> jsInvoker) : TurboModule(std::string{NativeArielCxxSpec::kModuleName}, jsInvoker) {
|
|
25
|
-
methodMap_["installRustCrate"] = MethodMetadata {.argCount = 0, .invoker = __installRustCrate};
|
|
26
|
-
methodMap_["cleanupRustCrate"] = MethodMetadata {.argCount = 0, .invoker = __cleanupRustCrate};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private:
|
|
30
|
-
static jsi::Value __installRustCrate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
|
|
31
|
-
static_assert(
|
|
32
|
-
bridging::getParameterCount(&T::installRustCrate) == 1,
|
|
33
|
-
"Expected installRustCrate(...) to have 1 parameters");
|
|
34
|
-
return bridging::callFromJs<bool>(rt, &T::installRustCrate, static_cast<NativeArielCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static jsi::Value __cleanupRustCrate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
|
|
38
|
-
static_assert(
|
|
39
|
-
bridging::getParameterCount(&T::cleanupRustCrate) == 1,
|
|
40
|
-
"Expected cleanupRustCrate(...) to have 1 parameters");
|
|
41
|
-
return bridging::callFromJs<bool>(rt, &T::cleanupRustCrate, static_cast<NativeArielCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
} // namespace facebook::react
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-native-ariel",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "0.1.0",
|
|
5
|
-
"files": [
|
|
6
|
-
"react_native_ariel_bg.wasm",
|
|
7
|
-
"react_native_ariel.js",
|
|
8
|
-
"react_native_ariel.d.ts"
|
|
9
|
-
],
|
|
10
|
-
"main": "react_native_ariel.js",
|
|
11
|
-
"types": "react_native_ariel.d.ts",
|
|
12
|
-
"sideEffects": [
|
|
13
|
-
"./snippets/*"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
File without changes
|
|
File without changes
|