Skip to content

Commit

Permalink
Implement polyfill for globalThis
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Duncalf committed Jun 16, 2022
1 parent cb9b955 commit 7d4931d
Show file tree
Hide file tree
Showing 17 changed files with 2,041 additions and 4,689 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const Person = {
* Logging out too quickly can cause an error if the timeout behavior is set to `openLocalRealm` ([#4453](https://github.com/realm/realm-js/issues/4453), since v10.0.0)
* Released `realm-network-transport` to adopt the changes published to fix `globalThis` undefined issue for older devices. ([#4350](https://github.com/realm/realm-js/issues/4350), since v10.0.0)
* Fixed flexible sync crash when updating subscriptions after token expiry. ([#4421](https://github.com/realm/realm-js/issues/4421), since v10.12.0)
* Fixed remaining uses of `globalThis` undefined issue, causing Realm to not load on iOS 11/12. ([#4350](https://github.com/realm/realm-js/issues/4350))

### Compatibility
* MongoDB Realm Cloud.
Expand All @@ -201,7 +202,7 @@ const Person = {

### Fixed
* Fixed issue that could cause mangling of binary data on a roundtrip to/from the database ([#4278](https://github.com/realm/realm-js/issues/4278), since v10.1.4).
* Fixed `globalThis` undefined issue for older devices. ([#4350](https://github.com/realm/realm-js/4350))
* Fixed `globalThis` undefined issue for older devices. ([#4350](https://github.com/realm/realm-js/issues/4350))
* Fixed a fatal sync error `Automatic recovery failed` during DiscardLocal client reset if the reset notifier callbacks were not set to something. ([realm/realm-core#5223](https://github.com/realm/realm-core/issues/5223), since v10.10.0)
* Changed parsed queries using the `between` operator to be inclusive of the limits, a closed interval instead of an open interval. This is to conform to the published documentation and for parity with NSPredicate's definition. ([realm/realm-core#5262](https://github.com/realm/realm-core/issues/5262), since v10.7.0)
* If a list of objects contains links to objects not included in the synchronized partition, the indices contained in the listener callback could be wrong. ([realm/realm-core#5164](https://github.com/realm/realm-core/issues/5164), since v10.0.0)
Expand Down
3 changes: 2 additions & 1 deletion lib/mongo-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

const { EJSON } = require("bson");
const { DefaultNetworkTransport } = require("realm-network-transport");
const { safeGlobalThis } = require("@realm.io/common");

const { cleanArguments, getEnvironment } = require("./utils");

Expand All @@ -29,7 +30,7 @@ function ensureWatchDependencies() {
if (environment === "reactnative") {
const EXPECTED_GLOBALS = ["fetch", "ReadableStream", "TextDecoder"];
for (const name of EXPECTED_GLOBALS) {
if (!(name in globalThis)) {
if (!(name in safeGlobalThis)) {
throw new Error(
`Realm expects the ${name} global: Please use https://www.npmjs.com/package/react-native-polyfill-globals`,
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"postinstall": "node scripts/submit-analytics.js"
},
"dependencies": {
"@realm.io/common": "^0.1.1",
"@realm.io/common": "^0.1.3",
"bindings": "^1.5.0",
"bson": "4.4.1",
"clang-format": "^1.6.0",
Expand Down
Loading

0 comments on commit 7d4931d

Please sign in to comment.