@evolu/common-web
Advanced tools
Comparing version 8.0.5 to 8.1.0
@@ -5,3 +5,3 @@ import { SqliteFactory, SyncFactory, Time, createDb, } from "@evolu/common"; | ||
import { NanoIdGeneratorLive } from "./NanoIdGeneratorLive.js"; | ||
import { Bip39Live, SyncLockLive } from "./PlatformLive.js"; | ||
import { SyncLockLive } from "./PlatformLive.js"; | ||
import { expose, wrap } from "./ProxyWorker.js"; | ||
@@ -14,2 +14,2 @@ import { SqliteFactoryLive } from "./SqliteFactoryLive.js"; | ||
}); | ||
createDb.pipe(Effect.provide(Layer.mergeAll(Bip39Live, SqliteFactory.Common.pipe(Layer.provide(SqliteFactoryLive), Layer.provide(NanoIdGeneratorLive)), NanoIdGeneratorLive, Time.Live, SyncFactoryLive, SyncLockLive)), Effect.runSync, expose); | ||
createDb.pipe(Effect.provide(Layer.mergeAll(SqliteFactory.Common.pipe(Layer.provide(SqliteFactoryLive), Layer.provide(NanoIdGeneratorLive)), NanoIdGeneratorLive, Time.Live, SyncFactoryLive, SyncLockLive)), Effect.runSync, expose); |
@@ -1,11 +0,4 @@ | ||
import { EvoluFactory, InvalidMnemonicError, Mnemonic } from "@evolu/common"; | ||
import * as Effect from "effect/Effect"; | ||
import { EvoluFactory } from "@evolu/common"; | ||
import * as Layer from "effect/Layer"; | ||
export declare const EvoluFactoryWeb: Layer.Layer<EvoluFactory, never, never>; | ||
/** | ||
* Parse a string to {@link Mnemonic}. | ||
* | ||
* This function is async because Bip39 is imported dynamically. | ||
*/ | ||
export declare const parseMnemonic: (mnemonic: string) => Effect.Effect<Mnemonic, InvalidMnemonicError>; | ||
export declare const | ||
@@ -12,0 +5,0 @@ /** |
@@ -1,6 +0,6 @@ | ||
import { Bip39, DbFactory, EvoluFactory, notSupportedPlatformWorker, } from "@evolu/common"; | ||
import { DbFactory, EvoluFactory, notSupportedPlatformWorker, } from "@evolu/common"; | ||
import * as Effect from "effect/Effect"; | ||
import * as Layer from "effect/Layer"; | ||
import { NanoIdGeneratorLive } from "./NanoIdGeneratorLive.js"; | ||
import { AppStateLive, Bip39Live } from "./PlatformLive.js"; | ||
import { AppStateLive } from "./PlatformLive.js"; | ||
import { wrap } from "./ProxyWorker.js"; | ||
@@ -18,8 +18,2 @@ const DbFactoryLive = Layer.succeed(DbFactory, { | ||
export const EvoluFactoryWeb = Layer.provide(EvoluFactory.Common, Layer.mergeAll(DbFactoryLive, NanoIdGeneratorLive, AppStateLive)); | ||
/** | ||
* Parse a string to {@link Mnemonic}. | ||
* | ||
* This function is async because Bip39 is imported dynamically. | ||
*/ | ||
export const parseMnemonic = Bip39.pipe(Effect.provide(Bip39Live), Effect.runSync).parse; | ||
// JSDoc doesn't support destructured parameters, so we must copy-paste | ||
@@ -26,0 +20,0 @@ // createEvolu docs from `evolu-common/src/Evolu.ts`. |
@@ -1,6 +0,5 @@ | ||
import { AppState, Bip39, SyncLock } from "@evolu/common"; | ||
import { AppState, SyncLock } from "@evolu/common"; | ||
import * as Layer from "effect/Layer"; | ||
export declare const AppStateLive: Layer.Layer<AppState, never, never>; | ||
export declare const SyncLockLive: Layer.Layer<SyncLock, never, never>; | ||
export declare const Bip39Live: Layer.Layer<Bip39, never, never>; | ||
//# sourceMappingURL=PlatformLive.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { AppState, Bip39, SyncLock, SyncLockAlreadySyncingError, getLockName, validateMnemonicToEffect, } from "@evolu/common"; | ||
import { AppState, SyncLock, SyncLockAlreadySyncingError, getLockName, } from "@evolu/common"; | ||
import * as Effect from "effect/Effect"; | ||
@@ -60,10 +60,1 @@ import * as Layer from "effect/Layer"; | ||
}); | ||
const importBip39WithEnglish = Effect.all([ | ||
Effect.promise(() => import("@scure/bip39")), | ||
Effect.promise(() => import("@scure/bip39/wordlists/english")), | ||
], { concurrency: "unbounded" }); | ||
export const Bip39Live = Layer.succeed(Bip39, Bip39.of({ | ||
make: importBip39WithEnglish.pipe(Effect.map(([{ generateMnemonic }, { wordlist }]) => generateMnemonic(wordlist, 128))), | ||
toSeed: (mnemonic) => Effect.promise(() => import("@scure/bip39")).pipe(Effect.flatMap((a) => Effect.promise(() => a.mnemonicToSeed(mnemonic)))), | ||
parse: (mnemonic) => importBip39WithEnglish.pipe(Effect.flatMap(([{ validateMnemonic }, { wordlist }]) => validateMnemonicToEffect(validateMnemonic)(mnemonic, wordlist))), | ||
})); |
{ | ||
"name": "@evolu/common-web", | ||
"version": "8.0.5", | ||
"version": "8.1.0", | ||
"description": "Common code for Evolu libraries targeting web", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
"vitest": "^1.6.0", | ||
"@evolu/common": "5.1.2", | ||
"@evolu/common": "5.2.0", | ||
"eslint-config-evolu": "1.0.0", | ||
@@ -43,3 +43,3 @@ "@evolu/tsconfig": "0.0.2" | ||
"peerDependencies": { | ||
"@evolu/common": "^5.1.2", | ||
"@evolu/common": "^5.2.0", | ||
"@sqlite.org/sqlite-wasm": "^3.45.3-build3" | ||
@@ -46,0 +46,0 @@ }, |
@@ -11,3 +11,3 @@ import { | ||
import { NanoIdGeneratorLive } from "./NanoIdGeneratorLive.js"; | ||
import { Bip39Live, SyncLockLive } from "./PlatformLive.js"; | ||
import { SyncLockLive } from "./PlatformLive.js"; | ||
import { expose, wrap } from "./ProxyWorker.js"; | ||
@@ -29,3 +29,2 @@ import { SqliteFactoryLive } from "./SqliteFactoryLive.js"; | ||
Layer.mergeAll( | ||
Bip39Live, | ||
SqliteFactory.Common.pipe( | ||
@@ -32,0 +31,0 @@ Layer.provide(SqliteFactoryLive), |
import { | ||
Bip39, | ||
Db, | ||
DbFactory, | ||
EvoluFactory, | ||
InvalidMnemonicError, | ||
Mnemonic, | ||
notSupportedPlatformWorker, | ||
@@ -13,3 +10,3 @@ } from "@evolu/common"; | ||
import { NanoIdGeneratorLive } from "./NanoIdGeneratorLive.js"; | ||
import { AppStateLive, Bip39Live } from "./PlatformLive.js"; | ||
import { AppStateLive } from "./PlatformLive.js"; | ||
import { wrap } from "./ProxyWorker.js"; | ||
@@ -35,14 +32,2 @@ | ||
/** | ||
* Parse a string to {@link Mnemonic}. | ||
* | ||
* This function is async because Bip39 is imported dynamically. | ||
*/ | ||
export const parseMnemonic: ( | ||
mnemonic: string, | ||
) => Effect.Effect<Mnemonic, InvalidMnemonicError> = Bip39.pipe( | ||
Effect.provide(Bip39Live), | ||
Effect.runSync, | ||
).parse; | ||
// JSDoc doesn't support destructured parameters, so we must copy-paste | ||
@@ -49,0 +34,0 @@ // createEvolu docs from `evolu-common/src/Evolu.ts`. |
import { | ||
AppState, | ||
Bip39, | ||
Mnemonic, | ||
SyncLock, | ||
@@ -9,3 +7,2 @@ SyncLockAlreadySyncingError, | ||
getLockName, | ||
validateMnemonicToEffect, | ||
} from "@evolu/common"; | ||
@@ -89,33 +86,1 @@ import * as Effect from "effect/Effect"; | ||
}); | ||
const importBip39WithEnglish = Effect.all( | ||
[ | ||
Effect.promise(() => import("@scure/bip39")), | ||
Effect.promise(() => import("@scure/bip39/wordlists/english")), | ||
], | ||
{ concurrency: "unbounded" }, | ||
); | ||
export const Bip39Live = Layer.succeed( | ||
Bip39, | ||
Bip39.of({ | ||
make: importBip39WithEnglish.pipe( | ||
Effect.map( | ||
([{ generateMnemonic }, { wordlist }]) => | ||
generateMnemonic(wordlist, 128) as Mnemonic, | ||
), | ||
), | ||
toSeed: (mnemonic) => | ||
Effect.promise(() => import("@scure/bip39")).pipe( | ||
Effect.flatMap((a) => Effect.promise(() => a.mnemonicToSeed(mnemonic))), | ||
), | ||
parse: (mnemonic) => | ||
importBip39WithEnglish.pipe( | ||
Effect.flatMap(([{ validateMnemonic }, { wordlist }]) => | ||
validateMnemonicToEffect(validateMnemonic)(mnemonic, wordlist), | ||
), | ||
), | ||
}), | ||
); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
45729
1047