diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cf4f75b..9d955a0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ x.x.x Release notes (yyyy-MM-dd) ============================================================= ### Enhancements -* A more meaningful exception will be thrown when trying to refresh the access token for a Realm with an invalid url. Previously, trying to connect to a Realm with a url that lacks the path component (e.g. `realm://foo.com`) would result in errors like `Cannot read property ‘token_data’ of undefined`. Instead, now we'll print out the Realm url and provide a more meaningful exception message. ([#ROS-1310](https://github.com/realm/realm-object-server-private/issues/1310), since v1.0.2) +* None. ### Fixed * ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?) @@ -13,7 +13,26 @@ x.x.x Release notes (yyyy-MM-dd) * File format: Generates Realms with format v9 (Reads and upgrades all previous formats) ### Internal -* Building for iOS can now use the `n` node version manager. Thanks to @SandyChapman! ([#2078](https://github.com/realm/realm-js/pull/2078) +* None. + +2.19.0 Release notes (2018-11-7) +============================================================= +### Enhancements +* A more meaningful exception will be thrown when trying to refresh the access token for a Realm with an invalid url. Previously, trying to connect to a Realm with a url that lacks the path component (e.g. `realm://foo.com`) would result in errors like `Cannot read property ‘token_data’ of undefined`. Instead, now we'll print out the Realm url and provide a more meaningful exception message. ([#ROS-1310](https://github.com/realm/realm-object-server-private/issues/1310), since v1.0.2) +* Adds support for Node 10. Pre-gyp'ed binaries are available for Node 6, 8, and 10. ([#1813](https://github.com/realm/realm-js/issues/1813) and [#2087](https://github.com/realm/realm-js/issues/2087)) + +### Fixed +* None. + +### Compatibility +* Realm Object Server: 3.11.0 or later. +* APIs are backwards compatible with all previous release of realm in the 2.x.y series. +* File format: Generates Realms with format v9 (Reads and upgrades all previous formats) + + ### Internal +* Building for iOS can now use the `n` node version manager. Thanks to @SandyChapman! ([#2078](https://github.com/realm/realm-js/pull/2078)) +* Upgrading to Realm Core v5.12.0. +* Upgrading to Realm Sync v3.13.1. 2.19.0-rc.4 Release notes (2018-10-17) ============================================================= diff --git a/binding.gyp b/binding.gyp index 4af696c8..370fed26 100644 --- a/binding.gyp +++ b/binding.gyp @@ -48,7 +48,10 @@ "conditions": [ ["runtime=='electron'", { "dependencies": [ "OpenSSL" ] - }] + }], + ["OS=='win'", { + "dependencies": [ "OpenSSL" ] + }], ] }, { diff --git a/dependencies.list b/dependencies.list index 4fa59c6c..12d57ae5 100644 --- a/dependencies.list +++ b/dependencies.list @@ -1,5 +1,5 @@ PACKAGE_NAME=realm-js -VERSION=2.19.0-rc.4 -REALM_CORE_VERSION=5.10.1 -REALM_SYNC_VERSION=3.10.0 +VERSION=2.19.0-rc.5 +REALM_CORE_VERSION=5.12.0 +REALM_SYNC_VERSION=3.13.1 REALM_OBJECT_SERVER_VERSION=3.11.1 diff --git a/package-lock.json b/package-lock.json index bd449615..cea3494e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "realm", - "version": "2.19.0-rc.1", + "version": "2.19.0-rc.4", "lockfileVersion": 1, "requires": true, "dependencies": { "@babel/code-frame": { "version": "7.0.0-beta.44", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz", - "integrity": "sha1-KgJkM2jegJFhYr5whlyXd08629k=", + "resolved": "http://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz", + "integrity": "sha512-cuAuTTIQ9RqcFRJ/Y8PvTh+paepNcaGxwQwjIDRWPXmzzyAeCO4KqS9ikMvq0MCbRk6GlYKwfzStrcP3/jSL8g==", "dev": true, "requires": { "@babel/highlight": "7.0.0-beta.44" @@ -15,8 +15,8 @@ }, "@babel/generator": { "version": "7.0.0-beta.44", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.0.0-beta.44.tgz", - "integrity": "sha1-x+Z7m1KEr89pswm1DX038+UDPUI=", + "resolved": "http://registry.npmjs.org/@babel/generator/-/generator-7.0.0-beta.44.tgz", + "integrity": "sha512-5xVb7hlhjGcdkKpMXgicAVgx8syK5VJz193k0i/0sLP6DzE6lRrU1K3B/rFefgdo9LPGMAOOOAWW4jycj07ShQ==", "dev": true, "requires": { "@babel/types": "7.0.0-beta.44", @@ -28,8 +28,8 @@ }, "@babel/helper-function-name": { "version": "7.0.0-beta.44", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.44.tgz", - "integrity": "sha1-4YVSqq4iMRAKbkheA4VLw1MtRN0=", + "resolved": "http://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.44.tgz", + "integrity": "sha512-MHRG2qZMKMFaBavX0LWpfZ2e+hLloT++N7rfM3DYOMUOGCD8cVjqZpwiL8a0bOX3IYcQev1ruciT0gdFFRTxzg==", "dev": true, "requires": { "@babel/helper-get-function-arity": "7.0.0-beta.44", @@ -39,8 +39,8 @@ }, "@babel/helper-get-function-arity": { "version": "7.0.0-beta.44", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.44.tgz", - "integrity": "sha1-0Dym3SufewseazLFbHKDYUDbOhU=", + "resolved": "http://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.44.tgz", + "integrity": "sha512-w0YjWVwrM2HwP6/H3sEgrSQdkCaxppqFeJtAnB23pRiJB5E/O9Yp7JAAeWBl+gGEgmBFinnTyOv2RN7rcSmMiw==", "dev": true, "requires": { "@babel/types": "7.0.0-beta.44" @@ -48,8 +48,8 @@ }, "@babel/helper-split-export-declaration": { "version": "7.0.0-beta.44", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.44.tgz", - "integrity": "sha1-wLNRc14PvLOCLIrY205YOwXr2dw=", + "resolved": "http://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.44.tgz", + "integrity": "sha512-aQ7QowtkgKKzPGf0j6u77kBMdUFVBKNHw2p/3HX/POt5/oz8ec5cs0GwlgM8Hz7ui5EwJnzyfRmkNF1Nx1N7aA==", "dev": true, "requires": { "@babel/types": "7.0.0-beta.44" @@ -57,8 +57,8 @@ }, "@babel/highlight": { "version": "7.0.0-beta.44", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.44.tgz", - "integrity": "sha1-GMlM5UORaoBVPtzc9oGJCyAHR9U=", + "resolved": "http://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.44.tgz", + "integrity": "sha512-Il19yJvy7vMFm8AVAh6OZzaFoAd0hbkeMZiX3P5HGD+z7dyI7RzndHB0dg6Urh/VAFfHtpOIzDUSxmY6coyZWQ==", "dev": true, "requires": { "chalk": "^2.0.0", @@ -68,8 +68,8 @@ }, "@babel/template": { "version": "7.0.0-beta.44", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.0.0-beta.44.tgz", - "integrity": "sha1-+IMvT9zuXVm/UV5ZX8UQbFKbOU8=", + "resolved": "http://registry.npmjs.org/@babel/template/-/template-7.0.0-beta.44.tgz", + "integrity": "sha512-w750Sloq0UNifLx1rUqwfbnC6uSUk0mfwwgGRfdLiaUzfAOiH0tHJE6ILQIUi3KYkjiCDTskoIsnfqZvWLBDng==", "dev": true, "requires": { "@babel/code-frame": "7.0.0-beta.44", @@ -80,8 +80,8 @@ }, "@babel/traverse": { "version": "7.0.0-beta.44", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.0.0-beta.44.tgz", - "integrity": "sha1-qXCixFR3rRgBfi5GWgYG/u4NKWY=", + "resolved": "http://registry.npmjs.org/@babel/traverse/-/traverse-7.0.0-beta.44.tgz", + "integrity": "sha512-UHuDz8ukQkJCDASKHf+oDt3FVUzFd+QYfuBIsiNu/4+/ix6pP/C+uQZJ6K1oEfbCMv/IKWbgDEh7fcsnIE5AtA==", "dev": true, "requires": { "@babel/code-frame": "7.0.0-beta.44", @@ -97,20 +97,26 @@ }, "dependencies": { "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true } } }, "@babel/types": { "version": "7.0.0-beta.44", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.0.0-beta.44.tgz", - "integrity": "sha1-axsWRZH3fewKA0KsqZXy0Eazp1c=", + "resolved": "http://registry.npmjs.org/@babel/types/-/types-7.0.0-beta.44.tgz", + "integrity": "sha512-5eTV4WRmqbaFM3v9gHAIljEQJU4Ssc6fxL61JN+Oe2ga/BwyjzjamwkCVVAQjHGuAX8i0BWo42dshL8eO5KfLQ==", "dev": true, "requires": { "esutils": "^2.0.2", @@ -142,40 +148,16 @@ "dev": true, "requires": { "acorn": "^5.0.3" - } - }, - "ajv": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.2.tgz", - "integrity": "sha512-hOs7GfvI6tUI1LfZddH82ky6mOMyTuY0mk7kE2pWpmhhUSkumzaTO5vbVwij39MdwPQWCV4Zv57Eo06NtL/GVA==", - "dev": true, - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.1" }, "dependencies": { - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", "dev": true } } }, - "ajv-keywords": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.2.0.tgz", - "integrity": "sha1-6GuBnGAs+IIa1jdBNpjx3sAhhHo=", - "dev": true - }, "ansi-escapes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", @@ -291,44 +273,6 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", "integrity": "sha1-8OAD2cqef1nHpQiUXXsu+aBKVC8=" }, - "babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", - "dev": true, - "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" - }, - "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, "babel-eslint": { "version": "8.2.6", "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-8.2.6.tgz", @@ -452,12 +396,6 @@ "supports-color": "^5.3.0" } }, - "chardet": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", - "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", - "dev": true - }, "chownr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz", @@ -510,9 +448,9 @@ "dev": true }, "combined-stream": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", "requires": { "delayed-stream": "~1.0.0" } @@ -574,9 +512,9 @@ }, "dependencies": { "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true } } @@ -587,6 +525,13 @@ "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "requires": { "assert-plus": "^1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } } }, "debug": { @@ -822,16 +767,16 @@ "dev": true }, "eslint": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.3.0.tgz", - "integrity": "sha1-U2laylITloqs35cMyyMeQqKyhfg=", + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.8.0.tgz", + "integrity": "sha512-Zok6Bru3y2JprqTNm14mgQ15YQu/SMDkWdnmHfFg770DIUlmMFd/gqqzCHekxzjHZJxXv3tmTpH0C1icaYJsRQ==", "dev": true, "requires": { - "ajv": "^6.5.0", - "babel-code-frame": "^6.26.0", + "@babel/code-frame": "^7.0.0", + "ajv": "^6.5.3", "chalk": "^2.1.0", "cross-spawn": "^6.0.5", - "debug": "^3.1.0", + "debug": "^4.0.1", "doctrine": "^2.1.0", "eslint-scope": "^4.0.0", "eslint-utils": "^1.3.1", @@ -843,11 +788,11 @@ "functional-red-black-tree": "^1.0.1", "glob": "^7.1.2", "globals": "^11.7.0", - "ignore": "^4.0.2", + "ignore": "^4.0.6", "imurmurhash": "^0.1.4", - "inquirer": "^5.2.0", + "inquirer": "^6.1.0", "is-resolvable": "^1.1.0", - "js-yaml": "^3.11.0", + "js-yaml": "^3.12.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", "lodash": "^4.17.5", @@ -858,16 +803,47 @@ "path-is-inside": "^1.0.2", "pluralize": "^7.0.0", "progress": "^2.0.0", - "regexpp": "^2.0.0", + "regexpp": "^2.0.1", "require-uncached": "^1.0.3", - "semver": "^5.5.0", - "string.prototype.matchall": "^2.0.0", + "semver": "^5.5.1", "strip-ansi": "^4.0.0", "strip-json-comments": "^2.0.1", - "table": "^4.0.3", + "table": "^5.0.2", "text-table": "^0.2.0" }, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "ajv": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", + "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", @@ -875,12 +851,12 @@ "dev": true }, "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz", + "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, "eslint-scope": { @@ -893,21 +869,58 @@ "estraverse": "^4.1.1" } }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true }, "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", "dev": true }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", @@ -916,6 +929,18 @@ "requires": { "ansi-regex": "^3.0.0" } + }, + "table": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/table/-/table-5.1.0.tgz", + "integrity": "sha512-e542in22ZLhD/fOIuXs/8yDZ9W61ltF8daM88rkRNtgTIct+vI2fTnAyu/Db2TCfEcI8i7mjZz6meLq0nW7TYg==", + "dev": true, + "requires": { + "ajv": "^6.5.3", + "lodash": "^4.17.10", + "slice-ansi": "1.0.0", + "string-width": "^2.1.1" + } } } }, @@ -968,9 +993,12 @@ }, "eslint-visitor-keys": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha1-PzGA+y4pEBdxastMnW1bXDSmqB0=", - "dev": true + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.0.tgz", + "integrity": "sha1-z7qLV9f7qT8XKYqKAGoEzaE9gPo=", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + } }, "espree": { "version": "4.0.0", @@ -1023,17 +1051,6 @@ "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha1-+LETa0Bx+9jrFAr/hYsQGewpFfo=" }, - "external-editor": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", - "integrity": "sha1-BFURz9jRM/OEZnPRBHwVTiFK09U=", - "dev": true, - "requires": { - "chardet": "^0.4.0", - "iconv-lite": "^0.4.17", - "tmp": "^0.0.33" - } - }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -1158,6 +1175,16 @@ "asynckit": "^0.4.0", "combined-stream": "1.0.6", "mime-types": "^2.1.12" + }, + "dependencies": { + "combined-stream": { + "version": "1.0.6", + "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "~1.0.0" + } + } } }, "fs-extra": { @@ -1225,6 +1252,13 @@ "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "requires": { "assert-plus": "^1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } } }, "glob": { @@ -1306,27 +1340,12 @@ "function-bind": "^1.0.2" } }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "has-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", - "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", - "dev": true - }, "has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", @@ -1420,21 +1439,21 @@ "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=" }, "inquirer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-5.2.0.tgz", - "integrity": "sha1-2zUMK3Paynf/EkOWLp8i8JloVyY=", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.0.tgz", + "integrity": "sha512-QIEQG4YyQ2UYZGDC4srMZ7BjHOmNk1lR2JQj5UknBapklm6WHA+VVH7N+sUdX3A7NeCfGF8o4X1S3Ao7nAcIeg==", "dev": true, "requires": { "ansi-escapes": "^3.0.0", "chalk": "^2.0.0", "cli-cursor": "^2.1.0", "cli-width": "^2.0.0", - "external-editor": "^2.1.0", + "external-editor": "^3.0.0", "figures": "^2.0.0", - "lodash": "^4.3.0", + "lodash": "^4.17.10", "mute-stream": "0.0.7", "run-async": "^2.2.0", - "rxjs": "^5.5.2", + "rxjs": "^6.1.0", "string-width": "^2.1.0", "strip-ansi": "^4.0.0", "through": "^2.3.6" @@ -1446,12 +1465,47 @@ "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", "dev": true }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, + "external-editor": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", + "integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==", + "dev": true, + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, + "rxjs": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", + "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -1708,9 +1762,12 @@ }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } }, "json-stringify-safe": { "version": "5.0.1", @@ -1725,6 +1782,12 @@ "graceful-fs": "^4.1.6" } }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -1843,9 +1906,9 @@ } }, "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha1-G3eTz3JZ6jj7NmHU04syYK+K5Oc=", + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, "loose-envify": { @@ -1870,17 +1933,19 @@ "integrity": "sha1-XUf3CcTJ/Dwha21GEnKA9As515A=", "dev": true }, - "mime-db": { - "version": "1.35.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", - "integrity": "sha1-BWnWV0ZkkSg3CWY603mpm5DZq0c=" - }, "mime-types": { - "version": "2.1.19", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", - "integrity": "sha1-ceRkU3p++BwV8tudl+kT/A/2BvA=", + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", "requires": { - "mime-db": "~1.35.0" + "mime-db": "~1.37.0" + }, + "dependencies": { + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" + } } }, "mimic-fn": { @@ -1927,9 +1992,9 @@ } }, "mkdirp": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz", - "integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=", + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" } @@ -1952,9 +2017,9 @@ "dev": true }, "nan": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz", - "integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=" + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", + "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" }, "natural-compare": { "version": "1.4.0", @@ -2002,16 +2067,6 @@ "rimraf": "^2.6.1", "semver": "^5.3.0", "tar": "^4" - }, - "dependencies": { - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "requires": { - "minimist": "0.0.8" - } - } } }, "nopt": { @@ -2041,9 +2096,9 @@ "integrity": "sha1-PBcyt7qTazoQMlrvYWRnwMy8yXk=" }, "npm-packlist": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.11.tgz", - "integrity": "sha1-hOjGg8vnhn00sdNX2JPOKeKKAt4=", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.12.tgz", + "integrity": "sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g==", "requires": { "ignore-walk": "^3.0.1", "npm-bundled": "^1.0.1" @@ -2247,6 +2302,11 @@ "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=" }, + "querystringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.0.0.tgz", + "integrity": "sha512-eTPo5t/4bgaMNZxyjWx6N2a6AuE0mq51KWvpc7nU/MAqixcI6v6KrGUKES0HaomdnolQBBXU/++X6/QQ9KL4tw==" + }, "rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", @@ -2260,7 +2320,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } @@ -2327,21 +2387,6 @@ "resolve": "^1.1.6" } }, - "regexp.prototype.flags": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.2.0.tgz", - "integrity": "sha1-azByTjBqJ4M+6xcbZqyIkLo35Bw=", - "dev": true, - "requires": { - "define-properties": "^1.1.2" - } - }, - "regexpp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.0.tgz", - "integrity": "sha1-sqdTSoXKGwM7z1zp/45W1OB1U2U=", - "dev": true - }, "request": { "version": "2.88.0", "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", @@ -2455,15 +2500,6 @@ "is-promise": "^2.1.0" } }, - "rxjs": { - "version": "5.5.11", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.11.tgz", - "integrity": "sha1-9zMCfKQ+O+xrmURzvkq5itQ87Yc=", - "dev": true, - "requires": { - "symbol-observable": "1.0.1" - } - }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", @@ -2622,6 +2658,13 @@ "jsbn": "~0.1.0", "safer-buffer": "^2.0.2", "tweetnacl": "~0.14.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } } }, "stream-counter": { @@ -2639,40 +2682,6 @@ "strip-ansi": "^3.0.0" } }, - "string.prototype.matchall": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-2.0.0.tgz", - "integrity": "sha1-Kvj+PS1txTyipZvTdrCJw8FSs8g=", - "dev": true, - "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.10.0", - "function-bind": "^1.1.1", - "has-symbols": "^1.0.0", - "regexp.prototype.flags": "^1.2.0" - }, - "dependencies": { - "es-abstract": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz", - "integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==", - "dev": true, - "requires": { - "es-to-primitive": "^1.1.1", - "function-bind": "^1.1.1", - "has": "^1.0.1", - "is-callable": "^1.1.3", - "is-regex": "^1.0.4" - } - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - } - } - }, "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", @@ -2683,7 +2692,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" @@ -2711,12 +2720,6 @@ "has-flag": "^3.0.0" } }, - "symbol-observable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz", - "integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ=", - "dev": true - }, "sync-request": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/sync-request/-/sync-request-3.0.1.tgz", @@ -2727,53 +2730,6 @@ "then-request": "^2.0.1" } }, - "table": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/table/-/table-4.0.3.tgz", - "integrity": "sha1-ALXitgLxeUuayvnKkIp2OGp4E7w=", - "dev": true, - "requires": { - "ajv": "^6.0.1", - "ajv-keywords": "^3.0.0", - "chalk": "^2.1.0", - "lodash": "^4.17.4", - "slice-ansi": "1.0.0", - "string-width": "^2.1.1" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } - } - }, "taffydb": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", @@ -2898,6 +2854,12 @@ "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", "dev": true }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "dev": true + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -2997,13 +2959,6 @@ "requires": { "querystringify": "^2.0.0", "requires-port": "^1.0.0" - }, - "dependencies": { - "querystringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.0.0.tgz", - "integrity": "sha512-eTPo5t/4bgaMNZxyjWx6N2a6AuE0mq51KWvpc7nU/MAqixcI6v6KrGUKES0HaomdnolQBBXU/++X6/QQ9KL4tw==" - } } }, "util-deprecate": { @@ -3040,6 +2995,13 @@ "assert-plus": "^1.0.0", "core-util-is": "1.0.2", "extsprintf": "^1.2.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } } }, "whatwg-fetch": { @@ -3082,17 +3044,6 @@ "dev": true, "requires": { "mkdirp": "^0.5.1" - }, - "dependencies": { - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - } } }, "xmlcreate": { diff --git a/package.json b/package.json index 8431d5aa..9eeb5a7b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "realm", "description": "Realm is a mobile database: an alternative to SQLite and key-value stores", - "version": "2.19.0-rc.4", + "version": "2.19.0-rc.5", "license": "See the actual license in the file LICENSE", "homepage": "https://realm.io", "keywords": [ @@ -83,7 +83,7 @@ "deepmerge": "2.1.0", "fs-extra": "^4.0.2", "ini": "^1.3.4", - "nan": "2.8.0", + "nan": "^2.10.0", "node-fetch": "^1.6.3", "node-pre-gyp": "^0.11.0", "progress": "^2.0.0", diff --git a/packaging/node-pre-gyp/base-image/Dockerfile b/packaging/node-pre-gyp/base-image/Dockerfile index fa8b0283..ae8169d0 100644 --- a/packaging/node-pre-gyp/base-image/Dockerfile +++ b/packaging/node-pre-gyp/base-image/Dockerfile @@ -31,7 +31,6 @@ RUN touch /var/lib/rpm/* \ ENV NVM_DIR /root/.nvm RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash RUN . $NVM_DIR/nvm.sh && \ - nvm install 4.4.7 && \ - nvm install 5.12.0 && \ - nvm install 6.5.0 && \ - nvm install 7.0.0 + nvm install 6.14.4 && \ + nvm install 8.12.0 && \ + nvm install 10.13.0 diff --git a/realm.gypi b/realm.gypi index 072bcf00..6e4aa6db 100644 --- a/realm.gypi +++ b/realm.gypi @@ -30,7 +30,6 @@ "targets": [ { "target_name": "object-store", - "dependencies": [ "realm-core" ], "type": "static_library", "include_dirs": [ "src/object-store/src", @@ -151,6 +150,8 @@ "src/object-store/src/sync/impl/sync_metadata.cpp", "src/object-store/src/sync/impl/work_queue.cpp" ], + }, { + "dependencies": [ "realm-core" ] }] ], "all_dependent_settings": { @@ -201,6 +202,17 @@ "dependencies": [ "realm-core" ], "link_settings": { "libraries": [ "-lrealm-sync<(debug_library_suffix)" ], + "conditions": [ + ["OS=='win'", { + "conditions": [ + ["target_arch=='ia32'", { + "libraries": [ "C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\x86\\mincore.lib" ] + }, { + "libraries": [ "C:\\Program Files (x86)\\Windows Kits\\8.1\\Lib\\winv6.3\\um\\x64\\mincore.lib" ] + }] + ] + }] + ] }, "all_dependent_settings": { "defines": [ "REALM_ENABLE_SYNC=1" ] @@ -228,12 +240,11 @@ "link_settings": { "conditions": [ ["OS=='win'", { - "libraries": [ "libeay32.lib", "ssleay32.lib" ], "conditions": [ ["target_arch=='ia32'", { - "library_dirs": [ "C:\\src\\vcpkg\\installed\\x86-windows-static\\lib" ] + "libraries": [ "C:\\src\\vcpkg\\installed\\x86-windows-static\\lib\\libeay32.lib", "C:\\src\\vcpkg\\installed\\x86-windows-static\\lib\\ssleay32.lib" ] }, { - "library_dirs": [ "C:\\src\\vcpkg\\installed\\x64-windows-static\\lib" ] + "libraries": [ "C:\\src\\vcpkg\\installed\\x64-windows-static\\lib\\libeay32.lib", "C:\\src\\vcpkg\\installed\\x64-windows-static\\lib\\ssleay32.lib" ] }], ] }], diff --git a/scripts/build-node-pre-gyp.ps1 b/scripts/build-node-pre-gyp.ps1 index ee738f45..307216e8 100644 --- a/scripts/build-node-pre-gyp.ps1 +++ b/scripts/build-node-pre-gyp.ps1 @@ -20,7 +20,7 @@ New-Item .\out -ItemType "directory" npm install --ignore-scripts foreach ($arch in "ia32", "x64") { - foreach ($version in "4.0.0", "5.0.0", "6.0.0", "7.0.0", "8.0.0") { + foreach ($version in "6.14.4", "8.12.0", "10.13.0") { Remove-Item .\build, .\compiled -Recurse -Force -ErrorAction Ignore .\node_modules\node-pre-gyp\bin\node-pre-gyp.cmd rebuild --target_arch=$arch --target=$version .\node_modules\node-pre-gyp\bin\node-pre-gyp.cmd package --target_arch=$arch --target=$version diff --git a/scripts/build-node-pre-gyp.sh b/scripts/build-node-pre-gyp.sh index f787bd98..c65a9116 100755 --- a/scripts/build-node-pre-gyp.sh +++ b/scripts/build-node-pre-gyp.sh @@ -1,6 +1,6 @@ #!/bin/bash -node_versions=${@:-4.4.7 5.12.0 6.5.0 7.0.0} +node_versions=${@:-6.14.4 8.12.0 10.13.0} topdir=$(cd $(dirname "$0")/..; pwd) @@ -36,7 +36,6 @@ for node_version in ${node_versions}; do nvm use ${node_version} || die "Could not load nodejs v${node_version}" npm install --build-from-source=realm "$EXTRA_NPM_ARGUMENTS" || die "Could not build module" - #./scripts/test.sh node || die "Unit tests for nodejs v${node_version} failed" ./node_modules/.bin/node-pre-gyp package || die "Could not package module" cp build/stage/node-pre-gyp/*.tar.gz ${topdir}/out/ ) diff --git a/scripts/download-realm.js b/scripts/download-realm.js index a8670d6d..2f8ae9d2 100644 --- a/scripts/download-realm.js +++ b/scripts/download-realm.js @@ -48,7 +48,7 @@ function getTempDir() { * conflict. * * It is also possible to overrride this temp directory by setting - * REALM_DOWNLOAD_CORE_TEMP_DIR so, for instance, CI systems will + * REALM_DOWNLOAD_CORE_TEMP_DIR so, for instance, CI systems will * be able to clean up files. */ return process.env.REALM_DOWNLOAD_CORE_TEMP_DIR || @@ -129,7 +129,8 @@ function extract(downloadedArchive, targetFolder, archiveRootFolder) { if (!archiveRootFolder) { return decompress(downloadedArchive, targetFolder); } else { - const tempExtractLocation = path.resolve(getTempDir(), path.basename(downloadedArchive, path.extname(downloadedArchive))); + const base = path.basename(downloadedArchive).split('.'); + const tempExtractLocation = path.resolve(getTempDir(), base.slice(0, base.length - 2).join('.')); return decompress(downloadedArchive, tempExtractLocation) .then(() => fs.readdir(path.resolve(tempExtractLocation, archiveRootFolder))) .then(items => Promise.all(items.map(item => { @@ -187,8 +188,7 @@ function getCoreRequirements(dependencies, options, required = {}) { } case 'linux': required.CORE_SERVER_FOLDER = 'core'; - required.CORE_ARCHIVE = `realm-core-${dependencies.REALM_CORE_VERSION}.tgz`; - required.CORE_ARCHIVE_ROOT = `realm-core-${dependencies.REALM_CORE_VERSION}`; + required.CORE_ARCHIVE = `realm-core-${flavor}-v${dependencies.REALM_CORE_VERSION}-Linux-devel.tar.gz`; return Promise.resolve(required); default: return Promise.reject(new Error(`Unsupported core platform '${options.platform}'`)); diff --git a/src/js_class.hpp b/src/js_class.hpp index 761838d5..b3fea748 100644 --- a/src/js_class.hpp +++ b/src/js_class.hpp @@ -27,12 +27,6 @@ namespace realm { namespace js { -template -using ConstructorType = void(typename T::Context, typename T::Object, size_t, const typename T::Value[]); - -template -using MethodType = void(typename T::Context, typename T::Function, typename T::Object, size_t, const typename T::Value[], ReturnValue &); - template struct Arguments { const typename T::Context ctx; @@ -52,15 +46,24 @@ struct Arguments { } } - void validate_count(size_t actual) const { - if (count != actual) { - throw std::invalid_argument(util::format("Invalid arguments: %1 expected, but %s supplied.", actual, count)); + void validate_count(size_t expected) const { + if (count != expected) { + throw std::invalid_argument(util::format("Invalid arguments: %1 expected, but %2 supplied.", expected, count)); + } + } + + void validate_between(size_t min, size_t max) const { + if (count < min || count > max) { + throw std::invalid_argument(util::format("Invalid arguments: expected between %1 and %2, but %3 supplied.", min, max, count)); } } }; template -using ArgumentsMethodType = void(typename T::Context, typename T::Object, Arguments, ReturnValue &); +using ConstructorType = void(typename T::Context, typename T::Object, Arguments &); + +template +using ArgumentsMethodType = void(typename T::Context, typename T::Object, Arguments &, ReturnValue &); template struct PropertyType { diff --git a/src/js_list.hpp b/src/js_list.hpp index ae4af82f..def1de03 100644 --- a/src/js_list.hpp +++ b/src/js_list.hpp @@ -65,22 +65,22 @@ struct ListClass : ClassDefinition, CollectionClass> { static bool set_index(ContextType, ObjectType, uint32_t, ValueType); // methods - static void push(ContextType, ObjectType, Arguments, ReturnValue &); - static void pop(ContextType, ObjectType, Arguments, ReturnValue &); - static void unshift(ContextType, ObjectType, Arguments, ReturnValue &); - static void shift(ContextType, ObjectType, Arguments, ReturnValue &); - static void splice(ContextType, ObjectType, Arguments, ReturnValue &); - static void snapshot(ContextType, ObjectType, Arguments, ReturnValue &); - static void filtered(ContextType, ObjectType, Arguments, ReturnValue &); - static void sorted(ContextType, ObjectType, Arguments, ReturnValue &); - static void is_valid(ContextType, ObjectType, Arguments, ReturnValue &); - static void is_empty(ContextType, ObjectType, Arguments, ReturnValue &); - static void index_of(ContextType, ObjectType, Arguments, ReturnValue &); + static void push(ContextType, ObjectType, Arguments &, ReturnValue &); + static void pop(ContextType, ObjectType, Arguments &, ReturnValue &); + static void unshift(ContextType, ObjectType, Arguments &, ReturnValue &); + static void shift(ContextType, ObjectType, Arguments &, ReturnValue &); + static void splice(ContextType, ObjectType, Arguments &, ReturnValue &); + static void snapshot(ContextType, ObjectType, Arguments &, ReturnValue &); + static void filtered(ContextType, ObjectType, Arguments &, ReturnValue &); + static void sorted(ContextType, ObjectType, Arguments &, ReturnValue &); + static void is_valid(ContextType, ObjectType, Arguments &, ReturnValue &); + static void is_empty(ContextType, ObjectType, Arguments &, ReturnValue &); + static void index_of(ContextType, ObjectType, Arguments &, ReturnValue &); // observable - static void add_listener(ContextType, ObjectType, Arguments, ReturnValue &); - static void remove_listener(ContextType, ObjectType, Arguments, ReturnValue &); - static void remove_all_listeners(ContextType, ObjectType, Arguments, ReturnValue &); + static void add_listener(ContextType, ObjectType, Arguments &, ReturnValue &); + static void remove_listener(ContextType, ObjectType, Arguments &, ReturnValue &); + static void remove_all_listeners(ContextType, ObjectType, Arguments &, ReturnValue &); std::string const name = "List"; @@ -157,7 +157,7 @@ bool ListClass::set_index(ContextType ctx, ObjectType object, uint32_t index, } template -void ListClass::push(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::push(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto list = get_internal>(this_object); for (size_t i = 0; i < args.count; i++) { validate_value(ctx, *list, args[i]); @@ -172,7 +172,7 @@ void ListClass::push(ContextType ctx, ObjectType this_object, Arguments args, } template -void ListClass::pop(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::pop(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); auto list = get_internal>(this_object); @@ -188,7 +188,7 @@ void ListClass::pop(ContextType ctx, ObjectType this_object, Arguments args, } template -void ListClass::unshift(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::unshift(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto list = get_internal>(this_object); for (size_t i = 0; i < args.count; i++) { validate_value(ctx, *list, args[i]); @@ -203,7 +203,7 @@ void ListClass::unshift(ContextType ctx, ObjectType this_object, Arguments ar } template -void ListClass::shift(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::shift(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); auto list = get_internal>(this_object); @@ -218,7 +218,7 @@ void ListClass::shift(ContextType ctx, ObjectType this_object, Arguments args } template -void ListClass::splice(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::splice(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto list = get_internal>(this_object); size_t size = list->size(); long index = std::min(Value::to_number(ctx, args[0]), size); @@ -251,36 +251,36 @@ void ListClass::splice(ContextType ctx, ObjectType this_object, Arguments arg } template -void ListClass::snapshot(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::snapshot(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); auto list = get_internal>(this_object); return_value.set(ResultsClass::create_instance(ctx, list->snapshot())); } template -void ListClass::filtered(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::filtered(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto list = get_internal>(this_object); return_value.set(ResultsClass::create_filtered(ctx, *list, args)); } template -void ListClass::sorted(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::sorted(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto list = get_internal>(this_object); return_value.set(ResultsClass::create_instance(ctx, list->sort(ResultsClass::get_keypaths(ctx, args)))); } template -void ListClass::is_valid(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::is_valid(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { return_value.set(get_internal>(this_object)->is_valid()); } template -void ListClass::is_empty(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::is_empty(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { return_value.set(get_internal>(this_object)->size() == 0); } template -void ListClass::index_of(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::index_of(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto fn = [&](auto&& row) { auto list = get_internal>(this_object); NativeAccessor accessor(ctx, *list); @@ -290,19 +290,19 @@ void ListClass::index_of(ContextType ctx, ObjectType this_object, Arguments a } template -void ListClass::add_listener(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::add_listener(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto list = get_internal>(this_object); ResultsClass::add_listener(ctx, *list, this_object, args); } template -void ListClass::remove_listener(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::remove_listener(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto list = get_internal>(this_object); ResultsClass::remove_listener(ctx, *list, this_object, args); } template -void ListClass::remove_all_listeners(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ListClass::remove_all_listeners(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); auto list = get_internal>(this_object); list->m_notification_tokens.clear(); diff --git a/src/js_realm.hpp b/src/js_realm.hpp index f5696553..1e548f13 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -218,26 +218,29 @@ public: static FunctionType create_constructor(ContextType); // methods - static void objects(ContextType, ObjectType, Arguments, ReturnValue &); - static void object_for_primary_key(ContextType, ObjectType, Arguments, ReturnValue &); - static void create(ContextType, ObjectType, Arguments, ReturnValue &); - static void delete_one(ContextType, ObjectType, Arguments, ReturnValue &); - static void delete_all(ContextType, ObjectType, Arguments, ReturnValue &); - static void write(ContextType, ObjectType, Arguments, ReturnValue &); - static void begin_transaction(ContextType, ObjectType, Arguments, ReturnValue&); - static void commit_transaction(ContextType, ObjectType, Arguments, ReturnValue&); - static void cancel_transaction(ContextType, ObjectType, Arguments, ReturnValue&); - static void add_listener(ContextType, ObjectType, Arguments, ReturnValue &); - static void async_open_realm(ContextType, ObjectType, Arguments, ReturnValue &); - static void remove_listener(ContextType, ObjectType, Arguments, ReturnValue &); - static void remove_all_listeners(ContextType, ObjectType, Arguments, ReturnValue &); - static void close(ContextType, ObjectType, Arguments, ReturnValue &); - static void compact(ContextType, ObjectType, Arguments, ReturnValue &); - static void writeCopyTo(ContextType, ObjectType, Arguments, ReturnValue &); - static void delete_model(ContextType, ObjectType, Arguments, ReturnValue &); - static void object_for_object_id(ContextType, ObjectType, Arguments, ReturnValue&); - static void privileges(ContextType, ObjectType, Arguments, ReturnValue&); - static void get_schema_name_from_object(ContextType, ObjectType, Arguments, ReturnValue&); + static void objects(ContextType, ObjectType, Arguments &, ReturnValue &); + static void object_for_primary_key(ContextType, ObjectType, Arguments &, ReturnValue &); + static void create(ContextType, ObjectType, Arguments &, ReturnValue &); + static void delete_one(ContextType, ObjectType, Arguments &, ReturnValue &); + static void delete_all(ContextType, ObjectType, Arguments &, ReturnValue &); + static void write(ContextType, ObjectType, Arguments &, ReturnValue &); + static void begin_transaction(ContextType, ObjectType, Arguments &, ReturnValue&); + static void commit_transaction(ContextType, ObjectType, Arguments &, ReturnValue&); + static void cancel_transaction(ContextType, ObjectType, Arguments &, ReturnValue&); + static void add_listener(ContextType, ObjectType, Arguments &, ReturnValue &); + static void wait_for_download_completion(ContextType, ObjectType, Arguments &, ReturnValue &); + static void remove_listener(ContextType, ObjectType, Arguments &, ReturnValue &); + static void remove_all_listeners(ContextType, ObjectType, Arguments &, ReturnValue &); + static void close(ContextType, ObjectType, Arguments &, ReturnValue &); + static void compact(ContextType, ObjectType, Arguments &, ReturnValue &); + static void writeCopyTo(ContextType, ObjectType, Arguments &, ReturnValue &); + static void delete_model(ContextType, ObjectType, Arguments &, ReturnValue &); + static void object_for_object_id(ContextType, ObjectType, Arguments &, ReturnValue&); + static void privileges(ContextType, ObjectType, Arguments &, ReturnValue&); + static void get_schema_name_from_object(ContextType, ObjectType, Arguments &, ReturnValue&); +#if REALM_ENABLE_SYNC + static void async_open_realm(ContextType, ObjectType, Arguments &, ReturnValue&); +#endif // properties static void get_empty(ContextType, ObjectType, ReturnValue &); @@ -253,15 +256,14 @@ public: #endif // static methods - static void constructor(ContextType, ObjectType, size_t, const ValueType[]); + static void constructor(ContextType, ObjectType, Arguments &); static SharedRealm create_shared_realm(ContextType, realm::Realm::Config, bool, ObjectDefaultsMap &&, ConstructorMap &&); - static bool get_realm_config(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[], - Realm::Config& config, ObjectDefaultsMap& defaults, ConstructorMap& constructors); + static bool get_realm_config(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[], realm::Realm::Config &, ObjectDefaultsMap &, ConstructorMap &); - static void schema_version(ContextType, ObjectType, Arguments, ReturnValue &); - static void clear_test_state(ContextType, ObjectType, Arguments, ReturnValue &); - static void copy_bundled_realm_files(ContextType, ObjectType, Arguments, ReturnValue &); - static void delete_file(ContextType, ObjectType, Arguments, ReturnValue &); + static void schema_version(ContextType, ObjectType, Arguments &, ReturnValue &); + static void clear_test_state(ContextType, ObjectType, Arguments &, ReturnValue &); + static void copy_bundled_realm_files(ContextType, ObjectType, Arguments &, ReturnValue &); + static void delete_file(ContextType, ObjectType, Arguments &, ReturnValue &); // static properties static void get_default_path(ContextType, ObjectType, ReturnValue &); @@ -447,13 +449,13 @@ static inline void convert_outdated_datetime_columns(const SharedRealm &realm) { } template -bool RealmClass::get_realm_config(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[], - Realm::Config& config, ObjectDefaultsMap& defaults, ConstructorMap& constructors) { +bool RealmClass::get_realm_config(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[], realm::Realm::Config& config, ObjectDefaultsMap& defaults, ConstructorMap& constructors) { + bool schema_updated = false; + if (argc > 1) { throw std::runtime_error("Invalid arguments when constructing 'Realm'"); } - bool schema_updated = false; if (argc == 0) { config.path = default_path(); } @@ -610,11 +612,11 @@ bool RealmClass::get_realm_config(ContextType ctx, ObjectType this_object, si } template -void RealmClass::constructor(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[]) { +void RealmClass::constructor(ContextType ctx, ObjectType this_object, Arguments& args) { realm::Realm::Config config; ObjectDefaultsMap defaults; ConstructorMap constructors; - bool schema_updated = get_realm_config(ctx, this_object, argc, arguments, config, defaults, constructors); + bool schema_updated = get_realm_config(ctx, this_object, args.count, args.value, config, defaults, constructors); auto realm = create_shared_realm(ctx, config, schema_updated, std::move(defaults), std::move(constructors)); // Fix for datetime -> timestamp conversion @@ -667,7 +669,7 @@ SharedRealm RealmClass::create_shared_realm(ContextType ctx, realm::Realm::Co } template -void RealmClass::schema_version(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::schema_version(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(2); realm::Realm::Config config; @@ -688,19 +690,19 @@ void RealmClass::schema_version(ContextType ctx, ObjectType this_object, Argu template -void RealmClass::clear_test_state(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::clear_test_state(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); js::clear_test_state(); } template -void RealmClass::copy_bundled_realm_files(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::copy_bundled_realm_files(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); realm::copy_bundled_realm_files(); } template -void RealmClass::delete_file(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::delete_file(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); ValueType value = args[0]; @@ -740,7 +742,7 @@ void RealmClass::delete_file(ContextType ctx, ObjectType this_object, Argumen } template -void RealmClass::delete_model(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::delete_model(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); ValueType value = args[0]; @@ -820,7 +822,7 @@ void RealmClass::get_sync_session(ContextType ctx, ObjectType object, ReturnV #if REALM_ENABLE_SYNC template -void RealmClass::async_open_realm(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::async_open_realm(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(2); auto callback_function = Value::validated_to_function(ctx, args[0 + (args.count == 2)]); Realm::Config config; @@ -907,7 +909,7 @@ void RealmClass::async_open_realm(ContextType ctx, ObjectType this_object, Ar #endif template -void RealmClass::objects(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::objects(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); SharedRealm realm = *get_internal>(this_object); @@ -916,7 +918,7 @@ void RealmClass::objects(ContextType ctx, ObjectType this_object, Arguments a } template -void RealmClass::object_for_primary_key(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::object_for_primary_key(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(2); SharedRealm realm = *get_internal>(this_object); @@ -934,7 +936,7 @@ void RealmClass::object_for_primary_key(ContextType ctx, ObjectType this_obje } template -void RealmClass::create(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::create(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(3); SharedRealm realm = *get_internal>(this_object); @@ -957,7 +959,7 @@ void RealmClass::create(ContextType ctx, ObjectType this_object, Arguments ar } template -void RealmClass::delete_one(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::delete_one(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); SharedRealm realm = *get_internal>(this_object); @@ -1005,7 +1007,7 @@ void RealmClass::delete_one(ContextType ctx, ObjectType this_object, Argument } template -void RealmClass::delete_all(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::delete_all(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); SharedRealm realm = *get_internal>(this_object); @@ -1027,7 +1029,7 @@ void RealmClass::delete_all(ContextType ctx, ObjectType this_object, Argument } template -void RealmClass::write(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::write(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); SharedRealm realm = *get_internal>(this_object); @@ -1047,7 +1049,7 @@ void RealmClass::write(ContextType ctx, ObjectType this_object, Arguments arg } template -void RealmClass::begin_transaction(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::begin_transaction(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); SharedRealm realm = *get_internal>(this_object); @@ -1055,7 +1057,7 @@ void RealmClass::begin_transaction(ContextType ctx, ObjectType this_object, A } template -void RealmClass::commit_transaction(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::commit_transaction(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); SharedRealm realm = *get_internal>(this_object); @@ -1063,7 +1065,7 @@ void RealmClass::commit_transaction(ContextType ctx, ObjectType this_object, } template -void RealmClass::cancel_transaction(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::cancel_transaction(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); SharedRealm realm = *get_internal>(this_object); @@ -1071,7 +1073,7 @@ void RealmClass::cancel_transaction(ContextType ctx, ObjectType this_object, } template -void RealmClass::add_listener(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::add_listener(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(2); auto name = validated_notification_name(ctx, args[0]); @@ -1088,7 +1090,7 @@ void RealmClass::add_listener(ContextType ctx, ObjectType this_object, Argume } template -void RealmClass::remove_listener(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::remove_listener(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(2); auto name = validated_notification_name(ctx, args[0]); @@ -1105,7 +1107,7 @@ void RealmClass::remove_listener(ContextType ctx, ObjectType this_object, Arg } template -void RealmClass::remove_all_listeners(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::remove_all_listeners(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); std::string name = "change"; if (args.count) { @@ -1123,7 +1125,7 @@ void RealmClass::remove_all_listeners(ContextType ctx, ObjectType this_object } template -void RealmClass::close(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::close(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); SharedRealm realm = *get_internal>(this_object); @@ -1131,7 +1133,7 @@ void RealmClass::close(ContextType ctx, ObjectType this_object, Arguments arg } template -void RealmClass::compact(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::compact(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); SharedRealm realm = *get_internal>(this_object); @@ -1143,7 +1145,7 @@ void RealmClass::compact(ContextType ctx, ObjectType this_object, Arguments a } template -void RealmClass::writeCopyTo(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::writeCopyTo(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(2); if (args.count == 0) { @@ -1179,7 +1181,7 @@ void RealmClass::writeCopyTo(ContextType ctx, ObjectType this_object, Argumen } template -void RealmClass::object_for_object_id(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue& return_value) { +void RealmClass::object_for_object_id(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue& return_value) { args.validate_count(2); #if REALM_ENABLE_SYNC @@ -1202,7 +1204,7 @@ void RealmClass::object_for_object_id(ContextType ctx, ObjectType this_object } template -void RealmClass::get_schema_name_from_object(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue& return_value) { +void RealmClass::get_schema_name_from_object(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue& return_value) { args.validate_count(1); // Try to map the input to the internal schema name for the given input. This should work for managed objects and @@ -1213,7 +1215,7 @@ void RealmClass::get_schema_name_from_object(ContextType ctx, ObjectType this } template -void RealmClass::privileges(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void RealmClass::privileges(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); using Privilege = realm::ComputedPrivileges; diff --git a/src/js_realm_object.hpp b/src/js_realm_object.hpp index 4cc117ba..cf27e89b 100644 --- a/src/js_realm_object.hpp +++ b/src/js_realm_object.hpp @@ -57,13 +57,13 @@ struct RealmObjectClass : ClassDefinition { static bool set_property(ContextType, ObjectType, const String &, ValueType); static std::vector get_property_names(ContextType, ObjectType); - static void is_valid(ContextType, FunctionType, ObjectType, size_t, const ValueType [], ReturnValue &); - static void get_object_schema(ContextType, FunctionType, ObjectType, size_t, const ValueType [], ReturnValue &); - static void linking_objects(ContextType, FunctionType, ObjectType, size_t, const ValueType [], ReturnValue &); - static void linking_objects_count(ContextType, FunctionType, ObjectType, size_t, const ValueType [], ReturnValue &); - static void get_object_id(ContextType, ObjectType, Arguments, ReturnValue &); - static void is_same_object(ContextType, ObjectType, Arguments, ReturnValue &); - static void set_link(ContextType, ObjectType, Arguments, ReturnValue &); + static void is_valid(ContextType, ObjectType, Arguments &, ReturnValue &); + static void get_object_schema(ContextType, ObjectType, Arguments &, ReturnValue &); + static void linking_objects(ContextType, ObjectType, Arguments &, ReturnValue &); + static void linking_objects_count(ContextType, ObjectType, Arguments &, ReturnValue &); + static void get_object_id(ContextType, ObjectType, Arguments &, ReturnValue &); + static void is_same_object(ContextType, ObjectType, Arguments &, ReturnValue &); + static void set_link(ContextType, ObjectType, Arguments &, ReturnValue &); static void get_realm(ContextType, ObjectType, ReturnValue &); @@ -91,12 +91,12 @@ struct RealmObjectClass : ClassDefinition { }; template -void RealmObjectClass::is_valid(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { +void RealmObjectClass::is_valid(ContextType, ObjectType this_object, Arguments &, ReturnValue &return_value) { return_value.set(get_internal>(this_object)->is_valid()); } template -void RealmObjectClass::get_object_schema(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { +void RealmObjectClass::get_object_schema(ContextType ctx, ObjectType this_object, Arguments &, ReturnValue &return_value) { auto object = get_internal>(this_object); return_value.set(Schema::object_for_object_schema(ctx, object->get_object_schema())); } @@ -156,7 +156,7 @@ bool RealmObjectClass::set_property(ContextType ctx, ObjectType object, const } template -void RealmObjectClass::set_link(ContextType ctx, ObjectType object, Arguments args, ReturnValue& return_value) { +void RealmObjectClass::set_link(ContextType ctx, ObjectType object, Arguments &args, ReturnValue& return_value) { args.validate_count(2); auto realm_object = get_internal>(object); @@ -231,7 +231,7 @@ std::vector> RealmObjectClass::get_property_names(ContextType ctx, } template -void RealmObjectClass::get_object_id(ContextType ctx, ObjectType object, Arguments args, ReturnValue& return_value) { +void RealmObjectClass::get_object_id(ContextType ctx, ObjectType object, Arguments &args, ReturnValue& return_value) { args.validate_maximum(0); #if REALM_ENABLE_SYNC @@ -249,7 +249,7 @@ void RealmObjectClass::get_object_id(ContextType ctx, ObjectType object, Argu } template -void RealmObjectClass::is_same_object(ContextType ctx, ObjectType object, Arguments args, ReturnValue& return_value) { +void RealmObjectClass::is_same_object(ContextType ctx, ObjectType object, Arguments &args, ReturnValue& return_value) { args.validate_count(1); ObjectType otherObject = Value::validated_to_object(ctx, args[0]); @@ -276,7 +276,7 @@ void RealmObjectClass::is_same_object(ContextType ctx, ObjectType object, Arg } template -void RealmObjectClass::linking_objects_count(ContextType ctx, FunctionType, ObjectType object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { +void RealmObjectClass::linking_objects_count(ContextType, ObjectType object, Arguments &, ReturnValue &return_value) { auto realm_object = get_internal>(object); const Row& row = realm_object->row(); @@ -291,11 +291,11 @@ void RealmObjectClass::linking_objects_count(ContextType ctx, FunctionType, O #include "js_results.hpp" template -void realm::js::RealmObjectClass::linking_objects(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 2); +void realm::js::RealmObjectClass::linking_objects(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { + args.validate_count(2); - std::string object_type = Value::validated_to_string(ctx, arguments[0], "objectType"); - std::string property_name = Value::validated_to_string(ctx, arguments[1], "property"); + std::string object_type = Value::validated_to_string(ctx, args[0], "objectType"); + std::string property_name = Value::validated_to_string(ctx, args[1], "property"); auto object = get_internal>(this_object); diff --git a/src/js_results.hpp b/src/js_results.hpp index 057293ec..cc15df52 100644 --- a/src/js_results.hpp +++ b/src/js_results.hpp @@ -74,40 +74,40 @@ struct ResultsClass : ClassDefinition, CollectionClass< static ObjectType create_instance(ContextType, SharedRealm, const std::string &object_type); template - static ObjectType create_filtered(ContextType, const U &, Arguments); + static ObjectType create_filtered(ContextType, const U &, Arguments &); - static std::vector> get_keypaths(ContextType, Arguments); + static std::vector> get_keypaths(ContextType, Arguments &); static void get_length(ContextType, ObjectType, ReturnValue &); static void get_type(ContextType, ObjectType, ReturnValue &); static void get_optional(ContextType, ObjectType, ReturnValue &); static void get_index(ContextType, ObjectType, uint32_t, ReturnValue &); - static void snapshot(ContextType, ObjectType, Arguments, ReturnValue &); - static void filtered(ContextType, ObjectType, Arguments, ReturnValue &); - static void sorted(ContextType, ObjectType, Arguments, ReturnValue &); - static void is_valid(ContextType, ObjectType, Arguments, ReturnValue &); - static void is_empty(ContextType, ObjectType, Arguments, ReturnValue &); + static void snapshot(ContextType, ObjectType, Arguments &, ReturnValue &); + static void filtered(ContextType, ObjectType, Arguments &, ReturnValue &); + static void sorted(ContextType, ObjectType, Arguments &, ReturnValue &); + static void is_valid(ContextType, ObjectType, Arguments &, ReturnValue &); + static void is_empty(ContextType, ObjectType, Arguments &, ReturnValue &); #if REALM_ENABLE_SYNC - static void subscribe(ContextType, ObjectType, Arguments, ReturnValue &); + static void subscribe(ContextType, ObjectType, Arguments &, ReturnValue &); #endif - static void index_of(ContextType, ObjectType, Arguments, ReturnValue &); + static void index_of(ContextType, ObjectType, Arguments &, ReturnValue &); template - static void index_of(ContextType, Fn&, Arguments, ReturnValue &); + static void index_of(ContextType, Fn&, Arguments &, ReturnValue &); - static void update(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); + static void update(ContextType, ObjectType, Arguments &, ReturnValue &); // observable - static void add_listener(ContextType, ObjectType, Arguments, ReturnValue &); - static void remove_listener(ContextType, ObjectType, Arguments, ReturnValue &); - static void remove_all_listeners(ContextType, ObjectType, Arguments, ReturnValue &); + static void add_listener(ContextType, ObjectType, Arguments &, ReturnValue &); + static void remove_listener(ContextType, ObjectType, Arguments &, ReturnValue &); + static void remove_all_listeners(ContextType, ObjectType, Arguments &, ReturnValue &); template - static void add_listener(ContextType, U&, ObjectType, Arguments); + static void add_listener(ContextType, U&, ObjectType, Arguments &); template - static void remove_listener(ContextType, U&, ObjectType, Arguments); + static void remove_listener(ContextType, U&, ObjectType, Arguments &); std::string const name = "Results"; @@ -171,7 +171,7 @@ inline void alias_backlinks(parser::KeyPathMapping &mapping, const realm::Shared template template -typename T::Object ResultsClass::create_filtered(ContextType ctx, const U &collection, Arguments args) { +typename T::Object ResultsClass::create_filtered(ContextType ctx, const U &collection, Arguments &args) { if (collection.get_type() != realm::PropertyType::Object) { throw std::runtime_error("Filtering non-object Lists and Results is not yet implemented."); } @@ -196,7 +196,7 @@ typename T::Object ResultsClass::create_filtered(ContextType ctx, const U &co template std::vector> -ResultsClass::get_keypaths(ContextType ctx, Arguments args) { +ResultsClass::get_keypaths(ContextType ctx, Arguments &args) { args.validate_maximum(2); std::vector> sort_order; @@ -262,37 +262,37 @@ void ResultsClass::get_index(ContextType ctx, ObjectType object, uint32_t ind } template -void ResultsClass::snapshot(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ResultsClass::snapshot(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); auto results = get_internal>(this_object); return_value.set(ResultsClass::create_instance(ctx, results->snapshot())); } template -void ResultsClass::filtered(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ResultsClass::filtered(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto results = get_internal>(this_object); return_value.set(create_filtered(ctx, *results, args)); } template -void ResultsClass::sorted(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ResultsClass::sorted(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto results = get_internal>(this_object); return_value.set(ResultsClass::create_instance(ctx, results->sort(ResultsClass::get_keypaths(ctx, args)))); } template -void ResultsClass::is_valid(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ResultsClass::is_valid(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { return_value.set(get_internal>(this_object)->is_valid()); } template -void ResultsClass::is_empty(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ResultsClass::is_empty(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { return_value.set(get_internal>(this_object)->size() == 0); } #if REALM_ENABLE_SYNC template -void ResultsClass::subscribe(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ResultsClass::subscribe(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); auto results = get_internal>(this_object); @@ -314,7 +314,7 @@ void ResultsClass::subscribe(ContextType ctx, ObjectType this_object, Argumen template template -void ResultsClass::index_of(ContextType ctx, Fn& fn, Arguments args, ReturnValue &return_value) { +void ResultsClass::index_of(ContextType ctx, Fn& fn, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); size_t ndx; @@ -337,10 +337,10 @@ void ResultsClass::index_of(ContextType ctx, Fn& fn, Arguments args, ReturnVa } template -void ResultsClass::update(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 2); +void ResultsClass::update(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { + args.validate_maximum(2); - std::string property = Value::validated_to_string(ctx, arguments[0], "property"); + std::string property = Value::validated_to_string(ctx, args[0], "property"); auto results = get_internal>(this_object); auto schema = results->get_object_schema(); @@ -358,13 +358,13 @@ void ResultsClass::update(ContextType ctx, FunctionType, ObjectType this_obje for (auto i = results->size(); i > 0; i--) { auto realm_object = realm::Object(realm, schema, results->get(i - 1)); auto obj = RealmObjectClass::create_instance(ctx, realm_object); - RealmObjectClass::set_property(ctx, obj, property, arguments[1]); + RealmObjectClass::set_property(ctx, obj, property, args[1]); } } template void ResultsClass::index_of(ContextType ctx, ObjectType this_object, - Arguments args, ReturnValue &return_value) { + Arguments &args, ReturnValue &return_value) { auto fn = [&](auto&& row) { auto results = get_internal>(this_object); NativeAccessor accessor(ctx, *results); @@ -375,7 +375,7 @@ void ResultsClass::index_of(ContextType ctx, ObjectType this_object, template template -void ResultsClass::add_listener(ContextType ctx, U& collection, ObjectType this_object, Arguments args) { +void ResultsClass::add_listener(ContextType ctx, U& collection, ObjectType this_object, Arguments &args) { args.validate_maximum(1); auto callback = Value::validated_to_function(ctx, args[0]); @@ -395,14 +395,14 @@ void ResultsClass::add_listener(ContextType ctx, U& collection, ObjectType th } template -void ResultsClass::add_listener(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ResultsClass::add_listener(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto results = get_internal>(this_object); add_listener(ctx, *results, this_object, args); } template template -void ResultsClass::remove_listener(ContextType ctx, U& collection, ObjectType this_object, Arguments args) { +void ResultsClass::remove_listener(ContextType ctx, U& collection, ObjectType this_object, Arguments &args) { args.validate_maximum(1); auto callback = Value::validated_to_function(ctx, args[0]); @@ -416,13 +416,13 @@ void ResultsClass::remove_listener(ContextType ctx, U& collection, ObjectType } template -void ResultsClass::remove_listener(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ResultsClass::remove_listener(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { auto results = get_internal>(this_object); remove_listener(ctx, *results, this_object, args); } template -void ResultsClass::remove_all_listeners(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void ResultsClass::remove_all_listeners(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); auto results = get_internal>(this_object); diff --git a/src/js_sync.hpp b/src/js_sync.hpp index bdef3467..569ad312 100644 --- a/src/js_sync.hpp +++ b/src/js_sync.hpp @@ -89,9 +89,9 @@ public: {"isAdminToken", {wrap, nullptr}}, }; - static void create_user(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); - static void admin_user(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); - static void get_existing_user(ContextType, ObjectType, Arguments, ReturnValue&); + static void create_user(ContextType, ObjectType, Arguments &, ReturnValue &); + static void admin_user(ContextType, ObjectType, Arguments &, ReturnValue &); + static void get_existing_user(ContextType, ObjectType, Arguments &, ReturnValue&); MethodMap const static_methods = { {"createUser", wrap}, @@ -100,15 +100,15 @@ public: }; /*static void current_user(ContextType ctx, ObjectType object, ReturnValue &return_value);*/ - static void all_users(ContextType ctx, ObjectType object, ReturnValue &return_value); + static void all_users(ContextType ctx, ObjectType object, ReturnValue &); PropertyMap const static_properties = { /*{"current", {wrap, nullptr}},*/ {"all", {wrap, nullptr}}, }; - static void logout(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); - static void session_for_on_disk_path(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); + static void logout(ContextType, ObjectType, Arguments &, ReturnValue &); + static void session_for_on_disk_path(ContextType, ObjectType, Arguments &, ReturnValue &); MethodMap const methods = { {"_logout", wrap}, @@ -145,39 +145,39 @@ void UserClass::is_admin_token(ContextType ctx, ObjectType object, ReturnValu } template -void UserClass::create_user(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 3, 5); +void UserClass::create_user(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { + args.validate_between(3, 5); SyncUserIdentifier userIdentifier { - Value::validated_to_string(ctx, arguments[1], "identity"), - Value::validated_to_string(ctx, arguments[0], "authServerUrl") + Value::validated_to_string(ctx, args[1], "identity"), + Value::validated_to_string(ctx, args[0], "authServerUrl") }; SharedUser *user = new SharedUser(syncManagerShared().get_user( userIdentifier, - Value::validated_to_string(ctx, arguments[2], "refreshToken") + Value::validated_to_string(ctx, args[2], "refreshToken") )); - if (argc == 5) { - (*user)->set_is_admin(Value::validated_to_boolean(ctx, arguments[4], "isAdmin")); + if (args.count == 5) { + (*user)->set_is_admin(Value::validated_to_boolean(ctx, args[4], "isAdmin")); } return_value.set(create_object>(ctx, user)); } template -void UserClass::admin_user(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 2, 2); +void UserClass::admin_user(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { + args.validate_count(2); SharedUser *user = new SharedUser(syncManagerShared().get_admin_token_user( - Value::validated_to_string(ctx, arguments[0], "authServerUrl"), - Value::validated_to_string(ctx, arguments[1], "refreshToken") + Value::validated_to_string(ctx, args[0], "authServerUrl"), + Value::validated_to_string(ctx, args[1], "refreshToken") )); return_value.set(create_object>(ctx, user)); } template -void UserClass::get_existing_user(ContextType ctx, ObjectType, Arguments arguments, ReturnValue& return_value) { - arguments.validate_count(2); +void UserClass::get_existing_user(ContextType ctx, ObjectType, Arguments &args, ReturnValue &return_value) { + args.validate_count(2); if (auto user = syncManagerShared().get_existing_logged_in_user(SyncUserIdentifier{ - Value::validated_to_string(ctx, arguments[1], "identity"), - Value::validated_to_string(ctx, arguments[0], "authServerUrl")})) { + Value::validated_to_string(ctx, args[1], "identity"), + Value::validated_to_string(ctx, args[0], "authServerUrl")})) { return_value.set(create_object>(ctx, new SharedUser(std::move(user)))); } } @@ -194,7 +194,7 @@ void UserClass::all_users(ContextType ctx, ObjectType object, ReturnValue &re } template -void UserClass::logout(ContextType ctx, FunctionType, ObjectType this_object, size_t, const ValueType[], ReturnValue &) { +void UserClass::logout(ContextType, ObjectType this_object, Arguments &, ReturnValue &) { get_internal>(this_object)->get()->log_out(); } @@ -224,20 +224,18 @@ public: static void get_state(ContextType, ObjectType, ReturnValue &); static void get_connection_state(ContextType, ObjectType, ReturnValue &); - static void simulate_error(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); - static void refresh_access_token(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); - 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 add_state_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &); - static void remove_state_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &); - static void add_connection_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &); - static void remove_connection_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &); - static void is_connected(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &); - static void resume(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &); - static void pause(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&); + static void simulate_error(ContextType, ObjectType, Arguments &, ReturnValue &); + static void refresh_access_token(ContextType, ObjectType, Arguments &, ReturnValue &); + static void add_progress_notification(ContextType ctx, ObjectType this_object, Arguments &, ReturnValue &); + static void remove_progress_notification(ContextType ctx, ObjectType this_object, Arguments &, ReturnValue &); + static void add_state_notification(ContextType ctx, ObjectType this_object, Arguments &, ReturnValue &); + static void remove_state_notification(ContextType ctx, ObjectType this_object, Arguments &, ReturnValue &); + static void add_connection_notification(ContextType ctx, ObjectType this_object, Arguments &, ReturnValue &); + static void remove_connection_notification(ContextType ctx, ObjectType this_object, Arguments &, ReturnValue &); + static void is_connected(ContextType ctx, ObjectType this_object, Arguments &, ReturnValue &); + static void resume(ContextType ctx, ObjectType this_object, Arguments &, ReturnValue &); + static void pause(ContextType ctx, ObjectType this_object, Arguments &, ReturnValue &); + static void override_server(ContextType, ObjectType, Arguments &, ReturnValue &); PropertyMap const properties = { {"config", {wrap, nullptr}}, @@ -403,9 +401,10 @@ private: }; template -void UserClass::session_for_on_disk_path(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { +void UserClass::session_for_on_disk_path(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { + args.validate_count(1); auto user = *get_internal>(this_object); - if (auto session = user->session_for_on_disk_path(Value::validated_to_string(ctx, arguments[0]))) { + if (auto session = user->session_for_on_disk_path(Value::validated_to_string(ctx, args[0]))) { return_value.set(create_object>(ctx, new WeakSession(session))); } else { return_value.set_undefined(); @@ -492,38 +491,38 @@ void SessionClass::get_connection_state(ContextType ctx, ObjectType object, R } template -void SessionClass::simulate_error(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &) { - validate_argument_count(argc, 2); +void SessionClass::simulate_error(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &) { + args.validate_count(2); if (auto session = get_internal>(this_object)->lock()) { - std::error_code error_code(Value::validated_to_number(ctx, arguments[0]), realm::sync::protocol_error_category()); - std::string message = Value::validated_to_string(ctx, arguments[1]); + std::error_code error_code(Value::validated_to_number(ctx, args[0]), realm::sync::protocol_error_category()); + std::string message = Value::validated_to_string(ctx, args[1]); SyncSession::OnlyForTesting::handle_error(*session, SyncError(error_code, message, false)); } } template -void SessionClass::refresh_access_token(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &) { - validate_argument_count(argc, 3); +void SessionClass::refresh_access_token(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &) { + args.validate_count(3); if (auto session = get_internal>(this_object)->lock()) { - std::string sync_label = Value::validated_to_string(ctx, arguments[2], "syncLabel"); + std::string sync_label = Value::validated_to_string(ctx, args[2], "syncLabel"); session->set_multiplex_identifier(std::move(sync_label)); - std::string access_token = Value::validated_to_string(ctx, arguments[0], "accessToken"); - std::string realm_url = Value::validated_to_string(ctx, arguments[1], "realmUrl"); + std::string access_token = Value::validated_to_string(ctx, args[0], "accessToken"); + std::string realm_url = Value::validated_to_string(ctx, args[1], "realmUrl"); session->refresh_access_token(std::move(access_token), std::move(realm_url)); } } template -void SessionClass::add_progress_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 3); +void SessionClass::add_progress_notification(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { + args.validate_count(3); if (auto session = get_internal>(this_object)->lock()) { - std::string direction = Value::validated_to_string(ctx, arguments[0], "direction"); - std::string mode = Value::validated_to_string(ctx, arguments[1], "mode"); + std::string direction = Value::validated_to_string(ctx, args[0], "direction"); + std::string mode = Value::validated_to_string(ctx, args[1], "mode"); SyncSession::NotifierType notifierType; if (direction == "download") { notifierType = SyncSession::NotifierType::download; @@ -546,7 +545,7 @@ void SessionClass::add_progress_notification(ContextType ctx, FunctionType, O throw std::invalid_argument("Invalid argument 'mode'. Only 'reportIndefinitely' and 'forCurrentlyOutstandingWork' progress notification modes are supported"); } - auto callback_function = Value::validated_to_function(ctx, arguments[2], "callback"); + auto callback_function = Value::validated_to_function(ctx, args[2], "callback"); Protected protected_callback(ctx, callback_function); Protected protected_this(ctx, this_object); @@ -573,9 +572,9 @@ void SessionClass::add_progress_notification(ContextType ctx, FunctionType, O } template -void SessionClass::remove_progress_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 1); - auto callback_function = Value::validated_to_function(ctx, arguments[0], "callback"); +void SessionClass::remove_progress_notification(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { + args.validate_count(1); + auto callback_function = Value::validated_to_function(ctx, args[0], "callback"); auto syncSessionProp = Object::get_property(ctx, callback_function, "_syncSession"); if (Value::is_undefined(ctx, syncSessionProp) || Value::is_null(ctx, syncSessionProp)) { return; @@ -591,10 +590,10 @@ void SessionClass::remove_progress_notification(ContextType ctx, FunctionType } template -void SessionClass::add_connection_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 1); +void SessionClass::add_connection_notification(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue &return_value) { + args.validate_count(1); if (auto session = get_internal>(this_object)->lock()) { - auto callback_function = Value::validated_to_function(ctx, arguments[0], "callback"); + auto callback_function = Value::validated_to_function(ctx, args[0], "callback"); Protected protected_callback(ctx, callback_function); Protected protected_this(ctx, this_object); Protected protected_ctx(Context::get_global_context(ctx)); @@ -620,9 +619,9 @@ void SessionClass::add_connection_notification(ContextType ctx, FunctionType, } template -void SessionClass::remove_connection_notification(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 1); - auto callback_function = Value::validated_to_function(ctx, arguments[0], "callback"); +void SessionClass::remove_connection_notification(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue &return_value) { + args.validate_count(1); + auto callback_function = Value::validated_to_function(ctx, args[0], "callback"); auto syncSessionProp = Object::get_property(ctx, callback_function, "_syncSession"); if (Value::is_undefined(ctx, syncSessionProp) || Value::is_null(ctx, syncSessionProp)) { return; @@ -637,8 +636,8 @@ void SessionClass::remove_connection_notification(ContextType ctx, FunctionTy } template -void SessionClass::is_connected(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 0); +void SessionClass::is_connected(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue &return_value) { + args.validate_count(0); return_value.set(false); if (auto session = get_internal>(this_object)->lock()) { auto state = session->state(); @@ -651,8 +650,8 @@ void SessionClass::is_connected(ContextType ctx, FunctionType, ObjectType thi } template -void SessionClass::resume(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 0); +void SessionClass::resume(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue &return_value) { + args.validate_count(0); return_value.set(false); if (auto session = get_internal>(this_object)->lock()) { session->revive_if_needed(); @@ -660,8 +659,8 @@ void SessionClass::resume(ContextType ctx, FunctionType, ObjectType this_obje } template -void SessionClass::pause(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 0); +void SessionClass::pause(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue &return_value) { + args.validate_count(0); return_value.set(false); if (auto session = get_internal>(this_object)->lock()) { session->log_out(); @@ -669,7 +668,7 @@ void SessionClass::pause(ContextType ctx, FunctionType, ObjectType this_objec } template -void SessionClass::override_server(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue&) { +void SessionClass::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"); @@ -719,10 +718,10 @@ public: static void get_error(ContextType, ObjectType, ReturnValue &); static void get_name(ContextType, ObjectType, ReturnValue &); - static void unsubscribe(ContextType, ObjectType, Arguments, ReturnValue &); - static void add_listener(ContextType, ObjectType, Arguments, ReturnValue &); - static void remove_listener(ContextType, ObjectType, Arguments, ReturnValue &); - static void remove_all_listeners(ContextType, ObjectType, Arguments, ReturnValue &); + static void unsubscribe(ContextType, ObjectType, Arguments &, ReturnValue &); + static void add_listener(ContextType, ObjectType, Arguments &, ReturnValue &); + static void remove_listener(ContextType, ObjectType, Arguments &, ReturnValue &); + static void remove_all_listeners(ContextType, ObjectType, Arguments &, ReturnValue &); PropertyMap const properties = { {"state", {wrap, nullptr}}, @@ -778,7 +777,7 @@ void SubscriptionClass::get_name(ContextType ctx, ObjectType object, ReturnVa } template -void SubscriptionClass::unsubscribe(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void SubscriptionClass::unsubscribe(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); auto subscription = get_internal>(this_object); partial_sync::unsubscribe(*subscription); @@ -786,7 +785,7 @@ void SubscriptionClass::unsubscribe(ContextType ctx, ObjectType this_object, } template -void SubscriptionClass::add_listener(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void SubscriptionClass::add_listener(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); auto subscription = get_internal>(this_object); @@ -808,7 +807,7 @@ void SubscriptionClass::add_listener(ContextType ctx, ObjectType this_object, } template -void SubscriptionClass::remove_listener(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void SubscriptionClass::remove_listener(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(1); auto subscription = get_internal>(this_object); @@ -823,7 +822,7 @@ void SubscriptionClass::remove_listener(ContextType ctx, ObjectType this_obje } template -void SubscriptionClass::remove_all_listeners(ContextType ctx, ObjectType this_object, Arguments args, ReturnValue &return_value) { +void SubscriptionClass::remove_all_listeners(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { args.validate_maximum(0); auto subscription = get_internal>(this_object); subscription->m_notification_tokens.clear(); @@ -841,14 +840,15 @@ class SyncClass : public ClassDefinition { using Value = js::Value; using Function = js::Function; using ReturnValue = js::ReturnValue; + using Arguments = js::Arguments; public: std::string const name = "Sync"; static FunctionType create_constructor(ContextType); - static void set_sync_log_level(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); - static void initiate_client_reset(ContextType, FunctionType, ObjectType, size_t, const ValueType[], ReturnValue &); + static void set_sync_log_level(ContextType, ObjectType, Arguments &, ReturnValue &); + static void initiate_client_reset(ContextType, ObjectType, Arguments &, ReturnValue &); // private static std::function session_bind_callback(ContextType ctx, ObjectType sync_constructor); @@ -876,18 +876,18 @@ inline typename T::Function SyncClass::create_constructor(ContextType ctx) { } template -void SyncClass::initiate_client_reset(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue & return_value) { - validate_argument_count(argc, 1); - std::string path = Value::validated_to_string(ctx, arguments[0]); +void SyncClass::initiate_client_reset(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue & return_value) { + args.validate_count(1); + std::string path = Value::validated_to_string(ctx, args[0]); if (!SyncManager::shared().immediately_run_file_actions(std::string(path))) { throw std::runtime_error(util::format("Realm was not configured correctly. Client Reset could not be run for Realm at: %1", path)); } } template -void SyncClass::set_sync_log_level(ContextType ctx, FunctionType, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) { - validate_argument_count(argc, 1); - std::string log_level = Value::validated_to_string(ctx, arguments[0]); +void SyncClass::set_sync_log_level(ContextType ctx, ObjectType this_object, Arguments &args, ReturnValue &return_value) { + args.validate_count(1); + std::string log_level = Value::validated_to_string(ctx, args[0]); std::istringstream in(log_level); // Throws in.imbue(std::locale::classic()); // Throws in.unsetf(std::ios_base::skipws); diff --git a/src/js_util.hpp b/src/js_util.hpp index 59faf4aa..b41cecb6 100644 --- a/src/js_util.hpp +++ b/src/js_util.hpp @@ -85,7 +85,7 @@ static inline void validate_argument_count_at_least(size_t count, size_t expecte template void compute_aggregate_on_collection(typename T::ContextType ctx, typename T::ObjectType this_object, - typename T::Arguments args, typename T::ReturnValue &return_value) { + typename T::Arguments &args, typename T::ReturnValue &return_value) { auto list = get_internal(this_object); diff --git a/src/jsc/jsc_class.hpp b/src/jsc/jsc_class.hpp index 031e26dd..738f55eb 100644 --- a/src/jsc/jsc_class.hpp +++ b/src/jsc/jsc_class.hpp @@ -31,7 +31,6 @@ using ClassDefinition = js::ClassDefinition; using ConstructorType = js::ConstructorType; using ArgumentsMethodType = js::ArgumentsMethodType; -using MethodType = js::MethodType; using Arguments = js::Arguments; using PropertyType = js::PropertyType; using IndexPropertyType = js::IndexPropertyType; @@ -229,8 +228,9 @@ inline JSValueRef ObjectWrap::call(JSContextRef ctx, JSObjectRef func // Classes without a constructor should still be subclassable. if (reinterpret_cast(s_class.constructor)) { + jsc::Arguments args{ctx, argc, arguments}; try { - s_class.constructor(ctx, this_object, argc, arguments); + s_class.constructor(ctx, this_object, args); } catch (std::exception &e) { *exception = jsc::Exception::value(ctx, e); @@ -249,8 +249,9 @@ inline JSObjectRef ObjectWrap::construct(JSContextRef ctx, JSObjectRe } JSObjectRef this_object = create_instance(ctx); + jsc::Arguments args{ctx, argc, arguments}; try { - s_class.constructor(ctx, this_object, argc, arguments); + s_class.constructor(ctx, this_object, args); } catch (std::exception &e) { *exception = jsc::Exception::value(ctx, e); @@ -381,24 +382,12 @@ namespace js { template class ObjectWrap : public jsc::ObjectWrap {}; -template -JSValueRef wrap(JSContextRef ctx, JSObjectRef function, JSObjectRef this_object, size_t argc, const JSValueRef arguments[], JSValueRef* exception) { - jsc::ReturnValue return_value(ctx); - try { - F(ctx, function, this_object, argc, arguments, return_value); - return return_value; - } - catch (std::exception &e) { - *exception = jsc::Exception::value(ctx, e); - return nullptr; - } -} - template JSValueRef wrap(JSContextRef ctx, JSObjectRef, JSObjectRef this_object, size_t argc, const JSValueRef arguments[], JSValueRef* exception) { + jsc::Arguments args{ctx, argc, arguments}; jsc::ReturnValue return_value(ctx); try { - F(ctx, this_object, jsc::Arguments{ctx, argc, arguments}, return_value); + F(ctx, this_object, args, return_value); return return_value; } catch (std::exception &e) { diff --git a/src/node/node_class.hpp b/src/node/node_class.hpp index e4693b19..88ff595f 100644 --- a/src/node/node_class.hpp +++ b/src/node/node_class.hpp @@ -30,7 +30,6 @@ template using ClassDefinition = js::ClassDefinition; using ConstructorType = js::ConstructorType; -using MethodType = js::MethodType; using ArgumentsMethodType = js::ArgumentsMethodType; using Arguments = js::Arguments; using PropertyType = js::PropertyType; @@ -51,7 +50,7 @@ class ObjectWrap : public Nan::ObjectWrap { return Nan::New(js_template); } - static void construct(const v8::FunctionCallbackInfo&); + static void construct(const Nan::FunctionCallbackInfo&); static bool has_instance(v8::Isolate* isolate, const v8::Local &value) { return get_template()->HasInstance(value); @@ -77,26 +76,26 @@ class ObjectWrap : public Nan::ObjectWrap { static v8::Local create_template(); - static void setup_method(v8::Local, const std::string &, v8::FunctionCallback); - static void setup_static_method(v8::Local, const std::string &, v8::FunctionCallback); + static void setup_method(v8::Local, const std::string &, Nan::FunctionCallback); + static void setup_static_method(v8::Local, const std::string &, Nan::FunctionCallback); template static void setup_property(v8::Local, const std::string &, const PropertyType &); - static void get_indexes(const v8::PropertyCallbackInfo&); - static void set_property(v8::Local, v8::Local, const v8::PropertyCallbackInfo&); + static void get_indexes(const Nan::PropertyCallbackInfo&); + static void set_property(v8::Local, v8::Local, const Nan::PropertyCallbackInfo&); - static void set_readonly_property(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) { + static void set_readonly_property(v8::Local property, v8::Local value, const Nan::PropertyCallbackInfo& info) { std::string message = std::string("Cannot assign to read only property '") + std::string(String(property)) + "'"; Nan::ThrowError(message.c_str()); } - static void set_readonly_index(uint32_t index, v8::Local value, const v8::PropertyCallbackInfo& info) { + static void set_readonly_index(uint32_t index, v8::Local value, const Nan::PropertyCallbackInfo& info) { std::string message = std::string("Cannot assign to read only index ") + util::to_string(index); Nan::ThrowError(message.c_str()); } - static void get_nonexistent_property(v8::Local, const v8::PropertyCallbackInfo&) { + static void get_nonexistent_property(v8::Local, const Nan::PropertyCallbackInfo&) { // Do nothing. This function exists only to prevent a crash where it is used. } }; @@ -112,7 +111,7 @@ class ObjectWrap { }; // This helper function is needed outside the scope of the ObjectWrap class as well. -static inline std::vector> get_arguments(const v8::FunctionCallbackInfo &info) { +static inline std::vector> get_arguments(const Nan::FunctionCallbackInfo &info) { int count = info.Length(); std::vector> arguments; arguments.reserve(count); @@ -159,7 +158,7 @@ template inline v8::Local ObjectWrap::create_template() { Nan::EscapableHandleScope scope; - v8::Local tpl = v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), construct); + v8::Local tpl = Nan::New(construct); v8::Local instance_tpl = tpl->InstanceTemplate(); v8::Local name = Nan::New(s_class.name).ToLocalChecked(); @@ -184,21 +183,21 @@ inline v8::Local ObjectWrap::create_template() if (s_class.index_accessor.getter) { auto &index_accessor = s_class.index_accessor; - instance_tpl->SetIndexedPropertyHandler(index_accessor.getter, index_accessor.setter ? index_accessor.setter : set_readonly_index, 0, 0, get_indexes); + Nan::SetIndexedPropertyHandler(instance_tpl, index_accessor.getter, index_accessor.setter ? index_accessor.setter : set_readonly_index, 0, 0, get_indexes); } if (s_class.string_accessor.getter || s_class.index_accessor.getter || s_class.index_accessor.setter) { // Use our own wrapper for the setter since we want to throw for negative indices. auto &string_accessor = s_class.string_accessor; - instance_tpl->SetNamedPropertyHandler(string_accessor.getter ? string_accessor.getter : get_nonexistent_property, set_property, 0, 0, string_accessor.enumerator); + Nan::SetNamedPropertyHandler(instance_tpl, string_accessor.getter ? string_accessor.getter : get_nonexistent_property, set_property, 0, 0, string_accessor.enumerator); } return scope.Escape(tpl); } template -inline void ObjectWrap::setup_method(v8::Local tpl, const std::string &name, v8::FunctionCallback callback) { +inline void ObjectWrap::setup_method(v8::Local tpl, const std::string &name, Nan::FunctionCallback callback) { v8::Local signature = Nan::New(tpl); - v8::Local fn_tpl = v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), callback, v8::Local(), signature); + v8::Local fn_tpl = Nan::New(callback, v8::Local(), signature); v8::Local fn_name = Nan::New(name).ToLocalChecked(); // The reason we use this rather than Nan::SetPrototypeMethod is DontEnum. @@ -207,8 +206,8 @@ inline void ObjectWrap::setup_method(v8::Local } template -inline void ObjectWrap::setup_static_method(v8::Local tpl, const std::string &name, v8::FunctionCallback callback) { - v8::Local fn_tpl = v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), callback); +inline void ObjectWrap::setup_static_method(v8::Local tpl, const std::string &name, Nan::FunctionCallback callback) { + v8::Local fn_tpl = Nan::New(callback); v8::Local fn_name = Nan::New(name).ToLocalChecked(); tpl->Set(fn_name, fn_tpl, v8::PropertyAttribute::DontEnum); @@ -221,17 +220,18 @@ inline void ObjectWrap::setup_property(v8::Local target, v8::Local prop_name = Nan::New(name).ToLocalChecked(); v8::PropertyAttribute attributes = v8::PropertyAttribute(v8::DontEnum | v8::DontDelete); - target->SetAccessor(prop_name, property.getter, property.setter ? property.setter : set_readonly_property, v8::Local(), v8::DEFAULT, attributes); + Nan::SetAccessor(target, prop_name, property.getter, property.setter ? property.setter : set_readonly_property, v8::Local(), v8::DEFAULT, attributes); } template -inline void ObjectWrap::construct(const v8::FunctionCallbackInfo& info) { +inline void ObjectWrap::construct(const Nan::FunctionCallbackInfo& info) { if (!info.IsConstructCall()) { Nan::ThrowError("Constructor must be called with new"); } if (reinterpret_cast(s_class.constructor)) { auto isolate = info.GetIsolate(); auto arguments = get_arguments(info); + node::Arguments args{isolate, arguments.size(), arguments.data()}; v8::Local this_object = info.This(); info.GetReturnValue().Set(this_object); @@ -239,7 +239,7 @@ inline void ObjectWrap::construct(const v8::FunctionCallbackInfoWrap(this_object); try { - s_class.constructor(isolate, this_object, arguments.size(), arguments.data()); + s_class.constructor(isolate, this_object, args); } catch (std::exception &e) { Nan::ThrowError(node::Exception::value(isolate, e)); @@ -251,7 +251,7 @@ inline void ObjectWrap::construct(const v8::FunctionCallbackInfo -inline void ObjectWrap::get_indexes(const v8::PropertyCallbackInfo& info) { +inline void ObjectWrap::get_indexes(const Nan::PropertyCallbackInfo& info) { uint32_t length; try { length = Object::validated_get_length(info.GetIsolate(), info.This()); @@ -270,7 +270,7 @@ inline void ObjectWrap::get_indexes(const v8::PropertyCallbackInfo -inline void ObjectWrap::set_property(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) { +inline void ObjectWrap::set_property(v8::Local property, v8::Local value, const Nan::PropertyCallbackInfo& info) { if (s_class.index_accessor.getter || s_class.index_accessor.setter) { try { // Negative indices are passed into this string property interceptor, so check for them here. @@ -296,28 +296,15 @@ namespace js { template class ObjectWrap : public node::ObjectWrap {}; -template -void wrap(const v8::FunctionCallbackInfo& info) { - v8::Isolate* isolate = info.GetIsolate(); - node::ReturnValue return_value(info.GetReturnValue()); - auto arguments = node::get_arguments(info); - - try { - F(isolate, info.Callee(), info.This(), arguments.size(), arguments.data(), return_value); - } - catch (std::exception &e) { - Nan::ThrowError(node::Exception::value(isolate, e)); - } -} - template -void wrap(const v8::FunctionCallbackInfo& info) { +void wrap(const Nan::FunctionCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); - node::ReturnValue return_value(info.GetReturnValue()); auto arguments = node::get_arguments(info); + node::Arguments args{isolate, arguments.size(), arguments.data()}; + node::ReturnValue return_value(info.GetReturnValue()); try { - F(isolate, info.This(), node::Arguments{isolate, arguments.size(), arguments.data()}, return_value); + F(isolate, info.This(), args, return_value); } catch (std::exception &e) { Nan::ThrowError(node::Exception::value(isolate, e)); @@ -326,7 +313,7 @@ void wrap(const v8::FunctionCallbackInfo& info) { template -void wrap(v8::Local property, const v8::PropertyCallbackInfo& info) { +void wrap(v8::Local property, const Nan::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); node::ReturnValue return_value(info.GetReturnValue()); try { @@ -338,7 +325,7 @@ void wrap(v8::Local property, const v8::PropertyCallbackInfo -void wrap(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) { +void wrap(v8::Local property, v8::Local value, const Nan::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); try { F(isolate, info.This(), value); @@ -349,7 +336,7 @@ void wrap(v8::Local property, v8::Local value, const v8:: } template -void wrap(uint32_t index, const v8::PropertyCallbackInfo& info) { +void wrap(uint32_t index, const Nan::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); node::ReturnValue return_value(info.GetReturnValue()); try { @@ -365,7 +352,7 @@ void wrap(uint32_t index, const v8::PropertyCallbackInfo& info) { } template -void wrap(uint32_t index, v8::Local value, const v8::PropertyCallbackInfo& info) { +void wrap(uint32_t index, v8::Local value, const Nan::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); try { if (F(isolate, info.This(), index, value)) { @@ -379,7 +366,7 @@ void wrap(uint32_t index, v8::Local value, const v8::PropertyCallback } template -void wrap(v8::Local property, const v8::PropertyCallbackInfo& info) { +void wrap(v8::Local property, const Nan::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); node::ReturnValue return_value(info.GetReturnValue()); try { @@ -391,7 +378,7 @@ void wrap(v8::Local property, const v8::PropertyCallbackInfo -void wrap(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) { +void wrap(v8::Local property, v8::Local value, const Nan::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); try { if (F(isolate, info.This(), property, value)) { @@ -405,7 +392,7 @@ void wrap(v8::Local property, v8::Local value, const v8:: } template -void wrap(const v8::PropertyCallbackInfo& info) { +void wrap(const Nan::PropertyCallbackInfo& info) { auto names = F(info.GetIsolate(), info.This()); int count = (int)names.size(); v8::Local array = Nan::New(count); diff --git a/src/node/node_return_value.hpp b/src/node/node_return_value.hpp index dfb3a1d7..7ee768ac 100644 --- a/src/node/node_return_value.hpp +++ b/src/node/node_return_value.hpp @@ -25,10 +25,10 @@ namespace js { template<> class ReturnValue { - v8::ReturnValue m_value; + Nan::ReturnValue m_value; public: - ReturnValue(v8::ReturnValue value) : m_value(value) {} + ReturnValue(Nan::ReturnValue value) : m_value(value) {} void set(const v8::Local &value) { m_value.Set(value); diff --git a/src/node/node_types.hpp b/src/node/node_types.hpp index b041e861..09dfea53 100644 --- a/src/node/node_types.hpp +++ b/src/node/node_types.hpp @@ -43,15 +43,15 @@ struct Types { using String = v8::Local; using Function = v8::Local; - using ConstructorCallback = v8::FunctionCallback; - using FunctionCallback = v8::FunctionCallback; - using PropertyGetterCallback = v8::AccessorGetterCallback; - using PropertySetterCallback = v8::AccessorSetterCallback; - using IndexPropertyGetterCallback = v8::IndexedPropertyGetterCallback; - using IndexPropertySetterCallback = v8::IndexedPropertySetterCallback; - using StringPropertyGetterCallback = v8::NamedPropertyGetterCallback; - using StringPropertySetterCallback = v8::NamedPropertySetterCallback; - using StringPropertyEnumeratorCallback = v8::NamedPropertyEnumeratorCallback; + using ConstructorCallback = Nan::FunctionCallback; + using FunctionCallback = Nan::FunctionCallback; + using PropertyGetterCallback = Nan::GetterCallback; + using PropertySetterCallback = Nan::SetterCallback; + using IndexPropertyGetterCallback = Nan::IndexGetterCallback; + using IndexPropertySetterCallback = Nan::IndexSetterCallback; + using StringPropertyGetterCallback = Nan::PropertyGetterCallback; + using StringPropertySetterCallback = Nan::PropertySetterCallback; + using StringPropertyEnumeratorCallback = Nan::PropertyEnumeratorCallback; }; template diff --git a/src/rpc.cpp b/src/rpc.cpp index 3a1afdba..7c5038b7 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -365,10 +365,10 @@ RPCServer::~RPCServer() { JSGlobalContextRelease(m_context); } -void RPCServer::run_callback(JSContextRef ctx, JSObjectRef function, JSObjectRef this_object, size_t argc, const JSValueRef arguments[], jsc::ReturnValue &return_value) { +JSValueRef RPCServer::run_callback(JSContextRef ctx, JSObjectRef function, JSObjectRef this_object, size_t argc, const JSValueRef arguments[], JSValueRef* exception) { RPCServer* server = get_rpc_server(JSContextGetGlobalContext(ctx)); if (!server) { - return; + return JSValueMakeUndefined(ctx); } u_int64_t counter = server->m_callback_call_counter++; @@ -419,11 +419,15 @@ void RPCServer::run_callback(JSContextRef ctx, JSObjectRef function, JSObjectRef assert(callback_id == resultCallbackId.get()); if (!error.is_null()) { - throw jsc::Exception(ctx, error.get()); + JSStringRef message = JSStringCreateWithUTF8CString(error.get().c_str()); + JSValueRef arguments[] { JSValueMakeString(ctx, message) }; + JSStringRelease(message); + + *exception = JSObjectMakeError(ctx, 1, arguments, nullptr); } - return_value.set(server->deserialize_json_value(results["result"])); + return server->deserialize_json_value(results["result"]); } @@ -649,7 +653,7 @@ JSValueRef RPCServer::deserialize_json_value(const json dict) { RPCObjectID callback_id = value.get(); if (!m_callbacks.count(callback_id)) { - JSObjectRef callback = JSObjectMakeFunctionWithCallback(m_context, nullptr, js::wrap); + JSObjectRef callback = JSObjectMakeFunctionWithCallback(m_context, nullptr, run_callback); m_callbacks.emplace(callback_id, js::Protected(m_context, callback)); m_callback_ids.emplace(callback, callback_id); } diff --git a/src/rpc.hpp b/src/rpc.hpp index f753c4eb..490bef1e 100644 --- a/src/rpc.hpp +++ b/src/rpc.hpp @@ -83,7 +83,7 @@ class RPCServer { RPCWorker m_worker; u_int64_t m_callback_call_counter; - static void run_callback(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], jsc::ReturnValue &); + static JSValueRef run_callback(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef *exception); RPCObjectID store_object(JSObjectRef object);