Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/react_native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const text_encoding_1 = require("text-encoding");
require("react-native-url-polyfill/auto");
require("fast-text-encoding");
const cbor_js_1 = __importDefault(require("cbor-js"));
const buffer_1 = require("buffer");
const stringify_buffer_keys_1 = require("../core/components/stringify_buffer_keys");
Expand All @@ -19,9 +19,7 @@ const LegacyCryptoModule_1 = __importDefault(require("../crypto/modules/LegacyCr
const pubnub_common_1 = require("../core/pubnub-common");
const configuration_2 = require("./configuration");
const common_1 = __importDefault(require("../cbor/common"));
// Polyfill global environment
global.TextEncoder = global.TextEncoder || text_encoding_1.TextEncoder;
global.TextDecoder = global.TextDecoder || text_encoding_1.TextDecoder;
// Polyfill global Buffer for React Native environment
global.Buffer = global.Buffer || buffer_1.Buffer;
/**
* PubNub client for React Native platform.
Expand Down
29 changes: 18 additions & 11 deletions package-lock.json

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

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@
"buffer": "^6.0.3",
"cbor-js": "^0.1.0",
"cbor-sync": "^1.0.4",
"fast-text-encoding": "^1.0.6",
"fflate": "^0.8.2",
"form-data": "^4.0.4",
"lil-uuid": "^0.1.1",
"node-fetch": "^2.7.0",
"proxy-agent": "^6.3.0",
"react-native-url-polyfill": "^2.0.0",
"text-encoding": "^0.7.0"
"react-native-url-polyfill": "^2.0.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
Expand All @@ -79,6 +79,7 @@
"@types/chai": "^4.3.14",
"@types/chai-as-promised": "^7.1.8",
"@types/expect": "^24.3.0",
"@types/fast-text-encoding": "^1.0.3",
"@types/lil-uuid": "^0.1.3",
"@types/mocha": "^9.1.0",
"@types/nock": "^9.3.1",
Expand Down Expand Up @@ -118,8 +119,8 @@
"sinon": "^7.5.0",
"sinon-chai": "^3.3.0",
"source-map-support": "^0.5.21",
"ts-mocha": "^10.0.0",
"ts-loader": "^9.5.2",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.2",
"tsx": "^4.7.1",
"typescript": "^5.4.5",
Expand Down
6 changes: 2 additions & 4 deletions src/react_native/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TextEncoder, TextDecoder } from 'text-encoding';
import 'react-native-url-polyfill/auto';
import 'fast-text-encoding';
import CborReader from 'cbor-js';
import { Buffer } from 'buffer';

Expand Down Expand Up @@ -29,9 +29,7 @@ export type {
} from '../core/components/retry-policy';
export type { PubNubConfiguration };

// Polyfill global environment
global.TextEncoder = global.TextEncoder || TextEncoder;
global.TextDecoder = global.TextDecoder || TextDecoder;
// Polyfill global Buffer for React Native environment
global.Buffer = global.Buffer || Buffer;

/**
Expand Down