Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

cliAuthHtml.ts

151 lines5.2 KB

1/** Nightly is the only published channel; `dev` is an unbundled checkout, where
2 the build define is absent. */
3export type LoopbackAuthorizationStage = "dev" | "nightly";
4​
5declare const __PIKU_BUILD_CHANNEL__: "nightly" | undefined;
6​
7export function resolveLoopbackAuthorizationStage(): LoopbackAuthorizationStage {
8 return typeof __PIKU_BUILD_CHANNEL__ === "undefined" ? "dev" : __PIKU_BUILD_CHANNEL__;
9}
10​
11const stageBrands = {
12 dev: "Piku Code (Dev)",
13 nightly: "Piku Code (Nightly)",
14} as const satisfies Record<LoopbackAuthorizationStage, string>;
15​
16export function renderLoopbackAuthorizationCompleteHtml(
17 stage: LoopbackAuthorizationStage = resolveLoopbackAuthorizationStage(),
18): string {
19 const stageBrand = stageBrands[stage];
20​
21 return `<!doctype html>
22<html lang="en">
23 <head>
24 <meta charset="utf-8" />
25 <meta name="viewport" content="width=device-width, initial-scale=1" />
26 <meta name="color-scheme" content="light dark" />
27 <title>Piku Connect authorization complete</title>
28 <style>
29 :root {
30 color-scheme: light dark;
31 font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
32 background: #f6f7f9;
33 color: #17191f;
34 }
35 * { box-sizing: border-box; }
36 body {
37 min-height: 100vh;
38 margin: 0;
39 display: grid;
40 place-items: center;
41 padding: 32px 16px;
42 background:
43 radial-gradient(48rem 22rem at 50% -8rem, rgba(47, 119, 235, 0.15), transparent),
44 #f6f7f9;
45 }
46 main {
47 width: min(100%, 576px);
48 overflow: hidden;
49 border: 1px solid rgba(23, 25, 31, 0.1);
50 border-radius: 20px;
51 background: rgba(255, 255, 255, 0.94);
52 box-shadow: 0 24px 64px rgba(16, 24, 40, 0.16);
53 }
54 .stage {
55 position: relative;
56 height: 96px;
57 overflow: hidden;
58 padding: 22px 24px;
59 color: white;
60 }
61 .stage-dev {
62 background: linear-gradient(145deg, #5ab8fa 0%, #347ff8 46%, #1939bd 100%);
63 }
64 .stage-dev::before {
65 content: "";
66 position: absolute;
67 inset: 0;
68 opacity: 0.42;
69 background-image:
70 linear-gradient(rgba(234, 246, 255, 0.25) 1px, transparent 1px),
71 linear-gradient(90deg, rgba(234, 246, 255, 0.25) 1px, transparent 1px),
72 linear-gradient(rgba(234, 246, 255, 0.12) 1px, transparent 1px),
73 linear-gradient(90deg, rgba(234, 246, 255, 0.12) 1px, transparent 1px);
74 background-size: 32px 32px, 32px 32px, 8px 8px, 8px 8px;
75 }
76 .stage-nightly {
77 background:
78 radial-gradient(22rem 8rem at 78% 18%, rgba(81, 101, 216, 0.42), transparent 58%),
79 linear-gradient(145deg, #07152f 0%, #151443 52%, #32155b 100%);
80 }
81 .stage-nightly::before {
82 content: "";
83 position: absolute;
84 inset: 0;
85 opacity: 0.78;
86 background-image:
87 radial-gradient(circle at 12px 12px, rgba(228, 234, 255, 0.9) 0 1px, transparent 1.5px),
88 radial-gradient(circle at 38px 28px, rgba(228, 234, 255, 0.58) 0 0.8px, transparent 1.3px),
89 radial-gradient(circle at 58px 9px, rgba(200, 215, 255, 0.72) 0 0.9px, transparent 1.4px);
90 background-size: 72px 48px, 96px 64px, 128px 56px;
91 }
92 .stage::after {
93 content: "";
94 position: absolute;
95 inset: 0;
96 background:
97 radial-gradient(circle at 78% 20%, rgba(210, 255, 255, 0.36), transparent 34%),
98 linear-gradient(to bottom, transparent 24%, rgba(8, 28, 89, 0.38));
99 }
100 .stage-content {
101 position: relative;
102 z-index: 1;
103 height: 100%;
104 display: flex;
105 align-items: center;
106 justify-content: space-between;
107 }
108 .brand {
109 margin: 0;
110 font-size: 10px;
111 font-weight: 700;
112 letter-spacing: 0.2em;
113 text-transform: uppercase;
114 }
115 .brand { color: rgba(255, 255, 255, 0.82); }
116 .content { padding: 30px 32px 34px; }
117 .eyebrow {
118 margin: 0 0 8px;
119 color: #2866cc;
120 font-size: 10px;
121 font-weight: 700;
122 letter-spacing: 0.18em;
123 text-transform: uppercase;
124 }
125 h1 { margin: 0; font-size: clamp(26px, 5vw, 34px); line-height: 1.12; letter-spacing: -0.035em; }
126 .description { margin: 12px 0 0; color: #646975; font-size: 15px; line-height: 1.6; }
127 @media (prefers-color-scheme: dark) {
128 :root { background: #101115; color: #f1f3f7; }
129 body { background: radial-gradient(48rem 22rem at 50% -8rem, rgba(55, 102, 210, 0.2), transparent), #101115; }
130 main { border-color: rgba(255, 255, 255, 0.1); background: rgba(25, 27, 33, 0.96); }
131 .eyebrow { color: #77a8ff; }
132 .description { color: #a8adb8; }
133 }
134 </style>
135 </head>
136 <body>
137 <main>
138 <header class="stage stage-${stage}" data-stage="${stage}">
139 <div class="stage-content">
140 <p class="brand">${stageBrand}</p>
141 </div>
142 </header>
143 <section class="content">
144 <p class="eyebrow">Browser authorization complete</p>
145 <h1>You're connected</h1>
146 <p class="description">Return to your terminal to finish setting up Piku Connect. You can close this window.</p>
147 </section>
148 </main>
149 </body>
150</html>`;