Commit Graph
263 Commits
Author SHA1 Message Date
Marc RousavyandGitHub baed798c3e feat: Create React Native ViewManager (+ Props + State) for HybridViews (#500) 2025-01-20 16:40:15 +01:00
Marc RousavyandGitHub 33871840a9 feat: Create HybridView code generator base (#494)
* feat: Create `HybridView` Swift and Kotlin base

* fix: HybridView

* feat: Add `HybridView.ts` to nitrogen

* feat: Add necessary changes to nitrogen

* fix: Actually resolve type to find base types (HybridView -> HybridObject)

* feat: Generate TestView.nitro.ts 🎉

* fix: Fix hybrid view base accidentally

* fix: Pass `HybridData` to super

* fix: Finally fix `HybridView` recursion

* fix: Make `HybridView` the protocol's base instead

* Always inherit HybridObject

* run nitrogen

* feat: Create props file

* Name it component

* fix: Indent

* Add warn for RN 78 requirement

* move into `views`

* Create `.mm` file as well

* Add super.load

* fix: Fix namespace

* fix: indent

* fix it?

* Update NitroDefines.hpp

* fix: Make `/views/` private header

* Add filter func and some docs

* feat: More docs

* sort

* feat: Also create Android part

* feat: Implement actual prop parsing

* ah fix

* fix: Runtime type

* fix: Add `hashString(string_view)` equivalent

* fix: Add string_view and string overloads

* fix: indent shadownode

* whoops

* fix: Wrap in state

* comments

* fix: Fix throw when RN isnt present

* fix: Fix `Any?` type

* fix: Includes

* feat: Autolink it and implement it..?

* fix: Load native part of `NitroImage` in shared OnLoad.kt file

* fix: Actually add view-manager to Package

* fix: Rename to Hybrid* prefix

* fix: Use the `*OnLoad` init func now

* fix: Remove duplicate JNI registrations
2025-01-15 20:18:15 +01:00
Marc RousavyandGitHub b387586142 fix: Rename TypeInfo.hpp to NitroTypeInfo.hpp (#498)
* fix: Replace `TypeInfo.hpp` with `NitroTypeInfo.hpp`

* fix: Format

* Update NitroTypeInfo.hpp
2025-01-15 18:57:31 +01:00
Marc RousavyandGitHub bbbeeaf6b8 feat: Specify RN version as compiler flag (#490)
* feat: Specify RN version in iOS

* Set RN version

* docs

* fix: Adjust scripts and add bootstrap

* fix: Fix react-native path again

* feat: Add `REACT_NATIVE_VERSION` flag to gradle

* fix: Use `tasks.register` to avoid reconfiguration

* fix: Use `project.layout.buildDirectory` instead of `project.buildDir`

* fix: arguments with comma

* fix: Use `buildDir` again

* fix: Pass `YES`

* feat: Add CMake C++ flags now

* fix: Indicate default overridden `HybridObject` constructor

* perf: Make `equals()` a bit faster
2025-01-13 14:13:00 +01:00
Marc Rousavy 347fa02a7d chore: release 0.21.0 2025-01-09 19:44:01 +01:00
Marc RousavyandGitHub a06c7d44af feat: Add new ArrayBuffer APIs (copy(), wrap(), allocate(), toData()) (#463)
* feat: Add `ArrayBuffer::copyBuffer(..)` API

* feat: Add `wrap` API for Kotlin

* feat: Add `ArrayBuffer.copy(data:)`

* perf: Copy Data a bit more effectively

* fix: Rename a bunch of things

* docs: Add creating docs

* feat: Add `ArrayBufferHolder.toData()`

* feat: Add `ArrayBuffer::copy(std::vector&)`

* perf: Change type of `.data` to `uint8_t*` to avoid upcast

* feat: Add `copyIfNeeded` flag

* Update array-buffers.md
2025-01-07 16:35:59 +01:00
Marc Rousavy 72076b2b64 chore: release 0.20.1 2024-12-22 14:00:09 +01:00
Marc RousavyandGitHub f21c79a1b4 perf: Make JS callbacks lock-free (#446) 2024-12-22 13:53:30 +01:00
Marc RousavyandGitHub 2ebff1b4a5 fix: Reject Promise with timeout if it gets destroyed (#444)
* fix: Reject Promise with timeout if it gets destroyed

If a Promise gets destroyed without ever being resolved or rejected, it goes stale.

This PR fixes this and rejects a Promise with a timeout error if it gets destructed and is still pending

* Add promise typename

* Reject swift promise as well

* Update Promise.hpp

* fix: Build

* Update Dispatcher.cpp

* fix: Also reject `JPromise` if it gets destroyed
2024-12-22 13:53:24 +01:00
Marc RousavyandGitHub 67ee05dc52 chore: Remove unused arg names (#443)
* chore: Remove unused arg names

* More

* chore: Even more

* rename _
2024-12-20 16:00:37 +01:00
Marc Rousavy c72e23de4a chore: release 0.20.0 2024-12-20 12:56:47 +01:00
Marc RousavyandGitHub 00e9db4087 perf: Create PromiseHolder<T> (#439)
* feat: Create `PromiseHolder<T>`

* fix: Fix PromiseHolder

* partial fix

* It works now

* fix: Make `_mutex` a value

* Move ctor

* perf: Move functions

* Add back deprecated func

* more explicit
2024-12-20 11:12:08 +01:00
Marc RousavyandGitHub 196fc9d0e0 perf: Mark all types that are used only in std::shared_ptr<T> as SWIFT_NONCOPYABLE (#435)
* fix: Mark all types that are used only in `std::shared_ptr<T>` as `SWIFT_UNSAFE_REFERENCE`

* Update AnyMap.hpp

* fix: Add `SWIFT_PRIVATE`

* fix: Use `SWIFT_NONCOPYABLE` instead!! THAT WORKS
2024-12-20 10:11:25 +01:00
Marc RousavyandGitHub 745e57e436 perf: Move more stuff into closures (#434)
* perf: Explicitly specify `@convention(c)` for inline closures

* Revert "perf: Explicitly specify `@convention(c)` for inline closures"

This reverts commit 05ad252024.

* fix: Make `SwiftClosure` non-null

* perf: Move into closure

* perf: Move even more
2024-12-19 15:05:10 +01:00
Marc RousavyandGitHub e6928c060f test: Add test where a callback is called multiple times (#432)
* test: Add test where a callback is called multiple times

* chore: Format

* fix: Fix types (int double)

* fix: fix loops

* Update HybridTestObjectKotlin.kt

* fix: Fix apple's breaking change for type infos
2024-12-19 11:15:54 +01:00
Marc Rousavy 82ccff24bc chore: release 0.19.0 2024-12-18 16:59:06 +01:00
Marc Rousavy a90e3e4101 fix: Fix catching std::runtime_error on Android 2024-12-10 16:29:32 +01:00
Marc RousavyandGitHub ea2c0709fc feat: Use std::shared_ptr<Promise<T>> instead of std::future<T> for callbacks that return a value (#412)
* feat: Use `std::shared_ptr<Promise<T>>` instead of `std::future<T>` for callbacks that return a value

* Update FunctionType.ts

* chore: Lint

* Update Dispatcher.hpp

* chore: Update Podfile.lock
2024-12-10 15:30:30 +01:00
Marc RousavyandGitHub 283f1f52ab feat: Allow std::future to go bi-directional (using new Promise impl) (#411)
* feat: Allow `std::future` to go bi-directional (using new `Promise` impl)

* Update JSIConverter+Future.hpp
2024-12-09 19:15:16 +01:00
Marc RousavyandGitHub 27e8cbb58e fix: Add workaround for error messages on Android (#408) 2024-12-09 17:39:39 +01:00
Marc RousavyandGitHub 5147fc7944 fix: Delete HybridObject copy & move ctors (#402) 2024-12-06 14:31:25 +01:00
Marc Rousavy 10e24b0b3d chore: release 0.18.2 2024-12-05 15:03:56 +01:00
Marc RousavyandGitHub 04e73d8c1d feat: Add native NITRO_VERSION to C++ codebase and warn if it's out of sync (#398)
* feat: Add `NITRO_VERSION` to NitroDefines.hpp and update it post bump

* feat: Log warning if nitro versions don't match
2024-12-05 15:01:37 +01:00
Marc RousavyandGitHub 4ffa3ae4ce fix: Replace placeholders to make them windows compatible (<<*>> -> $$*$$) (#385) 2024-12-03 15:59:19 +01:00
Marc RousavyandGitHub b916d5fd46 fix: Check std::exception_ptr for null (#381)
* fix: Check `std::exception_ptr` for null

* Replace `nullptr` with `null` in some errors
2024-12-02 15:21:38 +01:00
Marc RousavyandGitHub 826da789c8 fix: Use exception_ptr for Promise::reject (#380)
* fix: Attempt to fix exception_ptr

* fix: Remove the `reject(exception)` functions

* Update RuntimeError.hpp

* fix: Use `exception_ptr` for Promise
2024-12-02 14:12:22 +01:00
Marc RousavyandGitHub 584e38b7c7 feat: Allow using Error as type (#376)
* feat: Allow using `Error` as type

* feat: Add `throwError(error)` func to test object

* feat: Test `throwError(error)`

* Update getTests.ts

* fix: Fix bridging `std::exception_ptr` to Swift `Error`

* fix: Fix `__rejecter` still using `std.exception_ptr`

* fix: Fix Java `JThrowable` conversion

* fix: Update error message

* fix: Fix `__ndk1` prefix on Android

* fix: Make `reject` just forward to `exception_ptr`
2024-11-29 15:57:22 +01:00
Marc Rousavy 5a24994248 chore: Fix some docs 2024-11-27 19:09:57 +01:00
Marc RousavyandGitHub b069fb69a8 fix: Fix Promise rejections not having a message by using std::exception_ptr to avoid C++ object slicing (#369)
* fix: Use `std::exception_ptr` to preserve message

* fix: Catch exception

* fix: Fix `JSIConverter`

* Update AssertPromiseState.hpp

* Ok kinda fix?

* ugh

* fix again

* Update JSIConverter+Promise.hpp

* chore: Rename `_result` to `_state`

* feat: Allow comparing message

* fix: Fix `RuntimeError.description`

* feat: Test all of those error messages as well
2024-11-22 21:14:00 +01:00
Marc RousavyandGitHub 0747e099b7 fix: Fix ref counting with recursive mutex (#368)
* fix: Fix ref counting with recursive mutex

* Xcode
2024-11-22 19:42:38 +01:00
Marc RousavyandGitHub ed24de61f0 fix: Catch cases where a Promise<T> could potentially be rseolved twice (#362)
* fix: Catch cases where a `Promise<T>` could potentially be rseolved twice

* Update AssertPromiseState.hpp
2024-11-20 22:08:58 +01:00
Marc RousavyandGitHub 66e72d7057 feat: Add Promise::await() to Promise.hpp (#361) 2024-11-20 22:08:49 +01:00
Marc Rousavy d0052ecd62 fix: Fix moving sharedFunction after first callback call 2024-11-20 21:56:20 +01:00
Marc RousavyandGitHub 6da4f98904 feat: Support awaiting JS Promise in Kotlin and Swift (#355)
* feat: Support passing `Promise` to Kotlin

* feat: Add `onResolvedListener`

* feat: Add `.then`, `.catch` and `.await` to Promise!

* feat: Use `await`

* feat: Use `Throwable` instead of `String` for error on Android

* Update Promise.kt

* chore: Remove unused `reject(string)` function now

* Update Promise.hpp

* Update Promise.hpp

* feat: Implement `awaitPromise(..)` on iOS

* feat: Add `RuntimeError` and `.toCpp` to Swift

* fix: Fix duplicate symbol in `RuntimeError`

* feat: Add `ErrorType`

* feat: Add `const&` funcs to `Promise` for Swift

* feat: Add `dependencies` to SwiftCxxBridge

* fix: `error` type

* feat: Add `RuntimeError.from(std.exception)`

* feat: Add `getFunctionCopy()` to `SwiftClosure`

* fix: Account for `Promise<void>` resolver

* fix: Fix `UnsafeMutableRawPointer` being nullable (wrong type)

* nitrogen

* clean

* Update HybridTestObjectSwiftKotlinSpecCxx.swift

* feat: Add actual Promise listeners!!

* fix: Add `addOnResolvedListenerCopy` func for some cases

* chore: Format

* fix: Make `getFunctionCopy()` const

* feat: Support `Promise<void>` from JS!

* feat: Add `awaitAndGet` and `awaitAndGetComplex` promise tests

* feat: Test both new functions

* Slap a good ol' `mutex` on `Promise`

* fix: Fix `Promise<void>` never resolving because args count was `1` (`undefined`)

* fix: Fix Android wrong return type

* Update HybridTestObjectCpp.cpp
2024-11-19 18:06:31 +01:00
Marc RousavyandGitHub b6277ea157 feat: Allow converting Promise from JS to C++ (#354)
* feat: Allow converting `Promise` from JS to C++

* feat: Only expose `create()` in Promise

* fix: Use new `create()` fn

* feat: Add test for `awaitPromise(...)`

* fix: Call `.then` / `.catch`

* Delete `JSPromise`

* fix: Don't swallow errors in timeouted promise

* chore: Add `exception` include

* fix: Fix promise test

* fix: Properly chain .then and .catch functions

* Update getTests.ts

* chore: Format

* fix: Implement `canConvert` for Promise
2024-11-19 14:04:41 +01:00
Marc RousavyandGitHub dc1fdb0ad8 chore: Add deprecation notice to JSIConverter<std::future> (#351)
* chore: Add deprecation notice to `JSIConverter<std::future>`

* Update JSIConverter+Future.hpp

* chore: Fix order of initialization
2024-11-19 12:35:20 +01:00
Marc RousavyandGitHub 110dcbf29d feat: Use new, faster, simpler Promise<T> in Nitrogen (#349)
* fix: Add `Promise.hpp` to podspec

* feat: Use new `Promise<T>` type for C++ and Swift

just a minor bug left

* chore: Format

* fix: Fix nitrogen to use old `future` for function return types FOR NOW

* feat: Use new `Promise<T>` on Kotlin!

* chore: Remove unused `PromiseHolder` now

* chore: Format
2024-11-19 02:21:21 +01:00
Marc Rousavy c2becae22d chore: Clean up unused imports 2024-11-19 00:59:50 +01:00
Marc RousavyandGitHub 8cd7a2912e fix: Fix Promise::awaitFuture actually locking threads (#347)
* fix: Fix `Promise::awaitFuture` actually locking threads

* fix: Make tests only wait 1s instead of 2s
2024-11-19 00:52:43 +01:00
Marc Rousavy ae7cab0557 chore: Tidy Promise.hpp 2024-11-19 00:36:19 +01:00
Marc RousavyandGitHub f94cfbcbc8 feat: Allow ThreadPool to grow dynamically (#345)
* feat: Allow `ThreadPool` to grow dynamically

* feat: Add upper limit to `ThreadPool`

* fix: Fix potential race condition when ThreadPool gets destroyed while `addThread()`
2024-11-19 00:27:27 +01:00
Marc RousavyandGitHub 8832bc5225 feat: Add new Promise<T> implementation for C++ (#343)
* feat: Create `Promise.hpp`

* feat: Add `JSIConverter+Exception`

* feat: Base for `Promise` and `Exception`

* fix: Implement Exception conversion

* Implement `Promise::awaitFuture`

* Revive `+Future`

* fix: Speed up creating `ThreadPool`

* fix: Make `+Future` also just use `+Promise` impl

* fix: Thread pool has 10 threads now.

* feat: Allow `ThreadPool` to grow dynamically

* chore: Format C++
2024-11-19 00:01:46 +01:00
Marc RousavyandGitHub c491d394c1 fix: Perform safer checks for toContain(..) in example, and add NitroModules.hasNativeState(value) (#324)
* chore: Perform safer checks for `toContain(..)` in example

* feat: Add `NitroModules.hasNativeState(value)` to avoid crashing eaxmple in release

* fix: Explicitly check for `toString()` if it has NativeState
2024-11-12 18:18:44 +01:00
Marc RousavyandGitHub 1f3a004552 fix: Fix HybridObjectRegistry not being found with JNI in release (#316)
* fix: Fix `HybridObjectRegistry` not being found with JNI in release

* chore: Rename comment
2024-11-11 11:46:36 +01:00
Marc RousavyandGitHub 25b1917f50 fix: Pre-allocate defaultValue for funcs (#255) 2024-10-23 10:11:29 +02:00
Marc RousavyandGitHub 7afac07a83 fix: Fix NONNULL function pointers (#250)
* fix: Fix `NONNULL` function pointers

* Revert "fix: Fix `NONNULL` function pointers"

This reverts commit 5a3acb46d0.

* fix: Replace `NONNULL` with `_Nonnull` compiler keyword

* fix: Format
2024-10-22 11:52:03 +02:00
Marc RousavyandGitHub 6803be8cd9 fix: Add _Nonnull modifier to void* types for Swift (#231) 2024-10-15 20:39:45 +02:00
Marc RousavyandGitHub 2f24d281ad feat: Prettify Prototype names (#229)
* feat: Prettify Prototype names

* perf: Make it fast in release as well.

* Update TypeInfo.hpp

* fix: Remove unnecessary method now

* perf: Make namespace removal `::` faster

* Update TypeInfo.hpp
2024-10-15 19:48:34 +02:00
Marc RousavyandGitHub 57e7f26e61 fix: Make Nitro core compile on non-react-native environments (#195)
* fix: Make Nitro core compile on non-react-native environments

Guards `CallInvokerDispatcher` only if CallInvoker is available

* docs: Remove "Markdown page example" lol
2024-10-08 11:28:23 +02:00
Marc RousavyandGitHub 5f4d61e3cd feat: Use more precise C++ std errors (e.g. invalid_argument) (#179)
* feat: Use more precise C++ std errors (e.g. `invalid_argument`)

* Update bun.lockb

* chore: Re-generate specs
2024-10-07 17:12:16 +02:00