@ckb-ccc/connector 0.0.14-alpha.3 → 0.0.15

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 (48) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/assets/close.svg.d.ts +1 -1
  3. package/dist/assets/close.svg.d.ts.map +1 -1
  4. package/dist/assets/close.svg.js +1 -1
  5. package/dist/assets/diconnect.svg.d.ts +1 -1
  6. package/dist/assets/diconnect.svg.d.ts.map +1 -1
  7. package/dist/assets/diconnect.svg.js +1 -1
  8. package/dist/assets/left.svg.d.ts +1 -1
  9. package/dist/assets/left.svg.d.ts.map +1 -1
  10. package/dist/assets/left.svg.js +1 -1
  11. package/dist/assets/retry.svg.d.ts +1 -1
  12. package/dist/assets/retry.svg.d.ts.map +1 -1
  13. package/dist/assets/retry.svg.js +1 -1
  14. package/dist/assets/swap.svg.d.ts +1 -1
  15. package/dist/assets/swap.svg.d.ts.map +1 -1
  16. package/dist/assets/swap.svg.js +1 -1
  17. package/dist/assets/user.svg.d.ts +2 -0
  18. package/dist/assets/user.svg.d.ts.map +1 -0
  19. package/dist/assets/user.svg.js +18 -0
  20. package/dist/components/dialog.d.ts.map +1 -1
  21. package/dist/components/dialog.js +2 -1
  22. package/dist/connector/index.d.ts +1 -0
  23. package/dist/connector/index.d.ts.map +1 -1
  24. package/dist/connector/index.js +22 -7
  25. package/dist/events/index.d.ts +15 -0
  26. package/dist/events/index.d.ts.map +1 -0
  27. package/dist/events/index.js +19 -0
  28. package/dist/scenes/connected.d.ts +0 -4
  29. package/dist/scenes/connected.d.ts.map +1 -1
  30. package/dist/scenes/connected.js +10 -8
  31. package/dist/scenes/selecting/connecting.d.ts.map +1 -1
  32. package/dist/scenes/selecting/connecting.js +1 -3
  33. package/dist/scenes/selecting/index.d.ts +0 -5
  34. package/dist/scenes/selecting/index.d.ts.map +1 -1
  35. package/dist/scenes/selecting/index.js +4 -12
  36. package/package.json +2 -2
  37. package/src/assets/close.svg.ts +1 -1
  38. package/src/assets/diconnect.svg.ts +1 -1
  39. package/src/assets/left.svg.ts +1 -1
  40. package/src/assets/retry.svg.ts +1 -1
  41. package/src/assets/swap.svg.ts +1 -1
  42. package/src/assets/user.svg.ts +19 -0
  43. package/src/components/dialog.ts +2 -3
  44. package/src/connector/index.ts +28 -11
  45. package/src/events/index.ts +22 -0
  46. package/src/scenes/connected.ts +10 -8
  47. package/src/scenes/selecting/connecting.ts +1 -3
  48. package/src/scenes/selecting/index.ts +6 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @ckb-ccc/connector
2
2
 
3
+ ## 0.0.15
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2483637`](https://github.com/ckb-ecofund/ccc/commit/2483637c89a2e012ed6408d8cabc123b8a45faa9) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(connector): animation
8
+
9
+ ## 0.0.14
10
+
11
+ ### Patch Changes
12
+
13
+ - [#56](https://github.com/ckb-ecofund/ccc/pull/56) [`b4aa690`](https://github.com/ckb-ecofund/ccc/commit/b4aa69085d69fc0953629fd907212922d7d106dd) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(connector): manage button
14
+
15
+ - [#56](https://github.com/ckb-ecofund/ccc/pull/56) [`f13f4d3`](https://github.com/ckb-ecofund/ccc/commit/f13f4d319ca66b571029a65e945e3a038bfeea25) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Signer.findTransactions
16
+
17
+ - [#48](https://github.com/ckb-ecofund/ccc/pull/48) [`4fb114b`](https://github.com/ckb-ecofund/ccc/commit/4fb114bc421c7250eed7388c16f1c026875153e6) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(okx): make okx wallet happy
18
+
19
+ - [#54](https://github.com/ckb-ecofund/ccc/pull/54) [`3f49876`](https://github.com/ckb-ecofund/ccc/commit/3f49876826f5a9eeff8d14c7d8d7b9cf2cea0f32) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(connector): useless back button
20
+
21
+ - [#53](https://github.com/ckb-ecofund/ccc/pull/53) [`32bffff`](https://github.com/ckb-ecofund/ccc/commit/32bffff407934ec5d16bf7c5701b128d8b29c452) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(connector): select client
22
+
23
+ - Updated dependencies [[`f13f4d3`](https://github.com/ckb-ecofund/ccc/commit/f13f4d319ca66b571029a65e945e3a038bfeea25), [`4fb114b`](https://github.com/ckb-ecofund/ccc/commit/4fb114bc421c7250eed7388c16f1c026875153e6)]:
24
+ - @ckb-ccc/ccc@0.0.14
25
+
3
26
  ## 0.0.14-alpha.3
4
27
 
5
28
  ### Patch Changes
@@ -1,2 +1,2 @@
1
- export declare const CLOSE_SVG: import("lit").TemplateResult;
1
+ export declare const CLOSE_SVG: import("lit").TemplateResult<1>;
2
2
  //# sourceMappingURL=close.svg.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"close.svg.d.ts","sourceRoot":"","sources":["../../src/assets/close.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,8BAarB,CAAC"}
1
+ {"version":3,"file":"close.svg.d.ts","sourceRoot":"","sources":["../../src/assets/close.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,iCAarB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { html } from "lit/static-html.js";
1
+ import { html } from "lit";
2
2
  export const CLOSE_SVG = html `
3
3
  <svg
4
4
  width="12"
@@ -1,2 +1,2 @@
1
- export declare const DISCONNECT_SVG: import("lit").TemplateResult;
1
+ export declare const DISCONNECT_SVG: import("lit").TemplateResult<1>;
2
2
  //# sourceMappingURL=diconnect.svg.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diconnect.svg.d.ts","sourceRoot":"","sources":["../../src/assets/diconnect.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,8BAc1B,CAAC"}
1
+ {"version":3,"file":"diconnect.svg.d.ts","sourceRoot":"","sources":["../../src/assets/diconnect.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iCAc1B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { html } from "lit/static-html.js";
1
+ import { html } from "lit";
2
2
  export const DISCONNECT_SVG = html `
3
3
  <svg
4
4
  width="32"
@@ -1,2 +1,2 @@
1
- export declare const LEFT_SVG: import("lit").TemplateResult;
1
+ export declare const LEFT_SVG: import("lit").TemplateResult<1>;
2
2
  //# sourceMappingURL=left.svg.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"left.svg.d.ts","sourceRoot":"","sources":["../../src/assets/left.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,8BAcpB,CAAC"}
1
+ {"version":3,"file":"left.svg.d.ts","sourceRoot":"","sources":["../../src/assets/left.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,iCAcpB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { html } from "lit/static-html.js";
1
+ import { html } from "lit";
2
2
  export const LEFT_SVG = html `
3
3
  <svg
4
4
  width="8"
@@ -1,2 +1,2 @@
1
- export declare const RETRY_SVG: import("lit").TemplateResult;
1
+ export declare const RETRY_SVG: import("lit").TemplateResult<1>;
2
2
  //# sourceMappingURL=retry.svg.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"retry.svg.d.ts","sourceRoot":"","sources":["../../src/assets/retry.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,8BAarB,CAAC"}
1
+ {"version":3,"file":"retry.svg.d.ts","sourceRoot":"","sources":["../../src/assets/retry.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,iCAarB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { html } from "lit/static-html.js";
1
+ import { html } from "lit";
2
2
  export const RETRY_SVG = html `
3
3
  <svg
4
4
  width="12"
@@ -1,2 +1,2 @@
1
- export declare const SWAP_SVG: import("lit").TemplateResult;
1
+ export declare const SWAP_SVG: import("lit").TemplateResult<1>;
2
2
  //# sourceMappingURL=swap.svg.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"swap.svg.d.ts","sourceRoot":"","sources":["../../src/assets/swap.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,8BAkCpB,CAAC"}
1
+ {"version":3,"file":"swap.svg.d.ts","sourceRoot":"","sources":["../../src/assets/swap.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,iCAkCpB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { html } from "lit/static-html.js";
1
+ import { html } from "lit";
2
2
  export const SWAP_SVG = html `
3
3
  <svg
4
4
  width="13"
@@ -0,0 +1,2 @@
1
+ export declare const USER_SVG: import("lit").TemplateResult<1>;
2
+ //# sourceMappingURL=user.svg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.svg.d.ts","sourceRoot":"","sources":["../../src/assets/user.svg.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,iCAgBpB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { html } from "lit";
2
+ export const USER_SVG = html `
3
+ <svg
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ width="24"
6
+ height="24"
7
+ viewBox="-3 -3 30 30"
8
+ fill="none"
9
+ stroke="currentColor"
10
+ stroke-width="2"
11
+ stroke-linecap="round"
12
+ stroke-linejoin="round"
13
+ class="primary-icon"
14
+ >
15
+ <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" />
16
+ <circle cx="12" cy="7" r="4" />
17
+ </svg>
18
+ `;
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/components/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAK5C,qBACa,MAAO,SAAQ,UAAU;IAE7B,OAAO,EAAE,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC;IAEhC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEvB,MAAM;IA+BN,MAAM,CAAC,MAAM,0BA0DX;CACH"}
1
+ {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/components/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAM5C,qBACa,MAAO,SAAQ,UAAU;IAE7B,OAAO,EAAE,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC;IAEhC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEvB,MAAM;IA6BN,MAAM,CAAC,MAAM,0BA0DX;CACH"}
@@ -8,6 +8,7 @@ import { css, html, LitElement } from "lit";
8
8
  import { customElement, property } from "lit/decorators.js";
9
9
  import { CLOSE_SVG } from "../assets/close.svg.js";
10
10
  import { LEFT_SVG } from "../assets/left.svg.js";
11
+ import { CloseEvent } from "../events/index.js";
11
12
  let Dialog = class Dialog extends LitElement {
12
13
  render() {
13
14
  return html `
@@ -26,7 +27,7 @@ let Dialog = class Dialog extends LitElement {
26
27
  <span
27
28
  class="close active"
28
29
  @click=${() => {
29
- this.dispatchEvent(new Event("close", { bubbles: true, composed: true }));
30
+ this.dispatchEvent(new CloseEvent());
30
31
  }}
31
32
  >
32
33
  ${CLOSE_SVG}
@@ -28,6 +28,7 @@ export declare class WebComponentConnector extends LitElement {
28
28
  private readonly mainRef;
29
29
  private readonly bodyRef;
30
30
  render(): import("lit").TemplateResult<1>;
31
+ onClose(onClosed?: () => void): void;
31
32
  updated(): void;
32
33
  static styles: import("lit").CSSResult;
33
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connector/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,KAAK,CAAC;AAO5D,qBACa,qBAAsB,SAAQ,UAAU;IAE5C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,IA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{ LitElement, css, html } from "lit";
9
9
  import { customElement, property, state } from "lit/decorators.js";
10
10
  import { createRef, ref } from "lit/directives/ref.js";
11
+ import { CloseEvent, } from "../events/index.js";
11
12
  import { SignersController } from "../signers/index.js";
12
13
  let WebComponentConnector = class WebComponentConnector extends LitElement {
13
14
  constructor() {
@@ -21,11 +22,12 @@ let WebComponentConnector = class WebComponentConnector extends LitElement {
21
22
  this.client = client;
22
23
  }
23
24
  disconnect() {
24
- this.walletName = undefined;
25
- this.signerName = undefined;
26
- this.saveConnection();
27
- this.dispatchEvent(new Event("close", { bubbles: true, composed: true }));
28
- this.signer?.signer.disconnect();
25
+ this.onClose(() => {
26
+ this.walletName = undefined;
27
+ this.signerName = undefined;
28
+ this.saveConnection();
29
+ this.signer?.signer.disconnect();
30
+ });
29
31
  }
30
32
  loadConnection() {
31
33
  const { signerName, walletName, } = JSON.parse(window.localStorage.getItem("ccc-connection-info") ?? "{}");
@@ -85,10 +87,13 @@ let WebComponentConnector = class WebComponentConnector extends LitElement {
85
87
  class="background"
86
88
  @click=${(event) => {
87
89
  if (event.target === event.currentTarget) {
88
- this.dispatchEvent(new Event("close", { bubbles: true, composed: true }));
89
- this.bodyRef.value?.onClose?.();
90
+ this.onClose();
90
91
  }
91
92
  }}
93
+ @close=${(event) => {
94
+ event.stopPropagation();
95
+ this.onClose(event.callback);
96
+ }}
92
97
  @updated=${() => this.updated()}
93
98
  >
94
99
  <div class="main" ${ref(this.mainRef)}>
@@ -118,6 +123,16 @@ let WebComponentConnector = class WebComponentConnector extends LitElement {
118
123
  </div>
119
124
  </div>`;
120
125
  }
126
+ onClose(onClosed) {
127
+ if (this.mainRef.value) {
128
+ this.mainRef.value.style.height = "0";
129
+ }
130
+ setTimeout(() => {
131
+ this.dispatchEvent(new CloseEvent());
132
+ this.bodyRef.value?.onClose?.();
133
+ onClosed?.();
134
+ }, 150);
135
+ }
121
136
  updated() {
122
137
  if (!this.mainRef.value) {
123
138
  return;
@@ -0,0 +1,15 @@
1
+ import { ccc } from "@ckb-ccc/ccc";
2
+ export declare class SelectClientEvent extends Event {
3
+ client: ccc.Client;
4
+ constructor(client: ccc.Client);
5
+ }
6
+ export declare class ConnectedEvent extends Event {
7
+ readonly walletName: string;
8
+ readonly signerName: string;
9
+ constructor(walletName: string, signerName: string);
10
+ }
11
+ export declare class CloseEvent extends Event {
12
+ callback?: (() => void) | undefined;
13
+ constructor(callback?: (() => void) | undefined);
14
+ }
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,qBAAa,iBAAkB,SAAQ,KAAK;IACvB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAAlB,MAAM,EAAE,GAAG,CAAC,MAAM;CAGtC;AAED,qBAAa,cAAe,SAAQ,KAAK;aAErB,UAAU,EAAE,MAAM;aAClB,UAAU,EAAE,MAAM;gBADlB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM;CAIrC;AAED,qBAAa,UAAW,SAAQ,KAAK;IAChB,QAAQ,CAAC,SAAQ,IAAI;gBAArB,QAAQ,CAAC,SAAQ,IAAI,aAAA;CAGzC"}
@@ -0,0 +1,19 @@
1
+ export class SelectClientEvent extends Event {
2
+ constructor(client) {
3
+ super("select-client");
4
+ this.client = client;
5
+ }
6
+ }
7
+ export class ConnectedEvent extends Event {
8
+ constructor(walletName, signerName) {
9
+ super("connected");
10
+ this.walletName = walletName;
11
+ this.signerName = signerName;
12
+ }
13
+ }
14
+ export class CloseEvent extends Event {
15
+ constructor(callback) {
16
+ super("close", { bubbles: true, composed: true });
17
+ this.callback = callback;
18
+ }
19
+ }
@@ -1,9 +1,5 @@
1
1
  import { ccc } from "@ckb-ccc/ccc";
2
2
  import { LitElement, PropertyValues } from "lit";
3
- export declare class SelectClientEvent extends Event {
4
- client: ccc.Client;
5
- constructor(client: ccc.Client);
6
- }
7
3
  export declare function formatString(str: string | undefined, l?: number, r?: number): string | undefined;
8
4
  export declare class ConnectedScene extends LitElement {
9
5
  wallet?: ccc.Wallet;
@@ -1 +1 @@
1
- {"version":3,"file":"connected.d.ts","sourceRoot":"","sources":["../../src/scenes/connected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAa,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAQ5D,qBAAa,iBAAkB,SAAQ,KAAK;IACvB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAAlB,MAAM,EAAE,GAAG,CAAC,MAAM;CAGtC;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,CAAC,SAAI,EACL,CAAC,SAAI,GACJ,MAAM,GAAG,SAAS,CAKpB;AAED,qBACa,cAAe,SAAQ,UAAU;IAErC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAEpB,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAEpB,aAAa,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAG7E,OAAO,CAAC,kBAAkB,CAAC,CAAS;IAEpC,OAAO,CAAC,eAAe,CAAC,CAAS;IAEjC,OAAO,CAAC,OAAO,CAAC,CAAU;IAE1B,OAAO,CAAC,eAAe,CAAS;IAEhC,UAAU,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAgBzD,MAAM;IA8FN,MAAM,CAAC,MAAM,0BAmHX;IAEF,OAAO;CAGR"}
1
+ {"version":3,"file":"connected.d.ts","sourceRoot":"","sources":["../../src/scenes/connected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAa,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAU5D,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,CAAC,SAAI,EACL,CAAC,SAAI,GACJ,MAAM,GAAG,SAAS,CAKpB;AAED,qBACa,cAAe,SAAQ,UAAU;IAErC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAEpB,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAEpB,aAAa,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAG7E,OAAO,CAAC,kBAAkB,CAAC,CAAS;IAEpC,OAAO,CAAC,eAAe,CAAC,CAAS;IAEjC,OAAO,CAAC,OAAO,CAAC,CAAU;IAE1B,OAAO,CAAC,eAAe,CAAS;IAEhC,UAAU,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAgBzD,MAAM;IAoGN,MAAM,CAAC,MAAM,0BAmHX;IAEF,OAAO;CAGR"}
@@ -11,13 +11,9 @@ import { repeat } from "lit/directives/repeat.js";
11
11
  import { CKB_SVG } from "../assets/chains/index.js";
12
12
  import { DISCONNECT_SVG } from "../assets/diconnect.svg.js";
13
13
  import { SWAP_SVG } from "../assets/swap.svg.js";
14
+ import { USER_SVG } from "../assets/user.svg.js";
15
+ import { SelectClientEvent } from "../events/index.js";
14
16
  import { signerTypeToIcon } from "./selecting/signers.js";
15
- export class SelectClientEvent extends Event {
16
- constructor(client) {
17
- super("select-client");
18
- this.client = client;
19
- }
20
- }
21
17
  export function formatString(str, l = 9, r = 6) {
22
18
  if (str && str.length > l + r + 3) {
23
19
  return `${str.slice(0, l)}...${str.slice(-r)}`;
@@ -82,10 +78,16 @@ let ConnectedScene = class ConnectedScene extends LitElement {
82
78
 
83
79
  <ccc-button
84
80
  class="mt-2"
81
+ @click=${() => window.open("https://mobit.app/", "_blank")}
82
+ >
83
+ ${USER_SVG} Manage
84
+ </ccc-button>
85
+
86
+ <ccc-button
87
+ class="mt-1"
85
88
  @click=${() => this.dispatchEvent(new Event("disconnect"))}
86
89
  >
87
- ${DISCONNECT_SVG}
88
- Disconnect
90
+ ${DISCONNECT_SVG} Disconnect
89
91
  </ccc-button>
90
92
 
91
93
  <div
@@ -1 +1 @@
1
- {"version":3,"file":"connecting.d.ts","sourceRoot":"","sources":["../../../src/scenes/selecting/connecting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAInC,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,GAAG,CAAC,iBAAiB,EAC7B,MAAM,EAAE,GAAG,CAAC,UAAU,EACtB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,gBAAgB,EAAE,CAChB,MAAM,EAAE,GAAG,CAAC,iBAAiB,EAC7B,MAAM,EAAE,GAAG,CAAC,UAAU,KACnB,OAAO,gDA4Bb"}
1
+ {"version":3,"file":"connecting.d.ts","sourceRoot":"","sources":["../../../src/scenes/selecting/connecting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAInC,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,GAAG,CAAC,iBAAiB,EAC7B,MAAM,EAAE,GAAG,CAAC,UAAU,EACtB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,gBAAgB,EAAE,CAChB,MAAM,EAAE,GAAG,CAAC,iBAAiB,EAC7B,MAAM,EAAE,GAAG,CAAC,UAAU,KACnB,OAAO,gDA0Bb"}
@@ -21,9 +21,7 @@ export function generateConnectingScene(wallet, signer, error, onSignerSelected)
21
21
  class="mt-2"
22
22
  @click=${() => onSignerSelected(wallet, signer)}
23
23
  >
24
-
25
- ${RETRY_SVG}
26
- Try again
24
+ ${RETRY_SVG} Try again
27
25
  </ccc-button-pill>
28
26
  `,
29
27
  ];
@@ -1,10 +1,5 @@
1
1
  import { ccc } from "@ckb-ccc/ccc";
2
2
  import { LitElement } from "lit";
3
- export declare class ConnectedEvent extends Event {
4
- readonly walletName: string;
5
- readonly signerName: string;
6
- constructor(walletName: string, signerName: string);
7
- }
8
3
  export declare class SelectingScene extends LitElement {
9
4
  wallets?: ccc.WalletWithSigners[];
10
5
  private selectedWallet?;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scenes/selecting/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAM5C,qBAAa,cAAe,SAAQ,KAAK;aAErB,UAAU,EAAE,MAAM;aAClB,UAAU,EAAE,MAAM;gBADlB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM;CAIrC;AAED,qBACa,cAAe,SAAQ,UAAU;IAErC,OAAO,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,CAAC;IAGzC,OAAO,CAAC,cAAc,CAAC,CAAwB;IAE/C,OAAO,CAAC,cAAc,CAAC,CAAiB;IAExC,OAAO,CAAC,eAAe,CAAC,CAAS;IAEjC,MAAM;IA+CC,OAAO;IAMd,OAAO,CAAC,qBAAqB,CAwC3B;IAEF,MAAM,CAAC,MAAM,0BA0DX;IAEF,OAAO;CAGR"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scenes/selecting/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAO5C,qBACa,cAAe,SAAQ,UAAU;IAErC,OAAO,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,CAAC;IAGzC,OAAO,CAAC,cAAc,CAAC,CAAwB;IAE/C,OAAO,CAAC,cAAc,CAAC,CAAiB;IAExC,OAAO,CAAC,eAAe,CAAC,CAAS;IAEjC,MAAM;IA4CC,OAAO;IAMd,OAAO,CAAC,qBAAqB,CA2C3B;IAEF,MAAM,CAAC,MAAM,0BA0DX;IAEF,OAAO;CAGR"}
@@ -6,16 +6,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { css, html, LitElement } from "lit";
8
8
  import { customElement, property, state } from "lit/decorators.js";
9
+ import { CloseEvent, ConnectedEvent } from "../../events/index.js";
9
10
  import { generateConnectingScene } from "./connecting.js";
10
11
  import { generateSignersScene } from "./signers.js";
11
12
  import { generateWalletsScene } from "./wallets.js";
12
- export class ConnectedEvent extends Event {
13
- constructor(walletName, signerName) {
14
- super("connected");
15
- this.walletName = walletName;
16
- this.signerName = signerName;
17
- }
18
- }
19
13
  let SelectingScene = class SelectingScene extends LitElement {
20
14
  constructor() {
21
15
  super(...arguments);
@@ -49,8 +43,9 @@ let SelectingScene = class SelectingScene extends LitElement {
49
43
  this.connectingError = JSON.stringify(message);
50
44
  return;
51
45
  }
52
- this.dispatchEvent(new Event("close", { bubbles: true, composed: true }));
53
- this.dispatchEvent(new ConnectedEvent(wallet.name, signerInfo.name));
46
+ this.dispatchEvent(new CloseEvent(() => {
47
+ this.dispatchEvent(new ConnectedEvent(wallet.name, signerInfo.name));
48
+ }));
54
49
  })();
55
50
  };
56
51
  }
@@ -69,9 +64,6 @@ let SelectingScene = class SelectingScene extends LitElement {
69
64
  return html `<ccc-dialog
70
65
  header=${title}
71
66
  ?canBack=${this.selectedSigner || this.selectedWallet}
72
- @close=${() => {
73
- this.onClose();
74
- }}
75
67
  @back=${() => {
76
68
  if (!this.selectedSigner ||
77
69
  (this.selectedWallet && this.selectedWallet.signers.length <= 1)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckb-ccc/connector",
3
- "version": "0.0.14-alpha.3",
3
+ "version": "0.0.15",
4
4
  "description": "CCC - CKBer's Codebase. Common Chains Connector UI",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "lit": "^3.1.3",
37
- "@ckb-ccc/ccc": "0.0.14-alpha.2"
37
+ "@ckb-ccc/ccc": "0.0.14"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "rimraf ./dist && tsc",
@@ -1,4 +1,4 @@
1
- import { html } from "lit/static-html.js";
1
+ import { html } from "lit";
2
2
 
3
3
  export const CLOSE_SVG = html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from "lit/static-html.js";
1
+ import { html } from "lit";
2
2
 
3
3
  export const DISCONNECT_SVG = html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from "lit/static-html.js";
1
+ import { html } from "lit";
2
2
 
3
3
  export const LEFT_SVG = html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from "lit/static-html.js";
1
+ import { html } from "lit";
2
2
 
3
3
  export const RETRY_SVG = html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from "lit/static-html.js";
1
+ import { html } from "lit";
2
2
 
3
3
  export const SWAP_SVG = html`
4
4
  <svg
@@ -0,0 +1,19 @@
1
+ import { html } from "lit";
2
+
3
+ export const USER_SVG = html`
4
+ <svg
5
+ xmlns="http://www.w3.org/2000/svg"
6
+ width="24"
7
+ height="24"
8
+ viewBox="-3 -3 30 30"
9
+ fill="none"
10
+ stroke="currentColor"
11
+ stroke-width="2"
12
+ stroke-linecap="round"
13
+ stroke-linejoin="round"
14
+ class="primary-icon"
15
+ >
16
+ <path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" />
17
+ <circle cx="12" cy="7" r="4" />
18
+ </svg>
19
+ `;
@@ -2,6 +2,7 @@ import { css, html, LitElement } from "lit";
2
2
  import { customElement, property } from "lit/decorators.js";
3
3
  import { CLOSE_SVG } from "../assets/close.svg.js";
4
4
  import { LEFT_SVG } from "../assets/left.svg.js";
5
+ import { CloseEvent } from "../events/index.js";
5
6
 
6
7
  @customElement("ccc-dialog")
7
8
  export class Dialog extends LitElement {
@@ -27,9 +28,7 @@ export class Dialog extends LitElement {
27
28
  <span
28
29
  class="close active"
29
30
  @click=${() => {
30
- this.dispatchEvent(
31
- new Event("close", { bubbles: true, composed: true }),
32
- );
31
+ this.dispatchEvent(new CloseEvent());
33
32
  }}
34
33
  >
35
34
  ${CLOSE_SVG}
@@ -2,8 +2,11 @@ import { ccc } from "@ckb-ccc/ccc";
2
2
  import { LitElement, PropertyValues, css, html } from "lit";
3
3
  import { customElement, property, state } from "lit/decorators.js";
4
4
  import { Ref, createRef, ref } from "lit/directives/ref.js";
5
- import { SelectClientEvent } from "../scenes/connected.js";
6
- import { ConnectedEvent } from "../scenes/selecting/index.js";
5
+ import {
6
+ CloseEvent,
7
+ ConnectedEvent,
8
+ SelectClientEvent,
9
+ } from "../events/index.js";
7
10
  import { SignersController } from "../signers/index.js";
8
11
 
9
12
  @customElement("ccc-connector")
@@ -39,11 +42,12 @@ export class WebComponentConnector extends LitElement {
39
42
  private unregisterSignerReplacer?: () => void;
40
43
 
41
44
  public disconnect() {
42
- this.walletName = undefined;
43
- this.signerName = undefined;
44
- this.saveConnection();
45
- this.dispatchEvent(new Event("close", { bubbles: true, composed: true }));
46
- this.signer?.signer.disconnect();
45
+ this.onClose(() => {
46
+ this.walletName = undefined;
47
+ this.signerName = undefined;
48
+ this.saveConnection();
49
+ this.signer?.signer.disconnect();
50
+ });
47
51
  }
48
52
 
49
53
  private loadConnection() {
@@ -134,12 +138,13 @@ export class WebComponentConnector extends LitElement {
134
138
  class="background"
135
139
  @click=${(event: Event) => {
136
140
  if (event.target === event.currentTarget) {
137
- this.dispatchEvent(
138
- new Event("close", { bubbles: true, composed: true }),
139
- );
140
- this.bodyRef.value?.onClose?.();
141
+ this.onClose();
141
142
  }
142
143
  }}
144
+ @close=${(event: CloseEvent) => {
145
+ event.stopPropagation();
146
+ this.onClose(event.callback);
147
+ }}
143
148
  @updated=${() => this.updated()}
144
149
  >
145
150
  <div class="main" ${ref(this.mainRef)}>
@@ -171,6 +176,18 @@ export class WebComponentConnector extends LitElement {
171
176
  </div>`;
172
177
  }
173
178
 
179
+ onClose(onClosed?: () => void) {
180
+ if (this.mainRef.value) {
181
+ this.mainRef.value.style.height = "0";
182
+ }
183
+
184
+ setTimeout(() => {
185
+ this.dispatchEvent(new CloseEvent());
186
+ this.bodyRef.value?.onClose?.();
187
+ onClosed?.();
188
+ }, 150);
189
+ }
190
+
174
191
  updated() {
175
192
  if (!this.mainRef.value) {
176
193
  return;
@@ -0,0 +1,22 @@
1
+ import { ccc } from "@ckb-ccc/ccc";
2
+
3
+ export class SelectClientEvent extends Event {
4
+ constructor(public client: ccc.Client) {
5
+ super("select-client");
6
+ }
7
+ }
8
+
9
+ export class ConnectedEvent extends Event {
10
+ constructor(
11
+ public readonly walletName: string,
12
+ public readonly signerName: string,
13
+ ) {
14
+ super("connected");
15
+ }
16
+ }
17
+
18
+ export class CloseEvent extends Event {
19
+ constructor(public callback?: () => void) {
20
+ super("close", { bubbles: true, composed: true });
21
+ }
22
+ }
@@ -5,14 +5,10 @@ import { repeat } from "lit/directives/repeat.js";
5
5
  import { CKB_SVG } from "../assets/chains/index.js";
6
6
  import { DISCONNECT_SVG } from "../assets/diconnect.svg.js";
7
7
  import { SWAP_SVG } from "../assets/swap.svg.js";
8
+ import { USER_SVG } from "../assets/user.svg.js";
9
+ import { SelectClientEvent } from "../events/index.js";
8
10
  import { signerTypeToIcon } from "./selecting/signers.js";
9
11
 
10
- export class SelectClientEvent extends Event {
11
- constructor(public client: ccc.Client) {
12
- super("select-client");
13
- }
14
- }
15
-
16
12
  export function formatString(
17
13
  str: string | undefined,
18
14
  l = 9,
@@ -100,10 +96,16 @@ export class ConnectedScene extends LitElement {
100
96
 
101
97
  <ccc-button
102
98
  class="mt-2"
99
+ @click=${() => window.open("https://mobit.app/", "_blank")}
100
+ >
101
+ ${USER_SVG} Manage
102
+ </ccc-button>
103
+
104
+ <ccc-button
105
+ class="mt-1"
103
106
  @click=${() => this.dispatchEvent(new Event("disconnect"))}
104
107
  >
105
- ${DISCONNECT_SVG}
106
- Disconnect
108
+ ${DISCONNECT_SVG} Disconnect
107
109
  </ccc-button>
108
110
 
109
111
  <div
@@ -31,9 +31,7 @@ export function generateConnectingScene(
31
31
  class="mt-2"
32
32
  @click=${() => onSignerSelected(wallet, signer)}
33
33
  >
34
-
35
- ${RETRY_SVG}
36
- Try again
34
+ ${RETRY_SVG} Try again
37
35
  </ccc-button-pill>
38
36
  `,
39
37
  ];
@@ -1,19 +1,11 @@
1
1
  import { ccc } from "@ckb-ccc/ccc";
2
2
  import { css, html, LitElement } from "lit";
3
3
  import { customElement, property, state } from "lit/decorators.js";
4
+ import { CloseEvent, ConnectedEvent } from "../../events/index.js";
4
5
  import { generateConnectingScene } from "./connecting.js";
5
6
  import { generateSignersScene } from "./signers.js";
6
7
  import { generateWalletsScene } from "./wallets.js";
7
8
 
8
- export class ConnectedEvent extends Event {
9
- constructor(
10
- public readonly walletName: string,
11
- public readonly signerName: string,
12
- ) {
13
- super("connected");
14
- }
15
- }
16
-
17
9
  @customElement("ccc-selecting-scene")
18
10
  export class SelectingScene extends LitElement {
19
11
  @property()
@@ -55,9 +47,6 @@ export class SelectingScene extends LitElement {
55
47
  return html`<ccc-dialog
56
48
  header=${title}
57
49
  ?canBack=${this.selectedSigner || this.selectedWallet}
58
- @close=${() => {
59
- this.onClose();
60
- }}
61
50
  @back=${() => {
62
51
  if (
63
52
  !this.selectedSigner ||
@@ -116,8 +105,11 @@ export class SelectingScene extends LitElement {
116
105
  return;
117
106
  }
118
107
 
119
- this.dispatchEvent(new Event("close", { bubbles: true, composed: true }));
120
- this.dispatchEvent(new ConnectedEvent(wallet.name, signerInfo.name));
108
+ this.dispatchEvent(
109
+ new CloseEvent(() => {
110
+ this.dispatchEvent(new ConnectedEvent(wallet.name, signerInfo.name));
111
+ }),
112
+ );
121
113
  })();
122
114
  };
123
115