From bc65b96d462fadfaf2b429d8646a94fa7559a65c Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Fri, 6 Jun 2025 12:45:41 -0700 Subject: [PATCH] Sort events in deriveEventsMapped, bump nostr-tools --- .fdignore | 2 +- docs/lib/tools.md | 3 ++ packages/content/package.json | 2 +- packages/editor/package.json | 4 +-- packages/lib/src/Tools.ts | 10 ++++++ packages/signer/package.json | 2 +- packages/store/src/repository.ts | 8 ++--- packages/util/package.json | 2 +- packages/util/src/Relay.ts | 2 ++ pnpm-lock.yaml | 56 ++++++++++++-------------------- 10 files changed, 46 insertions(+), 45 deletions(-) diff --git a/.fdignore b/.fdignore index 603fd55..691ae4c 100644 --- a/.fdignore +++ b/.fdignore @@ -1,5 +1,5 @@ node_modules -#docs +docs docs/reference docs/.vitepress/cache build diff --git a/docs/lib/tools.md b/docs/lib/tools.md index c2cf118..e629222 100644 --- a/docs/lib/tools.md +++ b/docs/lib/tools.md @@ -289,6 +289,9 @@ export declare const ensurePlural: (x: T | T[]) => T[]; // Ensures values are not undefined export declare const removeNil: (xs: T[]) => (T & {})[]; + +// Returns a list of overlapping pairs of elements in xs +export declare const overlappingPairs: (xs: T[]) => T[][]; ``` ## Objects diff --git a/packages/content/package.json b/packages/content/package.json index b5537ce..d6d626c 100644 --- a/packages/content/package.json +++ b/packages/content/package.json @@ -21,7 +21,7 @@ }, "dependencies": { "@braintree/sanitize-url": "^7.0.2", - "nostr-tools": "^2.7.2" + "nostr-tools": "^2.14.2" }, "devDependencies": { "rimraf": "~6.0.0", diff --git a/packages/editor/package.json b/packages/editor/package.json index 78e26d2..4b85cf5 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -41,8 +41,8 @@ "@tiptap/suggestion": "^2.11.5", "@welshman/lib": "workspace:*", "@welshman/util": "workspace:*", - "nostr-editor": "github:cesardeazevedo/nostr-editor#a1babb361e081dd9548b852e15837525a2fc82bc", - "nostr-tools": "^2.7.2", + "nostr-editor": "github:cesardeazevedo/nostr-editor#98f579b93bd2b5a3344df42f769d2ea4c5d8cf55", + "nostr-tools": "^2.14.2", "tippy.js": "^6.3.7" }, "devDependencies": { diff --git a/packages/lib/src/Tools.ts b/packages/lib/src/Tools.ts index f88810e..e269f74 100644 --- a/packages/lib/src/Tools.ts +++ b/packages/lib/src/Tools.ts @@ -752,6 +752,16 @@ export const ensurePlural = (x: T | T[]) => (x instanceof Array ? x : [x]) /** Ensures values are not undefined */ export const removeNil = (xs: T[]) => xs.filter(isNotNil).map(assertNotNil) +/** Returns a list of overlapping pairs of elements in xs */ +export const overlappingPairs = (xs: T[]): T[][] => { + const result: T[][] = [] + for (let i = 0; i < xs.length - 1; i++) { + result.push([xs[i], xs[i + 1]]) + } + + return result +} + // ---------------------------------------------------------------------------- // Objects // ---------------------------------------------------------------------------- diff --git a/packages/signer/package.json b/packages/signer/package.json index ea83446..11c1a49 100644 --- a/packages/signer/package.json +++ b/packages/signer/package.json @@ -25,7 +25,7 @@ "@welshman/lib": "workspace:*", "@welshman/net": "workspace:*", "@welshman/util": "workspace:*", - "nostr-tools": "^2.7.2" + "nostr-tools": "^2.14.2" }, "devDependencies": { "@capacitor/core": "^7.2.0", diff --git a/packages/store/src/repository.ts b/packages/store/src/repository.ts index cf059b6..397296f 100644 --- a/packages/store/src/repository.ts +++ b/packages/store/src/repository.ts @@ -1,5 +1,5 @@ import {derived} from "svelte/store" -import {identity, ensurePlural, batch, partition, first} from "@welshman/lib" +import {sortBy, identity, ensurePlural, batch, partition, first} from "@welshman/lib" import {Repository} from "@welshman/relay" import {matchFilters, getIdAndAddress, getIdFilters, Filter, TrustedEvent} from "@welshman/util" import {custom} from "./custom.js" @@ -38,7 +38,7 @@ export const deriveEventsMapped = ( data.push(item) } - setter(data) + setter(sortBy(item => -itemToEvent(item).created_at, data)) } }) } @@ -59,7 +59,7 @@ export const deriveEventsMapped = ( } } - setter(data) + setter(sortBy(item => -itemToEvent(item).created_at, data)) const onUpdate = batch(300, (updates: {added: TrustedEvent[]; removed: Set}[]) => { const removed = new Set() @@ -109,7 +109,7 @@ export const deriveEventsMapped = ( } if (dirty) { - setter(data) + setter(sortBy(item => -itemToEvent(item).created_at, data)) } }) diff --git a/packages/util/package.json b/packages/util/package.json index a272475..35c4d68 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -22,7 +22,7 @@ "dependencies": { "@welshman/lib": "workspace:*", "@types/ws": "^8.5.13", - "nostr-tools": "^2.7.2", + "nostr-tools": "^2.14.2", "nostr-wasm": "^0.1.0" }, "devDependencies": { diff --git a/packages/util/src/Relay.ts b/packages/util/src/Relay.ts index 672294a..e05edd3 100644 --- a/packages/util/src/Relay.ts +++ b/packages/util/src/Relay.ts @@ -20,6 +20,8 @@ export type RelayProfile = { negentropy?: number description?: string supported_nips?: number[] + privacy_policy?: string + terms_of_service?: string limitation?: { min_pow_difficulty?: number payment_required?: boolean diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9e39298..a5e23fc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -121,8 +121,8 @@ importers: specifier: ^7.0.2 version: 7.1.1 nostr-tools: - specifier: ^2.7.2 - version: 2.12.0(typescript@5.8.2) + specifier: ^2.14.2 + version: 2.14.2(typescript@5.8.2) devDependencies: rimraf: specifier: ~6.0.0 @@ -204,11 +204,11 @@ importers: specifier: workspace:* version: link:../util nostr-editor: - specifier: github:cesardeazevedo/nostr-editor#a1babb361e081dd9548b852e15837525a2fc82bc - version: https://codeload.github.com/cesardeazevedo/nostr-editor/tar.gz/a1babb361e081dd9548b852e15837525a2fc82bc(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))(@tiptap/extension-image@2.11.7(@tiptap/core@2.11.7(@tiptap/pm@2.11.7)))(@tiptap/extension-link@2.11.7(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))(@tiptap/pm@2.11.7))(@tiptap/pm@2.11.7)(linkifyjs@4.2.0)(nostr-tools@2.12.0(typescript@5.8.2))(prosemirror-markdown@1.13.2)(prosemirror-model@1.25.0)(prosemirror-state@1.4.3)(tiptap-markdown@0.8.10(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))) + specifier: github:cesardeazevedo/nostr-editor#98f579b93bd2b5a3344df42f769d2ea4c5d8cf55 + version: https://codeload.github.com/cesardeazevedo/nostr-editor/tar.gz/98f579b93bd2b5a3344df42f769d2ea4c5d8cf55(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))(@tiptap/extension-image@2.11.7(@tiptap/core@2.11.7(@tiptap/pm@2.11.7)))(@tiptap/extension-link@2.11.7(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))(@tiptap/pm@2.11.7))(@tiptap/pm@2.11.7)(linkifyjs@4.2.0)(nostr-tools@2.14.2(typescript@5.8.2))(prosemirror-markdown@1.13.2)(prosemirror-model@1.25.0)(prosemirror-state@1.4.3)(tiptap-markdown@0.8.10(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))) nostr-tools: - specifier: ^2.7.2 - version: 2.12.0(typescript@5.8.2) + specifier: ^2.14.2 + version: 2.14.2(typescript@5.8.2) tippy.js: specifier: ^6.3.7 version: 6.3.7 @@ -351,8 +351,8 @@ importers: specifier: workspace:* version: link:../util nostr-tools: - specifier: ^2.7.2 - version: 2.12.0(typescript@5.8.2) + specifier: ^2.14.2 + version: 2.14.2(typescript@5.8.2) devDependencies: '@capacitor/core': specifier: ^7.2.0 @@ -398,8 +398,8 @@ importers: specifier: workspace:* version: link:../lib nostr-tools: - specifier: ^2.7.2 - version: 2.12.0(typescript@5.8.2) + specifier: ^2.14.2 + version: 2.14.2(typescript@5.8.2) nostr-wasm: specifier: ^0.1.0 version: 0.1.0 @@ -932,10 +932,6 @@ packages: '@noble/ciphers@0.5.3': resolution: {integrity: sha512-B0+6IIHiqEs3BPMT0hcRmHvEj2QHOLu+uwt+tqDDeVd0oyVzh7BPrDcPjRnV1PV/5LaknXJJQvOuRGR0zQJz+w==} - '@noble/ciphers@1.3.0': - resolution: {integrity: sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==} - engines: {node: ^14.21.3 || >=16} - '@noble/curves@1.1.0': resolution: {integrity: sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==} @@ -958,10 +954,6 @@ packages: resolution: {integrity: sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ==} engines: {node: ^14.21.3 || >=16} - '@noble/hashes@1.8.0': - resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==} - engines: {node: ^14.21.3 || >=16} - '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -2031,8 +2023,8 @@ packages: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} - nostr-editor@https://codeload.github.com/cesardeazevedo/nostr-editor/tar.gz/a1babb361e081dd9548b852e15837525a2fc82bc: - resolution: {tarball: https://codeload.github.com/cesardeazevedo/nostr-editor/tar.gz/a1babb361e081dd9548b852e15837525a2fc82bc} + nostr-editor@https://codeload.github.com/cesardeazevedo/nostr-editor/tar.gz/98f579b93bd2b5a3344df42f769d2ea4c5d8cf55: + resolution: {tarball: https://codeload.github.com/cesardeazevedo/nostr-editor/tar.gz/98f579b93bd2b5a3344df42f769d2ea4c5d8cf55} version: 0.0.4-pre.17 engines: {node: '>=18.16.1'} peerDependencies: @@ -2041,7 +2033,7 @@ packages: '@tiptap/extension-link': ^2.6.6 '@tiptap/pm': ^2.6.6 linkifyjs: ^4.1.3 - nostr-tools: ^2.7.2 + nostr-tools: ^2.14.2 prosemirror-markdown: ^1.13.0 prosemirror-model: ^1.22.3 prosemirror-state: ^1.4.3 @@ -2052,8 +2044,8 @@ packages: peerDependencies: '@capacitor/core': ^7.0.0 - nostr-tools@2.12.0: - resolution: {integrity: sha512-pUWEb020gTvt1XZvTa8AKNIHWFapjsv2NKyk43Ez2nnvz6WSXsrTFE0XtkNLSRBjPn6EpxumKeNiVzLz74jNSA==} + nostr-tools@2.14.2: + resolution: {integrity: sha512-YOIOn5EdJ2Kq5sQW5Zh4wOcqzR6kUyrCDHG4+mVD2szzthsyOTpiWX0yrwaRZGlHJG6q83vkhg95qc2W201XTQ==} peerDependencies: typescript: '>=5.0.0' peerDependenciesMeta: @@ -3076,8 +3068,6 @@ snapshots: '@noble/ciphers@0.5.3': {} - '@noble/ciphers@1.3.0': {} - '@noble/curves@1.1.0': dependencies: '@noble/hashes': 1.3.1 @@ -3096,8 +3086,6 @@ snapshots: '@noble/hashes@1.7.1': {} - '@noble/hashes@1.8.0': {} - '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -3185,12 +3173,12 @@ snapshots: '@scure/bip32@1.3.1': dependencies: '@noble/curves': 1.1.0 - '@noble/hashes': 1.3.1 + '@noble/hashes': 1.3.2 '@scure/base': 1.1.9 '@scure/bip39@1.2.1': dependencies: - '@noble/hashes': 1.3.1 + '@noble/hashes': 1.3.2 '@scure/base': 1.1.9 '@shikijs/core@2.5.0': @@ -4222,10 +4210,8 @@ snapshots: normalize-path@3.0.0: {} - nostr-editor@https://codeload.github.com/cesardeazevedo/nostr-editor/tar.gz/a1babb361e081dd9548b852e15837525a2fc82bc(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))(@tiptap/extension-image@2.11.7(@tiptap/core@2.11.7(@tiptap/pm@2.11.7)))(@tiptap/extension-link@2.11.7(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))(@tiptap/pm@2.11.7))(@tiptap/pm@2.11.7)(linkifyjs@4.2.0)(nostr-tools@2.12.0(typescript@5.8.2))(prosemirror-markdown@1.13.2)(prosemirror-model@1.25.0)(prosemirror-state@1.4.3)(tiptap-markdown@0.8.10(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))): + nostr-editor@https://codeload.github.com/cesardeazevedo/nostr-editor/tar.gz/98f579b93bd2b5a3344df42f769d2ea4c5d8cf55(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))(@tiptap/extension-image@2.11.7(@tiptap/core@2.11.7(@tiptap/pm@2.11.7)))(@tiptap/extension-link@2.11.7(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))(@tiptap/pm@2.11.7))(@tiptap/pm@2.11.7)(linkifyjs@4.2.0)(nostr-tools@2.14.2(typescript@5.8.2))(prosemirror-markdown@1.13.2)(prosemirror-model@1.25.0)(prosemirror-state@1.4.3)(tiptap-markdown@0.8.10(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))): dependencies: - '@noble/ciphers': 1.3.0 - '@noble/hashes': 1.8.0 '@tiptap/core': 2.11.7(@tiptap/pm@2.11.7) '@tiptap/extension-image': 2.11.7(@tiptap/core@2.11.7(@tiptap/pm@2.11.7)) '@tiptap/extension-link': 2.11.7(@tiptap/core@2.11.7(@tiptap/pm@2.11.7))(@tiptap/pm@2.11.7) @@ -4233,7 +4219,7 @@ snapshots: js-base64: 3.7.7 light-bolt11-decoder: 3.2.0 linkifyjs: 4.2.0 - nostr-tools: 2.12.0(typescript@5.8.2) + nostr-tools: 2.14.2(typescript@5.8.2) prosemirror-markdown: 1.13.2 prosemirror-model: 1.25.0 prosemirror-state: 1.4.3 @@ -4243,7 +4229,7 @@ snapshots: dependencies: '@capacitor/core': 7.2.0 - nostr-tools@2.12.0(typescript@5.8.2): + nostr-tools@2.14.2(typescript@5.8.2): dependencies: '@noble/ciphers': 0.5.3 '@noble/curves': 1.2.0 @@ -4251,8 +4237,8 @@ snapshots: '@scure/base': 1.1.1 '@scure/bip32': 1.3.1 '@scure/bip39': 1.2.1 - optionalDependencies: nostr-wasm: 0.1.0 + optionalDependencies: typescript: 5.8.2 nostr-wasm@0.1.0: {}