@kedaruma/revlm-client 1.0.23 → 1.0.24

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 CHANGED
@@ -24,6 +24,20 @@ const coll = db.collection<any>('collection_name');
24
24
  const all = await coll.find({});
25
25
  ```
26
26
 
27
+ ### React Native (Hermes) polyfills
28
+
29
+ Install RN-friendly crypto/text/Buffer polyfills and load the helper once at app startup (e.g. in `index.js` or `App.tsx`):
30
+
31
+ ```bash
32
+ pnpm add react-native-webcrypto react-native-get-random-values fast-text-encoding buffer
33
+ ```
34
+
35
+ ```ts
36
+ import '@kedaruma/revlm-client/rn-setup';
37
+ ```
38
+
39
+ The helper makes a best-effort attempt to wire `crypto`, `crypto.getRandomValues`, `crypto.subtle`, `TextEncoder`/`TextDecoder`, and `Buffer`. It is safe to import on non-RN platforms.
40
+
27
41
  ## Scripts
28
42
 
29
43
  - `pnpm run build` – bundle with `tsup`
@@ -0,0 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ export {
9
+ __require
10
+ };
package/dist/index.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import "./chunk-Y6FXYEAI.mjs";
2
+
1
3
  // src/Revlm.ts
2
4
  import { EJSON } from "bson";
3
5
  import { AuthClient } from "@kedaruma/revlm-shared";
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/rn-setup.ts
17
+ var rn_setup_exports = {};
18
+ module.exports = __toCommonJS(rn_setup_exports);
19
+ var safeRequire = (id) => {
20
+ try {
21
+ return require(id);
22
+ } catch {
23
+ return void 0;
24
+ }
25
+ };
26
+ var webcrypto = safeRequire("react-native-webcrypto");
27
+ var cryptoFromWebcrypto = webcrypto?.crypto;
28
+ if (cryptoFromWebcrypto && !global.crypto) {
29
+ global.crypto = cryptoFromWebcrypto;
30
+ }
31
+ safeRequire("react-native-get-random-values");
32
+ var fastTextEncoding = safeRequire("fast-text-encoding");
33
+ if (fastTextEncoding?.TextEncoder && !global.TextEncoder) {
34
+ global.TextEncoder = fastTextEncoding.TextEncoder;
35
+ }
36
+ if (fastTextEncoding?.TextDecoder && !global.TextDecoder) {
37
+ global.TextDecoder = fastTextEncoding.TextDecoder;
38
+ }
39
+ var bufferModule = safeRequire("buffer");
40
+ var BufferCtor = bufferModule?.Buffer;
41
+ if (BufferCtor && !global.Buffer) {
42
+ global.Buffer = BufferCtor;
43
+ }
@@ -0,0 +1,30 @@
1
+ import {
2
+ __require
3
+ } from "./chunk-Y6FXYEAI.mjs";
4
+
5
+ // src/rn-setup.ts
6
+ var safeRequire = (id) => {
7
+ try {
8
+ return __require(id);
9
+ } catch {
10
+ return void 0;
11
+ }
12
+ };
13
+ var webcrypto = safeRequire("react-native-webcrypto");
14
+ var cryptoFromWebcrypto = webcrypto?.crypto;
15
+ if (cryptoFromWebcrypto && !global.crypto) {
16
+ global.crypto = cryptoFromWebcrypto;
17
+ }
18
+ safeRequire("react-native-get-random-values");
19
+ var fastTextEncoding = safeRequire("fast-text-encoding");
20
+ if (fastTextEncoding?.TextEncoder && !global.TextEncoder) {
21
+ global.TextEncoder = fastTextEncoding.TextEncoder;
22
+ }
23
+ if (fastTextEncoding?.TextDecoder && !global.TextDecoder) {
24
+ global.TextDecoder = fastTextEncoding.TextDecoder;
25
+ }
26
+ var bufferModule = safeRequire("buffer");
27
+ var BufferCtor = bufferModule?.Buffer;
28
+ if (BufferCtor && !global.Buffer) {
29
+ global.Buffer = BufferCtor;
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kedaruma/revlm-client",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "private": false,
5
5
  "description": "TypeScript client SDK for talking to the Revlm server replacement for MongoDB Realm.",
6
6
  "keywords": [
@@ -25,6 +25,16 @@
25
25
  "types": "./dist/index.d.ts",
26
26
  "default": "./dist/index.js"
27
27
  }
28
+ },
29
+ "./rn-setup": {
30
+ "import": {
31
+ "types": "./dist/rn-setup.d.mts",
32
+ "default": "./dist/rn-setup.mjs"
33
+ },
34
+ "require": {
35
+ "types": "./dist/rn-setup.d.ts",
36
+ "default": "./dist/rn-setup.js"
37
+ }
28
38
  }
29
39
  },
30
40
  "sideEffects": false,
@@ -44,7 +54,7 @@
44
54
  "tsup": "^8.5.1"
45
55
  },
46
56
  "scripts": {
47
- "build": "tsup src/index.ts --format cjs,esm --dts --tsconfig tsconfig.build.json",
57
+ "build": "tsup src/index.ts src/rn-setup.ts --format cjs,esm --dts --tsconfig tsconfig.build.json",
48
58
  "clean": "rm -rf dist node_modules kedaruma-revlm-client-*.tgz",
49
59
  "test": "pnpm exec jest --config ../../jest.config.cjs packages/revlm-client/src/__tests__/ --runInBand --watchman=false --verbose"
50
60
  }