@startup-api/cloudflare 0.4.3 → 0.4.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startup-api/cloudflare",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,7 +15,7 @@
15
15
  <power-strip providers="{{ssr:providers}}" style="position: absolute; top: 0; right: 0; z-index: 9999; border-radius: 0 0 0 0.3rem">
16
16
  <svg viewBox="0 0 24 24" style="width: 1rem; height: 1rem"><path d="M7 2v11h3v9l7-12h-4l4-8z" fill="#ffcc00" /></svg>
17
17
  </power-strip>
18
- <script src="/users/power-strip.js" async></script>
18
+ <script type="module" src="/users/power-strip.js" async></script>
19
19
 
20
20
  <div class="header-area">
21
21
  <a href="/" class="back-link">← Back to Home</a>
@@ -181,7 +181,7 @@
181
181
  <power-strip providers="{{ssr:providers}}" style="position: absolute; top: 0; right: 0; z-index: 9999; border-radius: 0 0 0 0.3rem">
182
182
  <svg viewBox="0 0 24 24" style="width: 1rem; height: 1rem"><path d="M7 2v11h3v9l7-12h-4l4-8z" fill="#ffcc00" /></svg>
183
183
  </power-strip>
184
- <script src="/users/power-strip.js" async></script>
184
+ <script type="module" src="/users/power-strip.js" async></script>
185
185
 
186
186
  <h1>StartupAPI Admin</h1>
187
187
 
@@ -17,22 +17,15 @@ class PowerStrip extends HTMLElement {
17
17
  }
18
18
 
19
19
  detectBasePath() {
20
- const script =
21
- document.currentScript ||
22
- (function () {
23
- const scripts = document.getElementsByTagName('script');
24
- return scripts[scripts.length - 1];
25
- })();
26
-
27
- if (script && script.src) {
28
- try {
29
- const url = new URL(script.src);
30
- return url.pathname.substring(0, url.pathname.lastIndexOf('/'));
31
- } catch (e) {
32
- console.error('Failed to parse script URL', e);
33
- }
20
+ // This file is loaded as an ES module (`<script type="module">`), so `document.currentScript`
21
+ // is null. `import.meta.url` is the module's own URL and is the reliable way to locate ourselves.
22
+ try {
23
+ const url = new URL(import.meta.url);
24
+ return url.pathname.substring(0, url.pathname.lastIndexOf('/'));
25
+ } catch (e) {
26
+ console.error('Failed to derive base path from import.meta.url', e);
27
+ return '';
34
28
  }
35
- return '';
36
29
  }
37
30
 
38
31
  async connectedCallback() {
@@ -10,7 +10,7 @@
10
10
  <power-strip providers="{{ssr:providers}}" style="position: absolute; top: 0; right: 0; z-index: 9999; border-radius: 0 0 0 0.3rem">
11
11
  <svg viewBox="0 0 24 24" style="width: 1rem; height: 1rem"><path d="M7 2v11h3v9l7-12h-4l4-8z" fill="#ffcc00" /></svg>
12
12
  </power-strip>
13
- <script src="/users/power-strip.js" async></script>
13
+ <script type="module" src="/users/power-strip.js" async></script>
14
14
 
15
15
  <div class="header-area">
16
16
  <a href="/" class="back-link">← Back to Home</a>
@@ -451,7 +451,8 @@
451
451
  }
452
452
  function credentialIdentifier(c) {
453
453
  if (c.provider === 'atproto') {
454
- return c.handle ? `${c.handle} (${c.subject_id})` : c.subject_id;
454
+ if (!c.handle) return c.subject_id;
455
+ return `<span style="font-size: 1.05rem; font-weight: 600;">@${c.handle}</span> <span style="opacity: 0.6;">(${c.subject_id})</span>`;
455
456
  }
456
457
  return c.email || c.subject_id;
457
458
  }
package/src/PowerStrip.ts CHANGED
@@ -24,7 +24,7 @@ export async function injectPowerStrip(response: Response, usersPath: string, pr
24
24
  element(element) {
25
25
  // The script is always needed to define the <power-strip> custom element.
26
26
  // It is loaded from the USERS_PATH, which is intercepted by this worker.
27
- element.prepend(`<script src="${usersPath}power-strip.js" async></script>`, { html: true });
27
+ element.prepend(`<script type="module" src="${usersPath}power-strip.js" async></script>`, { html: true });
28
28
 
29
29
  // Defer the component decision until the end of <body>, by which point
30
30
  // the streaming parser has seen any author-supplied <power-strip>.
@@ -214,10 +214,14 @@ function providerLabel(provider: string): string {
214
214
  return provider.charAt(0).toUpperCase() + provider.slice(1);
215
215
  }
216
216
 
217
- /** The identifier shown under the provider name. atproto shows the handle with the DID in parens. */
217
+ /**
218
+ * The identifier shown under the provider name. atproto emphasizes the handle (larger, with an `@`)
219
+ * and de-emphasizes the DID in parentheses.
220
+ */
218
221
  function credentialIdentifier(c: any): string {
219
222
  if (c.provider === 'atproto') {
220
- return c.handle ? `${c.handle} (${c.subject_id})` : c.subject_id;
223
+ if (!c.handle) return c.subject_id;
224
+ return `<span style="font-size: 1.05rem; font-weight: 600;">@${c.handle}</span> <span style="opacity: 0.6;">(${c.subject_id})</span>`;
221
225
  }
222
226
  return c.email || c.subject_id;
223
227
  }