project: Move to ESM Modules

This commit is contained in:
Rajeh Taher
2025-07-17 13:54:17 +03:00
parent 19124426b2
commit 787aed88b8
69 changed files with 5143 additions and 4757 deletions
+10 -9
View File
@@ -12,7 +12,7 @@ import type {
} from '../Types'
import { Curve, signedKeyPair } from './crypto'
import { delay, generateRegistrationId } from './generics'
import { ILogger } from './logger'
import type { ILogger } from './logger'
/**
* Adds caching capability to a SignalKeyStore
@@ -67,8 +67,8 @@ export function makeCacheableSignalKeyStore(
async set(data) {
let keys = 0
for (const type in data) {
for (const id in data[type]) {
cache.set(getUniqueId(type, id), data[type][id])
for (const id in data[type as keyof SignalDataTypeMap]) {
cache.set(getUniqueId(type, id), data[type as keyof SignalDataTypeMap]![id])
keys += 1
}
}
@@ -118,7 +118,7 @@ export const addTransactionCapability = (
Object.assign(transactionCache[type]!, result)
}
return ids.reduce((dict, id) => {
return ids.reduce((dict: { [T in string]: any }, id) => {
const value = transactionCache[type]?.[id]
if (value) {
dict[id] = value
@@ -133,12 +133,13 @@ export const addTransactionCapability = (
set: data => {
if (isInTransaction()) {
logger.trace({ types: Object.keys(data) }, 'caching in transaction')
for (const key in data) {
transactionCache[key] = transactionCache[key] || {}
Object.assign(transactionCache[key], data[key])
for (const key_ in data) {
const key = key_ as keyof SignalDataTypeMap
transactionCache[key] = transactionCache[key] || ({} as any)
Object.assign(transactionCache[key]!, data[key])
mutations[key] = mutations[key] || {}
Object.assign(mutations[key], data[key])
mutations[key] = mutations[key] || ({} as any)
Object.assign(mutations[key]!, data[key])
}
} else {
return state.set(data)