Update docs, bump version

This commit is contained in:
Jon Staab
2025-09-05 09:30:27 -07:00
parent 0382dd479a
commit 8716d1fdb1
16 changed files with 30 additions and 21 deletions
+6
View File
@@ -20,6 +20,7 @@ Manages authentication state for a socket connection.
**Methods:** **Methods:**
- `doAuth(sign)` - Authenticate with the relay using provided signing function - `doAuth(sign)` - Authenticate with the relay using provided signing function
- `attemptAuth(sign)` - Attempt authentication with timeout handling - `attemptAuth(sign)` - Attempt authentication with timeout handling
- `retryAuth(sign)` - Retry authentication by resetting state and attempting auth again
- `cleanup()` - Clean up event listeners - `cleanup()` - Clean up event listeners
**Events:** **Events:**
@@ -39,4 +40,9 @@ authState.on(AuthStateEvent.Status, (status) => {
await authState.attemptAuth(async (template) => { await authState.attemptAuth(async (template) => {
return await signer.signEvent(template) return await signer.signEvent(template)
}) })
// Retry authentication if needed
await authState.retryAuth(async (template) => {
return await signer.signEvent(template)
})
``` ```
+6 -2
View File
@@ -14,12 +14,13 @@ Creates a writable store that synchronizes with a storage provider using JSON se
- `storage` - Storage provider implementing the StorageProvider interface - `storage` - Storage provider implementing the StorageProvider interface
- `defaultValue` - Default value if nothing exists in storage - `defaultValue` - Default value if nothing exists in storage
**Returns:** Writable Svelte store that persists changes to storage **Returns:** `Synced<T>` - A writable Svelte store with a `ready` promise that resolves when initial storage loading completes
The store automatically: The store automatically:
- Loads initial value from storage on creation - Loads initial value from storage asynchronously on creation
- Saves any changes back to storage - Saves any changes back to storage
- Falls back to defaultValue if storage is empty or invalid - Falls back to defaultValue if storage is empty or invalid
- Provides a `ready` promise that resolves when initial loading is complete
## Storage Provider Interface ## Storage Provider Interface
@@ -46,6 +47,9 @@ const userPreferences = synced({
} }
}) })
// Wait for initial loading to complete if needed
await userPreferences.ready
// Use like any writable store // Use like any writable store
userPreferences.subscribe(prefs => { userPreferences.subscribe(prefs => {
console.log("Preferences:", prefs) console.log("Preferences:", prefs)
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@welshman", "name": "@welshman",
"private": true, "private": true,
"version": "0.4.3", "version": "0.4.4",
"workspaces": [ "workspaces": [
"packages/*" "packages/*"
], ],
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/app", "name": "@welshman/app",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of svelte stores for use in building nostr client applications.", "description": "A collection of svelte stores for use in building nostr client applications.",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/content", "name": "@welshman/content",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of utilities for parsing nostr note content.", "description": "A collection of utilities for parsing nostr note content.",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/editor", "name": "@welshman/editor",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A batteries-included nostr editor.", "description": "A batteries-included nostr editor.",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/feeds", "name": "@welshman/feeds",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "Utilities for building dynamic nostr feeds.", "description": "Utilities for building dynamic nostr feeds.",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/lib", "name": "@welshman/lib",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of utilities.", "description": "A collection of utilities.",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/net", "name": "@welshman/net",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "Utilities for connecting with nostr relays.", "description": "Utilities for connecting with nostr relays.",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/relay", "name": "@welshman/relay",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "An in-memory nostr relay implementation.", "description": "An in-memory nostr relay implementation.",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/router", "name": "@welshman/router",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of utilities for nostr relay selection.", "description": "A collection of utilities for nostr relay selection.",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/signer", "name": "@welshman/signer",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A nostr signer implemenation supporting several login methods.", "description": "A nostr signer implemenation supporting several login methods.",
+5 -5
View File
@@ -42,7 +42,7 @@ describe("Store utilities", () => {
describe("synced", () => { describe("synced", () => {
it("should sync with localStorage", async () => { it("should sync with localStorage", async () => {
const store = await synced({ const store = synced({
key: "testKey", key: "testKey",
storage: localStorageProvider, storage: localStorageProvider,
defaultValue: "default", defaultValue: "default",
@@ -63,7 +63,7 @@ describe("Store utilities", () => {
it("should load existing value from localStorage", async () => { it("should load existing value from localStorage", async () => {
localStorage.setItem("testKey", JSON.stringify("existing")) localStorage.setItem("testKey", JSON.stringify("existing"))
const store = await synced({ const store = synced({
key: "testKey", key: "testKey",
storage: localStorageProvider, storage: localStorageProvider,
defaultValue: "default", defaultValue: "default",
@@ -78,7 +78,7 @@ describe("Store utilities", () => {
describe("getter", () => { describe("getter", () => {
it("should return current store value", async () => { it("should return current store value", async () => {
const store = await synced({ const store = synced({
key: "test", key: "test",
storage: localStorageProvider, storage: localStorageProvider,
defaultValue: "initial", defaultValue: "initial",
@@ -98,7 +98,7 @@ describe("Store utilities", () => {
describe("withGetter", () => { describe("withGetter", () => {
it("should add getter to writable store", async () => { it("should add getter to writable store", async () => {
const store = withGetter( const store = withGetter(
await synced({ synced({
key: "test", key: "test",
storage: localStorageProvider, storage: localStorageProvider,
defaultValue: "initial", defaultValue: "initial",
@@ -117,7 +117,7 @@ describe("Store utilities", () => {
describe("throttled", () => { describe("throttled", () => {
it("should throttle updates", async () => { it("should throttle updates", async () => {
const mockFn = vi.fn() const mockFn = vi.fn()
const store = await synced({ const store = synced({
key: "test", key: "test",
storage: localStorageProvider, storage: localStorageProvider,
defaultValue: 0, defaultValue: 0,
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/store", "name": "@welshman/store",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of utilities based on svelte/store for use with welshman", "description": "A collection of utilities based on svelte/store for use with welshman",
+1 -2
View File
@@ -40,8 +40,7 @@ export interface SyncedConfig<T> {
export const synced = <T>({key, storage, defaultValue}: SyncedConfig<T>) => { export const synced = <T>({key, storage, defaultValue}: SyncedConfig<T>) => {
const store = writable<T>(defaultValue) as Synced<T> const store = writable<T>(defaultValue) as Synced<T>
const syncPromise = sync({key, store, storage}) store.ready = sync({key, store, storage})
store.ready = syncPromise
return store return store
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/util", "name": "@welshman/util",
"version": "0.4.3", "version": "0.4.4",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of nostr-related utilities.", "description": "A collection of nostr-related utilities.",