@bwalletx/connect 0.2.0 → 0.4.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.
- package/BRAND.md +16 -0
- package/CHANGELOG.md +25 -0
- package/README.md +189 -4
- package/dist/bwalletx-connect.global.js +41 -3
- package/dist/bwalletx-connect.global.js.map +1 -1
- package/dist/bwalletx-shell.global.js +54 -0
- package/dist/bwalletx-shell.global.js.map +1 -0
- package/dist/chunk-7NAKOJGZ.js +442 -0
- package/dist/chunk-7NAKOJGZ.js.map +1 -0
- package/dist/chunk-FUQ46RJV.js +404 -0
- package/dist/chunk-FUQ46RJV.js.map +1 -0
- package/dist/chunk-OMEKHKMM.js +530 -0
- package/dist/chunk-OMEKHKMM.js.map +1 -0
- package/dist/index.cjs +425 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -62
- package/dist/index.d.ts +23 -62
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/dist/manifest-Caj_Raqm.d.cts +81 -0
- package/dist/manifest-Caj_Raqm.d.ts +81 -0
- package/dist/next.cjs +415 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +48 -0
- package/dist/next.d.ts +48 -0
- package/dist/next.js +107 -0
- package/dist/next.js.map +1 -0
- package/dist/react.cjs +586 -36
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +74 -28
- package/dist/react.d.ts +74 -28
- package/dist/react.js +175 -3
- package/dist/react.js.map +1 -1
- package/dist/server.cjs +339 -4
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +204 -2
- package/dist/server.d.ts +204 -2
- package/dist/server.js +36 -107
- package/dist/server.js.map +1 -1
- package/dist/shell-react.cjs +361 -0
- package/dist/shell-react.cjs.map +1 -0
- package/dist/shell-react.d.cts +58 -0
- package/dist/shell-react.d.ts +58 -0
- package/dist/shell-react.js +52 -0
- package/dist/shell-react.js.map +1 -0
- package/dist/shell.cjs +578 -0
- package/dist/shell.cjs.map +1 -0
- package/dist/shell.d.cts +132 -0
- package/dist/shell.d.ts +132 -0
- package/dist/shell.js +51 -0
- package/dist/shell.js.map +1 -0
- package/dist/wallets-VOKIKBbO.d.cts +250 -0
- package/dist/wallets-VOKIKBbO.d.ts +250 -0
- package/package.json +65 -14
- package/schema/bapp.schema.json +95 -0
|
@@ -0,0 +1,361 @@
|
|
|
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/shell/react.ts
|
|
21
|
+
var react_exports = {};
|
|
22
|
+
__export(react_exports, {
|
|
23
|
+
BappBar: () => BappBar,
|
|
24
|
+
BappDrawer: () => BappDrawer,
|
|
25
|
+
BappTopbar: () => BappTopbar
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(react_exports);
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
|
|
30
|
+
// src/shell/manifest.ts
|
|
31
|
+
var SLOT_IDS = ["wallet", "exchange", "b", "feed", "chat"];
|
|
32
|
+
function slotPath(m, slot) {
|
|
33
|
+
const s = m.slots[slot];
|
|
34
|
+
return s && s.enabled && s.path ? s.path : null;
|
|
35
|
+
}
|
|
36
|
+
var isSlotId = (v) => typeof v === "string" && SLOT_IDS.includes(v);
|
|
37
|
+
|
|
38
|
+
// src/shell/wallet.ts
|
|
39
|
+
var UA_RE = /\b(?:bWallet|YoursWalletMobile)\//;
|
|
40
|
+
var INSET_RE = /\bbWalletInset\/(\d{1,4})\b/;
|
|
41
|
+
function detectWalletUA(ua = typeof navigator !== "undefined" ? navigator.userAgent : "") {
|
|
42
|
+
const inset = INSET_RE.exec(ua);
|
|
43
|
+
if (inset || UA_RE.test(ua)) return { inWallet: true, via: "ua", ...inset ? { inset: Number(inset[1]) } : {} };
|
|
44
|
+
return { inWallet: false, via: null };
|
|
45
|
+
}
|
|
46
|
+
var state = { inWallet: false, via: null };
|
|
47
|
+
function walletState() {
|
|
48
|
+
return state;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/shell/elements.ts
|
|
52
|
+
var TOKENS = {
|
|
53
|
+
barHeight: 88,
|
|
54
|
+
barBg: "#0A0B0D",
|
|
55
|
+
hairline: "#1C1C1E",
|
|
56
|
+
icon: 20,
|
|
57
|
+
active: "#FFD24D",
|
|
58
|
+
inactive: "#F2F2F0",
|
|
59
|
+
label: "#98A2B3",
|
|
60
|
+
bSize: 52,
|
|
61
|
+
stripHeight: 28,
|
|
62
|
+
rowHeight: 56,
|
|
63
|
+
tool: 36,
|
|
64
|
+
toolRing: "#2A2A2C",
|
|
65
|
+
toolIcon: "#F5B800"
|
|
66
|
+
};
|
|
67
|
+
var DEFAULT_LABELS = { wallet: "Wallet", exchange: "Exchange", b: "b", feed: "Feed", chat: "Chat" };
|
|
68
|
+
var svg = (d) => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${d}</svg>`;
|
|
69
|
+
var ICONS = {
|
|
70
|
+
wallet: svg('<rect x="3" y="6" width="18" height="13" rx="2"/><path d="M3 10h18"/>'),
|
|
71
|
+
exchange: svg('<path d="M7 4v16M3 8l4-4 4 4M17 20V4M13 16l4 4 4-4"/>'),
|
|
72
|
+
feed: svg('<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M8 9h8M8 13h8M8 17h5"/>'),
|
|
73
|
+
chat: svg('<path d="M21 12a8 8 0 0 1-12 7l-5 1 1-4a8 8 0 1 1 16-4z"/>'),
|
|
74
|
+
menu: svg('<path d="M4 6h16M4 12h16M4 18h16"/>'),
|
|
75
|
+
close: svg('<path d="M6 6l12 12M18 6L6 18"/>')
|
|
76
|
+
};
|
|
77
|
+
var esc = (s) => s.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
78
|
+
var Base = typeof HTMLElement === "undefined" ? class {
|
|
79
|
+
} : HTMLElement;
|
|
80
|
+
function inWallet(el) {
|
|
81
|
+
const a = el.getAttribute("in-wallet");
|
|
82
|
+
if (a === "true" || a === "") return true;
|
|
83
|
+
if (a === "false") return false;
|
|
84
|
+
return walletState().inWallet || detectWalletUA().inWallet;
|
|
85
|
+
}
|
|
86
|
+
function emit(el, type, detail, cancelable = false) {
|
|
87
|
+
return el.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true, cancelable }));
|
|
88
|
+
}
|
|
89
|
+
function navigate(el, detail) {
|
|
90
|
+
const ok = emit(el, "bapp-navigate", { ...detail, source: "web" }, true);
|
|
91
|
+
if (ok && detail.path && el.getAttribute("navigate") !== "manual") location.assign(detail.path);
|
|
92
|
+
}
|
|
93
|
+
var ShellElement = class extends Base {
|
|
94
|
+
_manifest = null;
|
|
95
|
+
onWallet = () => this.render();
|
|
96
|
+
get manifest() {
|
|
97
|
+
return this._manifest;
|
|
98
|
+
}
|
|
99
|
+
set manifest(m) {
|
|
100
|
+
this._manifest = m;
|
|
101
|
+
this.render();
|
|
102
|
+
}
|
|
103
|
+
connectedCallback() {
|
|
104
|
+
if (!this.shadowRoot) this.attachShadow({ mode: "open" });
|
|
105
|
+
window.addEventListener("bapp-wallet", this.onWallet);
|
|
106
|
+
this.render();
|
|
107
|
+
}
|
|
108
|
+
disconnectedCallback() {
|
|
109
|
+
window.removeEventListener("bapp-wallet", this.onWallet);
|
|
110
|
+
}
|
|
111
|
+
attributeChangedCallback() {
|
|
112
|
+
if (this.shadowRoot) this.render();
|
|
113
|
+
}
|
|
114
|
+
accent() {
|
|
115
|
+
return this._manifest?.theme?.accent ?? TOKENS.active;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var BAR_CSS = `
|
|
119
|
+
:host{display:block;--bwx-accent:${TOKENS.active}}
|
|
120
|
+
:host([hidden]),:host([data-in-wallet]){display:none!important}
|
|
121
|
+
nav{height:${TOKENS.barHeight}px;box-sizing:border-box;background:${TOKENS.barBg};border-top:1px solid ${TOKENS.hairline};
|
|
122
|
+
display:flex;align-items:flex-start;padding:10px 0 env(safe-area-inset-bottom,0);font:10px/1.2 -apple-system,BlinkMacSystemFont,"SF Pro Text",system-ui,sans-serif}
|
|
123
|
+
button{all:unset;box-sizing:border-box;flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;gap:4px;cursor:pointer;
|
|
124
|
+
color:${TOKENS.inactive};-webkit-tap-highlight-color:transparent;touch-action:manipulation}
|
|
125
|
+
button:focus-visible{outline:2px solid var(--bwx-accent);outline-offset:2px;border-radius:10px}
|
|
126
|
+
button svg{width:${TOKENS.icon}px;height:${TOKENS.icon}px}
|
|
127
|
+
.lbl{font-size:10px;color:${TOKENS.label};white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
|
|
128
|
+
button[aria-current="page"]{color:var(--bwx-accent)}
|
|
129
|
+
button[aria-current="page"] .lbl{color:var(--bwx-accent);font-weight:700}
|
|
130
|
+
button:disabled{opacity:.35;cursor:default;pointer-events:none}
|
|
131
|
+
.b{width:${TOKENS.bSize}px;height:${TOKENS.bSize}px;border-radius:50%;background:#000;border:2px solid var(--bwx-accent);box-sizing:border-box;
|
|
132
|
+
display:grid;place-items:center;font:800 24px/1 Georgia,"Times New Roman",serif;color:var(--bwx-accent);margin-top:-4px}
|
|
133
|
+
button[data-slot="b"][aria-current="page"] .b{box-shadow:0 0 0 3px #FFD24D33}
|
|
134
|
+
`;
|
|
135
|
+
var BwalletxBarElement = class extends ShellElement {
|
|
136
|
+
static observedAttributes = ["active", "in-wallet", "hidden"];
|
|
137
|
+
holdTimer = null;
|
|
138
|
+
held = false;
|
|
139
|
+
get active() {
|
|
140
|
+
const a = this.getAttribute("active");
|
|
141
|
+
return isSlotId(a) ? a : null;
|
|
142
|
+
}
|
|
143
|
+
set active(s) {
|
|
144
|
+
if (s) this.setAttribute("active", s);
|
|
145
|
+
else this.removeAttribute("active");
|
|
146
|
+
}
|
|
147
|
+
attributeChangedCallback(name, old, val) {
|
|
148
|
+
super.attributeChangedCallback();
|
|
149
|
+
if (name === "active" && val !== old && isSlotId(val)) emit(this, "bapp-active", { slot: val });
|
|
150
|
+
}
|
|
151
|
+
render() {
|
|
152
|
+
const root = this.shadowRoot;
|
|
153
|
+
if (!root) return;
|
|
154
|
+
if (inWallet(this)) this.setAttribute("data-in-wallet", "");
|
|
155
|
+
else this.removeAttribute("data-in-wallet");
|
|
156
|
+
const m = this._manifest;
|
|
157
|
+
const active = this.active;
|
|
158
|
+
const slots = SLOT_IDS.map((id) => {
|
|
159
|
+
const s = m?.slots[id];
|
|
160
|
+
const enabled = !!s?.enabled;
|
|
161
|
+
const label = s?.label ?? DEFAULT_LABELS[id];
|
|
162
|
+
const cur = active === id ? ' aria-current="page"' : "";
|
|
163
|
+
const dis = enabled ? "" : ' disabled aria-disabled="true"';
|
|
164
|
+
if (id === "b") return `<button type="button" data-slot="b" aria-label="b agent${m ? ` in ${esc(m.name)}` : ""}"${cur}${dis}><span class="b">b</span></button>`;
|
|
165
|
+
return `<button type="button" data-slot="${id}" aria-label="${esc(label)}"${cur}${dis}>${ICONS[id]}<span class="lbl">${esc(label)}</span></button>`;
|
|
166
|
+
}).join("");
|
|
167
|
+
root.innerHTML = `<style>${BAR_CSS}</style><nav part="bar" aria-label="${m ? esc(m.name) : "App"} navigation" style="--bwx-accent:${this.accent()}">${slots}</nav>`;
|
|
168
|
+
root.querySelectorAll("button[data-slot]").forEach((b) => {
|
|
169
|
+
const id = b.dataset.slot;
|
|
170
|
+
if (id === "b") this.wireB(b);
|
|
171
|
+
else b.addEventListener("click", () => this.go(id));
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
go(id) {
|
|
175
|
+
const m = this._manifest;
|
|
176
|
+
if (!m || !m.slots[id]?.enabled) return;
|
|
177
|
+
this.active = id;
|
|
178
|
+
navigate(this, { slot: id, path: slotPath(m, id) });
|
|
179
|
+
}
|
|
180
|
+
/** (b): tap = bapp-b-press, hold (>=450ms) = bapp-b-hold {phase:'start'|'end'}. Hold-to-talk is a later phase. */
|
|
181
|
+
wireB(b) {
|
|
182
|
+
const clear = () => {
|
|
183
|
+
if (this.holdTimer) clearTimeout(this.holdTimer);
|
|
184
|
+
this.holdTimer = null;
|
|
185
|
+
};
|
|
186
|
+
b.addEventListener("pointerdown", () => {
|
|
187
|
+
this.held = false;
|
|
188
|
+
clear();
|
|
189
|
+
this.holdTimer = setTimeout(() => {
|
|
190
|
+
this.held = true;
|
|
191
|
+
emit(this, "bapp-b-hold", { phase: "start" });
|
|
192
|
+
}, 450);
|
|
193
|
+
});
|
|
194
|
+
const up = () => {
|
|
195
|
+
clear();
|
|
196
|
+
if (this.held) emit(this, "bapp-b-hold", { phase: "end" });
|
|
197
|
+
};
|
|
198
|
+
b.addEventListener("pointerup", up);
|
|
199
|
+
b.addEventListener("pointercancel", up);
|
|
200
|
+
b.addEventListener("pointerleave", up);
|
|
201
|
+
b.addEventListener("click", () => {
|
|
202
|
+
if (this.held) {
|
|
203
|
+
this.held = false;
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (!this._manifest?.slots.b.enabled) return;
|
|
207
|
+
emit(this, "bapp-b-press", { path: slotPath(this._manifest, "b") });
|
|
208
|
+
const p = slotPath(this._manifest, "b");
|
|
209
|
+
if (p) this.go("b");
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
var TOP_CSS = `
|
|
214
|
+
:host{display:block;--bwx-accent:${TOKENS.active};font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text",system-ui,sans-serif}
|
|
215
|
+
:host([hidden]){display:none!important}
|
|
216
|
+
.strip{height:${TOKENS.stripHeight}px;display:flex;align-items:center;justify-content:space-between;padding:0 16px;font-size:11px;color:#9a9a9a;background:${TOKENS.barBg}}
|
|
217
|
+
::slotted([slot^="strip"]){color:inherit}
|
|
218
|
+
.row{height:${TOKENS.rowHeight}px;box-sizing:border-box;display:flex;align-items:center;gap:8px;padding:0 12px;background:${TOKENS.barBg};border-bottom:1px solid ${TOKENS.hairline}}
|
|
219
|
+
.btn,::slotted([slot="tools"]){all:unset;box-sizing:border-box;width:${TOKENS.tool}px;height:${TOKENS.tool}px;flex:none;border-radius:50%;border:1px solid ${TOKENS.toolRing};
|
|
220
|
+
display:grid;place-items:center;color:${TOKENS.toolIcon};cursor:pointer;-webkit-tap-highlight-color:transparent}
|
|
221
|
+
.btn:focus-visible{outline:2px solid var(--bwx-accent);outline-offset:2px}
|
|
222
|
+
.btn svg{width:18px;height:18px}
|
|
223
|
+
.app{border-color:${TOKENS.toolIcon};background:#1a1405;font-weight:800;font-size:13px;line-height:1;overflow:hidden}
|
|
224
|
+
.app img{width:100%;height:100%;object-fit:cover}
|
|
225
|
+
.title{flex:1;min-width:0;color:#F2F2F0;font-weight:700;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
226
|
+
.title small{display:block;color:#777;font-weight:500;font-size:11px}
|
|
227
|
+
.tools{display:flex;gap:8px}
|
|
228
|
+
`;
|
|
229
|
+
var BwalletxTopbarElement = class extends ShellElement {
|
|
230
|
+
static observedAttributes = ["title", "subtitle", "in-wallet", "drawer", "menu", "strip", "hidden"];
|
|
231
|
+
render() {
|
|
232
|
+
const root = this.shadowRoot;
|
|
233
|
+
if (!root) return;
|
|
234
|
+
const m = this._manifest;
|
|
235
|
+
const wallet = inWallet(this);
|
|
236
|
+
const menu = wallet || this.getAttribute("menu") === "true";
|
|
237
|
+
const name = this.getAttribute("title") ?? m?.name ?? "";
|
|
238
|
+
const sub = this.getAttribute("subtitle");
|
|
239
|
+
const initials = name.replace(/[^A-Za-z0-9]/g, "").slice(0, 2) || "b";
|
|
240
|
+
const icon = m?.icon ? `<img src="${esc(m.icon)}" alt="">` : esc(initials);
|
|
241
|
+
const strip = this.getAttribute("strip") !== "off";
|
|
242
|
+
root.innerHTML = `<style>${TOP_CSS}</style><header part="topbar" style="--bwx-accent:${this.accent()}">
|
|
243
|
+
${strip ? `<div class="strip" part="strip"><slot name="strip-left"></slot><slot name="strip-right"></slot></div>` : ""}
|
|
244
|
+
<div class="row" part="row">
|
|
245
|
+
${menu ? `<button type="button" class="btn" data-act="menu" aria-label="bWalletX menu">${ICONS.menu}</button>` : ""}
|
|
246
|
+
<button type="button" class="btn app" data-act="drawer" aria-label="${esc(name || "App")} home and sections" aria-haspopup="true">${icon}</button>
|
|
247
|
+
<div class="title" part="title">${esc(name)}${sub ? `<small>${esc(sub)}</small>` : ""}</div>
|
|
248
|
+
<div class="tools"><slot name="tools"></slot>${wallet ? `<button type="button" class="btn" data-act="close" aria-label="Close ${esc(name || "app")}">${ICONS.close}</button>` : ""}</div>
|
|
249
|
+
</div></header>`;
|
|
250
|
+
root.querySelector('[data-act="menu"]')?.addEventListener("click", () => emit(this, "bapp-menu", {}));
|
|
251
|
+
root.querySelector('[data-act="close"]')?.addEventListener("click", () => emit(this, "bapp-close", {}));
|
|
252
|
+
root.querySelector('[data-act="drawer"]')?.addEventListener("click", () => {
|
|
253
|
+
if (!emit(this, "bapp-drawer-toggle", {}, true)) return;
|
|
254
|
+
const id = this.getAttribute("drawer");
|
|
255
|
+
const d = id ? document.getElementById(id) : document.querySelector("bwalletx-drawer");
|
|
256
|
+
d?.toggle();
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
var DRAWER_CSS = `
|
|
261
|
+
:host{position:fixed;inset:var(--bwx-drawer-top,84px) 0 var(--bwx-drawer-bottom,88px) 0;z-index:50;display:none;font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text",system-ui,sans-serif}
|
|
262
|
+
:host([open]){display:block}
|
|
263
|
+
.scrim{position:absolute;inset:0;background:#0009}
|
|
264
|
+
nav{position:absolute;top:0;left:0;bottom:0;width:min(78%,320px);box-sizing:border-box;background:#0d0e10;border-right:1px solid ${TOKENS.hairline};padding:14px;overflow:auto}
|
|
265
|
+
h4{margin:10px 0 6px;font-size:11px;color:#777;letter-spacing:.08em;text-transform:uppercase;font-weight:600}
|
|
266
|
+
a{display:flex;align-items:center;gap:10px;padding:11px 10px;border-radius:10px;color:#F2F2F0;text-decoration:none;font-size:15px}
|
|
267
|
+
a img{width:20px;height:20px}
|
|
268
|
+
a[aria-current="page"]{background:#1a1405;color:var(--bwx-accent)}
|
|
269
|
+
a:focus-visible{outline:2px solid var(--bwx-accent)}
|
|
270
|
+
hr{border:0;border-top:1px solid ${TOKENS.hairline};margin:10px 0}
|
|
271
|
+
.back{color:${TOKENS.toolIcon}}
|
|
272
|
+
`;
|
|
273
|
+
var BwalletxDrawerElement = class extends ShellElement {
|
|
274
|
+
static observedAttributes = ["open", "current", "in-wallet"];
|
|
275
|
+
get open() {
|
|
276
|
+
return this.hasAttribute("open");
|
|
277
|
+
}
|
|
278
|
+
set open(v) {
|
|
279
|
+
this.toggleAttribute("open", v);
|
|
280
|
+
}
|
|
281
|
+
toggle(force) {
|
|
282
|
+
this.open = force ?? !this.open;
|
|
283
|
+
}
|
|
284
|
+
render() {
|
|
285
|
+
const root = this.shadowRoot;
|
|
286
|
+
if (!root) return;
|
|
287
|
+
const m = this._manifest;
|
|
288
|
+
const cur = this.getAttribute("current") ?? (typeof location !== "undefined" ? location.pathname : "/");
|
|
289
|
+
const items = m ? [{ label: "Home", path: m.home }, ...m.drawer] : [];
|
|
290
|
+
const links = items.map((it, i) => `<a href="${esc(it.path)}" data-i="${i}"${it.path === cur ? ' aria-current="page"' : ""}>${"icon" in it && it.icon ? `<img src="${esc(it.icon)}" alt="">` : ""}${esc(it.label)}</a>`).join("");
|
|
291
|
+
const back = inWallet(this) ? `<hr><a href="#" class="back" data-act="close">\u2190 Back to bWalletX</a>` : "";
|
|
292
|
+
root.innerHTML = `<style>${DRAWER_CSS}</style><div class="scrim" part="scrim"></div><nav part="drawer" aria-label="${m ? esc(m.name) : "App"} sections" style="--bwx-accent:${this.accent()}"><h4>${m ? esc(m.name) : ""}</h4>${links}${back}</nav>`;
|
|
293
|
+
root.querySelector(".scrim").addEventListener("click", () => this.toggle(false));
|
|
294
|
+
root.querySelectorAll("a[data-i]").forEach((a) => a.addEventListener("click", (e) => {
|
|
295
|
+
e.preventDefault();
|
|
296
|
+
const it = items[Number(a.dataset.i)];
|
|
297
|
+
this.toggle(false);
|
|
298
|
+
navigate(this, { path: it.path });
|
|
299
|
+
}));
|
|
300
|
+
root.querySelector('[data-act="close"]')?.addEventListener("click", (e) => {
|
|
301
|
+
e.preventDefault();
|
|
302
|
+
this.toggle(false);
|
|
303
|
+
emit(this, "bapp-close", {});
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
function defineBappShell() {
|
|
308
|
+
if (typeof customElements === "undefined") return;
|
|
309
|
+
if (!customElements.get("bwalletx-bar")) customElements.define("bwalletx-bar", BwalletxBarElement);
|
|
310
|
+
if (!customElements.get("bwalletx-topbar")) customElements.define("bwalletx-topbar", BwalletxTopbarElement);
|
|
311
|
+
if (!customElements.get("bwalletx-drawer")) customElements.define("bwalletx-drawer", BwalletxDrawerElement);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/shell/react.ts
|
|
315
|
+
function useShell(tag, props, attrs, events) {
|
|
316
|
+
const ref = (0, import_react.useRef)(null);
|
|
317
|
+
(0, import_react.useEffect)(() => {
|
|
318
|
+
defineBappShell();
|
|
319
|
+
}, []);
|
|
320
|
+
(0, import_react.useEffect)(() => {
|
|
321
|
+
if (ref.current) ref.current.manifest = props.manifest;
|
|
322
|
+
}, [props.manifest]);
|
|
323
|
+
(0, import_react.useEffect)(() => {
|
|
324
|
+
const el = ref.current;
|
|
325
|
+
if (!el) return;
|
|
326
|
+
const all = { "bapp-navigate": props.onNavigate, ...events };
|
|
327
|
+
const subs = Object.entries(all).filter(([, h]) => h).map(([type, h]) => {
|
|
328
|
+
const fn = (e) => h(e.detail, e);
|
|
329
|
+
el.addEventListener(type, fn);
|
|
330
|
+
return () => el.removeEventListener(type, fn);
|
|
331
|
+
});
|
|
332
|
+
return () => subs.forEach((u) => u());
|
|
333
|
+
});
|
|
334
|
+
const a = { ref, id: props.id, class: props.className, style: props.style };
|
|
335
|
+
if (props.inWallet !== void 0 && props.inWallet !== "auto") a["in-wallet"] = String(props.inWallet);
|
|
336
|
+
if (props.manualNavigation) a.navigate = "manual";
|
|
337
|
+
for (const [k, v] of Object.entries(attrs)) if (v !== void 0) a[k] = v;
|
|
338
|
+
return (0, import_react.createElement)(tag, a, props.children);
|
|
339
|
+
}
|
|
340
|
+
function BappBar(p) {
|
|
341
|
+
return useShell("bwalletx-bar", p, { active: p.active ?? void 0 }, { "bapp-active": p.onActive, "bapp-b-press": p.onBPress, "bapp-b-hold": p.onBHold });
|
|
342
|
+
}
|
|
343
|
+
function BappTopbar(p) {
|
|
344
|
+
return useShell("bwalletx-topbar", p, {
|
|
345
|
+
title: p.title,
|
|
346
|
+
subtitle: p.subtitle,
|
|
347
|
+
drawer: p.drawer,
|
|
348
|
+
menu: p.menu ? "true" : void 0,
|
|
349
|
+
strip: p.strip === false ? "off" : void 0
|
|
350
|
+
}, { "bapp-menu": p.onMenu, "bapp-close": p.onClose, "bapp-drawer-toggle": p.onDrawerToggle });
|
|
351
|
+
}
|
|
352
|
+
function BappDrawer(p) {
|
|
353
|
+
return useShell("bwalletx-drawer", p, { open: p.open ? "" : void 0, current: p.current }, { "bapp-close": p.onClose });
|
|
354
|
+
}
|
|
355
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
356
|
+
0 && (module.exports = {
|
|
357
|
+
BappBar,
|
|
358
|
+
BappDrawer,
|
|
359
|
+
BappTopbar
|
|
360
|
+
});
|
|
361
|
+
//# sourceMappingURL=shell-react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shell/react.ts","../src/shell/manifest.ts","../src/shell/wallet.ts","../src/shell/elements.ts"],"sourcesContent":["/**\n * React wrappers for the bApp shell. The elements do the work; these set the manifest property\n * and wire the events.\n *\n * import { BappBar, BappTopbar, BappDrawer } from '@bwalletx/connect/shell/react';\n * <BappTopbar manifest={m} drawer=\"sections\" />\n * <BappDrawer id=\"sections\" manifest={m} />\n * <BappBar manifest={m} active=\"feed\" onNavigate={(d, e) => { e.preventDefault(); router.push(d.path) }} />\n */\nimport { createElement, useEffect, useRef, type CSSProperties, type ReactNode } from 'react';\nimport { defineBappShell } from './elements.js';\nimport type { BappManifest, SlotId } from './manifest.js';\n\nexport interface NavigateDetail { slot?: SlotId; path: string | null; source: 'web' | 'wallet' }\ntype Handler<D> = (detail: D, event: CustomEvent<D>) => void;\n\ninterface Common {\n manifest: BappManifest | null;\n /** \"auto\" (default) detects bWallet; true/false forces. */\n inWallet?: boolean | 'auto';\n /** true = never call location.assign; route in onNavigate. */\n manualNavigation?: boolean;\n onNavigate?: Handler<NavigateDetail>;\n id?: string;\n className?: string;\n style?: CSSProperties;\n /** Slotted content, e.g. <button slot=\"tools\"> or <span slot=\"strip-left\">. */\n children?: ReactNode;\n}\n\nfunction useShell(tag: string, props: Common, attrs: Record<string, string | undefined>, events: Record<string, Handler<any> | undefined>) {\n const ref = useRef<HTMLElement & { manifest: BappManifest | null }>(null);\n useEffect(() => { defineBappShell(); }, []);\n useEffect(() => { if (ref.current) ref.current.manifest = props.manifest; }, [props.manifest]);\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const all = { 'bapp-navigate': props.onNavigate, ...events };\n const subs = Object.entries(all).filter(([, h]) => h).map(([type, h]) => {\n const fn = (e: Event) => h!((e as CustomEvent).detail, e as CustomEvent);\n el.addEventListener(type, fn);\n return () => el.removeEventListener(type, fn);\n });\n return () => subs.forEach((u) => u());\n });\n const a: Record<string, unknown> = { ref, id: props.id, class: props.className, style: props.style };\n if (props.inWallet !== undefined && props.inWallet !== 'auto') a['in-wallet'] = String(props.inWallet);\n if (props.manualNavigation) a.navigate = 'manual';\n for (const [k, v] of Object.entries(attrs)) if (v !== undefined) a[k] = v;\n return createElement(tag, a, props.children);\n}\n\nexport interface BappBarProps extends Common {\n active?: SlotId | null;\n onActive?: Handler<{ slot: SlotId }>;\n onBPress?: Handler<{ path: string | null }>;\n onBHold?: Handler<{ phase: 'start' | 'end' }>;\n}\nexport function BappBar(p: BappBarProps) {\n return useShell('bwalletx-bar', p, { active: p.active ?? undefined }, { 'bapp-active': p.onActive, 'bapp-b-press': p.onBPress, 'bapp-b-hold': p.onBHold });\n}\n\nexport interface BappTopbarProps extends Common {\n title?: string;\n subtitle?: string;\n /** id of the <bwalletx-drawer> the app icon opens. */\n drawer?: string;\n /** Show ☰ on the web too (it always shows in the wallet). */\n menu?: boolean;\n strip?: boolean;\n onMenu?: Handler<object>;\n onClose?: Handler<object>;\n onDrawerToggle?: Handler<object>;\n}\nexport function BappTopbar(p: BappTopbarProps) {\n return useShell('bwalletx-topbar', p, {\n title: p.title, subtitle: p.subtitle, drawer: p.drawer, menu: p.menu ? 'true' : undefined, strip: p.strip === false ? 'off' : undefined,\n }, { 'bapp-menu': p.onMenu, 'bapp-close': p.onClose, 'bapp-drawer-toggle': p.onDrawerToggle });\n}\n\nexport interface BappDrawerProps extends Common {\n open?: boolean;\n /** Path to highlight; default location.pathname. */\n current?: string;\n onClose?: Handler<object>;\n}\nexport function BappDrawer(p: BappDrawerProps) {\n return useShell('bwalletx-drawer', p, { open: p.open ? '' : undefined, current: p.current }, { 'bapp-close': p.onClose });\n}\n\nexport type { BappManifest, SlotId } from './manifest.js';\n","/**\n * bApp manifest: /.well-known/bapp.json. One file declares the app's five scoped slots, its drawer\n * (Home + sections) and its like-to-fund config. The web bar draws from it; inside bWalletX the\n * wallet's native dock reads the same file. Every path is same-origin: no URLs, no schemes.\n */\n\nexport const SLOT_IDS = ['wallet', 'exchange', 'b', 'feed', 'chat'] as const;\nexport type SlotId = (typeof SLOT_IDS)[number];\n\nexport interface BappSlot {\n /** Same-origin path, e.g. \"/feed\". Required when enabled, except for \"b\" (the agent). */\n path?: string;\n /** Optional rename (\"Market\"); the icon and position never change. */\n label?: string;\n /** false = shown greyed out and not clickable. Slots are never hidden. */\n enabled: boolean;\n}\n\nexport interface BappDrawerItem {\n label: string;\n path: string;\n /** Optional same-origin icon path. */\n icon?: string;\n}\n\nexport interface BappLikeConfig {\n /** Which fields of a feed item hold the id, token (BSV-21 id / $TICKER), payee, title and media. */\n fields: { id: string; token: string; payee?: string; title?: string; media?: string };\n /** Price of one Like in US cents. Default 1 (one PNEE). */\n amountCents: number;\n /** Pay in PNEE (the wallet's USD-cent token) when held, else BSV. Default \"PNEE\". */\n currency: 'PNEE' | 'BSV';\n /** Daily cap in US cents. Default 100 ($1), never more. */\n dailyCapCents: number;\n}\n\nexport interface BappTheme {\n /** Active/accent colour, #RRGGBB. Default #FFD24D. */\n accent?: string;\n}\n\nexport interface BappManifest {\n version: 1;\n name: string;\n /** Same-origin path to a square icon. */\n icon: string;\n /** The app's Home (first drawer item). Default \"/\". */\n home: string;\n theme?: BappTheme;\n slots: Record<SlotId, BappSlot>;\n drawer: BappDrawerItem[];\n like?: BappLikeConfig;\n}\n\nexport type ValidationResult =\n | { ok: true; manifest: BappManifest; errors: [] }\n | { ok: false; errors: string[]; manifest?: undefined };\n\nexport const WELL_KNOWN_PATH = '/.well-known/bapp.json';\nexport const LIKE_DEFAULT_CENTS = 1;\nexport const LIKE_MAX_DAILY_CENTS = 100;\n\n/**\n * A same-origin path: starts with one \"/\", no \"//\" (protocol-relative), no backslashes, no control\n * characters, no scheme. Query and hash are allowed.\n */\nexport function isSameOriginPath(p: unknown): p is string {\n if (typeof p !== 'string' || p.length === 0 || p.length > 512) return false;\n if (p[0] !== '/' || p[1] === '/' || p[1] === '\\\\') return false;\n if (/[\\\\\\u0000-\\u001f\\u007f\\s]/.test(p)) return false;\n // Resolving against a dummy origin must not change origin.\n try {\n return new URL(p, 'https://bapp.invalid').origin === 'https://bapp.invalid';\n } catch {\n return false;\n }\n}\n\nconst isObj = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);\nconst str = (v: unknown, max = 64): v is string => typeof v === 'string' && v.trim().length > 0 && v.length <= max;\n\n/** Validate and normalise a parsed bapp.json. Never throws. */\nexport function validateManifest(input: unknown): ValidationResult {\n const errors: string[] = [];\n if (!isObj(input)) return { ok: false, errors: ['manifest must be a JSON object'] };\n const m = input;\n const known = new Set(['$schema', 'version', 'name', 'icon', 'home', 'theme', 'slots', 'drawer', 'like']);\n for (const k of Object.keys(m)) if (!known.has(k)) errors.push(`unknown field \"${k}\"`);\n\n if (m.version !== 1) errors.push('version must be 1');\n if (!str(m.name, 40)) errors.push('name must be a non-empty string (max 40)');\n if (!isSameOriginPath(m.icon)) errors.push('icon must be a same-origin path starting with \"/\"');\n const home = m.home === undefined ? '/' : m.home;\n if (!isSameOriginPath(home)) errors.push('home must be a same-origin path starting with \"/\"');\n\n let theme: BappTheme | undefined;\n if (m.theme !== undefined) {\n if (!isObj(m.theme)) errors.push('theme must be an object');\n else {\n for (const k of Object.keys(m.theme)) if (k !== 'accent') errors.push(`unknown field \"theme.${k}\"`);\n if (m.theme.accent !== undefined && !(typeof m.theme.accent === 'string' && /^#[0-9a-fA-F]{6}$/.test(m.theme.accent)))\n errors.push('theme.accent must be #RRGGBB');\n theme = m.theme.accent ? { accent: m.theme.accent as string } : {};\n }\n }\n\n const slots = {} as Record<SlotId, BappSlot>;\n if (!isObj(m.slots)) errors.push('slots must be an object with wallet, exchange, b, feed, chat');\n else {\n for (const k of Object.keys(m.slots)) if (!(SLOT_IDS as readonly string[]).includes(k)) errors.push(`unknown slot \"${k}\"`);\n for (const id of SLOT_IDS) {\n const s = m.slots[id];\n if (!isObj(s)) { errors.push(`slots.${id} is required (use \"enabled\": false for an unused slot)`); continue; }\n for (const k of Object.keys(s)) if (!['path', 'label', 'enabled'].includes(k)) errors.push(`unknown field \"slots.${id}.${k}\"`);\n if (typeof s.enabled !== 'boolean') errors.push(`slots.${id}.enabled must be true or false`);\n if (s.path !== undefined && !isSameOriginPath(s.path)) errors.push(`slots.${id}.path must be a same-origin path starting with \"/\"`);\n if (s.enabled === true && s.path === undefined && id !== 'b') errors.push(`slots.${id}.path is required when enabled`);\n if (s.label !== undefined && !str(s.label, 12)) errors.push(`slots.${id}.label must be a short string (max 12)`);\n slots[id] = { enabled: s.enabled === true, ...(s.path !== undefined ? { path: s.path as string } : {}), ...(s.label !== undefined ? { label: s.label as string } : {}) };\n }\n }\n\n const drawer: BappDrawerItem[] = [];\n if (m.drawer !== undefined) {\n if (!Array.isArray(m.drawer)) errors.push('drawer must be an array');\n else if (m.drawer.length > 24) errors.push('drawer has more than 24 items');\n else m.drawer.forEach((d, i) => {\n if (!isObj(d)) { errors.push(`drawer[${i}] must be an object`); return; }\n for (const k of Object.keys(d)) if (!['label', 'path', 'icon'].includes(k)) errors.push(`unknown field \"drawer[${i}].${k}\"`);\n if (!str(d.label, 40)) errors.push(`drawer[${i}].label must be a non-empty string (max 40)`);\n if (!isSameOriginPath(d.path)) errors.push(`drawer[${i}].path must be a same-origin path starting with \"/\"`);\n if (d.icon !== undefined && !isSameOriginPath(d.icon)) errors.push(`drawer[${i}].icon must be a same-origin path starting with \"/\"`);\n drawer.push({ label: d.label as string, path: d.path as string, ...(d.icon ? { icon: d.icon as string } : {}) });\n });\n }\n\n let like: BappLikeConfig | undefined;\n if (m.like !== undefined) {\n const l = m.like;\n if (!isObj(l)) errors.push('like must be an object');\n else {\n for (const k of Object.keys(l)) if (!['fields', 'amountCents', 'currency', 'dailyCapCents'].includes(k)) errors.push(`unknown field \"like.${k}\"`);\n const f = l.fields;\n if (!isObj(f) || !str(f.id) || !str(f.token)) errors.push('like.fields needs \"id\" and \"token\" field names');\n else for (const k of ['payee', 'title', 'media']) if (f[k] !== undefined && !str(f[k])) errors.push(`like.fields.${k} must be a field name`);\n const amount = l.amountCents ?? LIKE_DEFAULT_CENTS;\n const cap = l.dailyCapCents ?? LIKE_MAX_DAILY_CENTS;\n const currency = l.currency ?? 'PNEE';\n if (!Number.isInteger(amount) || (amount as number) < 1) errors.push('like.amountCents must be a whole number of cents, at least 1');\n if (!Number.isInteger(cap) || (cap as number) < 1 || (cap as number) > LIKE_MAX_DAILY_CENTS) errors.push('like.dailyCapCents must be 1..100 ($1 max)');\n else if (Number.isInteger(amount) && (amount as number) > (cap as number)) errors.push('like.amountCents cannot exceed like.dailyCapCents');\n if (currency !== 'PNEE' && currency !== 'BSV') errors.push('like.currency must be \"PNEE\" or \"BSV\"');\n if (isObj(f)) {\n const fields: BappLikeConfig['fields'] = { id: f.id as string, token: f.token as string };\n for (const k of ['payee', 'title', 'media'] as const) if (typeof f[k] === 'string') fields[k] = f[k] as string;\n like = { fields, amountCents: amount as number, currency: currency as 'PNEE' | 'BSV', dailyCapCents: cap as number };\n }\n }\n }\n\n if (errors.length) return { ok: false, errors };\n return {\n ok: true,\n errors: [],\n manifest: {\n version: 1, name: (m.name as string).trim(), icon: m.icon as string, home: home as string,\n ...(theme ? { theme } : {}), slots, drawer, ...(like ? { like } : {}),\n },\n };\n}\n\n/** Same as validateManifest but throws with every error listed. */\nexport function parseManifest(input: unknown): BappManifest {\n const r = validateManifest(input);\n if (!r.ok) throw new Error(`Invalid bapp.json:\\n- ${r.errors.join('\\n- ')}`);\n return r.manifest;\n}\n\n/** Fetch and validate /.well-known/bapp.json (same origin). */\nexport async function loadManifest(path: string = WELL_KNOWN_PATH, fetchImpl: typeof fetch = fetch): Promise<BappManifest> {\n if (!isSameOriginPath(path)) throw new Error('loadManifest: path must be same-origin');\n const res = await fetchImpl(path, { credentials: 'same-origin', headers: { accept: 'application/json' } });\n if (!res.ok) throw new Error(`loadManifest: ${path} returned ${res.status}`);\n return parseManifest(await res.json());\n}\n\n/** The path a slot points at, or null when disabled / no path. */\nexport function slotPath(m: BappManifest, slot: SlotId): string | null {\n const s = m.slots[slot];\n return s && s.enabled && s.path ? s.path : null;\n}\n\nexport const isSlotId = (v: unknown): v is SlotId => typeof v === 'string' && (SLOT_IDS as readonly string[]).includes(v);\n","/**\n * In-wallet mode. Inside bWalletX the wallet draws the dock natively; the app hides its web bar,\n * follows `bapp:navigate {slot}` from the wallet, and reports `bapp:active {slot}` back.\n * Protocol: docs/SHELL-PROTOCOL.md.\n */\nimport { isSlotId, slotPath, type BappManifest, type SlotId } from './manifest.js';\n\n/** Wallet web origins allowed to drive a framed bApp. Extension origins are passed in by the app. */\nexport const DEFAULT_WALLET_ORIGINS: readonly string[] = ['https://web.bwalletx.com', 'https://bwalletx.com'];\n\nexport type WalletVia = 'ua' | 'frame' | null;\nexport interface WalletDetection {\n inWallet: boolean;\n via: WalletVia;\n /** Bottom inset (px) the wallet reserves, from `bWalletInset/<n>`. */\n inset?: number;\n}\n\nconst UA_RE = /\\b(?:bWallet|YoursWalletMobile)\\//;\nconst INSET_RE = /\\bbWalletInset\\/(\\d{1,4})\\b/;\n\n/** Synchronous detection from the user agent (native app webviews). */\nexport function detectWalletUA(ua: string = typeof navigator !== 'undefined' ? navigator.userAgent : ''): WalletDetection {\n const inset = INSET_RE.exec(ua);\n if (inset || UA_RE.test(ua)) return { inWallet: true, via: 'ua', ...(inset ? { inset: Number(inset[1]) } : {}) };\n return { inWallet: false, via: null };\n}\n\nlet state: WalletDetection = { inWallet: false, via: null };\n/** Current detection (UA, or a completed frame handshake). */\nexport function walletState(): WalletDetection { return state; }\n\nfunction setState(next: WalletDetection, win: Window): void {\n state = next;\n if (next.inWallet) win.document?.documentElement?.setAttribute('data-bwx-in-wallet', next.via ?? '');\n win.dispatchEvent(new CustomEvent('bapp-wallet', { detail: next }));\n}\n\nexport interface ShellBridgeOptions {\n manifest: BappManifest;\n /** Allowed wallet origins for framed mode (exact match). Default DEFAULT_WALLET_ORIGINS. */\n walletOrigins?: readonly string[];\n /** Default: window. */\n win?: Window;\n /** Default: navigator.userAgent. */\n userAgent?: string;\n}\n\ntype Msg = { type?: unknown; v?: unknown; slot?: unknown };\n\n/**\n * Listens for the wallet and keeps it in sync. Navigation is dispatched as a cancelable\n * `bapp-navigate` event on window ({slot, path, source:'wallet'}); if nobody calls\n * preventDefault() the page goes to the slot's path with location.assign.\n */\nexport class ShellBridge {\n readonly manifest: BappManifest;\n private readonly origins: readonly string[];\n private readonly win: Window;\n private target: { win: Window; origin: string } | null = null;\n private active: SlotId | null = null;\n private readonly onMessage = (e: MessageEvent) => this.handle(e);\n private readonly onActive = (e: Event) => { const s = (e as CustomEvent).detail?.slot; if (isSlotId(s)) this.setActive(s); };\n private readonly onMenu = () => this.post({ type: 'bapp:menu' });\n private readonly onClose = () => this.post({ type: 'bapp:close' });\n\n constructor(opts: ShellBridgeOptions) {\n this.manifest = opts.manifest;\n this.origins = opts.walletOrigins ?? DEFAULT_WALLET_ORIGINS;\n this.win = opts.win ?? window;\n const ua = detectWalletUA(opts.userAgent);\n if (ua.inWallet) {\n // Native webview: the wallet injects messages into the page itself.\n this.target = { win: this.win, origin: this.win.location.origin };\n setState(ua, this.win);\n }\n }\n\n start(): this {\n this.win.addEventListener('message', this.onMessage);\n this.win.addEventListener('bapp-active', this.onActive);\n this.win.addEventListener('bapp-menu', this.onMenu);\n this.win.addEventListener('bapp-close', this.onClose);\n return this;\n }\n\n stop(): void {\n this.win.removeEventListener('message', this.onMessage);\n this.win.removeEventListener('bapp-active', this.onActive);\n this.win.removeEventListener('bapp-menu', this.onMenu);\n this.win.removeEventListener('bapp-close', this.onClose);\n }\n\n get inWallet(): boolean { return this.target !== null; }\n\n /** Tell the wallet which slot is showing (lights up the native dock). */\n setActive(slot: SlotId): void {\n this.active = slot;\n this.post({ type: 'bapp:active', v: 1, slot });\n }\n\n /** Is this message from a trusted wallet? */\n trusted(e: MessageEvent): boolean {\n const parent = this.win.parent;\n // Framed: only our direct parent, only an allowlisted origin.\n if (parent && parent !== this.win && e.source === parent) return this.origins.includes(e.origin);\n // Native webview (UA detected): injected into this page, so same window and same origin.\n if (this.target?.win === this.win && (e.source === this.win || e.source === null)) return e.origin === this.win.location.origin;\n return false;\n }\n\n private handle(e: MessageEvent): void {\n const d = e.data as Msg;\n if (!d || typeof d !== 'object' || typeof d.type !== 'string' || !d.type.startsWith('bapp:')) return;\n if (!this.trusted(e)) return;\n if (d.type === 'bapp:hello') {\n if (!this.target) {\n this.target = { win: e.source as Window, origin: e.origin };\n setState({ inWallet: true, via: 'frame' }, this.win);\n }\n this.post({ type: 'bapp:ready', v: 1, manifest: '/.well-known/bapp.json', ...(this.active ? { slot: this.active } : {}) });\n return;\n }\n if (d.type === 'bapp:navigate') {\n if (!isSlotId(d.slot)) return; // never a URL, only a slot id\n const path = slotPath(this.manifest, d.slot);\n if (d.slot !== 'b' && !path) return; // disabled or not in the manifest\n if (d.slot === 'b' && !this.manifest.slots.b.enabled) return;\n const ev = new CustomEvent('bapp-navigate', { cancelable: true, detail: { slot: d.slot, path, source: 'wallet' } });\n this.win.dispatchEvent(ev);\n if (!ev.defaultPrevented && path) this.win.location.assign(path);\n this.setActive(d.slot);\n }\n }\n\n private post(msg: Record<string, unknown>): void {\n if (!this.target) return;\n const { win, origin } = this.target;\n // Native webviews expose ReactNativeWebView; fall back to postMessage to self.\n const rn = (this.win as unknown as { ReactNativeWebView?: { postMessage(s: string): void } }).ReactNativeWebView;\n if (win === this.win && rn) rn.postMessage(JSON.stringify(msg));\n else win.postMessage(msg, origin);\n }\n}\n\n/** Convenience: create and start a bridge. */\nexport function startShellBridge(opts: ShellBridgeOptions): ShellBridge {\n return new ShellBridge(opts).start();\n}\n\n/** Test hook. */\nexport function _resetWalletState(): void { state = { inWallet: false, via: null }; }\n","/**\n * <bwalletx-bar>, <bwalletx-topbar>, <bwalletx-drawer>: the bApp shell drawn on the web.\n * Values match the bWalletX Dock exactly (see docs/BAPP-SHELL in the wallet repo).\n * Framework-free; React wrappers in ./react.ts.\n */\nimport { SLOT_IDS, isSlotId, slotPath, type BappManifest, type SlotId } from './manifest.js';\nimport { detectWalletUA, walletState } from './wallet.js';\n\nexport const TOKENS = {\n barHeight: 88, barBg: '#0A0B0D', hairline: '#1C1C1E', icon: 20, active: '#FFD24D', inactive: '#F2F2F0',\n label: '#98A2B3', bSize: 52, stripHeight: 28, rowHeight: 56, tool: 36, toolRing: '#2A2A2C', toolIcon: '#F5B800',\n} as const;\n\nconst DEFAULT_LABELS: Record<SlotId, string> = { wallet: 'Wallet', exchange: 'Exchange', b: 'b', feed: 'Feed', chat: 'Chat' };\nconst svg = (d: string) => `<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">${d}</svg>`;\nexport const ICONS = {\n wallet: svg('<rect x=\"3\" y=\"6\" width=\"18\" height=\"13\" rx=\"2\"/><path d=\"M3 10h18\"/>'),\n exchange: svg('<path d=\"M7 4v16M3 8l4-4 4 4M17 20V4M13 16l4 4 4-4\"/>'),\n feed: svg('<rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"2\"/><path d=\"M8 9h8M8 13h8M8 17h5\"/>'),\n chat: svg('<path d=\"M21 12a8 8 0 0 1-12 7l-5 1 1-4a8 8 0 1 1 16-4z\"/>'),\n menu: svg('<path d=\"M4 6h16M4 12h16M4 18h16\"/>'),\n close: svg('<path d=\"M6 6l12 12M18 6L6 18\"/>'),\n};\n\nconst esc = (s: string) => s.replace(/[&<>\"']/g, (c) => `&#${c.charCodeAt(0)};`);\nconst Base: typeof HTMLElement = typeof HTMLElement === 'undefined' ? (class {} as unknown as typeof HTMLElement) : HTMLElement;\n\n/** in-wallet attribute: \"true\" / \"false\" force it; anything else = auto-detect. */\nfunction inWallet(el: HTMLElement): boolean {\n const a = el.getAttribute('in-wallet');\n if (a === 'true' || a === '') return true;\n if (a === 'false') return false;\n return walletState().inWallet || detectWalletUA().inWallet;\n}\n\nfunction emit(el: HTMLElement, type: string, detail: unknown, cancelable = false): boolean {\n return el.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true, cancelable }));\n}\n\n/** Fire bapp-navigate; unless prevented (or navigate=\"manual\"), go to the path. */\nfunction navigate(el: HTMLElement, detail: { slot?: SlotId; path: string | null }): void {\n const ok = emit(el, 'bapp-navigate', { ...detail, source: 'web' }, true);\n if (ok && detail.path && el.getAttribute('navigate') !== 'manual') location.assign(detail.path);\n}\n\nabstract class ShellElement extends Base {\n protected _manifest: BappManifest | null = null;\n private readonly onWallet = () => this.render();\n get manifest(): BappManifest | null { return this._manifest; }\n set manifest(m: BappManifest | null) { this._manifest = m; this.render(); }\n connectedCallback(): void {\n if (!this.shadowRoot) this.attachShadow({ mode: 'open' });\n window.addEventListener('bapp-wallet', this.onWallet);\n this.render();\n }\n disconnectedCallback(): void { window.removeEventListener('bapp-wallet', this.onWallet); }\n attributeChangedCallback(): void { if (this.shadowRoot) this.render(); }\n protected accent(): string { return this._manifest?.theme?.accent ?? TOKENS.active; }\n abstract render(): void;\n}\n\n// ---------------------------------------------------------------- <bwalletx-bar>\nconst BAR_CSS = `\n:host{display:block;--bwx-accent:${TOKENS.active}}\n:host([hidden]),:host([data-in-wallet]){display:none!important}\nnav{height:${TOKENS.barHeight}px;box-sizing:border-box;background:${TOKENS.barBg};border-top:1px solid ${TOKENS.hairline};\n display:flex;align-items:flex-start;padding:10px 0 env(safe-area-inset-bottom,0);font:10px/1.2 -apple-system,BlinkMacSystemFont,\"SF Pro Text\",system-ui,sans-serif}\nbutton{all:unset;box-sizing:border-box;flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;gap:4px;cursor:pointer;\n color:${TOKENS.inactive};-webkit-tap-highlight-color:transparent;touch-action:manipulation}\nbutton:focus-visible{outline:2px solid var(--bwx-accent);outline-offset:2px;border-radius:10px}\nbutton svg{width:${TOKENS.icon}px;height:${TOKENS.icon}px}\n.lbl{font-size:10px;color:${TOKENS.label};white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}\nbutton[aria-current=\"page\"]{color:var(--bwx-accent)}\nbutton[aria-current=\"page\"] .lbl{color:var(--bwx-accent);font-weight:700}\nbutton:disabled{opacity:.35;cursor:default;pointer-events:none}\n.b{width:${TOKENS.bSize}px;height:${TOKENS.bSize}px;border-radius:50%;background:#000;border:2px solid var(--bwx-accent);box-sizing:border-box;\n display:grid;place-items:center;font:800 24px/1 Georgia,\"Times New Roman\",serif;color:var(--bwx-accent);margin-top:-4px}\nbutton[data-slot=\"b\"][aria-current=\"page\"] .b{box-shadow:0 0 0 3px #FFD24D33}\n`;\n\nexport class BwalletxBarElement extends ShellElement {\n static observedAttributes = ['active', 'in-wallet', 'hidden'];\n private holdTimer: ReturnType<typeof setTimeout> | null = null;\n private held = false;\n get active(): SlotId | null { const a = this.getAttribute('active'); return isSlotId(a) ? a : null; }\n set active(s: SlotId | null) {\n if (s) this.setAttribute('active', s); else this.removeAttribute('active');\n }\n attributeChangedCallback(name?: string, old?: string | null, val?: string | null): void {\n super.attributeChangedCallback();\n if (name === 'active' && val !== old && isSlotId(val)) emit(this, 'bapp-active', { slot: val });\n }\n render(): void {\n const root = this.shadowRoot;\n if (!root) return;\n if (inWallet(this)) this.setAttribute('data-in-wallet', ''); else this.removeAttribute('data-in-wallet');\n const m = this._manifest;\n const active = this.active;\n const slots = SLOT_IDS.map((id) => {\n const s = m?.slots[id];\n const enabled = !!s?.enabled;\n const label = s?.label ?? DEFAULT_LABELS[id];\n const cur = active === id ? ' aria-current=\"page\"' : '';\n const dis = enabled ? '' : ' disabled aria-disabled=\"true\"';\n if (id === 'b') return `<button type=\"button\" data-slot=\"b\" aria-label=\"b agent${m ? ` in ${esc(m.name)}` : ''}\"${cur}${dis}><span class=\"b\">b</span></button>`;\n return `<button type=\"button\" data-slot=\"${id}\" aria-label=\"${esc(label)}\"${cur}${dis}>${ICONS[id]}<span class=\"lbl\">${esc(label)}</span></button>`;\n }).join('');\n root.innerHTML = `<style>${BAR_CSS}</style><nav part=\"bar\" aria-label=\"${m ? esc(m.name) : 'App'} navigation\" style=\"--bwx-accent:${this.accent()}\">${slots}</nav>`;\n root.querySelectorAll<HTMLButtonElement>('button[data-slot]').forEach((b) => {\n const id = b.dataset.slot as SlotId;\n if (id === 'b') this.wireB(b);\n else b.addEventListener('click', () => this.go(id));\n });\n }\n private go(id: SlotId): void {\n const m = this._manifest;\n if (!m || !m.slots[id]?.enabled) return;\n this.active = id;\n navigate(this, { slot: id, path: slotPath(m, id) });\n }\n /** (b): tap = bapp-b-press, hold (>=450ms) = bapp-b-hold {phase:'start'|'end'}. Hold-to-talk is a later phase. */\n private wireB(b: HTMLButtonElement): void {\n const clear = () => { if (this.holdTimer) clearTimeout(this.holdTimer); this.holdTimer = null; };\n b.addEventListener('pointerdown', () => {\n this.held = false; clear();\n this.holdTimer = setTimeout(() => { this.held = true; emit(this, 'bapp-b-hold', { phase: 'start' }); }, 450);\n });\n const up = () => { clear(); if (this.held) emit(this, 'bapp-b-hold', { phase: 'end' }); };\n b.addEventListener('pointerup', up);\n b.addEventListener('pointercancel', up);\n b.addEventListener('pointerleave', up);\n b.addEventListener('click', () => {\n if (this.held) { this.held = false; return; }\n if (!this._manifest?.slots.b.enabled) return;\n emit(this, 'bapp-b-press', { path: slotPath(this._manifest, 'b') });\n const p = slotPath(this._manifest, 'b');\n if (p) this.go('b');\n });\n }\n}\n\n// ---------------------------------------------------------------- <bwalletx-topbar>\nconst TOP_CSS = `\n:host{display:block;--bwx-accent:${TOKENS.active};font-family:-apple-system,BlinkMacSystemFont,\"SF Pro Text\",system-ui,sans-serif}\n:host([hidden]){display:none!important}\n.strip{height:${TOKENS.stripHeight}px;display:flex;align-items:center;justify-content:space-between;padding:0 16px;font-size:11px;color:#9a9a9a;background:${TOKENS.barBg}}\n::slotted([slot^=\"strip\"]){color:inherit}\n.row{height:${TOKENS.rowHeight}px;box-sizing:border-box;display:flex;align-items:center;gap:8px;padding:0 12px;background:${TOKENS.barBg};border-bottom:1px solid ${TOKENS.hairline}}\n.btn,::slotted([slot=\"tools\"]){all:unset;box-sizing:border-box;width:${TOKENS.tool}px;height:${TOKENS.tool}px;flex:none;border-radius:50%;border:1px solid ${TOKENS.toolRing};\n display:grid;place-items:center;color:${TOKENS.toolIcon};cursor:pointer;-webkit-tap-highlight-color:transparent}\n.btn:focus-visible{outline:2px solid var(--bwx-accent);outline-offset:2px}\n.btn svg{width:18px;height:18px}\n.app{border-color:${TOKENS.toolIcon};background:#1a1405;font-weight:800;font-size:13px;line-height:1;overflow:hidden}\n.app img{width:100%;height:100%;object-fit:cover}\n.title{flex:1;min-width:0;color:#F2F2F0;font-weight:700;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.title small{display:block;color:#777;font-weight:500;font-size:11px}\n.tools{display:flex;gap:8px}\n`;\n\nexport class BwalletxTopbarElement extends ShellElement {\n static observedAttributes = ['title', 'subtitle', 'in-wallet', 'drawer', 'menu', 'strip', 'hidden'];\n render(): void {\n const root = this.shadowRoot;\n if (!root) return;\n const m = this._manifest;\n const wallet = inWallet(this);\n const menu = wallet || this.getAttribute('menu') === 'true';\n const name = this.getAttribute('title') ?? m?.name ?? '';\n const sub = this.getAttribute('subtitle');\n const initials = name.replace(/[^A-Za-z0-9]/g, '').slice(0, 2) || 'b';\n const icon = m?.icon ? `<img src=\"${esc(m.icon)}\" alt=\"\">` : esc(initials);\n const strip = this.getAttribute('strip') !== 'off';\n root.innerHTML = `<style>${TOP_CSS}</style><header part=\"topbar\" style=\"--bwx-accent:${this.accent()}\">\n${strip ? `<div class=\"strip\" part=\"strip\"><slot name=\"strip-left\"></slot><slot name=\"strip-right\"></slot></div>` : ''}\n<div class=\"row\" part=\"row\">\n${menu ? `<button type=\"button\" class=\"btn\" data-act=\"menu\" aria-label=\"bWalletX menu\">${ICONS.menu}</button>` : ''}\n<button type=\"button\" class=\"btn app\" data-act=\"drawer\" aria-label=\"${esc(name || 'App')} home and sections\" aria-haspopup=\"true\">${icon}</button>\n<div class=\"title\" part=\"title\">${esc(name)}${sub ? `<small>${esc(sub)}</small>` : ''}</div>\n<div class=\"tools\"><slot name=\"tools\"></slot>${wallet ? `<button type=\"button\" class=\"btn\" data-act=\"close\" aria-label=\"Close ${esc(name || 'app')}\">${ICONS.close}</button>` : ''}</div>\n</div></header>`;\n root.querySelector('[data-act=\"menu\"]')?.addEventListener('click', () => emit(this, 'bapp-menu', {}));\n root.querySelector('[data-act=\"close\"]')?.addEventListener('click', () => emit(this, 'bapp-close', {}));\n root.querySelector('[data-act=\"drawer\"]')?.addEventListener('click', () => {\n if (!emit(this, 'bapp-drawer-toggle', {}, true)) return;\n const id = this.getAttribute('drawer');\n const d = (id ? document.getElementById(id) : document.querySelector('bwalletx-drawer')) as BwalletxDrawerElement | null;\n d?.toggle();\n });\n }\n}\n\n// ---------------------------------------------------------------- <bwalletx-drawer>\nconst DRAWER_CSS = `\n:host{position:fixed;inset:var(--bwx-drawer-top,84px) 0 var(--bwx-drawer-bottom,88px) 0;z-index:50;display:none;font-family:-apple-system,BlinkMacSystemFont,\"SF Pro Text\",system-ui,sans-serif}\n:host([open]){display:block}\n.scrim{position:absolute;inset:0;background:#0009}\nnav{position:absolute;top:0;left:0;bottom:0;width:min(78%,320px);box-sizing:border-box;background:#0d0e10;border-right:1px solid ${TOKENS.hairline};padding:14px;overflow:auto}\nh4{margin:10px 0 6px;font-size:11px;color:#777;letter-spacing:.08em;text-transform:uppercase;font-weight:600}\na{display:flex;align-items:center;gap:10px;padding:11px 10px;border-radius:10px;color:#F2F2F0;text-decoration:none;font-size:15px}\na img{width:20px;height:20px}\na[aria-current=\"page\"]{background:#1a1405;color:var(--bwx-accent)}\na:focus-visible{outline:2px solid var(--bwx-accent)}\nhr{border:0;border-top:1px solid ${TOKENS.hairline};margin:10px 0}\n.back{color:${TOKENS.toolIcon}}\n`;\n\nexport class BwalletxDrawerElement extends ShellElement {\n static observedAttributes = ['open', 'current', 'in-wallet'];\n get open(): boolean { return this.hasAttribute('open'); }\n set open(v: boolean) { this.toggleAttribute('open', v); }\n toggle(force?: boolean): void { this.open = force ?? !this.open; }\n render(): void {\n const root = this.shadowRoot;\n if (!root) return;\n const m = this._manifest;\n const cur = this.getAttribute('current') ?? (typeof location !== 'undefined' ? location.pathname : '/');\n const items = m ? [{ label: 'Home', path: m.home }, ...m.drawer] : [];\n const links = items.map((it, i) => `<a href=\"${esc(it.path)}\" data-i=\"${i}\"${it.path === cur ? ' aria-current=\"page\"' : ''}>${'icon' in it && it.icon ? `<img src=\"${esc(it.icon)}\" alt=\"\">` : ''}${esc(it.label)}</a>`).join('');\n const back = inWallet(this) ? `<hr><a href=\"#\" class=\"back\" data-act=\"close\">← Back to bWalletX</a>` : '';\n root.innerHTML = `<style>${DRAWER_CSS}</style><div class=\"scrim\" part=\"scrim\"></div><nav part=\"drawer\" aria-label=\"${m ? esc(m.name) : 'App'} sections\" style=\"--bwx-accent:${this.accent()}\"><h4>${m ? esc(m.name) : ''}</h4>${links}${back}</nav>`;\n root.querySelector('.scrim')!.addEventListener('click', () => this.toggle(false));\n root.querySelectorAll<HTMLAnchorElement>('a[data-i]').forEach((a) => a.addEventListener('click', (e) => {\n e.preventDefault();\n const it = items[Number(a.dataset.i)]!;\n this.toggle(false);\n navigate(this, { path: it.path });\n }));\n root.querySelector('[data-act=\"close\"]')?.addEventListener('click', (e) => { e.preventDefault(); this.toggle(false); emit(this, 'bapp-close', {}); });\n }\n}\n\n/** Register the three elements (idempotent). */\nexport function defineBappShell(): void {\n if (typeof customElements === 'undefined') return;\n if (!customElements.get('bwalletx-bar')) customElements.define('bwalletx-bar', BwalletxBarElement);\n if (!customElements.get('bwalletx-topbar')) customElements.define('bwalletx-topbar', BwalletxTopbarElement);\n if (!customElements.get('bwalletx-drawer')) customElements.define('bwalletx-drawer', BwalletxDrawerElement);\n}\n\n/** Give every shell element on the page the same manifest. */\nexport function applyManifest(m: BappManifest, root: ParentNode = document): void {\n root.querySelectorAll<HTMLElement & { manifest: BappManifest | null }>('bwalletx-bar,bwalletx-topbar,bwalletx-drawer').forEach((el) => { el.manifest = m; });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mBAAqF;;;ACH9E,IAAM,WAAW,CAAC,UAAU,YAAY,KAAK,QAAQ,MAAM;AAqL3D,SAAS,SAAS,GAAiB,MAA6B;AACrE,QAAM,IAAI,EAAE,MAAM,IAAI;AACtB,SAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO;AAC7C;AAEO,IAAM,WAAW,CAAC,MAA4B,OAAO,MAAM,YAAa,SAA+B,SAAS,CAAC;;;AC9KxH,IAAM,QAAQ;AACd,IAAM,WAAW;AAGV,SAAS,eAAe,KAAa,OAAO,cAAc,cAAc,UAAU,YAAY,IAAqB;AACxH,QAAM,QAAQ,SAAS,KAAK,EAAE;AAC9B,MAAI,SAAS,MAAM,KAAK,EAAE,EAAG,QAAO,EAAE,UAAU,MAAM,KAAK,MAAM,GAAI,QAAQ,EAAE,OAAO,OAAO,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,EAAG;AAC/G,SAAO,EAAE,UAAU,OAAO,KAAK,KAAK;AACtC;AAEA,IAAI,QAAyB,EAAE,UAAU,OAAO,KAAK,KAAK;AAEnD,SAAS,cAA+B;AAAE,SAAO;AAAO;;;ACtBxD,IAAM,SAAS;AAAA,EACpB,WAAW;AAAA,EAAI,OAAO;AAAA,EAAW,UAAU;AAAA,EAA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AO,EAAE;AAAA,IAAO,UAAU,EAAE;AAAA,IAAU,QAAQ,EAAE;AAAA,IAAQ,MAAM,EAAE,OAAO,SAAS;AAAA,IAAW,OAAO,EAAE,UAAU,QAAQ,QAAQ;AAAA,EAChI,GAAG,EAAE,aAAa,EAAE,QAAQ,cAAc,EAAE,SAAS,sBAAsB,EAAE,eAAe,CAAC;AAC/F;AAQO,SAAS,WAAW,GAAoB;AAC7C,SAAO,SAAS,mBAAmB,GAAG,EAAE,MAAM,EAAE,OAAO,KAAK,QAAW,SAAS,EAAE,QAAQ,GAAG,EAAE,cAAc,EAAE,QAAQ,CAAC;AAC1H;","names":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
import { B as BappManifest, S as SlotId } from './manifest-Caj_Raqm.cjs';
|
|
4
|
+
|
|
5
|
+
interface NavigateDetail {
|
|
6
|
+
slot?: SlotId;
|
|
7
|
+
path: string | null;
|
|
8
|
+
source: 'web' | 'wallet';
|
|
9
|
+
}
|
|
10
|
+
type Handler<D> = (detail: D, event: CustomEvent<D>) => void;
|
|
11
|
+
interface Common {
|
|
12
|
+
manifest: BappManifest | null;
|
|
13
|
+
/** "auto" (default) detects bWallet; true/false forces. */
|
|
14
|
+
inWallet?: boolean | 'auto';
|
|
15
|
+
/** true = never call location.assign; route in onNavigate. */
|
|
16
|
+
manualNavigation?: boolean;
|
|
17
|
+
onNavigate?: Handler<NavigateDetail>;
|
|
18
|
+
id?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
/** Slotted content, e.g. <button slot="tools"> or <span slot="strip-left">. */
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
interface BappBarProps extends Common {
|
|
25
|
+
active?: SlotId | null;
|
|
26
|
+
onActive?: Handler<{
|
|
27
|
+
slot: SlotId;
|
|
28
|
+
}>;
|
|
29
|
+
onBPress?: Handler<{
|
|
30
|
+
path: string | null;
|
|
31
|
+
}>;
|
|
32
|
+
onBHold?: Handler<{
|
|
33
|
+
phase: 'start' | 'end';
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
declare function BappBar(p: BappBarProps): react.DOMElement<Record<string, unknown>, Element>;
|
|
37
|
+
interface BappTopbarProps extends Common {
|
|
38
|
+
title?: string;
|
|
39
|
+
subtitle?: string;
|
|
40
|
+
/** id of the <bwalletx-drawer> the app icon opens. */
|
|
41
|
+
drawer?: string;
|
|
42
|
+
/** Show ☰ on the web too (it always shows in the wallet). */
|
|
43
|
+
menu?: boolean;
|
|
44
|
+
strip?: boolean;
|
|
45
|
+
onMenu?: Handler<object>;
|
|
46
|
+
onClose?: Handler<object>;
|
|
47
|
+
onDrawerToggle?: Handler<object>;
|
|
48
|
+
}
|
|
49
|
+
declare function BappTopbar(p: BappTopbarProps): react.DOMElement<Record<string, unknown>, Element>;
|
|
50
|
+
interface BappDrawerProps extends Common {
|
|
51
|
+
open?: boolean;
|
|
52
|
+
/** Path to highlight; default location.pathname. */
|
|
53
|
+
current?: string;
|
|
54
|
+
onClose?: Handler<object>;
|
|
55
|
+
}
|
|
56
|
+
declare function BappDrawer(p: BappDrawerProps): react.DOMElement<Record<string, unknown>, Element>;
|
|
57
|
+
|
|
58
|
+
export { BappBar, type BappBarProps, BappDrawer, type BappDrawerProps, BappManifest, BappTopbar, type BappTopbarProps, type NavigateDetail, SlotId };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
import { B as BappManifest, S as SlotId } from './manifest-Caj_Raqm.js';
|
|
4
|
+
|
|
5
|
+
interface NavigateDetail {
|
|
6
|
+
slot?: SlotId;
|
|
7
|
+
path: string | null;
|
|
8
|
+
source: 'web' | 'wallet';
|
|
9
|
+
}
|
|
10
|
+
type Handler<D> = (detail: D, event: CustomEvent<D>) => void;
|
|
11
|
+
interface Common {
|
|
12
|
+
manifest: BappManifest | null;
|
|
13
|
+
/** "auto" (default) detects bWallet; true/false forces. */
|
|
14
|
+
inWallet?: boolean | 'auto';
|
|
15
|
+
/** true = never call location.assign; route in onNavigate. */
|
|
16
|
+
manualNavigation?: boolean;
|
|
17
|
+
onNavigate?: Handler<NavigateDetail>;
|
|
18
|
+
id?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
/** Slotted content, e.g. <button slot="tools"> or <span slot="strip-left">. */
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
interface BappBarProps extends Common {
|
|
25
|
+
active?: SlotId | null;
|
|
26
|
+
onActive?: Handler<{
|
|
27
|
+
slot: SlotId;
|
|
28
|
+
}>;
|
|
29
|
+
onBPress?: Handler<{
|
|
30
|
+
path: string | null;
|
|
31
|
+
}>;
|
|
32
|
+
onBHold?: Handler<{
|
|
33
|
+
phase: 'start' | 'end';
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
declare function BappBar(p: BappBarProps): react.DOMElement<Record<string, unknown>, Element>;
|
|
37
|
+
interface BappTopbarProps extends Common {
|
|
38
|
+
title?: string;
|
|
39
|
+
subtitle?: string;
|
|
40
|
+
/** id of the <bwalletx-drawer> the app icon opens. */
|
|
41
|
+
drawer?: string;
|
|
42
|
+
/** Show ☰ on the web too (it always shows in the wallet). */
|
|
43
|
+
menu?: boolean;
|
|
44
|
+
strip?: boolean;
|
|
45
|
+
onMenu?: Handler<object>;
|
|
46
|
+
onClose?: Handler<object>;
|
|
47
|
+
onDrawerToggle?: Handler<object>;
|
|
48
|
+
}
|
|
49
|
+
declare function BappTopbar(p: BappTopbarProps): react.DOMElement<Record<string, unknown>, Element>;
|
|
50
|
+
interface BappDrawerProps extends Common {
|
|
51
|
+
open?: boolean;
|
|
52
|
+
/** Path to highlight; default location.pathname. */
|
|
53
|
+
current?: string;
|
|
54
|
+
onClose?: Handler<object>;
|
|
55
|
+
}
|
|
56
|
+
declare function BappDrawer(p: BappDrawerProps): react.DOMElement<Record<string, unknown>, Element>;
|
|
57
|
+
|
|
58
|
+
export { BappBar, type BappBarProps, BappDrawer, type BappDrawerProps, BappManifest, BappTopbar, type BappTopbarProps, type NavigateDetail, SlotId };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineBappShell
|
|
3
|
+
} from "./chunk-OMEKHKMM.js";
|
|
4
|
+
|
|
5
|
+
// src/shell/react.ts
|
|
6
|
+
import { createElement, useEffect, useRef } from "react";
|
|
7
|
+
function useShell(tag, props, attrs, events) {
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
defineBappShell();
|
|
11
|
+
}, []);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (ref.current) ref.current.manifest = props.manifest;
|
|
14
|
+
}, [props.manifest]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const el = ref.current;
|
|
17
|
+
if (!el) return;
|
|
18
|
+
const all = { "bapp-navigate": props.onNavigate, ...events };
|
|
19
|
+
const subs = Object.entries(all).filter(([, h]) => h).map(([type, h]) => {
|
|
20
|
+
const fn = (e) => h(e.detail, e);
|
|
21
|
+
el.addEventListener(type, fn);
|
|
22
|
+
return () => el.removeEventListener(type, fn);
|
|
23
|
+
});
|
|
24
|
+
return () => subs.forEach((u) => u());
|
|
25
|
+
});
|
|
26
|
+
const a = { ref, id: props.id, class: props.className, style: props.style };
|
|
27
|
+
if (props.inWallet !== void 0 && props.inWallet !== "auto") a["in-wallet"] = String(props.inWallet);
|
|
28
|
+
if (props.manualNavigation) a.navigate = "manual";
|
|
29
|
+
for (const [k, v] of Object.entries(attrs)) if (v !== void 0) a[k] = v;
|
|
30
|
+
return createElement(tag, a, props.children);
|
|
31
|
+
}
|
|
32
|
+
function BappBar(p) {
|
|
33
|
+
return useShell("bwalletx-bar", p, { active: p.active ?? void 0 }, { "bapp-active": p.onActive, "bapp-b-press": p.onBPress, "bapp-b-hold": p.onBHold });
|
|
34
|
+
}
|
|
35
|
+
function BappTopbar(p) {
|
|
36
|
+
return useShell("bwalletx-topbar", p, {
|
|
37
|
+
title: p.title,
|
|
38
|
+
subtitle: p.subtitle,
|
|
39
|
+
drawer: p.drawer,
|
|
40
|
+
menu: p.menu ? "true" : void 0,
|
|
41
|
+
strip: p.strip === false ? "off" : void 0
|
|
42
|
+
}, { "bapp-menu": p.onMenu, "bapp-close": p.onClose, "bapp-drawer-toggle": p.onDrawerToggle });
|
|
43
|
+
}
|
|
44
|
+
function BappDrawer(p) {
|
|
45
|
+
return useShell("bwalletx-drawer", p, { open: p.open ? "" : void 0, current: p.current }, { "bapp-close": p.onClose });
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
BappBar,
|
|
49
|
+
BappDrawer,
|
|
50
|
+
BappTopbar
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=shell-react.js.map
|