Skip to content

Commit

Permalink
[10.20.0-beta.0] Bump version
Browse files Browse the repository at this point in the history
Hermes: Fixing a couple of breaking tests (#4120)

* Relaxing error message asserting tests

* Fixing testListSubscriptSetters

Catching missing libjsi.so as librealm.so loads (#4123)

Updated RN peer dependency version (#4124)

Fix classes not extending `Realm.Object` (#4125)

* Fixing custom classes not extending Realm.Object

* Adding a note to the changelog

* Update CHANGELOG.md

Co-authored-by: FFranck <[email protected]>

Co-authored-by: FFranck <[email protected]>

Fixed throwing "Illegal constructor" (#4128)

Clarifying the get_internal early return

Refixed throwing "Illegal constructor"

Various JSI fixes to greenlight more tests (#4129)

Flipper doesnt support inlined sourcemaps

Return an existing s_ctor

Testing with Hermes on CI (#4106)

* Adding hermes as target branch for the integration tests workflow

* Reading environment variable when enabling Hermes

* Adding test app to watchable directories

* Adding a hermes variant when testing React Native

* Making the ccache engine specific

* Moved react-native entry point to fix lint error

* Attempt at fixing ReactTestAppTests

* Update Podfile to work around the Catalyst issue

Fixes for type conversions and minor cleanups (#4137)
  • Loading branch information
kraenhansen committed Feb 14, 2022
1 parent 0ce1cd4 commit 199ce7a
Show file tree
Hide file tree
Showing 27 changed files with 353 additions and 110 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ on:
push:
branches:
- master
- hermes

jobs:
node:
Expand Down Expand Up @@ -147,7 +148,7 @@ jobs:
MOCHA_REMOTE_CONTEXT: missingServer
MOCHA_REMOTE_REPORTER: mocha-github-actions-reporter
react-native-ios:
name: React Native on ${{matrix.platform.name}} (${{ matrix.type }})
name: React Native on ${{matrix.platform.name}} (${{ matrix.type }} using ${{ matrix.platform.engine }})
runs-on: macos-latest
timeout-minutes: 60
strategy:
Expand All @@ -158,12 +159,18 @@ jobs:
type: [Release]
platform:
- name: ios
engine: hermes
build-configuration: simulator
- name: ios
engine: jsc
build-configuration: simulator
- name: catalyst
engine: jsc
build-configuration: catalyst
env:
# Pin the Xcode version
DEVELOPER_DIR: /Applications/Xcode_12.5.1.app
HERMES_ENABLED: ${{ matrix.platform.engine == 'hermes' && 'true' || 'false' }}
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -191,7 +198,7 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ github.job }}-${{ matrix.platform.name }}-${{ matrix.type }}
key: ${{ github.job }}-${{ matrix.platform.engine }}-${{ matrix.platform.name }}-${{ matrix.type }}
- name: Prepend ccache executables to the PATH
run: echo PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV

Expand Down Expand Up @@ -226,14 +233,20 @@ jobs:
RETRIES: 5
RETRY_DELAY: 300000 # 5 min
react-native-android:
name: React Native on Android (${{ matrix.type }})
name: React Native on Android (${{ matrix.type }} using ${{ matrix.engine }})
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
#TODO: Reactivate debug when builds are optimized
#type: [Release, Debug]
type: [Release]
type:
- Release
# TODO: Reactivate debug when builds are optimized
# - Debug
engine:
- hermes
- jsc
env:
HERMES_ENABLED: ${{ matrix.engine == 'hermes' && 'true' || 'false' }}
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -268,7 +281,7 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ github.job }}-${{ matrix.type }}
key: ${{ github.job }}-${{ matrix.engine }}-${{ matrix.type }}
- name: Prepend ccache executables to the PATH
run: echo PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV

Expand Down
3 changes: 1 addition & 2 deletions .watchmanconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"react-native/node_modules",
"packages/realm-app-importer",
"packages/realm-web",
"packages/realm-web-integration-tests",
"tests"
"packages/realm-web-integration-tests"
]
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

x.x.x Release notes (yyyy-MM-dd)
=============================================================

### Enhancements
* `Realm.writeCopyTo()` now supports creating snapshots of synced Realms, thus allowing apps to be shipped with partially-populated synced databases. ([#3782](https://github.com/realm/realm-js/issues/3782)
* Added beta support for flexible sync ([#4220](https://github.com/realm/realm-js/pull/4220)).
Expand All @@ -18,6 +20,26 @@ x.x.x Release notes (yyyy-MM-dd)
### Internal
* None.

10.20.0-beta.0 Release notes (2021-12-21)
=============================================================
NOTE: This release is rebased on our `10.11.0` release and as such contain the same enhancements and fixes.

### Enhancements
* Catching missing libjsi.so when loading the librealm.so and rethrowing a more meaningful error, instructing users to upgrade their version of React Native.

### Fixed
* Fixed support of user defined classes that don't extend `Realm.Object`.
* Fixed throwing "Illegal constructor" when `new` constructing anything other than `Realm` and `Realm.Object`.

### Compatibility
* MongoDB Realm Cloud.
* Realm Studio v11.0.0.
* APIs are backwards compatible with all previous releases of Realm JavaScript in the 10.5.x series.
* File format: generates Realms with format v22 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

### Internal
* Upgraded Realm Core to v11.7.0.

10.20.0-alpha.2 Release notes (2021-11-25)
=============================================================
NOTE: DO NOT USE THIS RELEASE IN PRODUCTION!
Expand Down
3 changes: 1 addition & 2 deletions RealmJS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Pod::Spec.new do |s|
s.source = { :http => 'https://github.com/realm/realm-js/blob/master/CONTRIBUTING.md#how-to-debug-react-native-podspec' }

s.source_files = 'react-native/ios/RealmReact/*.mm'
s.public_header_files = 'react-native/ios/RealmReact/*.h'

s.frameworks = uses_frameworks ? ['React'] : []

Expand All @@ -57,8 +58,6 @@ Pod::Spec.new do |s|
# Header search paths are prefixes to the path specified in #include macros
'HEADER_SEARCH_PATHS' => [
'"$(PODS_TARGET_SRCROOT)/react-native/ios/RealmReact/"',
'"$(PODS_TARGET_SRCROOT)/src/"',
'"$(PODS_TARGET_SRCROOT)/src/jsi/"',
'"$(PODS_ROOT)/Headers/Public/React-Core/"'
#"'#{app_path}/ios/Pods/Headers/Public/React-Core'" # Use this line instead of 👆 while linting
].join(' ')
Expand Down
2 changes: 1 addition & 1 deletion dependencies.list
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE_NAME=realm-js
VERSION=10.20.0-alpha.2
VERSION=10.20.0-beta.0
REALM_CORE_VERSION=11.9.0
NAPI_VERSION=4
OPENSSL_VERSION=1.1.1g
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import com.android.build.OutputFile
*/

project.ext.react = [
enableHermes: true, // clean and rebuild if changing
enableHermes: System.getenv().getOrDefault("HERMES_ENABLED", "true") == "true", // default: true
]

apply from: "../../node_modules/react-native/react.gradle"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/environments/react-native/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ target 'RealmReactNativeTests' do
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => true
:hermes_enabled => (ENV['HERMES_ENABLED'] || 'true') == 'true' # default: true
)

target 'RealmReactNativeTestsTests' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
// Fetching with inlineSourceMap=true to ease debugging.
return [NSURL URLWithString:[[[[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil] absoluteString] stringByAppendingString:@"&inlineSourceMap=true" ]];
// return [NSURL URLWithString:[[[[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil] absoluteString] stringByAppendingString:@"&inlineSourceMap=true" ]];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
Expand Down
6 changes: 6 additions & 0 deletions lib/react-native/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"@react-native-community",
"../../.eslintrc"
]
}
6 changes: 2 additions & 4 deletions lib/react-native.js → lib/react-native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
//
////////////////////////////////////////////////////////////////////////////

// eslint sourceType: module

import { Platform, NativeModules } from "react-native";

//switch how babel transpiled code creates children objects.
Expand All @@ -42,9 +40,9 @@ if (typeof global.Realm === "undefined") {
);
}

require("./extensions")(global.Realm);
require("../extensions")(global.Realm);

const utils = require("./utils");
const utils = require("../utils");
const versions = utils.getVersions();
global.Realm.App._setVersions(versions);

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "realm",
"description": "Realm is a mobile database: an alternative to SQLite and key-value stores",
"version": "10.20.0-alpha.2",
"version": "10.20.0-beta.0",
"license": "See the actual license in the file LICENSE",
"homepage": "https://realm.io",
"keywords": [
Expand Down Expand Up @@ -31,7 +31,7 @@
},
"types": "types/index.d.ts",
"main": "lib/index.js",
"react-native": "lib/react-native.js",
"react-native": "lib/react-native/index.js",
"files": [
"cmake",
"lib",
Expand Down Expand Up @@ -102,7 +102,7 @@
"url-parse": "^1.4.4"
},
"peerDependencies": {
"react-native": ">=0.60"
"react-native": ">=0.66.0"
},
"peerDependenciesMeta": {
"react-native": {
Expand Down Expand Up @@ -162,4 +162,4 @@
4
]
}
}
}
2 changes: 1 addition & 1 deletion packages/realm-network-transport/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ class RealmReactModule extends ReactContextBaseJavaModule {
private final AssetManager assetManager;

static {
SoLoader.loadLibrary("realm");
try {
SoLoader.loadLibrary("realm");
} catch (UnsatisfiedLinkError err) {
if (err.getMessage().contains("library \"libjsi.so\" not found")) {
throw new LinkageError("This version of Realm JS needs at least React Native version 0.66.0", err);
}
throw err;
}
}

public RealmReactModule(ReactApplicationContext reactContext) {
Expand Down
26 changes: 12 additions & 14 deletions src/js_object_accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,23 +554,21 @@ struct Unbox<JSEngine, Obj> {

auto current_realm = native_accessor->m_realm;
auto js_object = Value::validated_to_object(native_accessor->m_ctx, value);
auto realm_object = get_internal<JSEngine, RealmObjectClass<JSEngine>>(native_accessor->m_ctx, js_object);

auto is_ros_instance =
auto is_realm_object =
Object::template is_instance<RealmObjectClass<JSEngine>>(native_accessor->m_ctx, js_object);

if (is_ros_instance && realm_object && realm_object->realm() == current_realm) {
return realm_object->obj();
}

if (is_ros_instance && !policy.copy && !policy.update && !policy.create) {
throw std::runtime_error("Realm object is from another Realm");
}

// if our RealmObject isn't in ObjectStore, it's a detached object
// (not in to database), and we can't add it
if (is_ros_instance && !realm_object) {
throw std::runtime_error("Cannot reference a detached instance of Realm.Object");
if (is_realm_object) {
auto realm_object = get_internal<JSEngine, RealmObjectClass<JSEngine>>(native_accessor->m_ctx, js_object);
if (realm_object && realm_object->realm() == current_realm) {
return realm_object->obj();
}
else if (!policy.copy && !policy.update && !policy.create) {
throw std::runtime_error("Realm object is from another Realm");
}
else if (!realm_object) {
throw std::runtime_error("Cannot reference a detached instance of Realm.Object");
}
}

if (!policy.create) {
Expand Down
28 changes: 28 additions & 0 deletions src/js_realm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ class RealmClass : public ClassDefinition<T, SharedRealm, ObservableClass<T>> {
static void get_schema_name_from_object(ContextType, ObjectType, Arguments&, ReturnValue&);
static void update_schema(ContextType, ObjectType, Arguments&, ReturnValue&);

// NOTE: __to_object and __to_boolean are shims that allow type conversion tests
// on unit tests / CI. They probably shouldn't be available in production
static void __to_object(ContextType, ObjectType, Arguments&, ReturnValue&);
static void __to_boolean(ContextType, ObjectType, Arguments&, ReturnValue&);

#if REALM_ENABLE_SYNC
static void async_open_realm(ContextType, ObjectType, Arguments&, ReturnValue&);
#endif
Expand Down Expand Up @@ -419,6 +424,11 @@ class RealmClass : public ClassDefinition<T, SharedRealm, ObservableClass<T>> {
{"deleteModel", wrap<delete_model>},
{"_updateSchema", wrap<update_schema>},
{"_schemaName", wrap<get_schema_name_from_object>},

// NOTE: __to_object and __to_boolean are shims that allow type conversion tests
// on unit tests / CI. They probably shouldn't be available in production
{"__to_object", wrap<__to_object>},
{"__to_boolean", wrap<__to_boolean>},
};

PropertyMap<T> const properties = {
Expand Down Expand Up @@ -1435,6 +1445,24 @@ void RealmClass<T>::get_schema_name_from_object(ContextType ctx, ObjectType this
return_value.set(object_schema.name);
}

template <typename T>
void RealmClass<T>::__to_object(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value)
{
args.validate_count(1);
ObjectType newobj = Value::to_object(ctx, args[0]);

return_value.set(newobj);
}

template <typename T>
void RealmClass<T>::__to_boolean(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value)
{
args.validate_count(1);
bool is_bool = Value::to_boolean(ctx, args[0]);

return_value.set(is_bool);
}

/**
* Updates the schema.
*
Expand Down
Loading

0 comments on commit 199ce7a

Please sign in to comment.