@ckb-ccc/connector-react 0.0.2

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.
@@ -0,0 +1,12 @@
1
+ node_modules/
2
+
3
+ dist/
4
+
5
+ .npmignore
6
+ .prettierrc
7
+ tsconfig.json
8
+ eslint.config.mjs
9
+ .prettierrc
10
+
11
+ tsconfig.tsbuildinfo
12
+ .github/
@@ -0,0 +1,3 @@
1
+ export * from "./advancedBarrel";
2
+ export * as cccA from "./advancedBarrel";
3
+ //# sourceMappingURL=advanced.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../src/advanced.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./advancedBarrel";
2
+ export * as cccA from "./advancedBarrel";
@@ -0,0 +1,2 @@
1
+ export * from "@ckb-ccc/connector/advancedBarrel";
2
+ //# sourceMappingURL=advancedBarrel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "@ckb-ccc/connector/advancedBarrel";
@@ -0,0 +1,4 @@
1
+ export * from "@ckb-ccc/connector/barrel";
2
+ export * from "./components";
3
+ export * from "./hooks";
4
+ //# sourceMappingURL=barrel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
package/dist/barrel.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "@ckb-ccc/connector/barrel";
2
+ export * from "./components";
3
+ export * from "./hooks";
@@ -0,0 +1,7 @@
1
+ import { CloseEvent, ConnectedEvent, WebComponentConnector } from "@ckb-ccc/connector";
2
+ import { type EventName } from "@lit/react";
3
+ export declare const Connector: import("@lit/react").ReactWebComponent<WebComponentConnector, {
4
+ onConnected: EventName<ConnectedEvent>;
5
+ onClose: EventName<CloseEvent>;
6
+ }>;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,cAAc,EACd,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAG7D,eAAO,MAAM,SAAS;;;EAQpB,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { WebComponentConnector, } from "@ckb-ccc/connector";
3
+ import { createComponent } from "@lit/react";
4
+ import * as React from "react";
5
+ export const Connector = createComponent({
6
+ tagName: "ccc-connector",
7
+ elementClass: WebComponentConnector,
8
+ react: React,
9
+ events: {
10
+ onConnected: "connected",
11
+ onClose: "close",
12
+ },
13
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./useCcc";
2
+ export * from "./useSigner";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./useCcc";
2
+ export * from "./useSigner";
@@ -0,0 +1,12 @@
1
+ import { SignerInfo } from "@ckb-ccc/connector";
2
+ import * as React from "react";
3
+ import { ReactNode } from "react";
4
+ export declare function Provider({ children }: {
5
+ children: ReactNode;
6
+ }): React.JSX.Element;
7
+ export declare function useCcc(): {
8
+ open: () => unknown;
9
+ disconnect: () => unknown;
10
+ signerInfo?: SignerInfo | undefined;
11
+ };
12
+ //# sourceMappingURL=useCcc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCcc.d.ts","sourceRoot":"","sources":["../../src/hooks/useCcc.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAA2B,MAAM,OAAO,CAAC;AAS3D,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,qBAoB7D;AAED,wBAAgB,MAAM;;;;EAErB"}
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ import { createContext, useState } from "react";
4
+ import { Connector } from "../components";
5
+ const CCC_CONTEXT = createContext({ open: () => { }, disconnect: () => { } });
6
+ export function Provider({ children }) {
7
+ const [isOpen, setIsOpen] = useState(false);
8
+ const [signerInfo, setSignerInfo] = useState();
9
+ return (React.createElement(CCC_CONTEXT.Provider, { value: {
10
+ open: () => setIsOpen(true),
11
+ disconnect: () => setSignerInfo(undefined),
12
+ signerInfo,
13
+ } },
14
+ React.createElement(Connector, { isOpen: isOpen, onClose: () => setIsOpen(false), onConnected: ({ signerInfo }) => setSignerInfo(signerInfo) }),
15
+ children));
16
+ }
17
+ export function useCcc() {
18
+ return React.useContext(CCC_CONTEXT);
19
+ }
@@ -0,0 +1,2 @@
1
+ export declare function useSigner(): import("@ckb-ccc/core").Signer | undefined;
2
+ //# sourceMappingURL=useSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSigner.d.ts","sourceRoot":"","sources":["../../src/hooks/useSigner.tsx"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,+CAExB"}
@@ -0,0 +1,4 @@
1
+ import { useCcc } from "./useCcc";
2
+ export function useSigner() {
3
+ return useCcc().signerInfo?.signer;
4
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./barrel";
2
+ export * as ccc from "./barrel";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./barrel";
2
+ export * as ccc from "./barrel";
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@ckb-ccc/connector-react",
3
+ "version": "0.0.2",
4
+ "description": "Common Chains Connector UI Component for React",
5
+ "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
+ "license": "MIT",
7
+ "private": false,
8
+ "main": "dist/index.js",
9
+ "exports": {
10
+ ".": "./dist/index.js",
11
+ "./barrel": "./dist/barrel.js",
12
+ "./advancedBarrel": "./dist/advancedBarrel.js",
13
+ "./advanced": "./dist/advanced.js"
14
+ },
15
+ "scripts": {
16
+ "build": "rimraf ./dist && tsc",
17
+ "lint": "eslint",
18
+ "format": "prettier --write . && eslint --fix"
19
+ },
20
+ "devDependencies": {
21
+ "@eslint/js": "^9.1.1",
22
+ "@types/react": "^18",
23
+ "eslint": "^9.1.0",
24
+ "eslint-config-prettier": "^9.1.0",
25
+ "eslint-plugin-prettier": "^5.1.3",
26
+ "prettier": "^3.2.5",
27
+ "prettier-plugin-organize-imports": "^3.2.4",
28
+ "rimraf": "^5.0.5",
29
+ "typescript": "^5.4.5",
30
+ "typescript-eslint": "^7.7.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "@ckb-ccc/connector": "0.0.2",
37
+ "@lit/react": "^1.0.5",
38
+ "react": "^18"
39
+ },
40
+ "gitHead": "34b7f8d8443258188d47aad71246e787b544300b"
41
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./advancedBarrel";
2
+ export * as cccA from "./advancedBarrel";
@@ -0,0 +1 @@
1
+ export * from "@ckb-ccc/connector/advancedBarrel";
package/src/barrel.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "@ckb-ccc/connector/barrel";
2
+ export * from "./components";
3
+ export * from "./hooks";
@@ -0,0 +1,19 @@
1
+ "use client";
2
+
3
+ import {
4
+ CloseEvent,
5
+ ConnectedEvent,
6
+ WebComponentConnector,
7
+ } from "@ckb-ccc/connector";
8
+ import { createComponent, type EventName } from "@lit/react";
9
+ import * as React from "react";
10
+
11
+ export const Connector = createComponent({
12
+ tagName: "ccc-connector",
13
+ elementClass: WebComponentConnector,
14
+ react: React,
15
+ events: {
16
+ onConnected: "connected" as EventName<ConnectedEvent>,
17
+ onClose: "close" as EventName<CloseEvent>,
18
+ },
19
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./useCcc";
2
+ export * from "./useSigner";
@@ -0,0 +1,38 @@
1
+ "use client";
2
+
3
+ import { SignerInfo } from "@ckb-ccc/connector";
4
+ import * as React from "react";
5
+ import { ReactNode, createContext, useState } from "react";
6
+ import { Connector } from "../components";
7
+
8
+ const CCC_CONTEXT = createContext<{
9
+ open: () => unknown;
10
+ disconnect: () => unknown;
11
+ signerInfo?: SignerInfo;
12
+ }>({ open: () => {}, disconnect: () => {} });
13
+
14
+ export function Provider({ children }: { children: ReactNode }) {
15
+ const [isOpen, setIsOpen] = useState(false);
16
+ const [signerInfo, setSignerInfo] = useState<SignerInfo | undefined>();
17
+
18
+ return (
19
+ <CCC_CONTEXT.Provider
20
+ value={{
21
+ open: () => setIsOpen(true),
22
+ disconnect: () => setSignerInfo(undefined),
23
+ signerInfo,
24
+ }}
25
+ >
26
+ <Connector
27
+ isOpen={isOpen}
28
+ onClose={() => setIsOpen(false)}
29
+ onConnected={({ signerInfo }) => setSignerInfo(signerInfo)}
30
+ />
31
+ {children}
32
+ </CCC_CONTEXT.Provider>
33
+ );
34
+ }
35
+
36
+ export function useCcc() {
37
+ return React.useContext(CCC_CONTEXT);
38
+ }
@@ -0,0 +1,5 @@
1
+ import { useCcc } from "./useCcc";
2
+
3
+ export function useSigner() {
4
+ return useCcc().signerInfo?.signer;
5
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./barrel";
2
+ export * as ccc from "./barrel";