@quereus/plugin-react-native-leveldb 0.4.0 → 0.4.1
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/README.md +31 -0
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/plugin.js +35 -0
- package/dist/src/plugin.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,37 @@ npm install @quereus/plugin-react-native-leveldb @quereus/store @quereus/isolati
|
|
|
21
21
|
cd ios && pod install
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
## Required Polyfills
|
|
25
|
+
|
|
26
|
+
React Native apps typically need a few runtime polyfills for Quereus and its plugins:
|
|
27
|
+
|
|
28
|
+
- **`structuredClone`** - Quereus uses it internally for deep cloning operations
|
|
29
|
+
- **`TextEncoder` / `TextDecoder`** - Used by store plugins for binary data encoding
|
|
30
|
+
- **`Symbol.asyncIterator`** - Required for async-iterable support (for-await-of loops, async generators)
|
|
31
|
+
- Quereus uses async iterables extensively for query results and data streaming
|
|
32
|
+
- While Hermes has a workaround for AsyncGenerator objects, the `Symbol.asyncIterator` symbol itself must exist
|
|
33
|
+
- Without it, you'll get `ReferenceError: Can't find variable: Symbol` when checking for async iterables
|
|
34
|
+
|
|
35
|
+
**The plugin automatically checks for these polyfills** and throws a clear error message with installation instructions if any are missing.
|
|
36
|
+
|
|
37
|
+
You can use packages like `core-js` or provide your own implementations:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install core-js text-encoding
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then in your app's entry point:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import 'core-js/features/structured-clone';
|
|
47
|
+
import 'text-encoding';
|
|
48
|
+
|
|
49
|
+
// Ensure Symbol.asyncIterator exists
|
|
50
|
+
if (typeof Symbol.asyncIterator === 'undefined') {
|
|
51
|
+
(Symbol as any).asyncIterator = Symbol.for('Symbol.asyncIterator');
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
24
55
|
## Quick Start
|
|
25
56
|
|
|
26
57
|
### With registerPlugin (Recommended)
|
package/dist/src/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAA6B,MAAM,gBAAgB,CAAC;AAExE,OAAO,KAAK,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAA6B,MAAM,gBAAgB,CAAC;AAExE,OAAO,KAAK,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAgD9E;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;OAIG;IACH,MAAM,EAAE,aAAa,CAAC;IAEtB;;;OAGG;IACH,UAAU,EAAE,4BAA4B,CAAC;IAEzC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC/B,GAAG,EAAE,QAAQ,EACb,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAM;;;;;EA+CrC"}
|
package/dist/src/plugin.js
CHANGED
|
@@ -6,6 +6,39 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { StoreModule, createIsolatedStoreModule } from '@quereus/store';
|
|
8
8
|
import { ReactNativeLevelDBProvider } from './provider.js';
|
|
9
|
+
/**
|
|
10
|
+
* Check for required React Native polyfills and throw a helpful error if any are missing.
|
|
11
|
+
*/
|
|
12
|
+
function checkRequiredPolyfills() {
|
|
13
|
+
const missing = [];
|
|
14
|
+
// Check for structuredClone
|
|
15
|
+
if (typeof structuredClone === 'undefined') {
|
|
16
|
+
missing.push('structuredClone (used internally by Quereus)\n' +
|
|
17
|
+
' Install: npm install core-js\n' +
|
|
18
|
+
' Import: import \'core-js/features/structured-clone\';');
|
|
19
|
+
}
|
|
20
|
+
// Check for TextEncoder/TextDecoder
|
|
21
|
+
if (typeof TextEncoder === 'undefined' || typeof TextDecoder === 'undefined') {
|
|
22
|
+
missing.push('TextEncoder/TextDecoder (used by store plugins for binary data)\n' +
|
|
23
|
+
' Install: npm install text-encoding\n' +
|
|
24
|
+
' Import: import \'text-encoding\';');
|
|
25
|
+
}
|
|
26
|
+
// Check for Symbol.asyncIterator
|
|
27
|
+
if (typeof Symbol.asyncIterator === 'undefined') {
|
|
28
|
+
missing.push('Symbol.asyncIterator (required for async-iterable support)\n' +
|
|
29
|
+
' Quereus uses async generators and for-await-of loops extensively.\n' +
|
|
30
|
+
' While Hermes has special handling for AsyncGenerator objects, the symbol must exist.\n' +
|
|
31
|
+
' Add to your app entry point:\n' +
|
|
32
|
+
' if (typeof Symbol.asyncIterator === \'undefined\') {\n' +
|
|
33
|
+
' (Symbol as any).asyncIterator = Symbol.for(\'Symbol.asyncIterator\');\n' +
|
|
34
|
+
' }');
|
|
35
|
+
}
|
|
36
|
+
if (missing.length > 0) {
|
|
37
|
+
throw new Error('@quereus/plugin-react-native-leveldb requires the following polyfills:\n\n' +
|
|
38
|
+
missing.map((msg, i) => `${i + 1}. ${msg}`).join('\n\n') +
|
|
39
|
+
'\n\nFor more details, see: https://github.com/yourorg/quereus/tree/main/packages/quereus-plugin-react-native-leveldb#required-polyfills');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
9
42
|
/**
|
|
10
43
|
* Register the React Native LevelDB plugin with a database.
|
|
11
44
|
*
|
|
@@ -28,6 +61,8 @@ import { ReactNativeLevelDBProvider } from './provider.js';
|
|
|
28
61
|
* ```
|
|
29
62
|
*/
|
|
30
63
|
export default function register(_db, config = {}) {
|
|
64
|
+
// Check for required polyfills first
|
|
65
|
+
checkRequiredPolyfills();
|
|
31
66
|
// The LevelDB open function must be provided
|
|
32
67
|
const openFn = config.openFn;
|
|
33
68
|
if (!openFn) {
|
package/dist/src/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAG3D;;GAEG;AACH,SAAS,sBAAsB;IAC9B,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,4BAA4B;IAC5B,IAAI,OAAO,eAAe,KAAK,WAAW,EAAE,CAAC;QAC5C,OAAO,CAAC,IAAI,CACX,gDAAgD;YAChD,kCAAkC;YAClC,yDAAyD,CACzD,CAAC;IACH,CAAC;IAED,oCAAoC;IACpC,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE,CAAC;QAC9E,OAAO,CAAC,IA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