@canton-network/core-wallet-ui-components 0.1.0 → 0.2.0
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.
- package/dist/components/AppHeader.d.ts +7 -0
- package/dist/components/AppHeader.d.ts.map +1 -0
- package/dist/components/AppHeader.js +73 -0
- package/dist/components/AppLayout.d.ts +11 -0
- package/dist/components/AppLayout.d.ts.map +1 -0
- package/dist/components/AppLayout.js +87 -0
- package/dist/components/Configuration.d.ts +5 -0
- package/dist/components/Configuration.d.ts.map +1 -0
- package/dist/components/Configuration.js +24 -0
- package/dist/components/Discovery.d.ts +19 -0
- package/dist/components/Discovery.d.ts.map +1 -0
- package/dist/components/Discovery.js +148 -0
- package/dist/components/NetworkForm.d.ts +12 -0
- package/dist/components/NetworkForm.d.ts.map +1 -0
- package/dist/components/NetworkForm.js +164 -0
- package/dist/components/NetworkTable.d.ts +8 -0
- package/dist/components/NetworkTable.d.ts.map +1 -0
- package/dist/components/NetworkTable.js +67 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/themes/styles.d.ts +2 -0
- package/dist/themes/styles.d.ts.map +1 -0
- package/dist/themes/styles.js +75 -0
- package/dist/windows/discovery.d.ts +3 -0
- package/dist/windows/discovery.d.ts.map +1 -0
- package/dist/windows/discovery.js +32 -0
- package/dist/windows/popup.d.ts +12 -0
- package/dist/windows/popup.d.ts.map +1 -0
- package/dist/windows/popup.js +64 -0
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppHeader.d.ts","sourceRoot":"","sources":["../../src/components/AppHeader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAA;AAGtC,qBACa,SAAU,SAAQ,UAAU;IACT,OAAO,EAAE,MAAM,CAAoB;IAG/D,gBAAgB;IAIhB,MAAM;CA0CT"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
};
|
|
9
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
+
};
|
|
12
|
+
import { LitElement, html } from 'lit';
|
|
13
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
14
|
+
let AppHeader = class AppHeader extends LitElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.iconSrc = 'images/icon.png';
|
|
18
|
+
}
|
|
19
|
+
// Prevent shadow DOM so external CSS applies
|
|
20
|
+
createRenderRoot() {
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return html `
|
|
25
|
+
<div
|
|
26
|
+
class="header d-flex justify-content-between align-items-center"
|
|
27
|
+
>
|
|
28
|
+
<h2>
|
|
29
|
+
<div
|
|
30
|
+
class="logo-box"
|
|
31
|
+
@click=${() => (window.location.href = '/')}
|
|
32
|
+
aria-label="Go to home"
|
|
33
|
+
>
|
|
34
|
+
<img
|
|
35
|
+
src="${this.iconSrc}"
|
|
36
|
+
alt="Icon"
|
|
37
|
+
width="24"
|
|
38
|
+
height="24"
|
|
39
|
+
/>
|
|
40
|
+
Splice Wallet
|
|
41
|
+
</div>
|
|
42
|
+
</h2>
|
|
43
|
+
<div>
|
|
44
|
+
<button
|
|
45
|
+
class="btn btn-outline-secondary btn-sm"
|
|
46
|
+
id="settingsButton"
|
|
47
|
+
@click=${() => (window.location.href = '/networks/')}
|
|
48
|
+
>
|
|
49
|
+
Settings
|
|
50
|
+
</button>
|
|
51
|
+
<button
|
|
52
|
+
class="btn btn-outline-secondary btn-sm"
|
|
53
|
+
@click=${() => {
|
|
54
|
+
localStorage.clear();
|
|
55
|
+
window.location.href = '/login';
|
|
56
|
+
}}
|
|
57
|
+
id="logoutButton"
|
|
58
|
+
>
|
|
59
|
+
Logout
|
|
60
|
+
</button>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
__decorate([
|
|
67
|
+
property({ type: String }),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], AppHeader.prototype, "iconSrc", void 0);
|
|
70
|
+
AppHeader = __decorate([
|
|
71
|
+
customElement('app-header')
|
|
72
|
+
], AppHeader);
|
|
73
|
+
export { AppHeader };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class AppLayout extends LitElement {
|
|
3
|
+
iconSrc: string;
|
|
4
|
+
themeSrc?: string;
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
private customThemeCss;
|
|
7
|
+
updated(changedProps: Map<string, unknown>): Promise<void>;
|
|
8
|
+
private get effectiveThemeCss();
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=AppLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppLayout.d.ts","sourceRoot":"","sources":["../../src/components/AppLayout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAwB,MAAM,KAAK,CAAA;AAKtD,qBACa,SAAU,SAAQ,UAAU;IACT,OAAO,EAAE,MAAM,CAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAE7C,MAAM,CAAC,MAAM,0BAiBZ;IAED,OAAO,CAAC,cAAc,CAAsB;IAEtC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAqBhD,OAAO,KAAK,iBAAiB,GAE5B;IAED,MAAM;CAYT"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
};
|
|
9
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
+
};
|
|
12
|
+
import { LitElement, html, css, unsafeCSS } from 'lit';
|
|
13
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
14
|
+
import bootstrapCss from 'bootstrap/dist/css/bootstrap.min.css?inline';
|
|
15
|
+
import defaultTheme from '../../themes/default.css?inline';
|
|
16
|
+
let AppLayout = class AppLayout extends LitElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.iconSrc = '/images/icon.png';
|
|
20
|
+
this.customThemeCss = null;
|
|
21
|
+
}
|
|
22
|
+
static { this.styles = css `
|
|
23
|
+
${unsafeCSS(bootstrapCss.replaceAll(/:root/g, ':root,:host'))}
|
|
24
|
+
|
|
25
|
+
:host {
|
|
26
|
+
--bs-body-color: var(--splice-wk-text-color);
|
|
27
|
+
|
|
28
|
+
margin: 0;
|
|
29
|
+
font-family: var(--bs-body-font-family);
|
|
30
|
+
font-size: var(--bs-body-font-size);
|
|
31
|
+
font-weight: var(--bs-body-font-weight);
|
|
32
|
+
line-height: var(--bs-body-line-height);
|
|
33
|
+
color: var(--bs-body-color);
|
|
34
|
+
text-align: var(--bs-body-text-align);
|
|
35
|
+
background-color: var(--bs-body-bg);
|
|
36
|
+
-webkit-text-size-adjust: 100%;
|
|
37
|
+
-webkit-tap-highlight-color: transparent;
|
|
38
|
+
}
|
|
39
|
+
`; }
|
|
40
|
+
async updated(changedProps) {
|
|
41
|
+
if (changedProps.has('themeSrc')) {
|
|
42
|
+
if (this.themeSrc) {
|
|
43
|
+
try {
|
|
44
|
+
const res = await fetch(this.themeSrc);
|
|
45
|
+
if (!res.ok)
|
|
46
|
+
throw new Error(`HTTP ${res.status}`);
|
|
47
|
+
this.customThemeCss = await res.text();
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
console.warn(`[app-layout] Failed to load theme from "${this.themeSrc}":`, err);
|
|
51
|
+
this.customThemeCss = null;
|
|
52
|
+
}
|
|
53
|
+
this.requestUpdate();
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.customThemeCss = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
get effectiveThemeCss() {
|
|
61
|
+
return this.customThemeCss ?? defaultTheme;
|
|
62
|
+
}
|
|
63
|
+
render() {
|
|
64
|
+
return html `
|
|
65
|
+
<style>
|
|
66
|
+
${unsafeCSS(this.effectiveThemeCss)}
|
|
67
|
+
</style>
|
|
68
|
+
|
|
69
|
+
<app-header .iconSrc=${this.iconSrc}></app-header>
|
|
70
|
+
<div class="container" id="mainContent">
|
|
71
|
+
<slot></slot>
|
|
72
|
+
</div>
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
__decorate([
|
|
77
|
+
property({ type: String }),
|
|
78
|
+
__metadata("design:type", String)
|
|
79
|
+
], AppLayout.prototype, "iconSrc", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
property({ type: String }),
|
|
82
|
+
__metadata("design:type", String)
|
|
83
|
+
], AppLayout.prototype, "themeSrc", void 0);
|
|
84
|
+
AppLayout = __decorate([
|
|
85
|
+
customElement('app-layout')
|
|
86
|
+
], AppLayout);
|
|
87
|
+
export { AppLayout };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../src/components/Configuration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAA;AAGtC,qBACa,aAAc,SAAQ,UAAU;IACzC,SAAS,CAAC,MAAM;CAQnB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
};
|
|
9
|
+
import { html, LitElement } from 'lit';
|
|
10
|
+
import { customElement } from 'lit/decorators.js';
|
|
11
|
+
let Configuration = class Configuration extends LitElement {
|
|
12
|
+
render() {
|
|
13
|
+
return html `
|
|
14
|
+
<div>
|
|
15
|
+
<h1>Configuration</h1>
|
|
16
|
+
<p>Wallet Kernel configuration page.</p>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
Configuration = __decorate([
|
|
22
|
+
customElement('swk-configuration')
|
|
23
|
+
], Configuration);
|
|
24
|
+
export { Configuration };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DiscoverResult } from '@canton-network/core-types';
|
|
2
|
+
/**
|
|
3
|
+
* Discovery implements the view of the Wallet Kernel selection window.
|
|
4
|
+
* It is implemented directly as a Web Component without using LitElement, so to avoid having external dependencies.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Discovery extends HTMLElement {
|
|
7
|
+
static observedAttributes: string[];
|
|
8
|
+
get walletExtensionLoaded(): boolean;
|
|
9
|
+
set walletExtensionLoaded(val: boolean);
|
|
10
|
+
private root;
|
|
11
|
+
constructor();
|
|
12
|
+
verifiedKernels(): DiscoverResult[];
|
|
13
|
+
private renderKernelOption;
|
|
14
|
+
private selectKernel;
|
|
15
|
+
render(): void;
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
attributeChangedCallback(): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=Discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Discovery.d.ts","sourceRoot":"","sources":["../../src/components/Discovery.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAA;AAE/E;;;GAGG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACtC,MAAM,CAAC,kBAAkB,WAA8B;IAEvD,IAAI,qBAAqB,YAExB;IAED,IAAI,qBAAqB,CAAC,GAAG,SAAA,EAM5B;IAED,OAAO,CAAC,IAAI,CAAa;;IA2DzB,eAAe,IAAI,cAAc,EAAE;IAInC,OAAO,CAAC,kBAAkB;IA2B1B,OAAO,CAAC,YAAY;IAQpB,MAAM;IAiDN,iBAAiB;IAIjB,wBAAwB;CAG3B"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* Discovery implements the view of the Wallet Kernel selection window.
|
|
5
|
+
* It is implemented directly as a Web Component without using LitElement, so to avoid having external dependencies.
|
|
6
|
+
*/
|
|
7
|
+
export class Discovery extends HTMLElement {
|
|
8
|
+
static { this.observedAttributes = ['wallet-extension-loaded']; }
|
|
9
|
+
get walletExtensionLoaded() {
|
|
10
|
+
return this.hasAttribute('wallet-extension-loaded');
|
|
11
|
+
}
|
|
12
|
+
set walletExtensionLoaded(val) {
|
|
13
|
+
if (val) {
|
|
14
|
+
this.setAttribute('wallet-extension-loaded', '');
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
this.removeAttribute('wallet-extension-loaded');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
this.attachShadow({ mode: 'open' });
|
|
23
|
+
const styles = document.createElement('style');
|
|
24
|
+
styles.textContent = `
|
|
25
|
+
* {
|
|
26
|
+
color: var(--splice-wk-text-color, black);
|
|
27
|
+
font-family: var(--splice-wk-font-family);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
h1 {
|
|
31
|
+
margin: 0px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
div {
|
|
35
|
+
background-color: var(--splice-wk-background-color, none);
|
|
36
|
+
width: 100%;
|
|
37
|
+
height: 100%;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.kernel {
|
|
41
|
+
height: auto;
|
|
42
|
+
margin-bottom: 8px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.kernel button {
|
|
46
|
+
margin-left: 8px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
input {
|
|
50
|
+
margin-left: 8px;
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
this.root = document.createElement('div');
|
|
54
|
+
this.root.id = 'discovery-root';
|
|
55
|
+
if (this.shadowRoot) {
|
|
56
|
+
this.shadowRoot.appendChild(styles);
|
|
57
|
+
this.shadowRoot.appendChild(this.root);
|
|
58
|
+
}
|
|
59
|
+
if (window.opener) {
|
|
60
|
+
// uses the string literal instead of the WalletEvent enum to avoid bundling issues
|
|
61
|
+
window.opener.postMessage({ type: 'SPLICE_WALLET_EXT_READY' }, '*');
|
|
62
|
+
window.opener.addEventListener('message', (event) => {
|
|
63
|
+
if (event.data.type === 'SPLICE_WALLET_EXT_ACK') {
|
|
64
|
+
this.setAttribute('wallet-extension-loaded', '');
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
verifiedKernels() {
|
|
70
|
+
return [{ url: 'http://localhost:3000/rpc', walletType: 'remote' }];
|
|
71
|
+
}
|
|
72
|
+
renderKernelOption(kernel) {
|
|
73
|
+
const div = document.createElement('div');
|
|
74
|
+
div.setAttribute('class', 'kernel');
|
|
75
|
+
const span = document.createElement('span');
|
|
76
|
+
switch (kernel.walletType) {
|
|
77
|
+
case 'extension':
|
|
78
|
+
span.innerText = 'Browser Extension';
|
|
79
|
+
break;
|
|
80
|
+
case 'remote':
|
|
81
|
+
span.innerText = `${kernel.walletType} - ${kernel.url}`;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
const button = document.createElement('button');
|
|
85
|
+
button.innerText = `Connect`;
|
|
86
|
+
button.addEventListener('click', () => {
|
|
87
|
+
this.selectKernel(kernel);
|
|
88
|
+
});
|
|
89
|
+
div.appendChild(span);
|
|
90
|
+
div.appendChild(button);
|
|
91
|
+
return div;
|
|
92
|
+
}
|
|
93
|
+
selectKernel(kernel) {
|
|
94
|
+
if (window.opener) {
|
|
95
|
+
window.opener.postMessage(kernel, '*');
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.warn('no window opener...');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
render() {
|
|
102
|
+
const root = document.createElement('div');
|
|
103
|
+
const header = document.createElement('h1');
|
|
104
|
+
header.innerText = 'Add Remote Wallet Kernel';
|
|
105
|
+
const input = document.createElement('input');
|
|
106
|
+
input.setAttribute('autofocus', '');
|
|
107
|
+
input.setAttribute('id', 'wkurl');
|
|
108
|
+
input.setAttribute('type', 'text');
|
|
109
|
+
input.setAttribute('placeholder', 'RPC URL');
|
|
110
|
+
const button = document.createElement('button');
|
|
111
|
+
button.setAttribute('id', 'connect');
|
|
112
|
+
button.innerText = 'Connect';
|
|
113
|
+
button.addEventListener('click', () => {
|
|
114
|
+
const url = input.value;
|
|
115
|
+
console.log('Connecting to Wallet Kernel...' + url);
|
|
116
|
+
this.selectKernel({ url, walletType: 'remote' });
|
|
117
|
+
});
|
|
118
|
+
root.appendChild(header);
|
|
119
|
+
if (this.walletExtensionLoaded) {
|
|
120
|
+
const k = this.renderKernelOption({
|
|
121
|
+
walletType: 'extension',
|
|
122
|
+
});
|
|
123
|
+
root.appendChild(k);
|
|
124
|
+
}
|
|
125
|
+
for (const kernel of this.verifiedKernels()) {
|
|
126
|
+
const k = this.renderKernelOption(kernel);
|
|
127
|
+
root.appendChild(k);
|
|
128
|
+
}
|
|
129
|
+
root.appendChild(input);
|
|
130
|
+
root.appendChild(button);
|
|
131
|
+
// Replace the whole root (except styles), don't append
|
|
132
|
+
if (this.shadowRoot) {
|
|
133
|
+
Array.from(this.shadowRoot.childNodes).forEach((node) => {
|
|
134
|
+
if (!(node instanceof HTMLStyleElement)) {
|
|
135
|
+
this.shadowRoot.removeChild(node);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
this.shadowRoot.appendChild(root);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
connectedCallback() {
|
|
142
|
+
this.render();
|
|
143
|
+
}
|
|
144
|
+
attributeChangedCallback() {
|
|
145
|
+
this.render();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
customElements.define('swk-discovery', Discovery);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Network } from '@canton-network/core-wallet-store';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
export declare class NetworkForm extends LitElement {
|
|
4
|
+
editingNetwork: Network | null;
|
|
5
|
+
authType: string;
|
|
6
|
+
static styles: import("lit").CSSResult[];
|
|
7
|
+
private getAuthField;
|
|
8
|
+
onAuthTypeChange(e: Event): void;
|
|
9
|
+
handleSubmit(e: Event): void;
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=NetworkForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NetworkForm.d.ts","sourceRoot":"","sources":["../../src/components/NetworkForm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAA;AAItC,qBACa,WAAY,SAAQ,UAAU;IACX,cAAc,EAAE,OAAO,GAAG,IAAI,CAAO;IACrC,QAAQ,EAAE,MAAM,CAAa;IAEzD,MAAM,CAAC,MAAM,4BAAW;IAExB,OAAO,CAAC,YAAY;IAOpB,gBAAgB,CAAC,CAAC,EAAE,KAAK;IAKzB,YAAY,CAAC,CAAC,EAAE,KAAK;IAerB,MAAM;CA6GT"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
};
|
|
9
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
+
};
|
|
12
|
+
import { LitElement, html } from 'lit';
|
|
13
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
14
|
+
import { styles } from '../themes/styles.js';
|
|
15
|
+
let NetworkForm = class NetworkForm extends LitElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.editingNetwork = null;
|
|
19
|
+
this.authType = 'implicit';
|
|
20
|
+
}
|
|
21
|
+
static { this.styles = [styles]; }
|
|
22
|
+
getAuthField(field) {
|
|
23
|
+
if (!this.editingNetwork)
|
|
24
|
+
return '';
|
|
25
|
+
const auth = this.editingNetwork.auth;
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
return auth?.[field] ?? '';
|
|
28
|
+
}
|
|
29
|
+
onAuthTypeChange(e) {
|
|
30
|
+
const select = e.target;
|
|
31
|
+
this.authType = select.value;
|
|
32
|
+
}
|
|
33
|
+
handleSubmit(e) {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
const form = e.target;
|
|
36
|
+
const formData = new FormData(form);
|
|
37
|
+
this.dispatchEvent(new CustomEvent('form-submit', {
|
|
38
|
+
detail: formData,
|
|
39
|
+
bubbles: true,
|
|
40
|
+
composed: true,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
return html `
|
|
45
|
+
<form @submit=${this.handleSubmit}>
|
|
46
|
+
<input
|
|
47
|
+
name="name"
|
|
48
|
+
placeholder="Name"
|
|
49
|
+
.value=${this.editingNetwork?.name ?? ''}
|
|
50
|
+
required
|
|
51
|
+
/>
|
|
52
|
+
<input
|
|
53
|
+
name="chainId"
|
|
54
|
+
placeholder="Network Id"
|
|
55
|
+
.value=${this.editingNetwork?.chainId ?? ''}
|
|
56
|
+
required
|
|
57
|
+
/>
|
|
58
|
+
<input
|
|
59
|
+
name="synchronizerId"
|
|
60
|
+
placeholder="Synchronizer Id"
|
|
61
|
+
.value=${this.editingNetwork?.synchronizerId ?? ''}
|
|
62
|
+
required
|
|
63
|
+
/>
|
|
64
|
+
<input
|
|
65
|
+
name="description"
|
|
66
|
+
placeholder="Description"
|
|
67
|
+
.value=${this.editingNetwork?.description ?? ''}
|
|
68
|
+
required
|
|
69
|
+
/>
|
|
70
|
+
<input
|
|
71
|
+
name="ledgerApi.baseurl"
|
|
72
|
+
placeholder="Ledger API Base Url"
|
|
73
|
+
.value=${this.editingNetwork?.ledgerApi?.baseUrl ?? ''}
|
|
74
|
+
required
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<select
|
|
78
|
+
name="authType"
|
|
79
|
+
@change=${this.onAuthTypeChange}
|
|
80
|
+
.value=${this.authType}
|
|
81
|
+
>
|
|
82
|
+
<option value="password">password</option>
|
|
83
|
+
<option value="implicit">implicit</option>
|
|
84
|
+
</select>
|
|
85
|
+
|
|
86
|
+
${this.authType === 'implicit'
|
|
87
|
+
? html `
|
|
88
|
+
<input
|
|
89
|
+
name="domain"
|
|
90
|
+
placeholder="Domain"
|
|
91
|
+
.value=${this.getAuthField('domain')}
|
|
92
|
+
required
|
|
93
|
+
/>
|
|
94
|
+
<input
|
|
95
|
+
name="clientId"
|
|
96
|
+
placeholder="ClientId"
|
|
97
|
+
.value=${this.getAuthField('clientId')}
|
|
98
|
+
required
|
|
99
|
+
/>
|
|
100
|
+
<input
|
|
101
|
+
name="scope"
|
|
102
|
+
placeholder="Scope"
|
|
103
|
+
.value=${this.getAuthField('scope')}
|
|
104
|
+
required
|
|
105
|
+
/>
|
|
106
|
+
<input
|
|
107
|
+
name="audience"
|
|
108
|
+
placeholder="Audience"
|
|
109
|
+
.value=${this.getAuthField('audience')}
|
|
110
|
+
required
|
|
111
|
+
/>
|
|
112
|
+
`
|
|
113
|
+
: html `
|
|
114
|
+
<input
|
|
115
|
+
name="tokenUrl"
|
|
116
|
+
placeholder="TokenUrl"
|
|
117
|
+
.value=${this.getAuthField('tokenUrl')}
|
|
118
|
+
required
|
|
119
|
+
/>
|
|
120
|
+
<input
|
|
121
|
+
name="grantType"
|
|
122
|
+
placeholder="GrantType"
|
|
123
|
+
.value=${this.getAuthField('grantType')}
|
|
124
|
+
required
|
|
125
|
+
/>
|
|
126
|
+
<input
|
|
127
|
+
name="scope"
|
|
128
|
+
placeholder="Scope"
|
|
129
|
+
.value=${this.getAuthField('scope')}
|
|
130
|
+
required
|
|
131
|
+
/>
|
|
132
|
+
<input
|
|
133
|
+
name="audience"
|
|
134
|
+
placeholder="Audience"
|
|
135
|
+
.value=${this.getAuthField('audience')}
|
|
136
|
+
required
|
|
137
|
+
/>
|
|
138
|
+
`}
|
|
139
|
+
|
|
140
|
+
<div class="buttons">
|
|
141
|
+
<button type="submit">Save</button>
|
|
142
|
+
<button
|
|
143
|
+
type="button"
|
|
144
|
+
@click=${() => this.dispatchEvent(new Event('cancel'))}
|
|
145
|
+
>
|
|
146
|
+
Cancel
|
|
147
|
+
</button>
|
|
148
|
+
</div>
|
|
149
|
+
</form>
|
|
150
|
+
`;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
__decorate([
|
|
154
|
+
property({ type: Object }),
|
|
155
|
+
__metadata("design:type", Object)
|
|
156
|
+
], NetworkForm.prototype, "editingNetwork", void 0);
|
|
157
|
+
__decorate([
|
|
158
|
+
property({ type: String }),
|
|
159
|
+
__metadata("design:type", String)
|
|
160
|
+
], NetworkForm.prototype, "authType", void 0);
|
|
161
|
+
NetworkForm = __decorate([
|
|
162
|
+
customElement('network-form')
|
|
163
|
+
], NetworkForm);
|
|
164
|
+
export { NetworkForm };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Network } from '@canton-network/core-wallet-store';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
export declare class NetworkTable extends LitElement {
|
|
4
|
+
networks: Network[];
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=NetworkTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NetworkTable.d.ts","sourceRoot":"","sources":["../../src/components/NetworkTable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAA;AAKtC,qBACa,YAAa,SAAQ,UAAU;IACb,QAAQ,EAAE,OAAO,EAAE,CAAK;IAEnD,MAAM,CAAC,MAAM,4BAAW;IAExB,MAAM;CA2CT"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
};
|
|
9
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
+
};
|
|
12
|
+
import { LitElement, html } from 'lit';
|
|
13
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
14
|
+
import { styles } from '../themes/styles.js';
|
|
15
|
+
let NetworkTable = class NetworkTable extends LitElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.networks = [];
|
|
19
|
+
}
|
|
20
|
+
static { this.styles = [styles]; }
|
|
21
|
+
render() {
|
|
22
|
+
console.log('rendering with networks ' + JSON.stringify(this.networks));
|
|
23
|
+
return html `
|
|
24
|
+
<table>
|
|
25
|
+
<thead>
|
|
26
|
+
<tr>
|
|
27
|
+
<th>Name</th>
|
|
28
|
+
<th>ID</th>
|
|
29
|
+
<th>Description</th>
|
|
30
|
+
<th>Auth type</th>
|
|
31
|
+
<th>Synchronizer ID</th>
|
|
32
|
+
<th>Actions</th>
|
|
33
|
+
</tr>
|
|
34
|
+
</thead>
|
|
35
|
+
<tbody>
|
|
36
|
+
${this.networks.map((net) => html `
|
|
37
|
+
<tr>
|
|
38
|
+
<td>${net.name}</td>
|
|
39
|
+
<td>${net.chainId}</td>
|
|
40
|
+
<td>${net.description}</td>
|
|
41
|
+
<td>${net.auth.type}</td>
|
|
42
|
+
<td>${net.synchronizerId}</td>
|
|
43
|
+
<td class="actions">
|
|
44
|
+
<button>Update</button>
|
|
45
|
+
<button
|
|
46
|
+
@click=${() => this.dispatchEvent(new CustomEvent('delete', {
|
|
47
|
+
detail: net,
|
|
48
|
+
}))}
|
|
49
|
+
>
|
|
50
|
+
Delete
|
|
51
|
+
</button>
|
|
52
|
+
</td>
|
|
53
|
+
</tr>
|
|
54
|
+
`)}
|
|
55
|
+
</tbody>
|
|
56
|
+
</table>
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
__decorate([
|
|
61
|
+
property({ type: Array }),
|
|
62
|
+
__metadata("design:type", Array)
|
|
63
|
+
], NetworkTable.prototype, "networks", void 0);
|
|
64
|
+
NetworkTable = __decorate([
|
|
65
|
+
customElement('network-table')
|
|
66
|
+
], NetworkTable);
|
|
67
|
+
export { NetworkTable };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAA;AAI3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAElC,OAAO,2BAA2B,CAAA;AAClC,OAAO,+BAA+B,CAAA;AACtC,OAAO,8BAA8B,CAAA;AACrC,OAAO,6BAA6B,CAAA;AAGpC,qBACa,KAAM,SAAQ,UAAU;IACjC,MAAM,CAAC,MAAM,0BAMZ;IAGD,UAAU;;;QAST;IAED,OAAO,CAAC,wBAAwB;IAiBhC,SAAS,CAAC,MAAM;CA2BnB"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
1
3
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
4
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
5
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/themes/styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,yBAuElB,CAAA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { css } from 'lit';
|
|
4
|
+
export const styles = css `
|
|
5
|
+
.table-wrapper {
|
|
6
|
+
max-height: 300px;
|
|
7
|
+
overflow-y: auto;
|
|
8
|
+
border: 1px solid var(--splice-wk-border-color, #ccc);
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
table {
|
|
13
|
+
width: 100%;
|
|
14
|
+
border-collapse: collapse;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
thead th {
|
|
18
|
+
position: sticky;
|
|
19
|
+
top: 0;
|
|
20
|
+
z-index: 1;
|
|
21
|
+
text-align: left;
|
|
22
|
+
padding: 8px 12px;
|
|
23
|
+
border-bottom: 1px solid var(--splice-wk-border-color, #ccc);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
tbody td {
|
|
27
|
+
padding: 8px 12px;
|
|
28
|
+
border-bottom: 1px solid var(--splice-wk-border-color, #ccc);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
tr:nth-child(even) {
|
|
32
|
+
background-color: var(--splice-wk-background-color, none);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.actions button {
|
|
36
|
+
margin-right: 4px;
|
|
37
|
+
font-size: 0.8rem;
|
|
38
|
+
padding: 4px 8px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.modal {
|
|
42
|
+
position: fixed;
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.modal-content {
|
|
49
|
+
background: var(--splice-wk-background-color, none);
|
|
50
|
+
padding: 1.5rem;
|
|
51
|
+
border-radius: 8px;
|
|
52
|
+
width: 400px;
|
|
53
|
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.form {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
gap: 10px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
input,
|
|
63
|
+
select {
|
|
64
|
+
padding: 6px;
|
|
65
|
+
font-size: 1rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.buttons {
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: flex-end;
|
|
71
|
+
margin-top: 1rem;
|
|
72
|
+
gap: 0.5rem;
|
|
73
|
+
margin-bottom: 1.5rem;
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/windows/discovery.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAI3D,wBAAsB,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,CAiCxD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Discovery } from '../components/Discovery.js';
|
|
4
|
+
import { popup } from './popup.js';
|
|
5
|
+
export async function discover() {
|
|
6
|
+
const win = await popup(Discovery, {
|
|
7
|
+
title: 'Wallet Discovery',
|
|
8
|
+
target: 'wallet-discovery',
|
|
9
|
+
});
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
let response = undefined;
|
|
12
|
+
win.addEventListener('beforeunload', () => {
|
|
13
|
+
if (response === undefined) {
|
|
14
|
+
console.log('Wallet discovery window closed by user');
|
|
15
|
+
reject('User closed the wallet discovery window');
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const handler = (event) => {
|
|
19
|
+
if (event.origin === window.location.origin &&
|
|
20
|
+
typeof event.data.walletType === 'string') {
|
|
21
|
+
response = event.data;
|
|
22
|
+
resolve({
|
|
23
|
+
url: event.data.url,
|
|
24
|
+
walletType: event.data.walletType,
|
|
25
|
+
});
|
|
26
|
+
window.removeEventListener('message', handler);
|
|
27
|
+
win.close();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
window.addEventListener('message', handler);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface PopupOptions {
|
|
2
|
+
title?: string;
|
|
3
|
+
target?: string;
|
|
4
|
+
width?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
screenX?: number;
|
|
7
|
+
screenY?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function popup(component: new () => HTMLElement, options?: PopupOptions): Promise<Window>;
|
|
10
|
+
export declare function popupHref(url: URL | string, options?: PopupOptions): Promise<Window>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=popup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../../src/windows/popup.ts"],"names":[],"mappings":"AAKA,UAAU,YAAY;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,KAAK,CACjB,SAAS,EAAE,UAAU,WAAW,EAChC,OAAO,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,MAAM,CAAC,CA6DjB;AAED,wBAAgB,SAAS,CACrB,GAAG,EAAE,GAAG,GAAG,MAAM,EACjB,OAAO,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import styles from '../../themes/default.css?inline';
|
|
4
|
+
export function popup(component, options) {
|
|
5
|
+
const { title = 'Custom Popup', target = 'wallet-popup', width = 400, height = 500, screenX = 200, screenY = 200, } = options || {};
|
|
6
|
+
const html = `<!DOCTYPE html>
|
|
7
|
+
<html>
|
|
8
|
+
<head>
|
|
9
|
+
<title>${title}</title>
|
|
10
|
+
<style>
|
|
11
|
+
html, body {
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 0;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
body {
|
|
19
|
+
display: flex;
|
|
20
|
+
}
|
|
21
|
+
</style>
|
|
22
|
+
<style>${styles}</style>
|
|
23
|
+
</head>
|
|
24
|
+
<body>
|
|
25
|
+
</body>
|
|
26
|
+
|
|
27
|
+
<script>
|
|
28
|
+
customElements.define('popup-content', ${component})
|
|
29
|
+
|
|
30
|
+
const root = document.getElementsByTagName('body')[0]
|
|
31
|
+
|
|
32
|
+
const content = document.createElement('popup-content')
|
|
33
|
+
content.setAttribute('style', 'width: 100%; height: 100%;')
|
|
34
|
+
|
|
35
|
+
root.appendChild(content)
|
|
36
|
+
</script>
|
|
37
|
+
</html>`;
|
|
38
|
+
const url = URL.createObjectURL(new Blob([html], { type: 'text/html' }));
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const win = window.open(url, target, `width=${width},height=${height},screenX=${screenX},screenY=${screenY}`);
|
|
41
|
+
if (win) {
|
|
42
|
+
win.addEventListener('beforeunload', () => {
|
|
43
|
+
URL.revokeObjectURL(url); // clean up the URL object to prevent memory leaks
|
|
44
|
+
});
|
|
45
|
+
resolve(win);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
reject(new Error('Failed to open popup window.'));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function popupHref(url, options) {
|
|
53
|
+
const { target = 'wallet-popup', width = 400, height = 500, screenX = 200, screenY = 200, } = options || {};
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
const win = window.open(url, target, `width=${width},height=${height},screenX=${screenX},screenY=${screenY}`);
|
|
56
|
+
if (win) {
|
|
57
|
+
win.focus();
|
|
58
|
+
resolve(win);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
reject(new Error('Failed to open popup window.'));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canton-network/core-wallet-ui-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Reusable UI components for the Splice wallet",
|
|
6
|
-
"repository": "
|
|
6
|
+
"repository": "github:hyperledger-labs/splice-wallet-kernel",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"author": "Marc Juchli <marc.juchli@digitalasset.com>",
|
|
9
9
|
"main": "./dist/index.js",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"typescript": "^5.8.3",
|
|
24
24
|
"vite": "^6.3.5"
|
|
25
25
|
},
|
|
26
|
-
"packageManager": "yarn@4.9.
|
|
26
|
+
"packageManager": "yarn@4.9.4",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@canton-network/core-types": "^0.
|
|
29
|
-
"@canton-network/core-wallet-store": "^0.
|
|
28
|
+
"@canton-network/core-types": "^0.2.0",
|
|
29
|
+
"@canton-network/core-wallet-store": "^0.2.0",
|
|
30
30
|
"@popperjs/core": "^2.11.8",
|
|
31
31
|
"bootstrap": "^5.3.7",
|
|
32
32
|
"lit": "^3.3.0"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
|
-
"dist
|
|
35
|
+
"dist/**"
|
|
36
36
|
],
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|