@getpara/react-native-wallet 2.0.0-alpha.70 → 2.0.0-alpha.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/shim.js CHANGED
@@ -9,7 +9,37 @@ import { Buffer } from '@craftzdog/react-native-buffer';
9
9
  import process from 'process';
10
10
  import 'react-native-url-polyfill/auto';
11
11
  import { TextEncoder, TextDecoder } from 'text-encoding';
12
- import structuredClone from '@ungap/structured-clone';
12
+ let cachedStructuredCloneImpl;
13
+ const resolveStructuredClone = () => {
14
+ if (typeof cachedStructuredCloneImpl !== 'undefined') {
15
+ return cachedStructuredCloneImpl;
16
+ }
17
+ if (typeof globalThis.structuredClone === 'function') {
18
+ cachedStructuredCloneImpl = globalThis.structuredClone.bind(globalThis);
19
+ return cachedStructuredCloneImpl;
20
+ }
21
+ const isHermes = typeof globalThis.HermesInternal === 'object' && globalThis.HermesInternal !== null;
22
+ if (isHermes) {
23
+ // Hermes crashes when @ungap/structured-clone rewires Reflect helpers.
24
+ cachedStructuredCloneImpl = null;
25
+ return cachedStructuredCloneImpl;
26
+ }
27
+ try {
28
+ const maybePolyfill = require('@ungap/structured-clone');
29
+ const polyfill = (maybePolyfill && maybePolyfill.default) || maybePolyfill;
30
+ if (typeof polyfill === 'function') {
31
+ cachedStructuredCloneImpl = polyfill;
32
+ return cachedStructuredCloneImpl;
33
+ }
34
+ }
35
+ catch (err) {
36
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
37
+ console.warn('[Para React Native shim] Failed to load structuredClone polyfill', err);
38
+ }
39
+ }
40
+ cachedStructuredCloneImpl = null;
41
+ return cachedStructuredCloneImpl;
42
+ };
13
43
  const setupProcessPolyfill = () => {
14
44
  if (typeof globalThis.process === 'undefined') {
15
45
  globalThis.process = process;
@@ -239,9 +269,37 @@ const setupTextEncodingPolyfills = () => {
239
269
  globalThis.TextDecoder = TextDecoder;
240
270
  };
241
271
  const setupStructuredClonePolyfill = () => {
242
- if (typeof globalThis.structuredClone === 'undefined') {
243
- globalThis.structuredClone = structuredClone;
272
+ if (typeof globalThis.structuredClone === 'function') {
273
+ return;
244
274
  }
275
+ const structuredCloneImpl = resolveStructuredClone();
276
+ const safeStructuredClone = (value, options) => {
277
+ if (typeof structuredCloneImpl === 'function') {
278
+ try {
279
+ return structuredCloneImpl(value, options);
280
+ }
281
+ catch (err) {
282
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
283
+ console.warn('[Para React Native shim] structuredClone polyfill failed, falling back to JSON clone', err);
284
+ }
285
+ }
286
+ }
287
+ try {
288
+ return JSON.parse(JSON.stringify(value));
289
+ }
290
+ catch (_err) {
291
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
292
+ console.warn('[Para React Native shim] JSON clone failed, returning original value', _err);
293
+ }
294
+ return value;
295
+ }
296
+ };
297
+ Object.defineProperty(globalThis, 'structuredClone', {
298
+ value: safeStructuredClone,
299
+ configurable: true,
300
+ enumerable: false,
301
+ writable: true,
302
+ });
245
303
  };
246
304
  setupProcessPolyfill();
247
305
  setupBufferPolyfill();
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@getpara/react-native-wallet",
3
3
  "description": "Para Wallet for React Native",
4
- "version": "2.0.0-alpha.70",
4
+ "version": "2.0.0-alpha.71",
5
5
  "author": "Para Team <hello@getpara.com> (https://getpara.com)",
6
6
  "dependencies": {
7
- "@getpara/core-sdk": "2.0.0-alpha.70",
8
- "@getpara/user-management-client": "2.0.0-alpha.70",
9
- "@getpara/web-sdk": "2.0.0-alpha.70",
7
+ "@getpara/core-sdk": "2.0.0-alpha.71",
8
+ "@getpara/user-management-client": "2.0.0-alpha.71",
9
+ "@getpara/web-sdk": "2.0.0-alpha.71",
10
10
  "@peculiar/webcrypto": "^1.5.0",
11
11
  "@ungap/structured-clone": "1.3.0",
12
12
  "node-forge": "1.3.1",
@@ -93,5 +93,5 @@
93
93
  ]
94
94
  }
95
95
  },
96
- "gitHead": "99d44cff3c68c07dc1cd8c2709b6ca4cd57dca61"
96
+ "gitHead": "30e5bad6a141f1b56959432f11aaf1536b84dece"
97
97
  }
@@ -2,6 +2,7 @@ require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
  folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+ new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
5
6
 
6
7
  Pod::Spec.new do |s|
7
8
  s.name = "para-react-native-wallet"
@@ -19,8 +20,9 @@ Pod::Spec.new do |s|
19
20
 
20
21
  s.dependency "React-Core"
21
22
 
22
- # Don't install the dependencies when we run `pod install` in the old architecture.
23
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
23
+ if respond_to?(:install_modules_dependencies, true)
24
+ install_modules_dependencies(s)
25
+ elsif new_arch_enabled
24
26
  s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
25
27
  s.pod_target_xcconfig = {
26
28
  "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
@@ -33,4 +35,4 @@ Pod::Spec.new do |s|
33
35
  s.dependency "RCTTypeSafety"
34
36
  s.dependency "ReactCommon/turbomodule/core"
35
37
  end
36
- end
38
+ end
package/src/shim.js CHANGED
@@ -9,7 +9,42 @@ import { Buffer } from '@craftzdog/react-native-buffer';
9
9
  import process from 'process';
10
10
  import 'react-native-url-polyfill/auto';
11
11
  import { TextEncoder, TextDecoder } from 'text-encoding';
12
- import structuredClone from '@ungap/structured-clone';
12
+
13
+ let cachedStructuredCloneImpl;
14
+
15
+ const resolveStructuredClone = () => {
16
+ if (typeof cachedStructuredCloneImpl !== 'undefined') {
17
+ return cachedStructuredCloneImpl;
18
+ }
19
+
20
+ if (typeof globalThis.structuredClone === 'function') {
21
+ cachedStructuredCloneImpl = globalThis.structuredClone.bind(globalThis);
22
+ return cachedStructuredCloneImpl;
23
+ }
24
+
25
+ const isHermes = typeof globalThis.HermesInternal === 'object' && globalThis.HermesInternal !== null;
26
+ if (isHermes) {
27
+ // Hermes crashes when @ungap/structured-clone rewires Reflect helpers.
28
+ cachedStructuredCloneImpl = null;
29
+ return cachedStructuredCloneImpl;
30
+ }
31
+
32
+ try {
33
+ const maybePolyfill = require('@ungap/structured-clone');
34
+ const polyfill = (maybePolyfill && maybePolyfill.default) || maybePolyfill;
35
+ if (typeof polyfill === 'function') {
36
+ cachedStructuredCloneImpl = polyfill;
37
+ return cachedStructuredCloneImpl;
38
+ }
39
+ } catch (err) {
40
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
41
+ console.warn('[Para React Native shim] Failed to load structuredClone polyfill', err);
42
+ }
43
+ }
44
+
45
+ cachedStructuredCloneImpl = null;
46
+ return cachedStructuredCloneImpl;
47
+ };
13
48
 
14
49
  const setupProcessPolyfill = () => {
15
50
  if (typeof globalThis.process === 'undefined') {
@@ -272,9 +307,37 @@ const setupTextEncodingPolyfills = () => {
272
307
  };
273
308
 
274
309
  const setupStructuredClonePolyfill = () => {
275
- if (typeof globalThis.structuredClone === 'undefined') {
276
- globalThis.structuredClone = structuredClone;
310
+ if (typeof globalThis.structuredClone === 'function') {
311
+ return;
277
312
  }
313
+
314
+ const structuredCloneImpl = resolveStructuredClone();
315
+ const safeStructuredClone = (value, options) => {
316
+ if (typeof structuredCloneImpl === 'function') {
317
+ try {
318
+ return structuredCloneImpl(value, options);
319
+ } catch (err) {
320
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
321
+ console.warn('[Para React Native shim] structuredClone polyfill failed, falling back to JSON clone', err);
322
+ }
323
+ }
324
+ }
325
+ try {
326
+ return JSON.parse(JSON.stringify(value));
327
+ } catch (_err) {
328
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
329
+ console.warn('[Para React Native shim] JSON clone failed, returning original value', _err);
330
+ }
331
+ return value;
332
+ }
333
+ };
334
+
335
+ Object.defineProperty(globalThis, 'structuredClone', {
336
+ value: safeStructuredClone,
337
+ configurable: true,
338
+ enumerable: false,
339
+ writable: true,
340
+ });
278
341
  };
279
342
 
280
343
  setupProcessPolyfill();