@json-eval-rs/react-native 0.0.63 → 0.0.65

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/src/index.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { NativeModules, Platform } from 'react-native';
3
+ import { JSONParse, JSONStringify } from 'json-with-bigint';
3
4
 
4
5
  const LINKING_ERROR =
5
6
  `The package '@json-eval-rs/react-native' doesn't seem to be linked. Make sure: \n\n` +
@@ -337,12 +338,12 @@ export class JSONEval {
337
338
  const contextStr = context
338
339
  ? typeof context === 'string'
339
340
  ? context
340
- : JSON.stringify(context)
341
+ : JSONStringify(context)
341
342
  : null;
342
343
  const dataStr = data
343
344
  ? typeof data === 'string'
344
345
  ? data
345
- : JSON.stringify(data)
346
+ : JSONStringify(data)
346
347
  : null;
347
348
 
348
349
  const handle = JsonEvalRs.createFromCache(cacheKey, contextStr, dataStr);
@@ -362,16 +363,16 @@ export class JSONEval {
362
363
  context?: string | object | null
363
364
  ): Promise<any> {
364
365
  const logic =
365
- typeof logicStr === 'string' ? logicStr : JSON.stringify(logicStr);
366
+ typeof logicStr === 'string' ? logicStr : JSONStringify(logicStr);
366
367
  const dataStr = data
367
368
  ? typeof data === 'string'
368
369
  ? data
369
- : JSON.stringify(data)
370
+ : JSONStringify(data)
370
371
  : null;
371
372
  const contextStr = context
372
373
  ? typeof context === 'string'
373
374
  ? context
374
- : JSON.stringify(context)
375
+ : JSONStringify(context)
375
376
  : null;
376
377
 
377
378
  const resultStr = await JsonEvalRs.evaluateLogic(
@@ -379,7 +380,7 @@ export class JSONEval {
379
380
  dataStr,
380
381
  contextStr
381
382
  );
382
- return JSON.parse(resultStr);
383
+ return JSONParse(resultStr);
383
384
  }
384
385
 
385
386
  /**
@@ -398,16 +399,16 @@ export class JSONEval {
398
399
 
399
400
  try {
400
401
  const schemaStr =
401
- typeof schema === 'string' ? schema : JSON.stringify(schema);
402
+ typeof schema === 'string' ? schema : JSONStringify(schema);
402
403
  const contextStr = context
403
404
  ? typeof context === 'string'
404
405
  ? context
405
- : JSON.stringify(context)
406
+ : JSONStringify(context)
406
407
  : null;
407
408
  const dataStr = data
408
409
  ? typeof data === 'string'
409
410
  ? data
410
- : JSON.stringify(data)
411
+ : JSONStringify(data)
411
412
  : null;
412
413
 
413
414
  this.handle = JsonEvalRs.create(schemaStr, contextStr, dataStr);
@@ -427,10 +428,10 @@ export class JSONEval {
427
428
  /**
428
429
  * Convert value to JSON string
429
430
  * Performance note: If you have a pre-serialized JSON string, pass it directly
430
- * instead of an object to avoid the JSON.stringify overhead
431
+ * instead of an object to avoid the JSONStringify overhead
431
432
  */
432
433
  private toJsonString(value: string | object): string {
433
- return typeof value === 'string' ? value : JSON.stringify(value);
434
+ return typeof value === 'string' ? value : JSONStringify(value);
434
435
  }
435
436
 
436
437
  /**
@@ -457,7 +458,7 @@ export class JSONEval {
457
458
  const contextStr = options.context
458
459
  ? this.toJsonString(options.context)
459
460
  : null;
460
- const pathsJson = options.paths ? JSON.stringify(options.paths) : null;
461
+ const pathsJson = options.paths ? typeof options.paths === 'string' ? options.paths : JSONStringify(options.paths) : null;
461
462
 
462
463
  const resultStr = await JsonEvalRs.evaluate(
463
464
  this.handle,
@@ -465,7 +466,7 @@ export class JSONEval {
465
466
  contextStr,
466
467
  pathsJson
467
468
  );
468
- return JSON.parse(resultStr);
469
+ return JSONParse(resultStr);
469
470
  } catch (error) {
470
471
  const errorMessage =
471
472
  error instanceof Error ? error.message : String(error);
@@ -493,7 +494,7 @@ export class JSONEval {
493
494
  dataStr,
494
495
  contextStr
495
496
  );
496
- return JSON.parse(resultStr);
497
+ return JSONParse(resultStr);
497
498
  } catch (error) {
498
499
  const errorMessage =
499
500
  error instanceof Error ? error.message : String(error);
@@ -514,7 +515,7 @@ export class JSONEval {
514
515
 
515
516
  try {
516
517
  const { changedPaths, data, context, reEvaluate = true } = options;
517
- const changedPathsJson = JSON.stringify(changedPaths);
518
+ const changedPathsJson = typeof changedPaths === 'string' ? changedPaths : JSONStringify(changedPaths);
518
519
  const dataStr = data ? this.toJsonString(data) : null;
519
520
  const contextStr = context ? this.toJsonString(context) : null;
520
521
 
@@ -525,7 +526,7 @@ export class JSONEval {
525
526
  contextStr,
526
527
  reEvaluate
527
528
  );
528
- return JSON.parse(resultStr);
529
+ return JSONParse(resultStr);
529
530
  } catch (error) {
530
531
  const errorMessage =
531
532
  error instanceof Error ? error.message : String(error);
@@ -545,7 +546,7 @@ export class JSONEval {
545
546
  this.handle,
546
547
  skipLayout
547
548
  );
548
- return JSON.parse(resultStr);
549
+ return JSONParse(resultStr);
549
550
  }
550
551
 
551
552
  /**
@@ -556,7 +557,7 @@ export class JSONEval {
556
557
  async getSchemaValue(): Promise<Record<string, any>> {
557
558
  this.throwIfDisposed();
558
559
  const resultStr = await JsonEvalRs.getSchemaValue(this.handle);
559
- return JSON.parse(resultStr);
560
+ return JSONParse(resultStr);
560
561
  }
561
562
 
562
563
  /**
@@ -568,7 +569,7 @@ export class JSONEval {
568
569
  async getSchemaValueArray(): Promise<SchemaValueItem[]> {
569
570
  this.throwIfDisposed();
570
571
  const resultStr = await JsonEvalRs.getSchemaValueArray(this.handle);
571
- return JSON.parse(resultStr);
572
+ return JSONParse(resultStr);
572
573
  }
573
574
 
574
575
  /**
@@ -580,7 +581,7 @@ export class JSONEval {
580
581
  async getSchemaValueObject(): Promise<Record<string, any>> {
581
582
  this.throwIfDisposed();
582
583
  const resultStr = await JsonEvalRs.getSchemaValueObject(this.handle);
583
- return JSON.parse(resultStr);
584
+ return JSONParse(resultStr);
584
585
  }
585
586
 
586
587
  /**
@@ -597,7 +598,7 @@ export class JSONEval {
597
598
  this.handle,
598
599
  skipLayout
599
600
  );
600
- return JSON.parse(resultStr);
601
+ return JSONParse(resultStr);
601
602
  }
602
603
 
603
604
  /**
@@ -617,7 +618,7 @@ export class JSONEval {
617
618
  path,
618
619
  skipLayout
619
620
  );
620
- return resultStr ? JSON.parse(resultStr) : null;
621
+ return resultStr ? JSONParse(resultStr) : null;
621
622
  }
622
623
 
623
624
  /**
@@ -635,14 +636,14 @@ export class JSONEval {
635
636
  format: ReturnFormat = ReturnFormat.Nested
636
637
  ): Promise<any> {
637
638
  this.throwIfDisposed();
638
- const pathsJson = JSON.stringify(paths);
639
+ const pathsJson = typeof paths === 'string' ? paths : JSONStringify(paths);
639
640
  const resultStr = await JsonEvalRs.getEvaluatedSchemaByPaths(
640
641
  this.handle,
641
642
  pathsJson,
642
643
  skipLayout,
643
644
  format
644
645
  );
645
- return JSON.parse(resultStr);
646
+ return JSONParse(resultStr);
646
647
  }
647
648
 
648
649
  /**
@@ -654,7 +655,7 @@ export class JSONEval {
654
655
  async getSchemaByPath(path: string): Promise<any | null> {
655
656
  this.throwIfDisposed();
656
657
  const resultStr = await JsonEvalRs.getSchemaByPath(this.handle, path);
657
- return resultStr ? JSON.parse(resultStr) : null;
658
+ return resultStr ? JSONParse(resultStr) : null;
658
659
  }
659
660
 
660
661
  /**
@@ -670,13 +671,13 @@ export class JSONEval {
670
671
  format: ReturnFormat = ReturnFormat.Nested
671
672
  ): Promise<any> {
672
673
  this.throwIfDisposed();
673
- const pathsJson = JSON.stringify(paths);
674
+ const pathsJson = typeof paths === 'string' ? paths : JSONStringify(paths);
674
675
  const resultStr = await JsonEvalRs.getSchemaByPaths(
675
676
  this.handle,
676
677
  pathsJson,
677
678
  format
678
679
  );
679
- return JSON.parse(resultStr);
680
+ return JSONParse(resultStr);
680
681
  }
681
682
 
682
683
  /**
@@ -690,16 +691,16 @@ export class JSONEval {
690
691
  try {
691
692
  const { schema, context, data } = options;
692
693
  const schemaStr =
693
- typeof schema === 'string' ? schema : JSON.stringify(schema);
694
+ typeof schema === 'string' ? schema : JSONStringify(schema);
694
695
  const contextStr = context
695
696
  ? typeof context === 'string'
696
697
  ? context
697
- : JSON.stringify(context)
698
+ : JSONStringify(context)
698
699
  : null;
699
700
  const dataStr = data
700
701
  ? typeof data === 'string'
701
702
  ? data
702
- : JSON.stringify(data)
703
+ : JSONStringify(data)
703
704
  : null;
704
705
 
705
706
  await JsonEvalRs.reloadSchema(
@@ -739,12 +740,12 @@ export class JSONEval {
739
740
  const contextStr = context
740
741
  ? typeof context === 'string'
741
742
  ? context
742
- : JSON.stringify(context)
743
+ : JSONStringify(context)
743
744
  : null;
744
745
  const dataStr = data
745
746
  ? typeof data === 'string'
746
747
  ? data
747
- : JSON.stringify(data)
748
+ : JSONStringify(data)
748
749
  : null;
749
750
 
750
751
  await JsonEvalRs.reloadSchemaMsgpack(
@@ -780,12 +781,12 @@ export class JSONEval {
780
781
  const contextStr = context
781
782
  ? typeof context === 'string'
782
783
  ? context
783
- : JSON.stringify(context)
784
+ : JSONStringify(context)
784
785
  : null;
785
786
  const dataStr = data
786
787
  ? typeof data === 'string'
787
788
  ? data
788
- : JSON.stringify(data)
789
+ : JSONStringify(data)
789
790
  : null;
790
791
 
791
792
  await JsonEvalRs.reloadSchemaFromCache(
@@ -809,7 +810,7 @@ export class JSONEval {
809
810
  async cacheStats(): Promise<CacheStats> {
810
811
  this.throwIfDisposed();
811
812
  const resultStr = await JsonEvalRs.cacheStats(this.handle);
812
- return JSON.parse(resultStr);
813
+ return JSONParse(resultStr);
813
814
  }
814
815
 
815
816
  /**
@@ -925,7 +926,7 @@ export class JSONEval {
925
926
  dataStr,
926
927
  contextStr
927
928
  );
928
- return JSON.parse(resultStr);
929
+ return JSONParse(resultStr);
929
930
  }
930
931
 
931
932
  /**
@@ -965,7 +966,7 @@ export class JSONEval {
965
966
  dataStr,
966
967
  contextStr
967
968
  );
968
- return JSON.parse(resultStr);
969
+ return JSONParse(resultStr);
969
970
  }
970
971
 
971
972
  /**
@@ -991,7 +992,7 @@ export class JSONEval {
991
992
  contextStr,
992
993
  paths
993
994
  );
994
- return JSON.parse(resultStr);
995
+ return JSONParse(resultStr);
995
996
  }
996
997
 
997
998
  // ============================================================================
@@ -1043,7 +1044,7 @@ export class JSONEval {
1043
1044
  dataStr,
1044
1045
  contextStr
1045
1046
  );
1046
- return JSON.parse(resultStr);
1047
+ return JSONParse(resultStr);
1047
1048
  }
1048
1049
 
1049
1050
  /**
@@ -1073,7 +1074,7 @@ export class JSONEval {
1073
1074
  contextStr,
1074
1075
  options.reEvaluate ?? true
1075
1076
  );
1076
- return JSON.parse(resultStr);
1077
+ return JSONParse(resultStr);
1077
1078
  }
1078
1079
 
1079
1080
  /**
@@ -1110,7 +1111,7 @@ export class JSONEval {
1110
1111
  options.subformPath,
1111
1112
  options.resolveLayout || false
1112
1113
  );
1113
- return JSON.parse(resultStr);
1114
+ return JSONParse(resultStr);
1114
1115
  }
1115
1116
 
1116
1117
  /**
@@ -1128,7 +1129,7 @@ export class JSONEval {
1128
1129
  this.handle,
1129
1130
  options.subformPath
1130
1131
  );
1131
- return JSON.parse(resultStr);
1132
+ return JSONParse(resultStr);
1132
1133
  }
1133
1134
 
1134
1135
  /**
@@ -1147,7 +1148,7 @@ export class JSONEval {
1147
1148
  this.handle,
1148
1149
  options.subformPath
1149
1150
  );
1150
- return JSON.parse(resultStr);
1151
+ return JSONParse(resultStr);
1151
1152
  }
1152
1153
 
1153
1154
  /**
@@ -1166,7 +1167,7 @@ export class JSONEval {
1166
1167
  this.handle,
1167
1168
  options.subformPath
1168
1169
  );
1169
- return JSON.parse(resultStr);
1170
+ return JSONParse(resultStr);
1170
1171
  }
1171
1172
 
1172
1173
  /**
@@ -1185,7 +1186,7 @@ export class JSONEval {
1185
1186
  options.subformPath,
1186
1187
  options.resolveLayout || false
1187
1188
  );
1188
- return JSON.parse(resultStr);
1189
+ return JSONParse(resultStr);
1189
1190
  }
1190
1191
 
1191
1192
  /**
@@ -1205,7 +1206,7 @@ export class JSONEval {
1205
1206
  options.schemaPath,
1206
1207
  options.skipLayout || false
1207
1208
  );
1208
- return resultStr ? JSON.parse(resultStr) : null;
1209
+ return resultStr ? JSONParse(resultStr) : null;
1209
1210
  }
1210
1211
 
1211
1212
  /**
@@ -1220,7 +1221,7 @@ export class JSONEval {
1220
1221
  ): Promise<any> {
1221
1222
  this.throwIfDisposed();
1222
1223
 
1223
- const pathsJson = JSON.stringify(options.schemaPaths);
1224
+ const pathsJson = typeof options.schemaPaths === 'string' ? options.schemaPaths : JSONStringify(options.schemaPaths);
1224
1225
  const resultStr = await JsonEvalRs.getEvaluatedSchemaByPathsSubform(
1225
1226
  this.handle,
1226
1227
  options.subformPath,
@@ -1228,7 +1229,7 @@ export class JSONEval {
1228
1229
  options.skipLayout || false,
1229
1230
  options.format !== undefined ? options.format : ReturnFormat.Nested
1230
1231
  );
1231
- return JSON.parse(resultStr);
1232
+ return JSONParse(resultStr);
1232
1233
  }
1233
1234
 
1234
1235
  /**
@@ -1240,7 +1241,7 @@ export class JSONEval {
1240
1241
  this.throwIfDisposed();
1241
1242
 
1242
1243
  const resultStr = await JsonEvalRs.getSubformPaths(this.handle);
1243
- return JSON.parse(resultStr);
1244
+ return JSONParse(resultStr);
1244
1245
  }
1245
1246
 
1246
1247
  /**
@@ -1259,7 +1260,7 @@ export class JSONEval {
1259
1260
  options.subformPath,
1260
1261
  options.schemaPath
1261
1262
  );
1262
- return resultStr ? JSON.parse(resultStr) : null;
1263
+ return resultStr ? JSONParse(resultStr) : null;
1263
1264
  }
1264
1265
 
1265
1266
  /**
@@ -1274,14 +1275,14 @@ export class JSONEval {
1274
1275
  ): Promise<any> {
1275
1276
  this.throwIfDisposed();
1276
1277
 
1277
- const pathsJson = JSON.stringify(options.schemaPaths);
1278
+ const pathsJson = typeof options.schemaPaths === 'string' ? options.schemaPaths : JSONStringify(options.schemaPaths);
1278
1279
  const resultStr = await JsonEvalRs.getSchemaByPathsSubform(
1279
1280
  this.handle,
1280
1281
  options.subformPath,
1281
1282
  pathsJson,
1282
1283
  options.format !== undefined ? options.format : ReturnFormat.Nested
1283
1284
  );
1284
- return JSON.parse(resultStr);
1285
+ return JSONParse(resultStr);
1285
1286
  }
1286
1287
 
1287
1288
  /**