diff --git a/lib/index.js b/lib/index.js index 69643e20..37304227 100644 --- a/lib/index.js +++ b/lib/index.js @@ -46,7 +46,9 @@ if (typeof Realm != 'undefined') { Object.defineProperties(realmConstructor.Collection.prototype, require('./collection-methods')); // Add sync methods -realmConstructor.Sync.User = require('./sync').User; +if (realmConstructor.Sync) { + realmConstructor.Sync.User = require('./sync').User; +} // TODO: Remove this now useless object. var types = Object.freeze({ diff --git a/src/js_realm.hpp b/src/js_realm.hpp index 642b3b4a..31cc2448 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -29,13 +29,16 @@ #include "js_results.hpp" #include "js_schema.hpp" #include "js_observable.hpp" + +#if REALM_ENABLE_SYNC #include "js_sync.hpp" +#include "sync_config.hpp" +#endif #include "shared_realm.hpp" #include "binding_context.hpp" #include "object_accessor.hpp" #include "platform.hpp" -#include "sync_config.hpp" namespace realm { namespace js { @@ -259,14 +262,17 @@ inline typename T::Function RealmClass::create_constructor(ContextType ctx) { FunctionType list_constructor = ObjectWrap>::create_constructor(ctx); FunctionType results_constructor = ObjectWrap>::create_constructor(ctx); FunctionType realm_object_constructor = ObjectWrap>::create_constructor(ctx); - FunctionType sync_constructor = SyncClass::create_constructor(ctx); PropertyAttributes attributes = ReadOnly | DontEnum | DontDelete; Object::set_property(ctx, realm_constructor, "Collection", collection_constructor, attributes); Object::set_property(ctx, realm_constructor, "List", list_constructor, attributes); Object::set_property(ctx, realm_constructor, "Results", results_constructor, attributes); Object::set_property(ctx, realm_constructor, "Object", realm_object_constructor, attributes); + +#if REALM_ENABLE_SYNC + FunctionType sync_constructor = SyncClass::create_constructor(ctx); Object::set_property(ctx, realm_constructor, "Sync", sync_constructor, attributes); +#endif return realm_constructor; } @@ -383,8 +389,9 @@ void RealmClass::constructor(ContextType ctx, ObjectType this_object, size_t std::string encryption_key = NativeAccessor::to_binary(ctx, encryption_key_value); config.encryption_key = std::vector(encryption_key.begin(), encryption_key.end()); } - +#if REALM_ENABLE_SYNC SyncClass::populate_sync_config(ctx, object, config); +#endif } } else { diff --git a/src/object-store b/src/object-store index 8d891030..23ce6be5 160000 --- a/src/object-store +++ b/src/object-store @@ -1 +1 @@ -Subproject commit 8d8910304befb991331fda8c2aa286415fa38cee +Subproject commit 23ce6be5d581488887909ea57764369708cf267b