Commit Graph
27 Commits
Author SHA1 Message Date
Marc RousavyandGitHub 992e32e09e feat: Automatically install a UI-Thread Dispatcher (#1192)
* feat: Automatically install a UI-Thread Dispatcher if called on the UI Thread

* fix: Avoid runSync on UI

* Update UIThreadDispatcher.hpp
2026-02-01 17:31:40 +01:00
Marc RousavyandGitHub c94263763d perf: Cache jsi::PropNameIDs (makes Nitro 30% faster) (#1114)
* feat: Create `PropNameID` Cache

* Impl PropNameID

* fix: Use `const jsi::PropNameID&` instead of `BorrowingReference`

* perf: Use `PropNameIDCache` everywhere internally

* fix: Make use of `PropNameIDCache` in custom user defined structs

* fix: Use `PropNameIDCache` for Hybrid Views too

* fix: `jsi::Runtime` deref

* fix: Allow `JSICache` to use itself by caching itself first

* fix: Remove `allowCache` flag

* perf: Avoid `BorrowingReference<T>` copy and use `const T&`

* perf: Use `PropNameIDCache` inside `defineProperty(...)`

* docs: Add docs
2025-12-18 21:36:27 +01:00
Marc RousavyandGitHub 27dd56795d chore: Type out Object, Promise, Date and Error under CommonGlobals.cpp (#1113)
* chore: Split `Object`, `Promise`, `Date` and `Error` under `CommonGlobals.hpp`

* feat: Use it everywhere

* fix: Implement them

* fix: `resolved` -> `resolve`
2025-12-18 17:14:35 +01:00
Marc RousavyandGitHub 229e7d83db feat: Create ObjectUtils for Object.freeze, Object.defineProperty, ... (#967)
* feat: Create `ObjectUtils` for `Object.freeze`, `Object.defineProperty`, ...

* Use Object.create

* Fix missing obj

* fix: Better error

* Cache

* fix: Actually cache by preventing copy

* Object.create is part of RN 78

* Use `defineProperty(...)` for `Dispatcher` too

* Optimize Dispatcher install

* Create `getGlobalFunction`

* feat: Use `defineGlobal(...)` to define our global props

* fix: Move the globals

* fix: Don't protect/freeze the globals in JS

we already do it in native.
2025-10-17 18:35:16 +02:00
Marc RousavyandGitHub d834d76ef7 fix: Use JSIConverter<NativeState> for extracting Dispatcher (#964)
* chore: Split `JSIConverter<HybridObject>` and `JSIConverter<NativeState>`

* Use one header again
2025-10-16 12:29:28 +02:00
Marc RousavyandGitHub 7f1d108e49 fix: Catch Dispatcher cast issues (#963)
* fix: Catch `Dispatcher` cast issues

* Update Dispatcher.cpp

* Update Dispatcher.cpp

* fix: Improve `Dispatcher` downcasting code
2025-10-16 11:59:28 +02:00
Marc RousavyandGitHub 6dbb34f9d3 fix: Add NON_NULL, NULLABLE and CONTIGUOUS_MEMORY annotations on pointers (#902)
* chore: Add `NON_NULL` and `NULLABLE` annotations on all pointers

* feat: Add `CONTIGUOUS_MEMORY` and `NON_NULL`

* Create `InstanceMethod<...>`

* chore: Use `InstanceMethod<...>`
2025-09-26 13:45:54 +02:00
Marc RousavyandGitHub b9ce7462a3 fix: Add additional nullptr check to make_shared_from_jni function (#584)
* fix: Add additional nullptr check to `make_shared_from_jni` function

* fix: Allow move `&&` and forward

* Update JNISharedPtr.hpp

* fix: Add copy ctor

* fix: Avoid `emplace` if there can be duplicates

* Update JNISharedPtr.hpp

* fix: Don't call `release()` on global_ref!

* fix: Use `const &` to keep it lvalue

* Also check `cthis()`
2025-02-24 18:09:50 +01:00
Marc Rousavy 4733b4e4ea perf: Use .find(..) for cache lookups 2025-02-24 17:15:20 +01:00
Marc RousavyandGitHub 4d07b2a1d5 feat: Create Sync<T> to pass fully synchronous JS callbacks (#564)
* feat: Create `Sync<T>`

* Return

* Make it return number

* feat: Add `isSync` check...

* check

* Impl

* feat: Add `JSCallback`

* perf: Store `Dispatcher` in cache if really missed

* I think it builds now

* fix memory

* fix: Use `isAsync`

* Rename

* fix: Impl `callHybridFunction` again

* fix: Avoid forward decl

* Docs

* feat: Cache `regex` in `NitroTypeInfo`

* Update NitroTypeInfo.cpp

* perf: Make `Dispatcher` a `weak_ptr`

* Some formating

* fix: Fix styling in Benchmarks

* feat: Test if callbackSync returns same number

* fix: Fix warning in `toString()`

* Update Sync.ts

* perf: Allow `std::forward<...>`
2025-02-23 15:59:01 +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 03e1a716cf fix: Fix NITRO_DEBUG debug/release preprocessor directive (#132)
* fix: Use `NITRO_DEBUG` flag to predictably run debug/release code

* feat: Add `NitroModules.buildType`

* fix: Style `debug` label
2024-09-16 16:18:05 +02:00
Marc RousavyandGitHub b4592244f2 feat: AnyMap for Kotlin/Android (#60)
* feat: Create `JAnyMap` base

* Update JNIOnLoad.cpp

* feat: Create `AnyMap` methods

* fix: Fix wrong name & format

* feat: `setNull`

* log dimmed

* Update README.md
2024-08-27 18:02:39 +02:00
Marc RousavyandGitHub e7b9f412eb fix: Rewrite Logger to use platform NSLog / __android_log_print (#54)
* fix: Fix wrong include..?

* fix: Reimplement NitroLogger as a platform-specific logger

* fix: Copy args, and use proper tag

* fix: Fix sprintf crash because of wrong format argument

* fix: Fix Logger usage on iOS
2024-08-20 16:20:44 +02:00
Marc RousavyandGitHub acca5baaa4 fix: Replace #if DEBUG with #ifndef NDEBUG to make it work on Android (#53)
* fix: Fix `hasNativeState` checks and provide better errors

* fix: Replace `#if DEBUG` with `#ifndef NDEBUG` to make it work on Android
2024-08-20 15:30:03 +02:00
Marc Rousavy 882054e587 feat: Support JSIConverter<AnyMap>::canConvert (+ AnyValue and unordered_map<string, T>) 2024-08-07 13:56:10 +02:00
Marc Rousavy 9d69ba04ab chore: Run clang format 2024-07-31 17:39:56 +02:00
Marc Rousavy 404b125b8f fix: Kinda builds? 2024-07-30 13:31:22 +02:00
Marc Rousavy e6f84bee16 fix: Fix JS callbacks not using Dispatcher!!!!!
lol this broke a lot I cant believe I didnt catch this
2024-07-30 12:17:22 +02:00
Marc Rousavy 4adc79dcfc Rename to GetRuntimeID 2024-07-18 00:22:49 +02:00
Marc Rousavy f6853f7055 feat: Log runtime thread ID 2024-07-18 00:20:56 +02:00
Marc Rousavy 7bc2767348 fix: Move to namespace margelo::nitro 2024-07-17 21:49:11 +02:00
Marc Rousavy a6b69b309a perf: Speed up Dispatcher get calls 2024-06-23 12:27:04 +02:00
Marc Rousavy 2bc02c0f6f A ton of improvements around jsi::Runtime safe code. 2024-06-20 16:20:13 +02:00
Marc Rousavy caf953f552 fix imports 2024-06-20 10:47:50 +02:00
Marc Rousavy 84b995e4eb Rename to .hpp 2024-06-20 10:41:09 +02:00
Marc Rousavy b7f40384e1 Add Dispatcher 2024-06-19 19:59:03 +02:00