Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
625 lines (585 loc) · 24.7 KB
/
Copy pathindex.html
File metadata and controls
625 lines (585 loc) · 24.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
<!doctype html>
<html lang="en" dir="ltr">
<head>
<!-- Polyfill for three.js TSL WebGPU enum access.
Three.js assumes self.GPUShaderStage exists when self is defined,
but many browsers have self without WebGPU support. -->
<script>
if (typeof self !== 'undefined' && !self.GPUShaderStage) {
self.GPUShaderStage = Object.freeze({ VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 });
}
if (typeof self !== 'undefined' && !self.GPUBufferUsage) {
self.GPUBufferUsage = Object.freeze({
MAP_READ: 1, MAP_WRITE: 2, COPY_SRC: 4, COPY_DST: 8,
INDEX: 16, VERTEX: 32, UNIFORM: 64, STORAGE: 128,
INDIRECT: 256, QUERY_RESOLVE: 512
});
}
if (typeof self !== 'undefined' && !self.GPUTextureUsage) {
self.GPUTextureUsage = Object.freeze({
COPY_SRC: 1, COPY_DST: 2, TEXTURE_BINDING: 4,
STORAGE_BINDING: 8, RENDER_ATTACHMENT: 16
});
}
if (typeof self !== 'undefined' && !self.GPUColorWrite) {
self.GPUColorWrite = Object.freeze({
RED: 1, GREEN: 2, BLUE: 4, ALPHA: 8, ALL: 15
});
}
if (typeof self !== 'undefined' && !self.GPUMapMode) {
self.GPUMapMode = Object.freeze({ READ: 1, WRITE: 2 });
}
</script>
<!-- ELIZA_NATIVE_AGENT_IPC_BRIDGE_START -->
<script>
(() => {
if (typeof window === 'undefined' || typeof window.fetch !== 'function') return;
if (window.__ELIZA_ANDROID_IPC_FETCH_BRIDGE__) return;
const originalFetch = window.fetch.bind(window);
const ipcProtocol = 'eliza-local-agent:';
const ipcHost = 'ipc';
const ipcBase = 'eliza-local-agent://ipc';
const ipcPathPrefix = `//${ipcHost}`;
const localAgentPort = '31337';
const mobileRuntimeModeStorageKey = 'eliza:mobile-runtime-mode';
// The loopback (127.0.0.1:31337) → native-IPC rewrite below is only
// correct on a NATIVE Capacitor platform (iOS/Android), where the
// in-process local agent has no directly-reachable TCP port and
// `Agent.request` resolves to a NATIVE plugin. On any non-native host
// (Electrobun desktop, plain web) there is no native Agent plugin, so
// `Agent.request` falls back to the web implementation, which fetches
// `${apiBase}${path}` — the same loopback URL — and re-enters this bridge,
// recursing forever (renderer OOM). Gate the rewrite on a positive
// native-platform check so loopback fetches hit the real server directly
// everywhere else. Capacitor sets window.Capacitor on every platform and
// this runs at fetch time (after modules load), so the check is reliable.
function isNativeCapacitorAgentHost() {
try {
const cap = window.Capacitor;
if (!cap || typeof cap.getPlatform !== 'function') return false;
const p = cap.getPlatform();
return p === 'ios' || p === 'android';
} catch (_) {
return false;
}
}
function nativeModeUsesOnDeviceAgent() {
try {
const mode = window.localStorage.getItem(mobileRuntimeModeStorageKey);
if (mode === 'remote-mac' || mode === 'cloud') {
return false;
}
return true;
} catch (_) {
// error-policy:J4 storage unavailable — preserve native-local compatibility.
return true;
}
}
function rawUrl(input) {
try {
return input && typeof input === 'object' && 'url' in input ? input.url : String(input);
} catch (_) {
return null;
}
}
function ipcPath(raw) {
if (!raw) return null;
const trimmed = String(raw).trim();
if (!trimmed) return null;
const lower = trimmed.toLowerCase();
if (lower === ipcBase) return '/';
if (lower.indexOf(`${ipcBase}/`) === 0 || lower.indexOf(`${ipcBase}?`) === 0) {
const suffix = trimmed.slice(ipcBase.length);
return suffix.charAt(0) === '?' ? `/${suffix}` : suffix || '/';
}
try {
const url = new URL(trimmed, window.location?.href ? window.location.href : 'https://cloud.eliza.app');
if (
isNativeCapacitorAgentHost() &&
nativeModeUsesOnDeviceAgent() &&
url.protocol === 'http:' &&
url.port === localAgentPort &&
(url.hostname === '127.0.0.1' || url.hostname === 'localhost' || url.hostname === '[::1]' || url.hostname === '::1')
) {
return (url.pathname || '/') + url.search;
}
if (url.protocol !== ipcProtocol) return null;
if (url.hostname === ipcHost) return (url.pathname || '/') + url.search;
if (url.pathname === ipcPathPrefix) return url.search ? `/${url.search}` : '/';
if (url.pathname.indexOf(`${ipcPathPrefix}/`) === 0) {
return url.pathname.slice(ipcPathPrefix.length) + url.search;
}
} catch (_) {
return null;
}
return null;
}
function methodAllowsBody(method) {
const normalized = String(method || 'GET').toUpperCase();
return normalized !== 'GET' && normalized !== 'HEAD';
}
function headersToRecord(headers) {
const record = {};
if (!headers) return record;
new Headers(headers).forEach((value, key) => {
record[key] = value;
});
return record;
}
function unavailable(message) {
return new Response(JSON.stringify({
error: 'native_agent_unavailable',
message: message
}), {
status: 503,
statusText: 'Service Unavailable',
headers: { 'content-type': 'application/json' }
});
}
function bodyToString(body) {
if (body === null) return null;
if (body === undefined) return undefined;
if (typeof body === 'string') return body;
if (body instanceof URLSearchParams) return body.toString();
return undefined;
}
async function normalizeInit(input, init) {
const request = input instanceof Request ? input.clone() : null;
const method = String(init?.method || request?.method || 'GET').toUpperCase();
const headers = init?.headers || request?.headers;
if (!methodAllowsBody(method)) {
return { method: method, headers: headers };
}
if (init && 'body' in init) {
const explicitBody = bodyToString(init.body);
if (explicitBody === undefined && init.body != null) return null;
return { method: method, headers: headers, body: explicitBody || undefined };
}
if (!request) return { method: method, headers: headers };
const requestBody = await request.text();
return { method: method, headers: headers, body: requestBody || undefined };
}
function resolveAgentPlugin() {
try {
const cap = window.Capacitor;
if (!cap) return null;
const plugins = cap.Plugins || {};
return plugins.Agent || (typeof cap.registerPlugin === 'function' ? cap.registerPlugin('Agent') : null);
} catch (_) {
return null;
}
}
window.fetch = async function elizaAndroidIpcFetchBridge(input, init) {
const raw = rawUrl(input);
const path = ipcPath(raw);
if (path === null) return originalFetch(input, init);
const normalized = await normalizeInit(input, init);
if (!normalized) {
return unavailable('Android local-agent IPC only supports string request bodies');
}
const agent = resolveAgentPlugin();
if (!agent || typeof agent.request !== 'function') {
return unavailable('Android local-agent IPC is unavailable because the native Agent plugin is not registered');
}
const result = await agent.request({
method: normalized.method,
path: path,
headers: headersToRecord(normalized.headers),
body: methodAllowsBody(normalized.method) ? (normalized.body || null) : null
});
// Prefer the lossless base64 of the raw response bytes so binary
// payloads (e.g. local TTS WAV audio) survive intact; `body` is only a
// best-effort UTF-8 view that mangles non-text bytes.
let responseBody = result?.body ? result.body : '';
if (result && typeof result.bodyBase64 === 'string' && result.bodyBase64.length > 0) {
const binary = atob(result.bodyBase64);
const bytes = new Uint8Array(binary.length);
for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);
responseBody = bytes;
}
return new Response(responseBody, {
status: result?.status ? result.status : 200,
statusText: result?.statusText ? result.statusText : '',
headers: result?.headers ? result.headers : undefined
});
};
window.__ELIZA_ANDROID_IPC_FETCH_BRIDGE__ = true;
})();
</script>
<!-- ELIZA_NATIVE_AGENT_IPC_BRIDGE_END -->
<meta charset="UTF-8" />
<meta name="viewport" content="__APP_VIEWPORT_CONTENT__" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="theme-color" content="__APP_THEME_COLOR__" />
<meta name="color-scheme" content="dark" />
<!--
CSP hardening notes (W1-053):
- `object-src 'none'`, `base-uri 'none'`, `form-action 'self'`, and
`manifest-src 'self'` are hard backstops: the app renders no
<object>/<embed>/<base> tags and submits no cross-origin native forms.
- `script-src` carries `blob:` so authenticated remote view bundles fetched
by the API client can execute from short-lived module URLs. This permits
execution, not fetching, and remains a deliberate hardening boundary. It
still carries 'unsafe-inline' for the inline bootstrap
scripts in this file (WebGPU polyfill, Android IPC fetch bridge,
marketing launch surface) and 'unsafe-eval'/'wasm-unsafe-eval' for
runtime-evaluating dependencies. Dropping 'unsafe-inline' means moving
those bootstraps to external files or build-time CSP hashes — tracked as
follow-up, not safe to do blind.
- Session tokens (steward_session_token et al.) live in localStorage by
SPA bearer-token design; any script-injection sink therefore reaches
them. Output-encoding guards at each sink are the mitigation; this CSP
is the backstop, not the boundary.
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' electrobun://* https://*__APP_CSP_LOCAL_HTTP__;
script-src 'self' blob: 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' https://*__APP_CSP_LOCAL_HTTP__;
style-src 'self' 'unsafe-inline' https://*__APP_CSP_LOCAL_HTTP__;
connect-src 'self' blob: data: eliza-local-agent: https://* wss://*__APP_CSP_LOCAL_CONNECT__;
img-src 'self' data: blob: https://*__APP_CSP_LOCAL_HTTP__;
media-src 'self' blob: https://*__APP_CSP_LOCAL_HTTP__;
frame-src 'self' https://*__APP_CSP_LOCAL_HTTP__;
worker-src 'self' blob:;
object-src 'none';
base-uri 'none';
form-action 'self';
manifest-src 'self';
font-src 'self' data: https://*__APP_CSP_LOCAL_HTTP__;" />
<title>__APP_NAME__</title>
<meta name="description" content="__APP_DESCRIPTION__" />
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content="__APP_URL__" />
<meta property="og:title" content="__APP_NAME__" />
<meta property="og:description" content="__APP_DESCRIPTION__" />
<meta property="og:image" content="__APP_SHARE_IMAGE__" />
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content="__APP_URL__" />
<meta property="twitter:title" content="__APP_NAME__" />
<meta property="twitter:description" content="__APP_DESCRIPTION__" />
<meta property="twitter:image" content="__APP_SHARE_IMAGE__" />
<link rel="icon" type="image/svg+xml" href="/brand/favicons/favicon.svg" />
<link rel="icon" type="image/x-icon" href="/brand/favicons/favicon.ico" />
<link rel="icon" type="image/png" sizes="32x32" href="/brand/favicons/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/brand/favicons/favicon-16x16.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/brand/favicons/apple-touch-icon.png" />
<link rel="manifest" href="/site.webmanifest" />
<script>
// One bundle serves both the dark agent app and the light public marketing
// pages. Seed the marketing launch surface before the inline FOUC CSS is
// parsed so #root cannot paint the app's black fallback while the public
// renderer and its lazy landing-page chunk are still downloading.
(() => {
const marketingHostnames = [
"eliza.app",
"www.eliza.app",
"staging.eliza.app",
"elizacloud.ai",
"www.elizacloud.ai",
"dev.elizacloud.ai",
"staging.elizacloud.ai",
"b.eliza.app",
"eliza-app-b.pages.dev",
];
const hostname = (location.hostname || "").toLowerCase().replace(/\.$/, "");
if (marketingHostnames.indexOf(hostname) === -1) return;
const root = document.documentElement;
root.setAttribute("data-public-marketing", "true");
root.style.setProperty("--launch-bg", "#fdfaf7");
root.style.setProperty("--launch-foreground", "#000000");
root.style.colorScheme = "light";
const themeColor = document.querySelector('meta[name="theme-color"]');
const colorScheme = document.querySelector('meta[name="color-scheme"]');
if (themeColor) themeColor.setAttribute("content", "#fdfaf7");
if (colorScheme) colorScheme.setAttribute("content", "light");
// These are the only above-the-fold image requests in the desktop
// static hero. Start them from the HTML parse instead of waiting for
// the entry -> public shell -> landing-page module chain.
if (window.matchMedia("(min-width: 641px)").matches) {
for (const href of [
"/brand/logos/logo_white_orangebg.svg",
"/brand/logos/eliza_text_black.svg",
]) {
const preload = document.createElement("link");
preload.rel = "preload";
preload.as = "image";
preload.href = href;
preload.setAttribute("fetchpriority", "high");
document.head.appendChild(preload);
}
}
})();
</script>
<script>
// The agent app has one curated dark appearance. Public marketing was
// classified above and keeps its light launch surface through first paint.
(() => {
try {
const root = document.documentElement;
if (root.getAttribute('data-public-marketing') === 'true') {
root.classList.remove('dark');
root.setAttribute('data-theme', 'light');
return;
}
root.classList.add('dark');
root.style.colorScheme = 'dark';
root.setAttribute('data-theme', 'dark');
} catch {}
})();
</script>
<script>
// Classify native desktop-only surfaces before the FOUC guard below. The
// detached assistant is transparent; managed Workspace/Settings windows
// use a quiet charcoal canvas. Neither should flash the full-app black
// branded preboot shell while its renderer bundle loads.
(() => {
const params = new URLSearchParams(window.location.search);
const shellMode = params.get("shellMode") || params.get("shell-mode");
const root = document.documentElement;
if (shellMode === "chat-overlay") {
root.setAttribute("data-chat-overlay-preboot", "true");
root.style.setProperty("--launch-bg", "transparent");
return;
}
const desktopSurface = params.get("desktopSurface");
if (desktopSurface === "workspace" || desktopSurface === "settings") {
root.setAttribute("data-desktop-managed-preboot", "true");
root.style.setProperty("--launch-bg", "#181a20");
root.style.setProperty("--launch-foreground", "#f4f5f7");
}
})();
</script>
<style>
/* FOUC guard — runs before external CSS so we use concrete values.
The launch surface is black (#000000 — DEFAULT_BACKGROUND_COLOR, the
base field of the home ShaderBackground; the orange ember glow renders
on top of it). Keep it separate from --bg: --bg
resolves to the light/dark theme background and can flash white/black
before the loader appears. This surface PERSISTS as the page background
under the app: any strip the fixed background layers don't reach (the
iOS home-indicator safe-area under the composer, overscroll zones)
shows this color, so it must EQUAL the default home background — that
equality (enforced by test/brand-surface.test.ts) is what makes any
bleed-through invisible. */
:root {
--launch-bg: #000000;
--launch-foreground: #fdfaf7;
}
html,
body,
#root {
background-color: var(--launch-bg, #000000);
}
html[data-chat-overlay-preboot="true"],
html[data-chat-overlay-preboot="true"] body,
html[data-chat-overlay-preboot="true"] #root {
background: transparent;
background-color: transparent;
}
html, body {
margin: 0;
padding: 0;
color: var(--launch-foreground, #fdfaf7);
font-family: var(--font-sans, "Poppins", Arial, system-ui, sans-serif);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* The body remains full-bleed. Routed surfaces consume the shared safe-area
variables at their own interactive edges; applying the inset here as well
would shift every surface a second time once a native WebView resolves
env(safe-area-inset-*). */
#root {
min-height: 100dvh;
background-color: var(--launch-bg, #000000);
}
/* The shell lives OUTSIDE the React mount root as a fixed overlay: React
mounting must not wipe it, because with a lazy router shell the first
commits render empty Suspense fallbacks into #root — the measured
~1.4s blank on the hosted /login route (#18256). An inline observer below
removes it once #root paints meaningful content. */
.eliza-preboot-shell {
position: fixed;
inset: 0;
z-index: 9999;
min-height: 100dvh;
display: grid;
place-items: center;
overflow: hidden;
background: var(--launch-bg, #000000);
color: var(--launch-foreground, #fdfaf7);
}
/* Managed native windows and the detached assistant paint only their final
launch surfaces until React is ready. Hide the branded shell in CSS as
well as removing it below so no parser/first-frame timing can expose the
logo or loading copy. */
html[data-desktop-managed-preboot="true"] .eliza-preboot-shell,
html[data-chat-overlay-preboot="true"] .eliza-preboot-shell {
display: none;
}
.eliza-preboot-shell__content {
display: flex;
width: 100%;
max-width: 384px;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 20px;
padding: 0 24px;
text-align: center;
font-family: system-ui, sans-serif;
}
.eliza-preboot-shell__brand {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
}
.eliza-preboot-shell__mark {
width: 48px;
height: 48px;
object-fit: contain;
}
.eliza-preboot-shell__lockup {
width: min(17rem, 78vw);
height: auto;
object-fit: contain;
}
.eliza-preboot-shell__name {
font-size: 36px;
font-weight: 500;
line-height: 1;
letter-spacing: 0;
}
.eliza-preboot-shell__status {
margin: 0;
min-height: 20px;
font-size: 14px;
line-height: 20px;
opacity: 0.8;
animation: eliza-preboot-status-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes eliza-preboot-status-pulse {
50% {
opacity: 0.5;
}
}
@media (prefers-reduced-motion: reduce) {
.eliza-preboot-shell__status {
animation: none;
}
}
</style>
</head>
<body>
<div id="root"></div>
<div id="eliza-preboot-shell" class="eliza-preboot-shell" role="status" aria-live="polite" aria-label="Loading elizaOS">
<div class="eliza-preboot-shell__content">
<div class="eliza-preboot-shell__brand" aria-hidden="true">
<img class="eliza-preboot-shell__mark" src="%BASE_URL%brand/logos/logo_white_nobg.svg" alt="" />
<span class="eliza-preboot-shell__name">elizaOS</span>
</div>
<p class="eliza-preboot-shell__status">Booting up…</p>
</div>
</div>
<script>
// Remove the preboot shell only when #root paints MEANINGFUL content.
// React's first commits under the lazy web router shell render empty
// aria-busy Suspense fallbacks (#18256's ~1.4s blank once the old
// in-#root shell was wiped at mount); text or a media/control element is
// the signal the app has really painted. MutationObserver callbacks run
// before the next frame, so the swap is never visible as an overlay
// covering live UI. If boot never paints (script/network death) the
// branded shell intentionally stays, exactly like the old in-root shell.
(() => {
const shell = document.getElementById("eliza-preboot-shell");
const root = document.getElementById("root");
if (!shell) return;
// The overlay's host is transparent from the first style calculation.
// Remove the full-app brand lockup synchronously; ChatOverlay owns the
// only visible loading/ready surface in this specialized window.
if (document.documentElement.getAttribute("data-chat-overlay-preboot") === "true") {
shell.remove();
return;
}
// Managed native Workspace/Settings windows use the neutral launch canvas
// until their real shell paints; they never show branded loading chrome.
if (document.documentElement.getAttribute("data-desktop-managed-preboot") === "true") {
shell.remove();
return;
}
// The head classified public marketing before any CSS could paint. Drop
// the agent-branded boot shell synchronously and leave the already-white
// root visible until the static hero commits.
if (document.documentElement.getAttribute("data-public-marketing") === "true") {
shell.remove();
return;
}
if (!root || typeof MutationObserver !== "function") return;
const hasMeaningfulContent = () =>
(root.textContent || "").trim().length > 0 ||
root.querySelector("img,svg,canvas,video,iframe,input,button,textarea,select") !== null;
const observer = new MutationObserver(() => {
if (!hasMeaningfulContent()) return;
observer.disconnect();
shell.remove();
});
observer.observe(root, { childList: true, subtree: true, characterData: true });
if (hasMeaningfulContent()) {
observer.disconnect();
shell.remove();
}
})();
</script>
<!-- Node polyfills — inline sync script ensures they're available before any ESM module evaluates -->
<script>
if (typeof globalThis.process === "undefined") {
globalThis.process = {
env: { NODE_ENV: "development" },
cwd: () => "/",
platform: "browser",
version: "v0.0.0",
versions: {},
nextTick: (cb) => { Promise.resolve().then(cb); },
stdout: { write: () => {} },
stderr: { write: () => {} },
argv: [],
pid: 0,
exit: () => {},
on: function() { return this; },
off: function() { return this; },
emit: () => {},
browser: true,
};
}
if (typeof globalThis.Buffer === "undefined") {
globalThis.Buffer = {
alloc: (n) => new Uint8Array(n),
from: (a, enc) => {
if (typeof a === "string") {
if (enc === "base64") {
const b = atob(a);
const u = new Uint8Array(b.length);
for (let i = 0; i < b.length; i++) u[i] = b.charCodeAt(i);
return u;
}
return new TextEncoder().encode(a);
}
return new Uint8Array(a);
},
isBuffer: () => false,
concat: (bufs) => {
const total = bufs.reduce((s, b) => s + b.length, 0);
const result = new Uint8Array(total);
let offset = 0;
bufs.forEach((b) => { result.set(b, offset); offset += b.length; });
return result;
},
byteLength: (s) => new TextEncoder().encode(s).length,
};
}
</script>
<script type="module" src="/src/renderer-entry.ts"></script>
</body>
</html>