Merge branch 'master' of github.com:realm/realm-js into kneth/bugfix/invalid-token

This commit is contained in:
Kenneth Geisshirt 2017-10-13 18:26:30 +02:00
commit a99e433d0a
12 changed files with 1358 additions and 295 deletions

View File

@ -9,10 +9,25 @@ X.Y.Z Release notes
### Bug fixes
* None.
2.0.0-rc20 Release notes (2017-10-11)
2.0.0-rc22 Release notes (2017-10-13)
=============================================================
### Breaking changes
* None
* None.
### Enhancements
* None.
### Bug fixes
* None.
### Internal
* Upgrading to Realm Sync 2.0.2.
* Upgrading to Realm Object Server 2.0.0-rc.5.
2.0.0-rc21 Release notes (2017-10-12)
=============================================================
### Breaking changes
* None.
### Enhancements
* Added `update` method to `Realm.Results` to support bulk updates (#808).
@ -23,11 +38,11 @@ X.Y.Z Release notes
* Respect custom Realm paths when using `Realm.open` (#1392 and #1393).
### Internal
* Upgrading to Realm Sync 2.0.0-rc28.
* Upgrading to Realm Sync 2.0.1.
* Upgrading to Realm Object Server 2.0.0-rc.4.
* OpenSSL for Android is distributed in a separate package, and the build system needed updates to accommendate this.
* Added `-fvisibility=hidden` to Android builds (reduces size of `.so` file).
* Add `Session._overrideServer` to force an existing session to connect to a different server.
2.0.0-rc19 Release notes (2017-10-7)
=============================================================

4
Jenkinsfile vendored
View File

@ -210,7 +210,9 @@ def doWindowsBuild() {
node('windows && nodejs') {
unstash 'source'
try {
bat 'npm install --build-from-source=realm'
sshagent(['realm-ci-ssh']) {
bat 'npm install --build-from-source=realm --realm_enable_sync'
}
dir('tests') {
bat 'npm install'
bat 'npm run test'

View File

@ -1,9 +1,5 @@
{
"variables": {
"realm_node_build_as_library%": "0",
"realm_download_binaries%": "1"
},
"includes": [
"includes": [
"target_defaults.gypi",
"realm.gypi"
],
@ -15,120 +11,23 @@
],
"sources": [
"src/node/platform.cpp",
"src/js_realm.cpp"
"src/js_realm.cpp",
"src/node/node_init.cpp"
],
"include_dirs": [
"src"
],
"conditions": [
["realm_node_build_as_library", {
"type": "static_library",
"export_dependent_settings": [ "object-store" ]
}, {
"sources": [
"src/node/node_init.cpp"
]
}]
]
},
{
"target_name": "object-store",
"dependencies": [ "realm-core" ],
"type": "static_library",
"include_dirs": [
"src/object-store/src",
"src/object-store/external/pegtl"
],
"defines": [ "REALM_PLATFORM_NODE=1" ],
"sources": [
"src/object-store/src/binding_callback_thread_observer.cpp",
"src/object-store/src/collection_notifications.cpp",
"src/object-store/src/index_set.cpp",
"src/object-store/src/list.cpp",
"src/object-store/src/object.cpp",
"src/object-store/src/placeholder.cpp",
"src/object-store/src/object_schema.cpp",
"src/object-store/src/object_store.cpp",
"src/object-store/src/results.cpp",
"src/object-store/src/schema.cpp",
"src/object-store/src/shared_realm.cpp",
"src/object-store/src/thread_safe_reference.cpp",
"src/object-store/src/impl/collection_change_builder.cpp",
"src/object-store/src/impl/collection_notifier.cpp",
"src/object-store/src/impl/list_notifier.cpp",
"src/object-store/src/impl/object_notifier.cpp",
"src/object-store/src/impl/primitive_list_notifier.cpp",
"src/object-store/src/impl/realm_coordinator.cpp",
"src/object-store/src/impl/results_notifier.cpp",
"src/object-store/src/impl/transact_log_handler.cpp",
"src/object-store/src/impl/weak_realm_notifier.cpp",
"src/object-store/src/parser/parser.cpp",
"src/object-store/src/parser/query_builder.cpp",
"src/object-store/src/util/format.cpp",
"src/object-store/src/util/uuid.cpp",
],
"conditions": [
["OS=='win'", {
"sources": [
"src/object-store/src/impl/windows/external_commit_helper.cpp",
]
}],
["OS=='linux'", {
"sources": [
"src/object-store/src/impl/epoll/external_commit_helper.cpp",
]
}],
["OS=='mac'", {
"sources": [
"src/object-store/src/impl/apple/external_commit_helper.cpp",
"src/object-store/src/impl/apple/keychain_helper.cpp",
"src/object-store/src/sync/impl/apple/network_reachability_observer.cpp",
"src/object-store/src/sync/impl/apple/system_configuration.cpp"
]
}],
["realm_enable_sync", {
"dependencies": [ "realm-sync" ],
"sources": [
"src/object-store/src/sync/sync_manager.cpp",
"src/object-store/src/sync/sync_user.cpp",
"src/object-store/src/sync/sync_session.cpp",
"src/object-store/src/sync/sync_config.cpp",
"src/object-store/src/sync/partial_sync.cpp",
"src/object-store/src/sync/impl/sync_file.cpp",
"src/object-store/src/sync/impl/sync_metadata.cpp"
],
}]
],
"all_dependent_settings": {
"defines": [ "REALM_PLATFORM_NODE=1" ],
"include_dirs": [
"src/object-store/src",
"src/object-store/src/impl",
"src/object-store/src/impl/apple",
"src/object-store/src/parser",
"src/object-store/external/pegtl"
]
},
"export_dependent_settings": [
"<@(_dependencies)" # re-export settings related to linking the realm binaries
]
}
],
"conditions": [
["not realm_node_build_as_library", {
"targets": [
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "<(module_name)" ],
"copies": [
{
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "<(module_name)" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
"destination": "<(module_path)"
}
]
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
"destination": "<(module_path)"
}
]
}]
}
]
}

View File

@ -1,5 +1,5 @@
PACKAGE_NAME=realm-js
VERSION=2.0.0-rc20
REALM_CORE_VERSION=4.0.1
REALM_SYNC_VERSION=2.0.0-rc28
REALM_OBJECT_SERVER_VERSION=2.0.0-rc.4
VERSION=2.0.0-rc22
REALM_CORE_VERSION=4.0.2
REALM_SYNC_VERSION=2.0.2
REALM_OBJECT_SERVER_VERSION=2.0.0-rc.5

1073
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{
"name": "realm",
"description": "Realm is a mobile database: an alternative to SQLite and key-value stores",
"version": "2.0.0-rc20",
"version": "2.0.0-rc22",
"license": "Apache-2.0",
"homepage": "https://realm.io",
"keywords": [
@ -80,13 +80,14 @@
"dependencies": {
"command-line-args": "^4.0.6",
"decompress": "^4.2.0",
"decompress-tarxz": "^2.1.1",
"fs-extra": "^4.0.2",
"ini": "^1.3.4",
"lzma-native": "^3.0.1",
"nan": "^2.3.3",
"node-fetch": "^1.6.3",
"node-pre-gyp": "^0.6.36",
"prop-types": "^15.5.10",
"progress": "^2.0.0",
"prop-types": "^15.5.10",
"request": "^2.78.0",
"stream-counter": "^1.0.0",
"sync-request": "^3.0.1",

View File

@ -68,11 +68,11 @@ LOCAL_SRC_FILES += src/object-store/src/schema.cpp
LOCAL_SRC_FILES += src/object-store/src/shared_realm.cpp
LOCAL_SRC_FILES += src/object-store/src/thread_safe_reference.cpp
ifeq ($(strip $(BUILD_TYPE_SYNC)),1)
LOCAL_SRC_FILES += src/object-store/src/sync/partial_sync.cpp
LOCAL_SRC_FILES += src/object-store/src/sync/sync_config.cpp
LOCAL_SRC_FILES += src/object-store/src/sync/sync_manager.cpp
LOCAL_SRC_FILES += src/object-store/src/sync/sync_session.cpp
LOCAL_SRC_FILES += src/object-store/src/sync/sync_user.cpp
LOCAL_SRC_FILES += src/object-store/src/sync/sync_config.cpp
LOCAL_SRC_FILES += src/object-store/src/sync/partial_sync.cpp
LOCAL_SRC_FILES += src/object-store/src/sync/sync_permission.cpp
LOCAL_SRC_FILES += src/object-store/src/sync/impl/sync_file.cpp
LOCAL_SRC_FILES += src/object-store/src/sync/impl/sync_metadata.cpp

View File

@ -1,6 +1,8 @@
{
"variables": {
"use_realm_debug%": "<!(node -p \"'REALMJS_USE_DEBUG_CORE' in process.env ? 1 : 0\")"
"realm_download_binaries%": "1",
"use_realm_debug%": "<!(node -p \"'REALMJS_USE_DEBUG_CORE' in process.env ? 1 : 0\")",
"realm_js_dir%": "<(module_root_dir)"
},
"conditions": [
["OS=='mac'", {
@ -25,6 +27,89 @@
}]
],
"targets": [
{
"target_name": "object-store",
"dependencies": [ "realm-core" ],
"type": "static_library",
"include_dirs": [
"src/object-store/src",
"src/object-store/external/pegtl"
],
"defines": [ "REALM_PLATFORM_NODE=1" ],
"sources": [
"src/object-store/src/binding_callback_thread_observer.cpp",
"src/object-store/src/collection_notifications.cpp",
"src/object-store/src/index_set.cpp",
"src/object-store/src/list.cpp",
"src/object-store/src/object.cpp",
"src/object-store/src/placeholder.cpp",
"src/object-store/src/object_schema.cpp",
"src/object-store/src/object_store.cpp",
"src/object-store/src/results.cpp",
"src/object-store/src/schema.cpp",
"src/object-store/src/shared_realm.cpp",
"src/object-store/src/thread_safe_reference.cpp",
"src/object-store/src/impl/collection_change_builder.cpp",
"src/object-store/src/impl/collection_notifier.cpp",
"src/object-store/src/impl/list_notifier.cpp",
"src/object-store/src/impl/object_notifier.cpp",
"src/object-store/src/impl/primitive_list_notifier.cpp",
"src/object-store/src/impl/realm_coordinator.cpp",
"src/object-store/src/impl/results_notifier.cpp",
"src/object-store/src/impl/transact_log_handler.cpp",
"src/object-store/src/impl/weak_realm_notifier.cpp",
"src/object-store/src/parser/parser.cpp",
"src/object-store/src/parser/query_builder.cpp",
"src/object-store/src/util/format.cpp",
"src/object-store/src/util/uuid.cpp",
],
"conditions": [
["OS=='win'", {
"sources": [
"src/object-store/src/impl/windows/external_commit_helper.cpp",
]
}],
["OS=='linux'", {
"sources": [
"src/object-store/src/impl/epoll/external_commit_helper.cpp",
]
}],
["OS=='mac'", {
"sources": [
"src/object-store/src/impl/apple/external_commit_helper.cpp",
"src/object-store/src/impl/apple/keychain_helper.cpp",
"src/object-store/src/sync/impl/apple/network_reachability_observer.cpp",
"src/object-store/src/sync/impl/apple/system_configuration.cpp"
]
}],
["realm_enable_sync", {
"dependencies": [ "realm-sync" ],
"sources": [
"src/object-store/src/sync/partial_sync.cpp",
"src/object-store/src/sync/sync_config.cpp",
"src/object-store/src/sync/sync_manager.cpp",
"src/object-store/src/sync/sync_user.cpp",
"src/object-store/src/sync/sync_session.cpp",
"src/object-store/src/sync/sync_config.cpp",
"src/object-store/src/sync/impl/sync_file.cpp",
"src/object-store/src/sync/impl/sync_metadata.cpp"
],
}]
],
"all_dependent_settings": {
"defines": [ "REALM_PLATFORM_NODE=1" ],
"include_dirs": [
"src/object-store/src",
"src/object-store/src/impl",
"src/object-store/src/impl/apple",
"src/object-store/src/parser",
"src/object-store/external/pegtl"
]
},
"export_dependent_settings": [
"<@(_dependencies)" # re-export settings related to linking the realm binaries
]
},
{
"target_name": "realm-core",
"type": "none",
@ -57,7 +142,13 @@
"type": "none",
"dependencies": [ "realm-core" ],
"direct_dependent_settings": {
"libraries": [ "-lrealm-sync-node<(debug_library_suffix)" ]
"conditions": [
["OS=='win'", {
"libraries": [ "-lrealm-sync<(debug_library_suffix)" ]
}, {
"libraries": [ "-lrealm-sync-node<(debug_library_suffix)" ]
}]
]
},
"all_dependent_settings": {
"defines": [ "REALM_ENABLE_SYNC=1" ]
@ -81,7 +172,7 @@
},
{
"variables": {
"vendor_dir%": "<(module_root_dir)/vendor/realm-<(OS)-<(target_arch)<(debug_library_suffix)"
"vendor_dir": "<(realm_js_dir)/vendor/realm-<(OS)-<(target_arch)<(debug_library_suffix)"
},
"target_name": "vendored-realm",
"type": "none",
@ -107,9 +198,9 @@
"actions": [
{
"action_name": "download-realm",
"inputs": [ "<(module_root_dir)/scripts/download-realm.js" ],
"inputs": [ "<(realm_js_dir)/scripts/download-realm.js" ],
"outputs": [ "<(vendor_dir)" ],
"action": [ "node", "<(module_root_dir)/scripts/download-realm.js", "<(OS)", ">(download_realm_debug_flag)", ">(download_realm_sync_flag)", "--arch=<(target_arch)" ]
"action": [ "node", "<(realm_js_dir)/scripts/download-realm.js", "<(OS)", ">(download_realm_debug_flag)", ">(download_realm_sync_flag)", "--arch=<(target_arch)" ]
}
]
}]

View File

@ -18,50 +18,34 @@
'use strict';
const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');
const os = require('os');
const child_process = require('child_process');
const fetch = require('node-fetch');
const ini = require('ini').parse;
const decompress = require('decompress');
function decompressXZ() {
// taken from https://github.com/kevva/decompress-tarxz undex the MIT license
// we don't add it as a dependency because it depends on too old a version of lzma-native
// which doesn't have node-pre-gyp binaries for recent Node versions
const decompressTar = require('decompress-tar');
const fileType = require('file-type');
const isStream = require('is-stream');
const lzmaNative = require('lzma-native');
return function(input) {
if (!Buffer.isBuffer(input) && !isStream(input)) {
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
function exec() {
const args = Array.from(arguments);
return new Promise((resolve, reject) => {
function callback(error, stdout, stderr) {
if (error) {
reject(error);
} else {
resolve(stdout.trim());
}
}
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'xz')) {
return Promise.resolve([]);
}
const decompressor = lzmaNative.createDecompressor();
const result = decompressTar()(decompressor);
if (Buffer.isBuffer(input)) {
decompressor.end(input);
} else {
input.pipe(decompressor);
}
return result;
}
args.push(callback);
child_process.exec.apply(null, args);
});
}
function printProgress(input, totalBytes) {
function printProgress(input, totalBytes, archive) {
const ProgressBar = require('progress');
const StreamCounter = require('stream-counter');
const message = 'Downloading Realm binaries [:bar] (:ratek)';
const message = `Downloading ${archive} [:bar] (:ratek)`;
const bar = new ProgressBar(message, {
complete: '=',
incomplete: ' ',
@ -74,28 +58,136 @@ function printProgress(input, totalBytes) {
});
}
function download(url, destination) {
function download(serverFolder, archive, destination) {
const url = `https://static.realm.io/downloads/${serverFolder}/${archive}`;
return fetch(url).then((response) => {
if (response.status !== 200) {
throw new Error(`Error downloading ${url} - received status ${response.status} ${response.statusText}`);
}
const totalBytes = parseInt(response.headers.get('Content-Length'));
if (fs.existsSync(destination) && fs.statSync(destination).size === totalBytes) {
return;
}
if (process.stdout.isTTY) {
printProgress(response.body, totalBytes);
} else {
console.log(`Downloading ${url}`);
}
return new Promise((resolve) => {
const file = fs.createWriteStream(destination);
response.body.pipe(file).once('finish', () => file.close(resolve));
const lastModified = new Date(response.headers.get('Last-Modified'));
return fs.exists(destination)
.then(exists => {
if (!exists) {
return saveFile();
} else {
return fs.stat(destination)
.then(stat => {
if (stat.mtime.getTime() !== lastModified.getTime()) {
return saveFile();
}
})
}
});
function saveFile() {
if (process.stdout.isTTY) {
printProgress(response.body, parseInt(response.headers.get('Content-Length')), archive);
} else {
console.log(`Downloading ${archive}`);
}
return new Promise((resolve) => {
const file = fs.createWriteStream(destination);
response.body.pipe(file).once('finish', () => file.close(resolve));
}).then(() => fs.utimes(destination, lastModified, lastModified));
}
});
}
function extract(downloadedArchive, targetFolder, archiveRootFolder) {
console.log(`Extracting ${path.basename(downloadedArchive)} => ${targetFolder}`);
const decompressOptions = /tar\.xz$/.test(downloadedArchive) ? { plugins: [ require('decompress-tarxz')() ] } : undefined;
if (!archiveRootFolder) {
return decompress(downloadedArchive, targetFolder, decompressOptions);
} else {
const tempExtractLocation = path.resolve(os.tmpdir(), path.basename(downloadedArchive, path.extname(downloadedArchive)));
return decompress(downloadedArchive, tempExtractLocation, decompressOptions)
.then(() => fs.readdir(path.resolve(tempExtractLocation, archiveRootFolder)))
.then(items => Promise.all(items.map(item => {
const source = path.resolve(tempExtractLocation, archiveRootFolder, item);
const target = path.resolve(targetFolder, item);
return fs.copy(source, target, { filter: n => path.extname(n) !== '.so' });
})))
.then(() => fs.remove(tempExtractLocation))
}
}
function acquireCore(options, dependencies, target) {
let serverFolder = `core/v${dependencies.REALM_CORE_VERSION}`;
let flavor = options.debug ? 'Debug' : 'Release';
let archive, archiveRootFolder;
switch (options.platform) {
case 'mac':
serverFolder += `/macos/${flavor}`;
archive = `realm-core-${flavor}-v${dependencies.REALM_CORE_VERSION}-Darwin-devel.tar.gz`;
break;
case 'ios':
flavor = flavor === 'Debug' ? 'MinSizeDebug' : flavor;
serverFolder += `/ios/${flavor}`;
archive = `realm-core-${flavor}-v${dependencies.REALM_CORE_VERSION}-iphoneos.tar.gz`;
break;
case 'win':
if (!options.arch) throw new Error(`Specifying '--arch' is required for platform 'win'`);
const arch = options.arch === 'ia32' ? 'Win32' : options.arch;
serverFolder += `/windows/${arch}/nouwp/${flavor}`;
archive = `realm-core-${flavor}-v${dependencies.REALM_CORE_VERSION}-Windows-${arch}-devel.tar.gz`;
break;
case 'linux':
serverFolder = 'core';
archive = `realm-core-${dependencies.REALM_CORE_VERSION}.tgz`;
archiveRootFolder = `realm-core-${dependencies.REALM_CORE_VERSION}`;
break;
}
const downloadedArchive = path.resolve(os.tmpdir(), archive);
return download(serverFolder, archive, downloadedArchive)
.then(() => extract(downloadedArchive, target, archiveRootFolder));
}
function getSyncCommitSha(version) {
return exec(`git ls-remote git@github.com:realm/realm-sync.git --tags "v${version}^{}"`)
.then(stdout => {
if (!Boolean(stdout)) {
return exec(`git ls-remote git@github.com:realm/realm-sync.git --tags "v${version}"`)
} else {
return stdout;
}
}).then(stdout => /([^\t]+)/.exec(stdout)[0]);
}
function acquireSync(options, dependencies, target) {
let serverFolder = 'sync';
let flavor = options.debug ? 'Debug' : 'Release';
let archive, archiveRootFolder;
let promise = Promise.resolve();
switch (options.platform) {
case 'mac':
archive = `realm-sync-node-cocoa-${dependencies.REALM_SYNC_VERSION}.tar.gz`;
archiveRootFolder = `realm-sync-node-cocoa-${dependencies.REALM_SYNC_VERSION}`;
break;
case 'ios':
archive = `realm-sync-cocoa-${dependencies.REALM_SYNC_VERSION}.tar.xz`;
archiveRootFolder = `core`;
break;
case 'win':
promise = acquireCore(options, dependencies, target)
.then(() => getSyncCommitSha(dependencies.REALM_SYNC_VERSION))
.then(sha => serverFolder += `/sha-version/${sha}`);
const arch = options.arch === 'ia32' ? 'Win32' : options.arch;
archive = `realm-sync-${flavor}-v${dependencies.REALM_SYNC_VERSION}-Windows-${arch}-devel.tar.gz`;
break;
default:
throw new Error(`Unsupported sync platform '${options.platform}'`);
}
const downloadedArchive = path.resolve(os.tmpdir(), archive);
return promise
.then(() => download(serverFolder, archive, downloadedArchive))
.then(() => extract(downloadedArchive, target, archiveRootFolder));
}
const optionDefinitions = [
{ name: 'platform', type: String, defaultOption: true },
{ name: 'arch', type: String },
@ -103,59 +195,11 @@ const optionDefinitions = [
{ name: 'debug', type: Boolean },
];
const options = require('command-line-args')(optionDefinitions);
console.log(options);
let serverFolder, archive, extractedFolder;
const dependencies = ini(fs.readFileSync(path.resolve(__dirname, '../dependencies.list'), 'utf8'));
if (!options.sync) {
serverFolder = `core/v${dependencies.REALM_CORE_VERSION}/`;
let flavor = options.debug ? 'Debug' : 'Release';
switch (options.platform) {
case 'mac':
serverFolder += `macos/${flavor}`;
archive = `realm-core-${flavor}-v${dependencies.REALM_CORE_VERSION}-Darwin-devel.tar.xz`;
break;
case 'ios':
flavor = flavor === 'Debug' ? 'MinSizeDebug' : flavor;
serverFolder += `ios/${flavor}`;
archive = `realm-core-${flavor}-v${dependencies.REALM_CORE_VERSION}-iphoneos.tar.xz`;
break;
case '..\\win': // handle gyp idiocy
options.platform = 'win';
case 'win':
const arch = options.arch === 'ia32' ? 'Win32' : options.arch;
serverFolder += `windows/${arch}/nouwp/${flavor}`;
archive = `realm-core-${flavor}-v${dependencies.REALM_CORE_VERSION}-Windows-${arch}-devel.tar.gz`;
break;
case 'linux':
serverFolder = 'core';
archive = `realm-core-${dependencies.REALM_CORE_VERSION}.tgz`;
extractedFolder = `realm-core-${dependencies.REALM_CORE_VERSION}`;
break;
}
} else {
serverFolder = 'sync';
switch (options.platform) {
case 'mac':
archive = `realm-sync-node-cocoa-${dependencies.REALM_SYNC_VERSION}.tar.gz`;
extractedFolder = `realm-sync-node-cocoa-${dependencies.REALM_SYNC_VERSION}`;
break;
case 'ios':
archive = `realm-sync-cocoa-${dependencies.REALM_SYNC_VERSION}.tar.xz`;
extractedFolder = `core`;
break;
}
if (options.platform === '..\\win') {
options.platform = 'win'; // handle gyp idiocy
}
if (!archive) {
process.exit();
}
const url = `https://static.realm.io/downloads/${serverFolder}/${archive}`;
const vendorDir = path.resolve(__dirname, '../vendor');
const downloadedArchive = path.resolve(os.tmpdir(), archive);
let realmDir = path.resolve(vendorDir, `realm-${options.platform}`);
if (options.arch) {
@ -165,29 +209,9 @@ if (options.debug) {
realmDir += '-dbg'
}
if (!fs.existsSync(realmDir)) {
const targetFolder = extractedFolder ? vendorDir : realmDir;
const dependencies = ini(fs.readFileSync(path.resolve(__dirname, '../dependencies.list'), 'utf8'));
const decompressOptions = /tar\.xz$/.test(archive) ? { plugins: [ decompressXZ() ] } : undefined;
let pipeline = download(url, downloadedArchive);
pipeline = pipeline.then(() => decompress(downloadedArchive, targetFolder, decompressOptions));
if (extractedFolder) {
pipeline = pipeline.then(() => {
fs.renameSync(path.resolve(vendorDir, extractedFolder), realmDir);
const libDir = path.resolve(realmDir, 'lib')
if (fs.existsSync(libDir)) {
// Remove all shared libraries as we want to just use the static ones
fs.readdirSync(libDir)
.filter(name => /\.so$/.test(name))
.forEach(name => fs.unlinkSync(path.resolve(libDir, name)));
}
});
}
pipeline.catch(error => {
console.log('Downloading Realm binaries failed with', error);
process.exit(-1);
});
}
const acquire = options.sync ? acquireSync : acquireCore;
fs.emptyDir(realmDir)
.then(() => acquire(options, dependencies, realmDir))
.catch(error => console.error(error));

View File

@ -179,6 +179,7 @@ class SessionClass : public ClassDefinition<T, WeakSession> {
using Object = js::Object<T>;
using Value = js::Value<T>;
using ReturnValue = js::ReturnValue<T>;
using Arguments = js::Arguments<T>;
public:
std::string const name = "Session";
@ -196,6 +197,8 @@ public:
static void add_progress_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &);
static void remove_progress_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &);
static void override_server(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue&);
PropertyMap<T> const properties = {
{"config", {wrap<get_config>, nullptr}},
{"user", {wrap<get_user>, nullptr}},
@ -206,6 +209,7 @@ public:
MethodMap<T> const methods = {
{"_simulateError", wrap<simulate_error>},
{"_refreshAccessToken", wrap<refresh_access_token>},
{"_overrideServer", wrap<override_server>},
{"addProgressNotification", wrap<add_progress_notification>},
{"removeProgressNotification", wrap<remove_progress_notification>},
};
@ -511,6 +515,23 @@ void SessionClass<T>::remove_progress_notification(ContextType ctx, FunctionType
}
}
template<typename T>
void SessionClass<T>::override_server(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue&) {
args.validate_count(2);
std::string address = Value::validated_to_string(ctx, args[0], "address");
double port = Value::validated_to_number(ctx, args[1], "port");
if (port < 1 || port > 65535 || uint16_t(port) != port) {
std::ostringstream message;
message << "Invalid port number. Expected an integer in the range 1-65,535, got '" << port << "'";
throw std::invalid_argument(message.str());
}
if (auto session = get_internal<T, SessionClass<T>>(this_object)->lock()) {
session->override_server(std::move(address), uint16_t(port));
}
}
template<typename T>
class SyncClass : public ClassDefinition<T, void*> {
using GlobalContextType = typename T::GlobalContext;

View File

@ -22,6 +22,13 @@ const Realm = require('realm');
global.enableSyncTests = Realm.Sync;
const isNodeProcess = typeof process === 'object' && process + '' === '[object process]';
function node_require(module) { return require(module); }
if (isNodeProcess && process.platform === 'win32') {
global.enableSyncTests = false;
}
var TESTS = {
ListTests: require('./list-tests'),
LinkingObjectsTests: require('./linkingobjects-tests'),
@ -30,14 +37,10 @@ var TESTS = {
ResultsTests: require('./results-tests'),
QueryTests: require('./query-tests'),
MigrationTests: require('./migration-tests'),
EncryptionTests: require('./encryption-tests'),
// GarbageCollectionTests: require('./garbage-collection'),
};
// encryption is not supported on windows
if (!(typeof process === 'object' && process.platform === 'win32')) {
TESTS.EncryptionTests = require('./encryption-tests');
}
// If sync is enabled, run the sync tests
if (global.enableSyncTests) {
TESTS.UserTests = require('./user-tests');
@ -50,12 +53,9 @@ if (global.enableSyncTests) {
}
}
function node_require(module) { return require(module); }
// If on node, run the async tests
const isNodeProcess = typeof process === 'object' && process + '' === '[object process]';
if (isNodeProcess) {
//TESTS.AsyncTests = node_require('./async-tests');
if (isNodeProcess && process.platform !== 'win32') {
TESTS.AsyncTests = node_require('./async-tests');
}
var SPECIAL_METHODS = {

7
vendor/json.hpp vendored
View File

@ -66,8 +66,11 @@ Class @ref nlohmann::basic_json is a good entry point for the documentation.
// enable ssize_t for MSVC
#ifdef _MSC_VER
#include <basetsd.h>
using ssize_t = SSIZE_T;
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
typedef SSIZE_T ssize_t;
#define _SSIZE_T_
#define _SSIZE_T_DEFINED
#endif
#endif
/*!