@layers/react-native 3.2.7 → 3.2.8
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 +23 -0
- package/dist/att-BFy6dcWE.d.ts.map +1 -1
- package/dist/index-BNM5Q_2v.d.ts.map +1 -1
- package/dist/index-BaCWtOOT.d.mts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -1
- package/dist/skan-DnKHcXAj.d.ts.map +1 -1
- package/dist/{src-A7xqoTvD.mjs → src-BxA1wIJ6.mjs} +38 -4
- package/dist/{src-A7xqoTvD.mjs.map → src-BxA1wIJ6.mjs.map} +1 -1
- package/dist/{src-DkJclY0S.js → src-D_EHJJlX.js} +37 -3
- package/package.json +2 -2
|
@@ -937,7 +937,7 @@ function hostAppIsRegisteredOn(rn) {
|
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
939
|
const DUPLICATE_REACT_NATIVE_MESSAGE = "[Layers] The SDK resolved a SECOND copy of react-native, not the one your app runs. React Native delivers native lifecycle events to a single copy, so this listener can never fire: $app_background and $app_foreground will not be emitted and the background crash-safety snapshot will not run, which loses every event queued since the last flush on any launch that ends in a kill. Fix the duplicate in your bundler — in a Metro monorepo set `resolver.disableHierarchicalLookup = true` and list every workspace node_modules in `resolver.nodeModulesPaths` — or hand the SDK your app's module: `new LayersReactNative({ ..., appState: AppState })` with AppState imported from 'react-native'.";
|
|
940
|
-
const SDK_VERSION = "3.2.
|
|
940
|
+
const SDK_VERSION = "3.2.8";
|
|
941
941
|
var LayersReactNative = class LayersReactNative {
|
|
942
942
|
core;
|
|
943
943
|
eagerPersistence;
|
|
@@ -2261,14 +2261,16 @@ async function createAsyncStoragePersistence(appId) {
|
|
|
2261
2261
|
if (AsyncStorage) {
|
|
2262
2262
|
const sdkKeys = (await AsyncStorage.getAllKeys()).filter((k) => k.startsWith(prefix));
|
|
2263
2263
|
if (sdkKeys.length > 0) {
|
|
2264
|
-
const pairs = await AsyncStorage
|
|
2264
|
+
const pairs = await readManyFromAsyncStorage(AsyncStorage, sdkKeys);
|
|
2265
2265
|
for (const [key, value] of pairs) if (value) {
|
|
2266
2266
|
const shortKey = key.slice(prefix.length);
|
|
2267
2267
|
memoryStore.set(shortKey, base64Decode(value));
|
|
2268
2268
|
}
|
|
2269
2269
|
}
|
|
2270
2270
|
}
|
|
2271
|
-
} catch {
|
|
2271
|
+
} catch (error) {
|
|
2272
|
+
warnPersistencePreloadFailed(error);
|
|
2273
|
+
}
|
|
2272
2274
|
return {
|
|
2273
2275
|
write(key, data) {
|
|
2274
2276
|
memoryStore.set(key, new Uint8Array(data));
|
|
@@ -2346,6 +2348,38 @@ async function deleteFromAsyncStorage(key) {
|
|
|
2346
2348
|
await AsyncStorage.removeItem(key);
|
|
2347
2349
|
} catch {}
|
|
2348
2350
|
}
|
|
2351
|
+
let _warnedAsyncStorageBatchShape = false;
|
|
2352
|
+
let _warnedPersistencePreloadFailed = false;
|
|
2353
|
+
/**
|
|
2354
|
+
* Batch-read `keys` through whichever multi-key API the installed AsyncStorage
|
|
2355
|
+
* exposes.
|
|
2356
|
+
*
|
|
2357
|
+
* v3.0.0 removed `multiGet` in favour of `getMany`, and changed the return
|
|
2358
|
+
* type with it: `multiGet` answers `[key, value][]`, `getMany` answers
|
|
2359
|
+
* `Record<key, value | null>`. Calling the v1/v2 name unconditionally threw
|
|
2360
|
+
* `TypeError: AsyncStorage.multiGet is not a function` on v3 — and because
|
|
2361
|
+
* `>=1.21.0` admits v3, and npm's `latest` has been v3 since v3.0.0, that was
|
|
2362
|
+
* the default install.
|
|
2363
|
+
*/
|
|
2364
|
+
async function readManyFromAsyncStorage(storage, keys) {
|
|
2365
|
+
if (typeof storage.multiGet === "function") return (await storage.multiGet(keys)).map(([key, value]) => [key, value ?? null]);
|
|
2366
|
+
if (typeof storage.getMany === "function") {
|
|
2367
|
+
const record = await storage.getMany([...keys]);
|
|
2368
|
+
return keys.map((key) => [key, record?.[key] ?? null]);
|
|
2369
|
+
}
|
|
2370
|
+
warnAsyncStorageBatchShape();
|
|
2371
|
+
return Promise.all(keys.map(async (key) => [key, await storage.getItem(key)]));
|
|
2372
|
+
}
|
|
2373
|
+
function warnAsyncStorageBatchShape() {
|
|
2374
|
+
if (_warnedAsyncStorageBatchShape) return;
|
|
2375
|
+
_warnedAsyncStorageBatchShape = true;
|
|
2376
|
+
console.warn("[Layers] @react-native-async-storage/async-storage exposes neither multiGet (v1/v2) nor getMany (v3) — falling back to one read per key to restore persisted identity and queued events. If launches start reporting as new installs, pin async-storage to a version this SDK recognises (>=1.21.0).");
|
|
2377
|
+
}
|
|
2378
|
+
function warnPersistencePreloadFailed(error) {
|
|
2379
|
+
if (_warnedPersistencePreloadFailed) return;
|
|
2380
|
+
_warnedPersistencePreloadFailed = true;
|
|
2381
|
+
console.warn("[Layers] could not read persisted SDK state back from AsyncStorage — this launch starts with a fresh identity and an empty event queue, and will report itself as a new install. Check @react-native-async-storage/async-storage compatibility; the SDK supports v1.21+, v2 and v3.", error);
|
|
2382
|
+
}
|
|
2349
2383
|
let _asyncStorage = void 0;
|
|
2350
2384
|
let _asyncStoragePromise = null;
|
|
2351
2385
|
async function loadAsyncStorage() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layers/react-native",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"mobile"
|
|
68
68
|
],
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@layers/core-wasm": "3.2.
|
|
70
|
+
"@layers/core-wasm": "3.2.8"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@react-native-async-storage/async-storage": ">=1.21.0",
|