@nostrify/react 0.2.11 → 0.2.13

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.
Files changed (84) hide show
  1. package/.turbo/turbo-build.log +22 -2
  2. package/.turbo/turbo-setup.log +13 -0
  3. package/.turbo/turbo-test.log +13 -0
  4. package/CHANGELOG.md +18 -0
  5. package/example/useAuthor.ts +3 -2
  6. package/example/useCurrentUser.ts +2 -2
  7. package/example/useSocialFeed.ts +2 -2
  8. package/login/NLogin.ts +3 -1
  9. package/login/NUser.ts +4 -2
  10. package/login/NostrLoginContext.ts +1 -1
  11. package/login/NostrLoginProvider.ts +2 -2
  12. package/login/mod.ts +4 -4
  13. package/login/nostrLoginReducer.ts +1 -1
  14. package/login/useNostrLogin.ts +1 -1
  15. package/login/useNostrLoginReducer.ts +2 -2
  16. package/mod.ts +3 -2
  17. package/package.json +9 -7
  18. package/tsconfig.json +7 -1
  19. package/useNostr.ts +1 -1
  20. package/dist/NostrContext.d.ts +0 -13
  21. package/dist/NostrContext.d.ts.map +0 -1
  22. package/dist/NostrContext.js +0 -7
  23. package/dist/NostrContext.js.map +0 -1
  24. package/dist/example/test-helpers.d.ts +0 -2
  25. package/dist/example/test-helpers.d.ts.map +0 -1
  26. package/dist/example/test-helpers.js +0 -31
  27. package/dist/example/test-helpers.js.map +0 -1
  28. package/dist/example/useAuthor.d.ts +0 -5
  29. package/dist/example/useAuthor.d.ts.map +0 -1
  30. package/dist/example/useAuthor.js +0 -27
  31. package/dist/example/useAuthor.js.map +0 -1
  32. package/dist/example/useCurrentUser.d.ts +0 -9
  33. package/dist/example/useCurrentUser.d.ts.map +0 -1
  34. package/dist/example/useCurrentUser.js +0 -42
  35. package/dist/example/useCurrentUser.js.map +0 -1
  36. package/dist/example/useLoginActions.d.ts +0 -6
  37. package/dist/example/useLoginActions.d.ts.map +0 -1
  38. package/dist/example/useLoginActions.js +0 -21
  39. package/dist/example/useLoginActions.js.map +0 -1
  40. package/dist/example/useSocialFeed.d.ts +0 -4
  41. package/dist/example/useSocialFeed.d.ts.map +0 -1
  42. package/dist/example/useSocialFeed.js +0 -10
  43. package/dist/example/useSocialFeed.js.map +0 -1
  44. package/dist/login/NLogin.d.ts +0 -46
  45. package/dist/login/NLogin.d.ts.map +0 -1
  46. package/dist/login/NLogin.js +0 -72
  47. package/dist/login/NLogin.js.map +0 -1
  48. package/dist/login/NUser.d.ts +0 -22
  49. package/dist/login/NUser.d.ts.map +0 -1
  50. package/dist/login/NUser.js +0 -37
  51. package/dist/login/NUser.js.map +0 -1
  52. package/dist/login/NostrLoginContext.d.ts +0 -24
  53. package/dist/login/NostrLoginContext.d.ts.map +0 -1
  54. package/dist/login/NostrLoginContext.js +0 -7
  55. package/dist/login/NostrLoginContext.js.map +0 -1
  56. package/dist/login/NostrLoginProvider.d.ts +0 -15
  57. package/dist/login/NostrLoginProvider.d.ts.map +0 -1
  58. package/dist/login/NostrLoginProvider.js +0 -19
  59. package/dist/login/NostrLoginProvider.js.map +0 -1
  60. package/dist/login/mod.d.ts +0 -5
  61. package/dist/login/mod.d.ts.map +0 -1
  62. package/dist/login/mod.js +0 -5
  63. package/dist/login/mod.js.map +0 -1
  64. package/dist/login/nostrLoginReducer.d.ts +0 -16
  65. package/dist/login/nostrLoginReducer.d.ts.map +0 -1
  66. package/dist/login/nostrLoginReducer.js +0 -26
  67. package/dist/login/nostrLoginReducer.js.map +0 -1
  68. package/dist/login/useNostrLogin.d.ts +0 -3
  69. package/dist/login/useNostrLogin.d.ts.map +0 -1
  70. package/dist/login/useNostrLogin.js +0 -10
  71. package/dist/login/useNostrLogin.js.map +0 -1
  72. package/dist/login/useNostrLoginReducer.d.ts +0 -4
  73. package/dist/login/useNostrLoginReducer.d.ts.map +0 -1
  74. package/dist/login/useNostrLoginReducer.js +0 -13
  75. package/dist/login/useNostrLoginReducer.js.map +0 -1
  76. package/dist/mod.d.ts +0 -3
  77. package/dist/mod.d.ts.map +0 -1
  78. package/dist/mod.js +0 -3
  79. package/dist/mod.js.map +0 -1
  80. package/dist/tsconfig.tsbuildinfo +0 -1
  81. package/dist/useNostr.d.ts +0 -3
  82. package/dist/useNostr.d.ts.map +0 -1
  83. package/dist/useNostr.js +0 -10
  84. package/dist/useNostr.js.map +0 -1
@@ -1,5 +1,25 @@
1
1
 
2
2
 
3
- > @nostrify/react@0.2.11 build /home/sid/repos/NSpec/packages/react
4
- > tsc -p tsconfig.json
3
+ > @nostrify/react@0.2.12 build /home/sid/repos/nostrify/packages/react
4
+ > tsc -p tsconfig.json && node ../../esbuild.config.js --package ./
5
5
 
6
+
7
+ dist/login/NLogin.js 2.0kb
8
+ dist/example/test-helpers.js 1.2kb
9
+ dist/example/useCurrentUser.js 1.1kb
10
+ dist/login/NUser.js 978b 
11
+ dist/example/useAuthor.js 829b 
12
+ dist/login/nostrLoginReducer.js 743b 
13
+ dist/login/NostrLoginProvider.js 669b 
14
+ dist/example/useLoginActions.js 560b 
15
+ dist/login/useNostrLoginReducer.js 486b 
16
+ dist/example/useSocialFeed.js 370b 
17
+ dist/login/useNostrLogin.js 321b 
18
+ dist/useNostr.js 286b 
19
+ dist/login/mod.js 257b 
20
+ dist/mod.js 163b 
21
+ dist/login/NostrLoginContext.js 120b 
22
+ dist/NostrContext.js 114b 
23
+ dist/example/vite-env.d.js 0b 
24
+
25
+ ⚡ Done in 39ms
@@ -0,0 +1,13 @@
1
+
2
+
3
+ > @nostrify/react@0.2.11 setup /home/sid/repos/nostrify/packages/react
4
+ > pnpm i
5
+
6
+ (node:1234100) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
7
+ (Use `node --trace-deprecation ...` to show where the warning was created)
8
+ Scope: all 9 workspace projects
9
+ ../.. | Progress: resolved 1, reused 0, downloaded 0, added 0
10
+ ../.. | +1 +
11
+ ../.. | Progress: resolved 1, reused 0, downloaded 0, added 0
12
+ ../.. | Progress: resolved 1, reused 1, downloaded 0, added 0
13
+ ../.. | Progress: resolved 1, reused 1, downloaded 0, added 0, done
@@ -0,0 +1,13 @@
1
+
2
+
3
+ > @nostrify/react@0.2.12 test /home/sid/repos/nostrify/packages/react
4
+ > node --test "**/*.test.ts"
5
+
6
+ ℹ tests 0
7
+ ℹ suites 0
8
+ ℹ pass 0
9
+ ℹ fail 0
10
+ ℹ cancelled 0
11
+ ℹ skipped 0
12
+ ℹ todo 0
13
+ ℹ duration_ms 11.763475
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @nostrify/react
2
2
 
3
+ ## 0.2.13
4
+
5
+ ### Patch Changes
6
+
7
+ - tests should pass now
8
+ - Updated dependencies
9
+ - @nostrify/nostrify@0.46.9
10
+ - @nostrify/types@0.36.5
11
+
12
+ ## 0.2.12
13
+
14
+ ### Patch Changes
15
+
16
+ - Get tests passing in CI, use esbuild to build final JS files
17
+ - Updated dependencies
18
+ - @nostrify/nostrify@0.46.8
19
+ - @nostrify/types@0.36.4
20
+
3
21
  ## 0.2.11
4
22
 
5
23
  ### Patch Changes
@@ -1,7 +1,8 @@
1
- import { type NostrEvent, type NostrMetadata, NSchema as n } from '@nostrify/nostrify';
1
+ import { NSchema as n } from '@nostrify/nostrify';
2
+ import type { NostrEvent, NostrMetadata } from '@nostrify/types';
2
3
  import { useSuspenseQuery } from '@tanstack/react-query';
3
4
 
4
- import { useNostr } from '../useNostr.js';
5
+ import { useNostr } from '../useNostr.ts';
5
6
 
6
7
  export function useAuthor(
7
8
  pubkey: string | undefined,
@@ -1,8 +1,8 @@
1
1
  import { type NLoginType, NUser, useNostrLogin } from '@nostrify/react/login';
2
2
  import { useMemo } from 'react';
3
3
 
4
- import { useAuthor } from './useAuthor.js';
5
- import { useNostr } from '../useNostr.js';
4
+ import { useAuthor } from './useAuthor.ts';
5
+ import { useNostr } from '../useNostr.ts';
6
6
 
7
7
  export function useCurrentUser() {
8
8
  const { nostr } = useNostr();
@@ -1,8 +1,8 @@
1
1
  import { useSuspenseQuery, type UseSuspenseQueryResult } from '@tanstack/react-query';
2
2
 
3
- import { useNostr } from '../useNostr.js';
3
+ import { useNostr } from '../useNostr.ts';
4
4
 
5
- import type { NostrEvent } from '@nostrify/nostrify';
5
+ import type { NostrEvent } from '@nostrify/types';
6
6
 
7
7
  export function useSocialFeed(): UseSuspenseQueryResult<NostrEvent[]> {
8
8
  const { nostr } = useNostr();
package/login/NLogin.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { BunkerURI, NConnectSigner, type NostrSigner, type NPool, NSecSigner } from '@nostrify/nostrify';
1
+ import { BunkerURI, NConnectSigner, NSecSigner } from '@nostrify/nostrify';
2
+ import type { NPool } from '@nostrify/nostrify';
2
3
  import { generateSecretKey, getPublicKey, nip19 } from 'nostr-tools';
4
+ import type { NostrSigner } from '@nostrify/types';
3
5
 
4
6
  /** An object represeting any supported Nostr login credentials. */
5
7
  export type NLoginType = NLoginNsec | NLoginBunker | NLoginExtension | NLoginOther;
package/login/NUser.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { NBrowserSigner, NConnectSigner, type NostrSigner, type NPool, NSecSigner } from '@nostrify/nostrify';
1
+ import { NBrowserSigner, NConnectSigner, NSecSigner } from '@nostrify/nostrify';
2
2
  import { nip19 } from 'nostr-tools';
3
+ import type { NPool } from '@nostrify/nostrify';
4
+ import type { NostrSigner } from '@nostrify/types';
3
5
 
4
- import type { NLoginBunker, NLoginExtension, NLoginNsec } from './NLogin.js';
6
+ import type { NLoginBunker, NLoginExtension, NLoginNsec } from './NLogin.ts';
5
7
 
6
8
  /** Represents a Nostr user with authentication credentials. */
7
9
  export class NUser {
@@ -1,6 +1,6 @@
1
1
  import { type Context, createContext } from 'react';
2
2
 
3
- import type { NLoginType } from './NLogin.js';
3
+ import type { NLoginType } from './NLogin.ts';
4
4
 
5
5
  /**
6
6
  * NostrLoginContextType defines the shape of the context that will be provided
@@ -1,7 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
 
3
- import { NostrLoginContext, NostrLoginContextType } from './NostrLoginContext.js';
4
- import { useNostrLoginReducer } from './useNostrLoginReducer.js';
3
+ import { NostrLoginContext, NostrLoginContextType } from './NostrLoginContext.ts';
4
+ import { useNostrLoginReducer } from './useNostrLoginReducer.ts';
5
5
 
6
6
  import type { FC, ReactNode } from 'react';
7
7
 
package/login/mod.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { NLogin, type NLoginType } from './NLogin.js';
2
- export { NostrLoginProvider } from './NostrLoginProvider.js';
3
- export { NUser } from './NUser.js';
4
- export { useNostrLogin } from './useNostrLogin.js';
1
+ export { NLogin, type NLoginType } from './NLogin.ts';
2
+ export { NostrLoginProvider } from './NostrLoginProvider.ts';
3
+ export { NUser } from './NUser.ts';
4
+ export { useNostrLogin } from './useNostrLogin.ts';
@@ -1,4 +1,4 @@
1
- import type { NLoginType } from './NLogin.js';
1
+ import type { NLoginType } from './NLogin.ts';
2
2
 
3
3
  export type NLoginAction =
4
4
  | { type: 'login.add'; login: NLoginType; set?: boolean }
@@ -1,6 +1,6 @@
1
1
  import { useContext } from 'react';
2
2
 
3
- import { NostrLoginContext, type NostrLoginContextType } from './NostrLoginContext.js';
3
+ import { NostrLoginContext, type NostrLoginContextType } from './NostrLoginContext.ts';
4
4
 
5
5
  export function useNostrLogin(): NostrLoginContextType {
6
6
  const context = useContext(NostrLoginContext);
@@ -1,8 +1,8 @@
1
1
  import { useEffect, useReducer } from 'react';
2
2
 
3
- import { type NLoginAction, nostrLoginReducer } from './nostrLoginReducer.js';
3
+ import { type NLoginAction, nostrLoginReducer } from './nostrLoginReducer.ts';
4
4
 
5
- import type { NLoginType } from './NLogin.js';
5
+ import type { NLoginType } from './NLogin.ts';
6
6
 
7
7
  export function useNostrLoginReducer(
8
8
  storageKey: string,
package/mod.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { NostrContext, type NostrContextType } from './NostrContext.js';
2
- export { useNostr } from './useNostr.js';
1
+ export { NostrContext, type NostrContextType } from './NostrContext.ts';
2
+ export { useNostr } from './useNostr.ts';
3
+ export * from './login/mod.ts';
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@nostrify/react",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "exports": {
5
- ".": "./dist/mod.js",
6
- "./login": "./dist/login/mod.js"
5
+ ".": "./dist/mod.ts",
6
+ "./login": "./dist/login/mod.ts"
7
7
  },
8
- "main": "dist/mod.js",
8
+ "main": "./mod.ts",
9
9
  "types": "dist/mod.d.ts",
10
10
  "type": "module",
11
11
  "devDependencies": {
@@ -21,13 +21,15 @@
21
21
  "react": "^18.0.0",
22
22
  "react-dom": "^18.0.0",
23
23
  "nostr-tools": "^2.13.0",
24
- "@nostrify/types": "0.36.3",
25
- "@nostrify/nostrify": "0.46.7"
24
+ "@nostrify/types": "0.36.5",
25
+ "@nostrify/nostrify": "0.46.9"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
30
  "scripts": {
31
- "build": "tsc -p tsconfig.json"
31
+ "build": "npx tsc -p tsconfig.json && node ../../esbuild.config.js --package ./",
32
+ "setup": "pnpm i",
33
+ "test": "node --test \"**/*.test.ts\""
32
34
  }
33
35
  }
package/tsconfig.json CHANGED
@@ -10,5 +10,11 @@
10
10
  },
11
11
  "include": [
12
12
  "./**/*.ts"
13
+ ],
14
+ "exclude": [
15
+ "**/*.test.ts",
16
+ "**/*.bench.ts",
17
+ "example",
18
+ "dist"
13
19
  ]
14
- }
20
+ }
package/useNostr.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { useContext } from 'react';
2
2
 
3
- import { NostrContext, type NostrContextType } from './NostrContext.js';
3
+ import { NostrContext, type NostrContextType } from './NostrContext.ts';
4
4
 
5
5
  export function useNostr(): NostrContextType {
6
6
  const context = useContext(NostrContext);
@@ -1,13 +0,0 @@
1
- import { type Context } from 'react';
2
- import type { NPool } from '@nostrify/nostrify';
3
- /** The shape of the Nostr context provided by NostrProvider. */
4
- export interface NostrContextType {
5
- /** The Nostr relay pool for querying and publishing events */
6
- nostr: NPool;
7
- }
8
- /**
9
- * React context for Nostr functionality.
10
- * Use this with useContext or the useNostr hook to access Nostr features.
11
- */
12
- export declare const NostrContext: Context<NostrContextType | undefined>;
13
- //# sourceMappingURL=NostrContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NostrContext.d.ts","sourceRoot":"","sources":["../NostrContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAE9D,CAAC"}
@@ -1,7 +0,0 @@
1
- import { createContext } from 'react';
2
- /**
3
- * React context for Nostr functionality.
4
- * Use this with useContext or the useNostr hook to access Nostr features.
5
- */
6
- export const NostrContext = createContext(undefined);
7
- //# sourceMappingURL=NostrContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NostrContext.js","sourceRoot":"","sources":["../NostrContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,aAAa,EAAE,MAAM,OAAO,CAAC;AAUpD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAA0C,aAAa,CAC9E,SAAS,CACV,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function polyfillDOM(): void;
2
- //# sourceMappingURL=test-helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../../example/test-helpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,IAAI,IAAI,CA8BlC"}
@@ -1,31 +0,0 @@
1
- import { PropertySymbol, Window } from 'happy-dom';
2
- export function polyfillDOM() {
3
- const window = new Window();
4
- const document = window.document;
5
- const browserWindow = document[PropertySymbol.window];
6
- const setInnerHTML = (html) => document.documentElement.innerHTML = html;
7
- const cancelAsync = () => window.happyDOM.abort();
8
- Object.assign(globalThis, {
9
- window,
10
- document,
11
- HTMLElement: browserWindow.HTMLElement,
12
- Element: browserWindow.Element,
13
- Node: browserWindow.Node,
14
- navigator: browserWindow.navigator,
15
- DocumentFragment: browserWindow.DocumentFragment,
16
- DocumentType: browserWindow.DocumentType,
17
- SVGElement: browserWindow.SVGElement,
18
- Text: browserWindow.Text,
19
- requestAnimationFrame: browserWindow.requestAnimationFrame,
20
- cancelAnimationFrame: browserWindow.cancelAnimationFrame,
21
- setTimeout: browserWindow.setTimeout,
22
- clearTimeout: browserWindow.clearTimeout,
23
- setInterval: browserWindow.setInterval,
24
- clearInterval: browserWindow.clearInterval,
25
- queueMicrotask: browserWindow.queueMicrotask,
26
- AbortController: browserWindow.AbortController,
27
- cancelAsync,
28
- setInnerHTML,
29
- });
30
- }
31
- //# sourceMappingURL=test-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../../example/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,UAAU,WAAW;IACzB,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,MAAM,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAEtD,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,GAAG,IAAI,CAAC;IACjF,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAElD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;QACxB,MAAM;QACN,QAAQ;QACR,WAAW,EAAE,aAAa,CAAC,WAAW;QACtC,OAAO,EAAE,aAAa,CAAC,OAAO;QAC9B,IAAI,EAAE,aAAa,CAAC,IAAI;QACxB,SAAS,EAAE,aAAa,CAAC,SAAS;QAClC,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;QAChD,YAAY,EAAE,aAAa,CAAC,YAAY;QACxC,UAAU,EAAE,aAAa,CAAC,UAAU;QACpC,IAAI,EAAE,aAAa,CAAC,IAAI;QACxB,qBAAqB,EAAE,aAAa,CAAC,qBAAqB;QAC1D,oBAAoB,EAAE,aAAa,CAAC,oBAAoB;QACxD,UAAU,EAAE,aAAa,CAAC,UAAU;QACpC,YAAY,EAAE,aAAa,CAAC,YAAY;QACxC,WAAW,EAAE,aAAa,CAAC,WAAW;QACtC,aAAa,EAAE,aAAa,CAAC,aAAa;QAC1C,cAAc,EAAE,aAAa,CAAC,cAAc;QAC5C,eAAe,EAAE,aAAa,CAAC,eAAe;QAC9C,WAAW;QACX,YAAY;KACb,CAAC,CAAC;AACL,CAAC"}
@@ -1,5 +0,0 @@
1
- import { type NostrEvent, type NostrMetadata } from '@nostrify/nostrify';
2
- export declare function useAuthor(pubkey: string | undefined): NostrMetadata & {
3
- event?: NostrEvent;
4
- };
5
- //# sourceMappingURL=useAuthor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAuthor.d.ts","sourceRoot":"","sources":["../../example/useAuthor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAgB,MAAM,oBAAoB,CAAC;AAKvF,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,aAAa,GAAG;IAAE,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,CA6BxC"}
@@ -1,27 +0,0 @@
1
- import { NSchema as n } from '@nostrify/nostrify';
2
- import { useSuspenseQuery } from '@tanstack/react-query';
3
- import { useNostr } from '../useNostr.js';
4
- export function useAuthor(pubkey) {
5
- const { nostr } = useNostr();
6
- const { data } = useSuspenseQuery({
7
- queryKey: ['author', pubkey ?? ''],
8
- queryFn: async ({ signal }) => {
9
- if (!pubkey) {
10
- return {};
11
- }
12
- const [event] = await nostr.query([{ kinds: [0], authors: [pubkey], limit: 1 }], { signal: AbortSignal.any([signal, AbortSignal.timeout(500)]) });
13
- if (!event) {
14
- return {};
15
- }
16
- try {
17
- const metadata = n.json().pipe(n.metadata()).parse(event.content);
18
- return { ...metadata, event };
19
- }
20
- catch {
21
- return { event };
22
- }
23
- },
24
- });
25
- return data;
26
- }
27
- //# sourceMappingURL=useAuthor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAuthor.js","sourceRoot":"","sources":["../../example/useAuthor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,OAAO,IAAI,CAAC,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,UAAU,SAAS,CACvB,MAA0B;IAE1B,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAE7B,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAyC;QACxE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAC;QAClC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,KAAK,CAAC,KAAK,CAC/B,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,MAAO,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAC9C,EAAE,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAChE,CAAC;YAEF,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAClE,OAAO,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,CAAC;YAChC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,9 +0,0 @@
1
- import { NUser } from '@nostrify/react/login';
2
- export declare function useCurrentUser(): {
3
- user: NUser;
4
- users: NUser[];
5
- metadata: import("@nostrify/types").NostrMetadata & {
6
- event?: import("@nostrify/types").NostrEvent;
7
- };
8
- };
9
- //# sourceMappingURL=useCurrentUser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCurrentUser.d.ts","sourceRoot":"","sources":["../../example/useCurrentUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAiB,MAAM,uBAAuB,CAAC;AAM9E,wBAAgB,cAAc;;;;;;EAyC7B"}
@@ -1,42 +0,0 @@
1
- import { NUser, useNostrLogin } from '@nostrify/react/login';
2
- import { useMemo } from 'react';
3
- import { useAuthor } from './useAuthor.js';
4
- import { useNostr } from '../useNostr.js';
5
- export function useCurrentUser() {
6
- const { nostr } = useNostr();
7
- const { logins } = useNostrLogin();
8
- function loginToUser(login) {
9
- switch (login.type) {
10
- case 'nsec':
11
- return NUser.fromNsecLogin(login);
12
- case 'bunker':
13
- return NUser.fromBunkerLogin(login, nostr);
14
- case 'extension':
15
- return NUser.fromExtensionLogin(login);
16
- default:
17
- // Learn how to define other login types: https://nostrify.dev/react/logins#custom-login-types
18
- throw new Error(`Unsupported login type: ${login.type}`);
19
- }
20
- }
21
- const users = useMemo(() => {
22
- const users = [];
23
- for (const login of logins) {
24
- try {
25
- const user = loginToUser(login);
26
- users.push(user);
27
- }
28
- catch (error) {
29
- console.warn('Skipped invalid login', login.id, error);
30
- }
31
- }
32
- return users;
33
- }, [logins, nostr]);
34
- const user = users[0];
35
- const metadata = useAuthor(user?.pubkey);
36
- return {
37
- user,
38
- users,
39
- metadata,
40
- };
41
- }
42
- //# sourceMappingURL=useCurrentUser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCurrentUser.js","sourceRoot":"","sources":["../../example/useCurrentUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,UAAU,cAAc;IAC5B,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAC;IAEnC,SAAS,WAAW,CAAC,KAAiB;QACpC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,MAAM;gBACT,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACpC,KAAK,QAAQ;gBACX,OAAO,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC7C,KAAK,WAAW;gBACd,OAAO,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YACzC;gBACE,8FAA8F;gBAC9F,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,MAAM,KAAK,GAAY,EAAE,CAAC;QAE1B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;gBAChC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAEpB,MAAM,IAAI,GAAsB,KAAK,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAEzC,OAAO;QACL,IAAI;QACJ,KAAK;QACL,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -1,6 +0,0 @@
1
- export declare function useLoginActions(): {
2
- nsec(nsec: string): void;
3
- bunker(uri: string): Promise<void>;
4
- extension(): Promise<void>;
5
- };
6
- //# sourceMappingURL=useLoginActions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLoginActions.d.ts","sourceRoot":"","sources":["../../example/useLoginActions.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe;eAKhB,MAAM,GAAG,IAAI;gBAIN,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;iBAIrB,OAAO,CAAC,IAAI,CAAC;EAKnC"}
@@ -1,21 +0,0 @@
1
- import { useNostr } from '@nostrify/react';
2
- import { NLogin, useNostrLogin } from '@nostrify/react/login';
3
- export function useLoginActions() {
4
- const { nostr } = useNostr();
5
- const { addLogin } = useNostrLogin();
6
- return {
7
- nsec(nsec) {
8
- const login = NLogin.fromNsec(nsec);
9
- addLogin(login);
10
- },
11
- async bunker(uri) {
12
- const login = await NLogin.fromBunker(uri, nostr);
13
- addLogin(login);
14
- },
15
- async extension() {
16
- const login = await NLogin.fromExtension();
17
- addLogin(login);
18
- },
19
- };
20
- }
21
- //# sourceMappingURL=useLoginActions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLoginActions.js","sourceRoot":"","sources":["../../example/useLoginActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,UAAU,eAAe;IAC7B,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC7B,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;IAErC,OAAO;QACL,IAAI,CAAC,IAAY;YACf,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACpC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,GAAW;YACtB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAClD,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;QACD,KAAK,CAAC,SAAS;YACb,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;YAC3C,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,4 +0,0 @@
1
- import { type UseSuspenseQueryResult } from '@tanstack/react-query';
2
- import type { NostrEvent } from '@nostrify/nostrify';
3
- export declare function useSocialFeed(): UseSuspenseQueryResult<NostrEvent[]>;
4
- //# sourceMappingURL=useSocialFeed.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSocialFeed.d.ts","sourceRoot":"","sources":["../../example/useSocialFeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAItF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,wBAAgB,aAAa,IAAI,sBAAsB,CAAC,UAAU,EAAE,CAAC,CAWpE"}
@@ -1,10 +0,0 @@
1
- import { useSuspenseQuery } from '@tanstack/react-query';
2
- import { useNostr } from '../useNostr.js';
3
- export function useSocialFeed() {
4
- const { nostr } = useNostr();
5
- return useSuspenseQuery({
6
- queryKey: ['social-feed'],
7
- queryFn: () => nostr.query([{ kinds: [1], limit: 5 }], { signal: AbortSignal.timeout(5000) }),
8
- });
9
- }
10
- //# sourceMappingURL=useSocialFeed.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSocialFeed.js","sourceRoot":"","sources":["../../example/useSocialFeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA+B,MAAM,uBAAuB,CAAC;AAEtF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,MAAM,UAAU,aAAa;IAC3B,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAE7B,OAAO,gBAAgB,CAAC;QACtB,QAAQ,EAAE,CAAC,aAAa,CAAC;QACzB,OAAO,EAAE,GAAG,EAAE,CACZ,KAAK,CAAC,KAAK,CACT,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAC1B,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CACtC;KACJ,CAAC,CAAC;AACL,CAAC"}
@@ -1,46 +0,0 @@
1
- import { type NPool } from '@nostrify/nostrify';
2
- /** An object represeting any supported Nostr login credentials. */
3
- export type NLoginType = NLoginNsec | NLoginBunker | NLoginExtension | NLoginOther;
4
- /** Nostr login with nsec. */
5
- export type NLoginNsec = NLoginBase<'nsec', {
6
- nsec: `nsec1${string}`;
7
- }>;
8
- /** NIP-46 (aka remote signer) login. */
9
- export type NLoginBunker = NLoginBase<'bunker', {
10
- bunkerPubkey: string;
11
- clientNsec: `nsec1${string}`;
12
- relays: string[];
13
- }>;
14
- /** NIP-07 (browser extension) login. */
15
- export type NLoginExtension = NLoginBase<'extension', null>;
16
- /** Additional login types created by the library user. */
17
- export type NLoginOther = NLoginBase<`x-${string}`, {
18
- [key: string]: unknown;
19
- }>;
20
- /** Base properties shared by Nostr login objects. */
21
- interface NLoginBase<T extends string, D> {
22
- id: string;
23
- type: T;
24
- pubkey: string;
25
- createdAt: string;
26
- data: D;
27
- }
28
- /** Class representing Nostr login credentials. */
29
- export declare class NLogin<T extends string, D> implements NLoginBase<T, D> {
30
- id: string;
31
- type: T;
32
- pubkey: string;
33
- createdAt: string;
34
- data: D;
35
- constructor(type: T, pubkey: string, data: D);
36
- /** Create a login object from an nsec. */
37
- static fromNsec(nsec: string): NLoginNsec;
38
- /** Create a login object from a bunker URI. */
39
- static fromBunker(uri: string, pool: NPool): Promise<NLoginBunker>;
40
- /** Create a login object from a browser extension. */
41
- static fromExtension(): Promise<NLoginExtension>;
42
- /** Convert to a JSON-serializable object. */
43
- toJSON(): NLoginBase<T, D>;
44
- }
45
- export {};
46
- //# sourceMappingURL=NLogin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NLogin.d.ts","sourceRoot":"","sources":["../../login/NLogin.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,KAAK,KAAK,EAAc,MAAM,oBAAoB,CAAC;AAGzG,mEAAmE;AACnE,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,eAAe,GAAG,WAAW,CAAC;AAEnF,6BAA6B;AAC7B,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,EAAE;IAC1C,IAAI,EAAE,QAAQ,MAAM,EAAE,CAAC;CACxB,CAAC,CAAC;AAEH,wCAAwC;AACxC,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,QAAQ,EAAE;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,QAAQ,MAAM,EAAE,CAAC;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC,CAAC;AAEH,wCAAwC;AACxC,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAE5D,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,MAAM,EAAE,EAAE;IAClD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC,CAAC;AAEH,qDAAqD;AACrD,UAAU,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,CAAC,CAAC;CACT;AAED,kDAAkD;AAClD,qBAAa,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,CAAE,YAAW,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,CAAC,CAAC;gBAEH,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAQ5C,0CAA0C;IAC1C,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAezC,+CAA+C;WAClC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC;IA4BxE,sDAAsD;WACzC,aAAa,IAAI,OAAO,CAAC,eAAe,CAAC;IAYtD,6CAA6C;IAC7C,MAAM,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;CAS3B"}