@coinlist-co/react 0.0.1

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 (47) hide show
  1. package/README.md +7 -0
  2. package/dist/chunk-5E3P7AMH.js +20 -0
  3. package/dist/chunk-5E3P7AMH.js.map +1 -0
  4. package/dist/chunk-F56RBKNS.js +63 -0
  5. package/dist/chunk-F56RBKNS.js.map +1 -0
  6. package/dist/chunk-NLJMUHOG.js +253 -0
  7. package/dist/chunk-NLJMUHOG.js.map +1 -0
  8. package/dist/chunk-OETRTIQ4.js +274 -0
  9. package/dist/chunk-OETRTIQ4.js.map +1 -0
  10. package/dist/chunk-YJQMJFA7.js +16 -0
  11. package/dist/chunk-YJQMJFA7.js.map +1 -0
  12. package/dist/client/components/index.cjs +445 -0
  13. package/dist/client/components/index.cjs.map +1 -0
  14. package/dist/client/components/index.d.cts +19 -0
  15. package/dist/client/components/index.d.ts +19 -0
  16. package/dist/client/components/index.js +399 -0
  17. package/dist/client/components/index.js.map +1 -0
  18. package/dist/client/core/index.cjs +566 -0
  19. package/dist/client/core/index.cjs.map +1 -0
  20. package/dist/client/core/index.d.cts +22 -0
  21. package/dist/client/core/index.d.ts +22 -0
  22. package/dist/client/core/index.js +35 -0
  23. package/dist/client/core/index.js.map +1 -0
  24. package/dist/client/hooks/index.cjs +56 -0
  25. package/dist/client/hooks/index.cjs.map +1 -0
  26. package/dist/client/hooks/index.d.cts +14 -0
  27. package/dist/client/hooks/index.d.ts +14 -0
  28. package/dist/client/hooks/index.js +9 -0
  29. package/dist/client/hooks/index.js.map +1 -0
  30. package/dist/client/index.cjs +621 -0
  31. package/dist/client/index.cjs.map +1 -0
  32. package/dist/client/index.d.cts +18 -0
  33. package/dist/client/index.d.ts +18 -0
  34. package/dist/client/index.js +41 -0
  35. package/dist/client/index.js.map +1 -0
  36. package/dist/client/styles.css +2 -0
  37. package/dist/coinlist-client-BH_Cn_7u.d.cts +71 -0
  38. package/dist/coinlist-client-fkB3J-2a.d.ts +71 -0
  39. package/dist/oauth-session-g0OPJNKn.d.cts +59 -0
  40. package/dist/oauth-session-g0OPJNKn.d.ts +59 -0
  41. package/dist/server/index.cjs +405 -0
  42. package/dist/server/index.cjs.map +1 -0
  43. package/dist/server/index.d.cts +37 -0
  44. package/dist/server/index.d.ts +37 -0
  45. package/dist/server/index.js +142 -0
  46. package/dist/server/index.js.map +1 -0
  47. package/package.json +122 -0
@@ -0,0 +1,22 @@
1
+ export { A as AuthState, C as ClientConfig, a as CoinListClient, O as OauthClientErrorReason, b as OauthClientResult, c as createCoinListClient } from '../../coinlist-client-fkB3J-2a.js';
2
+ import { N as Newtype } from '../../oauth-session-g0OPJNKn.js';
3
+ export { A as AuthorizationCode, C as ClientId, a as ClientSecret, b as CodeChallenge, c as CodeVerifier, O as OAuthAccessToken, d as OAuthRefreshToken, e as OAuthSession, R as RedirectUri } from '../../oauth-session-g0OPJNKn.js';
4
+
5
+ type UserDto = {
6
+ id: string;
7
+ email: string;
8
+ };
9
+
10
+ type UserId = Newtype<string, 'UserId'>;
11
+ declare const UserId: (value: string) => UserId;
12
+ type UserEmail = Newtype<string, 'UserEmail'>;
13
+ declare const UserEmail: (value: string) => UserEmail;
14
+ type User = {
15
+ id: UserId;
16
+ email: UserEmail;
17
+ };
18
+ declare const User: {
19
+ fromDto: (dto: UserDto) => User;
20
+ };
21
+
22
+ export { User, UserEmail, UserId };
@@ -0,0 +1,35 @@
1
+ import {
2
+ User,
3
+ UserEmail,
4
+ UserId
5
+ } from "../../chunk-YJQMJFA7.js";
6
+ import {
7
+ createCoinListClient
8
+ } from "../../chunk-OETRTIQ4.js";
9
+ import {
10
+ OAuthRefreshToken,
11
+ OAuthSession
12
+ } from "../../chunk-5E3P7AMH.js";
13
+ import {
14
+ AuthorizationCode,
15
+ ClientId,
16
+ ClientSecret,
17
+ CodeChallenge,
18
+ CodeVerifier,
19
+ RedirectUri
20
+ } from "../../chunk-NLJMUHOG.js";
21
+ export {
22
+ AuthorizationCode,
23
+ ClientId,
24
+ ClientSecret,
25
+ CodeChallenge,
26
+ CodeVerifier,
27
+ OAuthRefreshToken,
28
+ OAuthSession,
29
+ RedirectUri,
30
+ User,
31
+ UserEmail,
32
+ UserId,
33
+ createCoinListClient
34
+ };
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/client/hooks/index.ts
21
+ var hooks_exports = {};
22
+ __export(hooks_exports, {
23
+ useCoinList: () => useCoinList
24
+ });
25
+ module.exports = __toCommonJS(hooks_exports);
26
+
27
+ // src/client/hooks/useCoinList.ts
28
+ var import_react2 = require("react");
29
+
30
+ // src/client/CoinListProvider.tsx
31
+ var import_react = require("react");
32
+ var import_jsx_runtime = require("react/jsx-runtime");
33
+ var CoinListContext = (0, import_react.createContext)(null);
34
+
35
+ // src/client/hooks/useCoinList.ts
36
+ function useCoinList() {
37
+ const context = (0, import_react2.useContext)(CoinListContext);
38
+ if (context === null) {
39
+ throw new CoinListClientInitializationError();
40
+ }
41
+ return {
42
+ isReady: context.isReady,
43
+ coinlist: context.coinlist
44
+ };
45
+ }
46
+ var CoinListClientInitializationError = class extends Error {
47
+ constructor(message = "useCoinList() must be used within CoinListProvider. Wrap your app with <CoinListProvider config={...}>.") {
48
+ super(message);
49
+ this.name = "CoinListClientInitializationError";
50
+ }
51
+ };
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ useCoinList
55
+ });
56
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/hooks/index.ts","../../../src/client/hooks/useCoinList.ts","../../../src/client/CoinListProvider.tsx"],"sourcesContent":["export { useCoinList } from '@/client/hooks/useCoinList';\n","import { useContext } from 'react';\nimport { CoinListContext } from '@/client/CoinListProvider';\nimport type { CoinListClient } from '@/client/core/coinlist-client';\n\nexport interface UseCoinListResult {\n /**\n * Indicates whether the CoinList client has been initialized and ready to use.\n * While isReady is false, then the current user state will be `unknown`.\n */\n isReady: boolean;\n coinlist: CoinListClient;\n}\n\nexport function useCoinList(): UseCoinListResult {\n const context = useContext(CoinListContext);\n if (context === null) {\n throw new CoinListClientInitializationError();\n }\n\n return {\n isReady: context.isReady,\n coinlist: context.coinlist,\n };\n}\n\nexport class CoinListClientInitializationError extends Error {\n constructor(\n message = 'useCoinList() must be used within CoinListProvider. Wrap your app with <CoinListProvider config={...}>.'\n ) {\n super(message);\n this.name = 'CoinListClientInitializationError';\n }\n}\n","/**\n * Global CoinList initialization for React apps.\n * Wrap your app once at the root; use useCoinList() anywhere below.\n */\n\nimport {\n createContext,\n type ReactNode,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport {\n type ClientConfig,\n type CoinListClient,\n createCoinListClient,\n} from '@/client/core/coinlist-client';\n\nexport type CoinListContextValue = {\n coinlist: CoinListClient;\n isReady: boolean;\n};\n\nexport const CoinListContext = createContext<CoinListContextValue | null>(null);\n\nexport type CoinListProviderProps = {\n config: ClientConfig;\n children: ReactNode;\n};\n\n/**\n * Provide CoinList (api + config) to the tree. Initialize once at app root with your config.\n */\nexport function CoinListProvider({ config, children }: CoinListProviderProps) {\n const [isReady, setIsReady] = useState(false);\n const coinlist = useMemo(() => createCoinListClient(config), [config]);\n\n useEffect(() => {\n let isCancelled = false;\n if (coinlist.getAuthState() === 'unknown') {\n coinlist\n .init()\n .then(() => {\n if (!isCancelled) {\n setIsReady(true);\n }\n })\n .catch(() => {\n if (!isCancelled) {\n setIsReady(true);\n }\n });\n } else {\n setIsReady(true);\n }\n\n return () => {\n isCancelled = true;\n };\n }, [coinlist]);\n\n const value = useMemo(() => ({ coinlist, isReady }), [coinlist, isReady]);\n\n return (\n <CoinListContext.Provider value={value}>\n {children}\n </CoinListContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA2B;;;ACK3B,mBAMO;AAqDH;AAzCG,IAAM,sBAAkB,4BAA2C,IAAI;;;ADVvE,SAAS,cAAiC;AAC/C,QAAM,cAAU,0BAAW,eAAe;AAC1C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,kCAAkC;AAAA,EAC9C;AAEA,SAAO;AAAA,IACL,SAAS,QAAQ;AAAA,IACjB,UAAU,QAAQ;AAAA,EACpB;AACF;AAEO,IAAM,oCAAN,cAAgD,MAAM;AAAA,EAC3D,YACE,UAAU,2GACV;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;","names":["import_react"]}
@@ -0,0 +1,14 @@
1
+ import { a as CoinListClient } from '../../coinlist-client-BH_Cn_7u.cjs';
2
+ import '../../oauth-session-g0OPJNKn.cjs';
3
+
4
+ interface UseCoinListResult {
5
+ /**
6
+ * Indicates whether the CoinList client has been initialized and ready to use.
7
+ * While isReady is false, then the current user state will be `unknown`.
8
+ */
9
+ isReady: boolean;
10
+ coinlist: CoinListClient;
11
+ }
12
+ declare function useCoinList(): UseCoinListResult;
13
+
14
+ export { useCoinList };
@@ -0,0 +1,14 @@
1
+ import { a as CoinListClient } from '../../coinlist-client-fkB3J-2a.js';
2
+ import '../../oauth-session-g0OPJNKn.js';
3
+
4
+ interface UseCoinListResult {
5
+ /**
6
+ * Indicates whether the CoinList client has been initialized and ready to use.
7
+ * While isReady is false, then the current user state will be `unknown`.
8
+ */
9
+ isReady: boolean;
10
+ coinlist: CoinListClient;
11
+ }
12
+ declare function useCoinList(): UseCoinListResult;
13
+
14
+ export { useCoinList };
@@ -0,0 +1,9 @@
1
+ import {
2
+ useCoinList
3
+ } from "../../chunk-F56RBKNS.js";
4
+ import "../../chunk-OETRTIQ4.js";
5
+ import "../../chunk-NLJMUHOG.js";
6
+ export {
7
+ useCoinList
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}