sequoia-cli 0.5.0 → 0.5.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.
@@ -113,21 +113,34 @@ const styles = `
113
113
  align-items: center;
114
114
  gap: 0.375rem;
115
115
  padding: 0.5rem 1rem;
116
- background: var(--sequoia-accent-color, #2563eb);
117
- color: #ffffff;
118
116
  border: none;
119
- border-radius: var(--sequoia-border-radius, 8px);
117
+ border-radius: var(--sequoia-border-radius, 15px);
120
118
  font-size: 0.875rem;
121
119
  font-weight: 500;
122
120
  cursor: pointer;
123
121
  text-decoration: none;
124
122
  transition: background-color 0.15s ease;
123
+ margin-left:10px;
124
+ }
125
+
126
+ .sequoia-reply-bluesky {
127
+ background: var(--sequoia-accent-color, #2563eb);
128
+ color: #ffffff;
129
+ }
130
+
131
+ .sequoia-reply-blacksky {
132
+ background: var(--sequoia-accent-color, #6060E9);
133
+ color: #ffffff;
125
134
  }
126
135
 
127
- .sequoia-reply-button:hover {
136
+ .sequoia-reply-bluesky:hover {
128
137
  background: color-mix(in srgb, var(--sequoia-accent-color, #2563eb) 85%, black);
129
138
  }
130
139
 
140
+ .sequoia-reply-blacksky:hover {
141
+ background: color-mix(in srgb, var(--sequoia-accent-color, #5252c3) 85%, black);
142
+ }
143
+
131
144
  .sequoia-reply-button svg {
132
145
  width: 1rem;
133
146
  height: 1rem;
@@ -547,6 +560,20 @@ function buildBskyAppUrl(postUri) {
547
560
  return `https://bsky.app/profile/${parsed.did}/post/${parsed.rkey}`;
548
561
  }
549
562
 
563
+ /**
564
+ * Build a Blacksky app URL for a post
565
+ * @param {string} postUri - AT Protocol URI for the post
566
+ * @returns {string} Blacksky app URL
567
+ */
568
+ function buildBlackskyAppUrl(postUri) {
569
+ const parsed = parseAtUri(postUri);
570
+ if (!parsed) {
571
+ throw new Error(`Invalid post URI: ${postUri}`);
572
+ }
573
+
574
+ return `https://blacksky.community/profile/${parsed.did}/post/${parsed.rkey}`;
575
+ }
576
+
550
577
  /**
551
578
  * Type guard for ThreadViewPost
552
579
  * @param {any} post - Post to check
@@ -563,6 +590,8 @@ function isThreadViewPost(post) {
563
590
  const BLUESKY_ICON = `<svg class="sequoia-bsky-logo" viewBox="0 0 600 530" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
564
591
  <path d="m135.72 44.03c66.496 49.921 138.02 151.14 164.28 205.46 26.262-54.316 97.782-155.54 164.28-205.46 47.98-36.021 125.72-63.892 125.72 24.795 0 17.712-10.155 148.79-16.111 170.07-20.703 73.984-96.144 92.854-163.25 81.433 117.3 19.964 147.14 86.092 82.697 152.22-122.39 125.59-175.91-31.511-189.63-71.766-2.514-7.3797-3.6904-10.832-3.7077-7.8964-0.0174-2.9357-1.1937 0.51669-3.7077 7.8964-13.714 40.255-67.233 197.36-189.63 71.766-64.444-66.128-34.605-132.26 82.697-152.22-67.108 11.421-142.55-7.4491-163.25-81.433-5.9562-21.282-16.111-152.36-16.111-170.07 0-88.687 77.742-60.816 125.72-24.795z"/>
565
592
  </svg>`;
593
+ const BLACKSKY_ICON =
594
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.0620117 0.348442 87.9941 74.9653"><path d="M41.9565 74.9643L24.0161 74.9653L41.9565 74.9643ZM63.8511 74.9653H45.9097L63.8501 74.9643V57.3286H63.8511V74.9653ZM45.9097 44.5893C45.9099 49.2737 49.7077 53.0707 54.3921 53.0707H63.8501V57.3286H54.3921C49.7077 57.3286 45.9099 61.1257 45.9097 65.81V74.9643H41.9565V65.81C41.9563 61.1258 38.1593 57.3287 33.4751 57.3286H24.0161V53.0707H33.4741C38.1587 53.0707 41.9565 49.2729 41.9565 44.5883V35.1303H45.9097V44.5893ZM63.8511 53.0707H63.8501V35.1303H63.8511V53.0707Z" fill="white"></path><path d="M52.7272 9.83198C49.4148 13.1445 49.4148 18.5151 52.7272 21.8275L59.4155 28.5158L56.4051 31.5262L49.7169 24.8379C46.4044 21.5254 41.0338 21.5254 37.7213 24.8379L31.2482 31.3111L28.4527 28.5156L34.9259 22.0424C38.2383 18.7299 38.2383 13.3594 34.9259 10.0469L28.2378 3.35883L31.2482 0.348442L37.9365 7.03672C41.2489 10.3492 46.6195 10.3492 49.932 7.03672L56.6203 0.348442L59.4155 3.14371L52.7272 9.83198Z" fill="white"/><path d="M24.3831 23.2335C23.1706 27.7584 25.8559 32.4095 30.3808 33.6219L39.5172 36.07L38.4154 40.182L29.2793 37.734C24.7544 36.5215 20.1033 39.2068 18.8909 43.7317L16.5215 52.5745L12.7028 51.5513L15.0721 42.7088C16.2846 38.1839 13.5993 33.5328 9.07434 32.3204L-0.0620117 29.8723L1.03987 25.76L10.1762 28.2081C14.7011 29.4206 19.3522 26.7352 20.5647 22.2103L23.0127 13.074L26.8311 14.0971L24.3831 23.2335Z" fill="white"/><path d="M67.3676 22.0297C68.5801 26.5546 73.2311 29.2399 77.756 28.0275L86.8923 25.5794L87.9941 29.6914L78.8578 32.1394C74.3329 33.3519 71.6476 38.003 72.86 42.5279L75.2294 51.3707L71.411 52.3938L69.0417 43.5513C67.8293 39.0264 63.1782 36.3411 58.6533 37.5535L49.5169 40.0016L48.415 35.8894L57.5514 33.4413C62.0763 32.2288 64.7616 27.5778 63.5492 23.0528L61.1011 13.9165L64.9195 12.8934L67.3676 22.0297Z" fill="white"/></svg>';
566
595
 
567
596
  // ============================================================================
568
597
  // Web Component
@@ -660,6 +689,7 @@ class SequoiaComments extends BaseElement {
660
689
  }
661
690
 
662
691
  const postUrl = buildBskyAppUrl(document.bskyPostRef.uri);
692
+ const blackskyPostUrl = buildBlackskyAppUrl(document.bskyPostRef.uri);
663
693
 
664
694
  // Fetch the post thread
665
695
  const thread = await getPostThread(document.bskyPostRef.uri, this.depth);
@@ -667,12 +697,12 @@ class SequoiaComments extends BaseElement {
667
697
  // Check if there are any replies
668
698
  const replies = thread.replies?.filter(isThreadViewPost) ?? [];
669
699
  if (replies.length === 0) {
670
- this.state = { type: "empty", postUrl };
700
+ this.state = { type: "empty", postUrl, blackskyPostUrl };
671
701
  this.render();
672
702
  return;
673
703
  }
674
704
 
675
- this.state = { type: "loaded", thread, postUrl };
705
+ this.state = { type: "loaded", thread, postUrl, blackskyPostUrl };
676
706
  this.render();
677
707
  } catch (error) {
678
708
  const message =
@@ -716,10 +746,14 @@ class SequoiaComments extends BaseElement {
716
746
  this.commentsContainer.innerHTML = `
717
747
  <div class="sequoia-comments-header">
718
748
  <h3 class="sequoia-comments-title">Comments</h3>
719
- <a href="${this.state.postUrl}" target="_blank" rel="noopener noreferrer" class="sequoia-reply-button">
720
- ${BLUESKY_ICON}
721
- Reply on Bluesky
722
- </a>
749
+ <div>
750
+ <a href="${this.state.postUrl}" target="_blank" rel="noopener noreferrer" class="sequoia-reply-button sequoia-reply-bluesky">
751
+ ${BLUESKY_ICON}
752
+ </a>
753
+ <a href="${this.state.blackskyPostUrl}" target="_blank" rel="noopener noreferrer" class="sequoia-reply-button sequoia-reply-blacksky">
754
+ ${BLACKSKY_ICON}
755
+ </a>
756
+ </div>
723
757
  </div>
724
758
  <div class="sequoia-empty">
725
759
  No comments yet. Be the first to reply on Bluesky!
@@ -746,10 +780,14 @@ class SequoiaComments extends BaseElement {
746
780
  this.commentsContainer.innerHTML = `
747
781
  <div class="sequoia-comments-header">
748
782
  <h3 class="sequoia-comments-title">${commentCount} Comment${commentCount !== 1 ? "s" : ""}</h3>
749
- <a href="${this.state.postUrl}" target="_blank" rel="noopener noreferrer" class="sequoia-reply-button">
750
- ${BLUESKY_ICON}
751
- Reply on Bluesky
752
- </a>
783
+ <div>
784
+ <a href="${this.state.postUrl}" target="_blank" rel="noopener noreferrer" class="sequoia-reply-button sequoia-reply-bluesky">
785
+ ${BLUESKY_ICON}
786
+ </a>
787
+ <a href="${this.state.blackskyPostUrl}" target="_blank" rel="noopener noreferrer" class="sequoia-reply-button sequoia-reply-blacksky">
788
+ ${BLACKSKY_ICON}
789
+ </a>
790
+ </div>
753
791
  </div>
754
792
  <div class="sequoia-comments-list">
755
793
  ${threadsHtml}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Sequoia Subscribe - A Bluesky-powered subscribe component
2
+ * Sequoia Subscribe - An AT Protocol-powered subscribe component
3
3
  *
4
4
  * A self-contained Web Component that lets users subscribe to a publication
5
5
  * via the AT Protocol by creating a site.standard.graph.subscription record.
@@ -13,7 +13,9 @@
13
13
  * Attributes:
14
14
  * - publication-uri: Override the publication AT URI (optional)
15
15
  * - callback-uri: Redirect URI after OAuth authentication (default: "https://sequoia.pub/subscribe")
16
- * - label: Button label text (default: "Subscribe on Bluesky")
16
+ * - button-type: Branding style "sequoia" (default), "bluesky", "blacksky", "atmosphere", or "plain"
17
+ * - label: Override the subscribe button label text
18
+ * - unsubscribe-label: Override the unsubscribe button label text
17
19
  * - hide: Set to "auto" to hide if no publication URI is detected
18
20
  *
19
21
  * CSS Custom Properties:
@@ -23,6 +25,7 @@
23
25
  * - --sequoia-accent-color: Accent/button color (default: #2563eb)
24
26
  * - --sequoia-secondary-color: Secondary text color (default: #6b7280)
25
27
  * - --sequoia-border-radius: Border radius (default: 8px)
28
+ * - --sequoia-icon-display: Icon display mode (default: inline-block) — set to "none" to hide
26
29
  *
27
30
  * Events:
28
31
  * - sequoia-subscribed: Fired when the subscription is created successfully.
@@ -74,19 +77,12 @@ const styles = `
74
77
  }
75
78
 
76
79
  .sequoia-subscribe-button svg {
80
+ display: var(--sequoia-icon-display, inline-block);
77
81
  width: 1rem;
78
82
  height: 1rem;
79
83
  flex-shrink: 0;
80
84
  }
81
85
 
82
- .sequoia-subscribe-button--success {
83
- background: #16a34a;
84
- }
85
-
86
- .sequoia-subscribe-button--success:hover:not(:disabled) {
87
- background: color-mix(in srgb, #16a34a 85%, black);
88
- }
89
-
90
86
  .sequoia-loading-spinner {
91
87
  display: inline-block;
92
88
  width: 1rem;
@@ -118,9 +114,136 @@ const BLUESKY_ICON = `<svg class="sequoia-bsky-logo" viewBox="0 0 600 530" fill=
118
114
  <path d="m135.72 44.03c66.496 49.921 138.02 151.14 164.28 205.46 26.262-54.316 97.782-155.54 164.28-205.46 47.98-36.021 125.72-63.892 125.72 24.795 0 17.712-10.155 148.79-16.111 170.07-20.703 73.984-96.144 92.854-163.25 81.433 117.3 19.964 147.14 86.092 82.697 152.22-122.39 125.59-175.91-31.511-189.63-71.766-2.514-7.3797-3.6904-10.832-3.7077-7.8964-0.0174-2.9357-1.1937 0.51669-3.7077 7.8964-13.714 40.255-67.233 197.36-189.63 71.766-64.444-66.128-34.605-132.26 82.697-152.22-67.108 11.421-142.55-7.4491-163.25-81.433-5.9562-21.282-16.111-152.36-16.111-170.07 0-88.687 77.742-60.816 125.72-24.795z"/>
119
115
  </svg>`;
120
116
 
121
- const CHECK_ICON = `<svg viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
122
- <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>
123
- </svg>`;
117
+ const BLACKSKY_ICON = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.0620117 0.348442 87.9941 74.9653" fill="currentColor"><path d="M41.9565 74.9643L24.0161 74.9653L41.9565 74.9643ZM63.8511 74.9653H45.9097L63.8501 74.9643V57.3286H63.8511V74.9653ZM45.9097 44.5893C45.9099 49.2737 49.7077 53.0707 54.3921 53.0707H63.8501V57.3286H54.3921C49.7077 57.3286 45.9099 61.1257 45.9097 65.81V74.9643H41.9565V65.81C41.9563 61.1258 38.1593 57.3287 33.4751 57.3286H24.0161V53.0707H33.4741C38.1587 53.0707 41.9565 49.2729 41.9565 44.5883V35.1303H45.9097V44.5893ZM63.8511 53.0707H63.8501V35.1303H63.8511V53.0707Z"/><path d="M52.7272 9.83198C49.4148 13.1445 49.4148 18.5151 52.7272 21.8275L59.4155 28.5158L56.4051 31.5262L49.7169 24.8379C46.4044 21.5254 41.0338 21.5254 37.7213 24.8379L31.2482 31.3111L28.4527 28.5156L34.9259 22.0424C38.2383 18.7299 38.2383 13.3594 34.9259 10.0469L28.2378 3.35883L31.2482 0.348442L37.9365 7.03672C41.2489 10.3492 46.6195 10.3492 49.932 7.03672L56.6203 0.348442L59.4155 3.14371L52.7272 9.83198Z"/><path d="M24.3831 23.2335C23.1706 27.7584 25.8559 32.4095 30.3808 33.6219L39.5172 36.07L38.4154 40.182L29.2793 37.734C24.7544 36.5215 20.1033 39.2068 18.8909 43.7317L16.5215 52.5745L12.7028 51.5513L15.0721 42.7088C16.2846 38.1839 13.5993 33.5328 9.07434 32.3204L-0.0620117 29.8723L1.03987 25.76L10.1762 28.2081C14.7011 29.4206 19.3522 26.7352 20.5647 22.2103L23.0127 13.074L26.8311 14.0971L24.3831 23.2335Z"/><path d="M67.3676 22.0297C68.5801 26.5546 73.2311 29.2399 77.756 28.0275L86.8923 25.5794L87.9941 29.6914L78.8578 32.1394C74.3329 33.3519 71.6476 38.003 72.86 42.5279L75.2294 51.3707L71.411 52.3938L69.0417 43.5513C67.8293 39.0264 63.1782 36.3411 58.6533 37.5535L49.5169 40.0016L48.415 35.8894L57.5514 33.4413C62.0763 32.2288 64.7616 27.5778 63.5492 23.0528L61.1011 13.9165L64.9195 12.8934L67.3676 22.0297Z"/></svg>`;
118
+
119
+ const SEQUOIA_ICON = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 95 151" fill="none" stroke="currentColor" stroke-width="10.5" stroke-linecap="round" stroke-linejoin="round"><path d="M47.25 145.217V54.2167M68.25 111.596C74.6356 107.909 79.9382 102.606 83.6245 96.2201C87.3108 89.8341 89.251 82.5902 89.25 75.2167C89.2641 64.2875 85.0033 53.7863 77.378 45.9567C78.8172 41.2475 79.1324 36.2663 78.2981 31.4132C77.4638 26.5601 75.5033 21.9701 72.574 18.0118C69.6448 14.0535 65.8283 10.8371 61.4309 8.62081C57.0335 6.4045 52.1778 5.25 47.2535 5.25C42.3292 5.25 37.4734 6.4045 33.0761 8.62081C28.6787 10.8371 24.8622 14.0535 21.9329 18.0118C19.0037 21.9701 17.0432 26.5601 16.2089 31.4132C15.3746 36.2663 15.6897 41.2475 17.129 45.9567C9.50114 53.7851 5.23776 64.2866 5.25003 75.2167C5.25003 90.7567 13.699 104.337 26.25 111.596M47.25 96.2167L64.75 78.7167M47.25 82.2167L29.75 64.7167M33.25 145.217H61.25"/></svg>`;
120
+
121
+ const ATMOSPHERE_ICON = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 114 114" fill="currentColor"><path d="M56.9119 114C48.655 114 41.0566 112.632 34.1167 109.896C27.1769 107.16 21.1488 103.284 16.0326 98.268C10.9125 93.2969 6.87661 87.3195 4.17911 80.712C1.39304 73.9733 0 66.652 0 58.748C0 49.324 1.44369 40.964 4.33108 33.668C7.26912 26.372 11.3216 20.2413 16.4885 15.276C21.6743 10.2798 27.829 6.39999 34.5726 3.876C41.4618 1.292 48.8322 0 56.6839 0C66.3085 0 74.7427 1.49467 81.9865 4.484C89.2303 7.47333 95.2583 11.5267 100.071 16.644C104.833 21.6798 108.483 27.6613 110.784 34.2C113.115 40.736 114.178 47.576 113.976 54.72C113.722 64.5493 111.671 72.0986 107.821 77.368C103.971 82.5866 97.9938 85.196 89.8888 85.196C85.7259 85.2315 81.6218 84.2118 77.9594 82.232C74.4587 80.3688 71.7969 77.2446 70.513 73.492L74.92 73.72C72.8431 77.6213 70.0064 80.3573 66.4098 81.928C62.9411 83.4714 59.1886 84.2738 55.3922 84.284C50.2759 84.284 45.7676 83.1946 41.8671 81.016C37.9939 78.8144 34.8103 75.5775 32.673 71.668C30.4442 67.6653 29.3297 63.0293 29.3297 57.76C29.3297 52.3387 30.4948 47.652 32.825 43.7C35.0512 39.7998 38.3119 36.5909 42.247 34.428C46.1981 32.2493 50.6559 31.16 55.6201 31.16C58.9128 31.16 62.332 31.844 65.8779 33.212C69.4745 34.58 72.2606 36.5053 74.2362 38.988L71.1208 42.94V33.288H81.3027L81.0747 60.572C81.0747 64.4733 81.8345 67.412 83.3542 69.388C84.8739 71.364 87.1281 72.352 90.1168 72.352C92.7509 72.352 94.7771 71.6173 96.1955 70.148C97.6645 68.628 98.6776 66.576 99.2348 63.992C99.8841 61.0707 100.24 58.092 100.299 55.1C100.451 47.2467 99.2855 40.6347 96.8033 35.264C94.3212 29.8933 90.9526 25.5613 86.6975 22.268C82.5822 18.9703 77.857 16.5168 72.7925 15.048C67.7269 13.528 62.6866 12.768 57.6717 12.768C50.5799 12.768 44.2732 13.908 38.7517 16.188C33.2302 18.4173 28.5699 21.584 24.7707 25.688C21.0222 29.7413 18.1855 34.5547 16.2605 40.128C14.3863 45.6507 13.4998 51.7307 13.6011 58.368C13.8037 64.9547 14.9941 70.8826 17.1723 76.152C19.2339 81.2487 22.3399 85.857 26.2904 89.68C30.2557 93.4697 34.9649 96.3941 40.1194 98.268C45.4383 100.244 51.2637 101.232 57.5957 101.232C61.1416 101.232 64.6622 100.827 68.1575 100.016C71.7034 99.256 74.9453 98.1666 77.8834 96.748L82.2145 108.604C78.314 110.428 74.2108 111.771 69.9051 112.632C65.6345 113.546 61.2791 114.004 56.9119 114ZM56.304 71.364C59.9006 71.364 62.9146 70.3253 65.3461 68.248C67.7775 66.1706 68.9933 62.6493 68.9933 57.684C68.9933 53.1747 67.9042 49.78 65.726 47.5C63.5984 45.1693 60.5844 44.004 56.6839 44.004C52.0742 44.004 48.6296 45.22 46.3501 47.652C44.0706 50.084 42.9308 53.428 42.9308 57.684C42.9308 62.0413 44.0959 65.4106 46.4261 67.792C48.8069 70.1733 52.0996 71.364 56.304 71.364Z"/></svg>`;
122
+
123
+ // ============================================================================
124
+ // Button Type Configuration
125
+ // ============================================================================
126
+
127
+ const BUTTON_TYPES = {
128
+ sequoia: {
129
+ icon: SEQUOIA_ICON,
130
+ subscribe: "Subscribe on Sequoia",
131
+ unsubscribe: "Unsubscribe",
132
+ },
133
+ bluesky: {
134
+ icon: BLUESKY_ICON,
135
+ subscribe: "Subscribe on Bluesky",
136
+ unsubscribe: "Unsubscribe",
137
+ },
138
+ blacksky: {
139
+ icon: BLACKSKY_ICON,
140
+ subscribe: "Subscribe on Blacksky",
141
+ unsubscribe: "Unsubscribe",
142
+ },
143
+ atmosphere: {
144
+ icon: ATMOSPHERE_ICON,
145
+ subscribe: "Subscribe on Atmosphere",
146
+ unsubscribe: "Unsubscribe",
147
+ },
148
+ plain: { icon: "", subscribe: "Subscribe", unsubscribe: "Unsubscribe" },
149
+ };
150
+
151
+ // ============================================================================
152
+ // DID Storage
153
+ // ============================================================================
154
+
155
+ /**
156
+ * Store the subscriber DID. Tries a cookie first; falls back to localStorage.
157
+ * @param {string} did
158
+ */
159
+ function storeSubscriberDid(did) {
160
+ try {
161
+ const expires = new Date(
162
+ Date.now() + 365 * 24 * 60 * 60 * 1000,
163
+ ).toUTCString();
164
+ document.cookie = `sequoia_did=${encodeURIComponent(did)}; expires=${expires}; path=/; SameSite=Lax`;
165
+ } catch {
166
+ // Cookie write may fail in some embedded contexts
167
+ }
168
+ try {
169
+ localStorage.setItem("sequoia_did", did);
170
+ } catch {
171
+ // localStorage may be unavailable
172
+ }
173
+ }
174
+
175
+ /**
176
+ * Retrieve the stored subscriber DID. Checks cookie first, then localStorage.
177
+ * @returns {string | null}
178
+ */
179
+ function getStoredSubscriberDid() {
180
+ try {
181
+ const match = document.cookie.match(/(?:^|;\s*)sequoia_did=([^;]+)/);
182
+ if (match) {
183
+ const did = decodeURIComponent(match[1]);
184
+ if (did.startsWith("did:")) return did;
185
+ }
186
+ } catch {
187
+ // ignore
188
+ }
189
+ try {
190
+ const did = localStorage.getItem("sequoia_did");
191
+ if (did?.startsWith("did:")) return did;
192
+ } catch {
193
+ // ignore
194
+ }
195
+ return null;
196
+ }
197
+
198
+ /**
199
+ * Remove the stored subscriber DID from both cookie and localStorage.
200
+ */
201
+ function clearSubscriberDid() {
202
+ try {
203
+ document.cookie =
204
+ "sequoia_did=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Lax";
205
+ } catch {
206
+ // ignore
207
+ }
208
+ try {
209
+ localStorage.removeItem("sequoia_did");
210
+ } catch {
211
+ // ignore
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Check the current page URL for sequoia_did / sequoia_unsubscribed params
217
+ * set by the subscribe redirect flow. Consumes them by removing from the URL.
218
+ */
219
+ function consumeReturnParams() {
220
+ const url = new URL(window.location.href);
221
+ const did = url.searchParams.get("sequoia_did");
222
+ const unsubscribed = url.searchParams.get("sequoia_unsubscribed");
223
+
224
+ let changed = false;
225
+
226
+ if (unsubscribed === "1") {
227
+ clearSubscriberDid();
228
+ url.searchParams.delete("sequoia_unsubscribed");
229
+ changed = true;
230
+ }
231
+
232
+ if (did && did.startsWith("did:")) {
233
+ storeSubscriberDid(did);
234
+ url.searchParams.delete("sequoia_did");
235
+ changed = true;
236
+ }
237
+
238
+ if (changed) {
239
+ const cleanUrl = url.pathname + (url.search || "") + (url.hash || "");
240
+ try {
241
+ window.history.replaceState(null, "", cleanUrl);
242
+ } catch {
243
+ // ignore
244
+ }
245
+ }
246
+ }
124
247
 
125
248
  // ============================================================================
126
249
  // AT Protocol Functions
@@ -178,20 +301,26 @@ class SequoiaSubscribe extends BaseElement {
178
301
  wrapper.part = "container";
179
302
 
180
303
  this.wrapper = wrapper;
304
+ this.subscribed = false;
181
305
  this.state = { type: "idle" };
182
306
  this.abortController = null;
183
307
  this.render();
184
308
  }
185
309
 
186
310
  static get observedAttributes() {
187
- return ["publication-uri", "callback-uri", "label", "hide"];
311
+ return [
312
+ "publication-uri",
313
+ "callback-uri",
314
+ "label",
315
+ "unsubscribe-label",
316
+ "button-type",
317
+ "hide",
318
+ ];
188
319
  }
189
320
 
190
321
  connectedCallback() {
191
- // Pre-check publication availability so hide="auto" can take effect
192
- if (!this.publicationUri) {
193
- this.checkPublication();
194
- }
322
+ consumeReturnParams();
323
+ this.checkPublication();
195
324
  }
196
325
 
197
326
  disconnectedCallback() {
@@ -199,12 +328,7 @@ class SequoiaSubscribe extends BaseElement {
199
328
  }
200
329
 
201
330
  attributeChangedCallback() {
202
- // Reset to idle if attributes change after an error or success
203
- if (
204
- this.state.type === "error" ||
205
- this.state.type === "subscribed" ||
206
- this.state.type === "no-publication"
207
- ) {
331
+ if (this.state.type === "error" || this.state.type === "no-publication") {
208
332
  this.state = { type: "idle" };
209
333
  }
210
334
  this.render();
@@ -219,7 +343,16 @@ class SequoiaSubscribe extends BaseElement {
219
343
  }
220
344
 
221
345
  get label() {
222
- return this.getAttribute("label") ?? "Subscribe on Bluesky";
346
+ return this.getAttribute("label") ?? null;
347
+ }
348
+
349
+ get unsubscribeLabel() {
350
+ return this.getAttribute("unsubscribe-label") ?? null;
351
+ }
352
+
353
+ get buttonType() {
354
+ const val = this.getAttribute("button-type");
355
+ return val && val in BUTTON_TYPES ? val : "sequoia";
223
356
  }
224
357
 
225
358
  get hide() {
@@ -232,15 +365,49 @@ class SequoiaSubscribe extends BaseElement {
232
365
  this.abortController = new AbortController();
233
366
 
234
367
  try {
235
- await fetchPublicationUri();
368
+ const uri = this.publicationUri ?? (await fetchPublicationUri());
369
+ this.checkSubscription(uri);
236
370
  } catch {
237
371
  this.state = { type: "no-publication" };
238
372
  this.render();
239
373
  }
240
374
  }
241
375
 
376
+ async checkSubscription(publicationUri) {
377
+ try {
378
+ const checkUrl = new URL(`${this.callbackUri}/check`);
379
+ checkUrl.searchParams.set("publicationUri", publicationUri);
380
+
381
+ // Pass the stored DID so the server can check without a session cookie
382
+ const storedDid = getStoredSubscriberDid();
383
+ if (storedDid) {
384
+ checkUrl.searchParams.set("did", storedDid);
385
+ }
386
+
387
+ const res = await fetch(checkUrl.toString(), {
388
+ credentials: "include",
389
+ });
390
+ if (!res.ok) return;
391
+ const data = await res.json();
392
+ if (data.subscribed) {
393
+ this.subscribed = true;
394
+ this.render();
395
+ }
396
+ } catch {
397
+ // Ignore errors — show default subscribe button
398
+ }
399
+ }
400
+
242
401
  async handleClick() {
243
- if (this.state.type === "loading" || this.state.type === "subscribed") {
402
+ if (this.state.type === "loading") {
403
+ return;
404
+ }
405
+
406
+ // Unsubscribe: redirect to full-page unsubscribe flow
407
+ if (this.subscribed) {
408
+ const publicationUri =
409
+ this.publicationUri ?? (await fetchPublicationUri());
410
+ window.location.href = `${this.callbackUri}?publicationUri=${encodeURIComponent(publicationUri)}&action=unsubscribe`;
244
411
  return;
245
412
  }
246
413
 
@@ -251,21 +418,25 @@ class SequoiaSubscribe extends BaseElement {
251
418
  const publicationUri =
252
419
  this.publicationUri ?? (await fetchPublicationUri());
253
420
 
254
- // POST to the callbackUri (e.g. https://sequoia.pub/subscribe).
255
- // If the server reports the user isn't authenticated it returns a
256
- // subscribeUrl for the full-page OAuth + subscription flow.
257
421
  const response = await fetch(this.callbackUri, {
258
422
  method: "POST",
259
423
  headers: { "Content-Type": "application/json" },
260
424
  credentials: "include",
425
+ referrerPolicy: "no-referrer-when-downgrade",
261
426
  body: JSON.stringify({ publicationUri }),
262
427
  });
263
428
 
264
429
  const data = await response.json();
265
430
 
266
431
  if (response.status === 401 && data.authenticated === false) {
267
- // Redirect to the hosted subscribe page to complete OAuth
268
- window.location.href = data.subscribeUrl;
432
+ // Redirect to the hosted subscribe page to complete OAuth,
433
+ // passing the current page URL (without credentials) as returnTo.
434
+ const subscribeUrl = new URL(data.subscribeUrl);
435
+ const pageUrl = new URL(window.location.href);
436
+ pageUrl.username = "";
437
+ pageUrl.password = "";
438
+ subscribeUrl.searchParams.set("returnTo", pageUrl.toString());
439
+ window.location.href = subscribeUrl.toString();
269
440
  return;
270
441
  }
271
442
 
@@ -274,7 +445,17 @@ class SequoiaSubscribe extends BaseElement {
274
445
  }
275
446
 
276
447
  const { recordUri } = data;
277
- this.state = { type: "subscribed", recordUri, publicationUri };
448
+
449
+ // Store the DID from the record URI (at://did:aaa:bbb/...)
450
+ if (recordUri) {
451
+ const didMatch = recordUri.match(/^at:\/\/(did:[^/]+)/);
452
+ if (didMatch) {
453
+ storeSubscriberDid(didMatch[1]);
454
+ }
455
+ }
456
+
457
+ this.subscribed = true;
458
+ this.state = { type: "idle" };
278
459
  this.render();
279
460
 
280
461
  this.dispatchEvent(
@@ -285,7 +466,6 @@ class SequoiaSubscribe extends BaseElement {
285
466
  }),
286
467
  );
287
468
  } catch (error) {
288
- // Don't overwrite state if we already navigated away
289
469
  if (this.state.type !== "loading") return;
290
470
 
291
471
  const message =
@@ -315,21 +495,15 @@ class SequoiaSubscribe extends BaseElement {
315
495
  }
316
496
 
317
497
  const isLoading = type === "loading";
318
- const isSubscribed = type === "subscribed";
498
+ const config = BUTTON_TYPES[this.buttonType] ?? BUTTON_TYPES.sequoia;
319
499
 
320
500
  const icon = isLoading
321
501
  ? `<span class="sequoia-loading-spinner"></span>`
322
- : isSubscribed
323
- ? CHECK_ICON
324
- : BLUESKY_ICON;
325
-
326
- const label = isSubscribed ? "Subscribed" : this.label;
327
- const buttonClass = [
328
- "sequoia-subscribe-button",
329
- isSubscribed ? "sequoia-subscribe-button--success" : "",
330
- ]
331
- .filter(Boolean)
332
- .join(" ");
502
+ : config.icon;
503
+
504
+ const label = this.subscribed
505
+ ? (this.unsubscribeLabel ?? config.unsubscribe)
506
+ : (this.label ?? config.subscribe);
333
507
 
334
508
  const errorHtml =
335
509
  type === "error"
@@ -338,11 +512,11 @@ class SequoiaSubscribe extends BaseElement {
338
512
 
339
513
  this.wrapper.innerHTML = `
340
514
  <button
341
- class="${buttonClass}"
515
+ class="sequoia-subscribe-button"
342
516
  type="button"
343
517
  part="button"
344
- ${isLoading || isSubscribed ? "disabled" : ""}
345
- aria-label="${isSubscribed ? "Subscribed" : this.label}"
518
+ ${isLoading ? "disabled" : ""}
519
+ aria-label="${label}"
346
520
  >
347
521
  ${icon}
348
522
  ${label}
@@ -350,10 +524,8 @@ class SequoiaSubscribe extends BaseElement {
350
524
  ${errorHtml}
351
525
  `;
352
526
 
353
- if (type !== "subscribed") {
354
- const btn = this.wrapper.querySelector("button");
355
- btn?.addEventListener("click", () => this.handleClick());
356
- }
527
+ const btn = this.wrapper.querySelector("button");
528
+ btn?.addEventListener("click", () => this.handleClick());
357
529
  }
358
530
  }
359
531
 
package/dist/index.js CHANGED
@@ -2512,9 +2512,156 @@ var require_browser = __commonJS((exports, module) => {
2512
2512
  };
2513
2513
  });
2514
2514
 
2515
+ // ../../node_modules/.bun/supports-color@10.2.2/node_modules/supports-color/index.js
2516
+ var exports_supports_color = {};
2517
+ __export(exports_supports_color, {
2518
+ default: () => supports_color_default2,
2519
+ createSupportsColor: () => createSupportsColor2
2520
+ });
2521
+ import process3 from "node:process";
2522
+ import os2 from "node:os";
2523
+ import tty2 from "node:tty";
2524
+ function hasFlag2(flag, argv = globalThis.Deno ? globalThis.Deno.args : process3.argv) {
2525
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
2526
+ const position = argv.indexOf(prefix + flag);
2527
+ const terminatorPosition = argv.indexOf("--");
2528
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
2529
+ }
2530
+ function envForceColor2() {
2531
+ if (!("FORCE_COLOR" in env2)) {
2532
+ return;
2533
+ }
2534
+ if (env2.FORCE_COLOR === "true") {
2535
+ return 1;
2536
+ }
2537
+ if (env2.FORCE_COLOR === "false") {
2538
+ return 0;
2539
+ }
2540
+ if (env2.FORCE_COLOR.length === 0) {
2541
+ return 1;
2542
+ }
2543
+ const level = Math.min(Number.parseInt(env2.FORCE_COLOR, 10), 3);
2544
+ if (![0, 1, 2, 3].includes(level)) {
2545
+ return;
2546
+ }
2547
+ return level;
2548
+ }
2549
+ function translateLevel2(level) {
2550
+ if (level === 0) {
2551
+ return false;
2552
+ }
2553
+ return {
2554
+ level,
2555
+ hasBasic: true,
2556
+ has256: level >= 2,
2557
+ has16m: level >= 3
2558
+ };
2559
+ }
2560
+ function _supportsColor2(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
2561
+ const noFlagForceColor = envForceColor2();
2562
+ if (noFlagForceColor !== undefined) {
2563
+ flagForceColor2 = noFlagForceColor;
2564
+ }
2565
+ const forceColor = sniffFlags ? flagForceColor2 : noFlagForceColor;
2566
+ if (forceColor === 0) {
2567
+ return 0;
2568
+ }
2569
+ if (sniffFlags) {
2570
+ if (hasFlag2("color=16m") || hasFlag2("color=full") || hasFlag2("color=truecolor")) {
2571
+ return 3;
2572
+ }
2573
+ if (hasFlag2("color=256")) {
2574
+ return 2;
2575
+ }
2576
+ }
2577
+ if ("TF_BUILD" in env2 && "AGENT_NAME" in env2) {
2578
+ return 1;
2579
+ }
2580
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
2581
+ return 0;
2582
+ }
2583
+ const min = forceColor || 0;
2584
+ if (env2.TERM === "dumb") {
2585
+ return min;
2586
+ }
2587
+ if (process3.platform === "win32") {
2588
+ const osRelease = os2.release().split(".");
2589
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
2590
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
2591
+ }
2592
+ return 1;
2593
+ }
2594
+ if ("CI" in env2) {
2595
+ if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => (key in env2))) {
2596
+ return 3;
2597
+ }
2598
+ if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env2)) || env2.CI_NAME === "codeship") {
2599
+ return 1;
2600
+ }
2601
+ return min;
2602
+ }
2603
+ if ("TEAMCITY_VERSION" in env2) {
2604
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
2605
+ }
2606
+ if (env2.COLORTERM === "truecolor") {
2607
+ return 3;
2608
+ }
2609
+ if (env2.TERM === "xterm-kitty") {
2610
+ return 3;
2611
+ }
2612
+ if (env2.TERM === "xterm-ghostty") {
2613
+ return 3;
2614
+ }
2615
+ if (env2.TERM === "wezterm") {
2616
+ return 3;
2617
+ }
2618
+ if ("TERM_PROGRAM" in env2) {
2619
+ const version = Number.parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
2620
+ switch (env2.TERM_PROGRAM) {
2621
+ case "iTerm.app": {
2622
+ return version >= 3 ? 3 : 2;
2623
+ }
2624
+ case "Apple_Terminal": {
2625
+ return 2;
2626
+ }
2627
+ }
2628
+ }
2629
+ if (/-256(color)?$/i.test(env2.TERM)) {
2630
+ return 2;
2631
+ }
2632
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
2633
+ return 1;
2634
+ }
2635
+ if ("COLORTERM" in env2) {
2636
+ return 1;
2637
+ }
2638
+ return min;
2639
+ }
2640
+ function createSupportsColor2(stream, options = {}) {
2641
+ const level = _supportsColor2(stream, {
2642
+ streamIsTTY: stream && stream.isTTY,
2643
+ ...options
2644
+ });
2645
+ return translateLevel2(level);
2646
+ }
2647
+ var env2, flagForceColor2, supportsColor2, supports_color_default2;
2648
+ var init_supports_color2 = __esm(() => {
2649
+ ({ env: env2 } = process3);
2650
+ if (hasFlag2("no-color") || hasFlag2("no-colors") || hasFlag2("color=false") || hasFlag2("color=never")) {
2651
+ flagForceColor2 = 0;
2652
+ } else if (hasFlag2("color") || hasFlag2("colors") || hasFlag2("color=true") || hasFlag2("color=always")) {
2653
+ flagForceColor2 = 1;
2654
+ }
2655
+ supportsColor2 = {
2656
+ stdout: createSupportsColor2({ isTTY: tty2.isatty(1) }),
2657
+ stderr: createSupportsColor2({ isTTY: tty2.isatty(2) })
2658
+ };
2659
+ supports_color_default2 = supportsColor2;
2660
+ });
2661
+
2515
2662
  // ../../node_modules/.bun/cmd-ts@0.14.3/node_modules/cmd-ts/node_modules/debug/src/node.js
2516
2663
  var require_node = __commonJS((exports, module) => {
2517
- var tty2 = __require("tty");
2664
+ var tty3 = __require("tty");
2518
2665
  var util = __require("util");
2519
2666
  exports.init = init;
2520
2667
  exports.log = log;
@@ -2525,8 +2672,8 @@ var require_node = __commonJS((exports, module) => {
2525
2672
  exports.destroy = util.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
2526
2673
  exports.colors = [6, 2, 3, 4, 5, 1];
2527
2674
  try {
2528
- const supportsColor2 = (()=>{throw new Error("Cannot require module "+"supports-color");})();
2529
- if (supportsColor2 && (supportsColor2.stderr || supportsColor2).level >= 2) {
2675
+ const supportsColor3 = (init_supports_color2(), __toCommonJS(exports_supports_color));
2676
+ if (supportsColor3 && (supportsColor3.stderr || supportsColor3).level >= 2) {
2530
2677
  exports.colors = [
2531
2678
  20,
2532
2679
  21,
@@ -2627,7 +2774,7 @@ var require_node = __commonJS((exports, module) => {
2627
2774
  return obj;
2628
2775
  }, {});
2629
2776
  function useColors() {
2630
- return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty2.isatty(process.stderr.fd);
2777
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty3.isatty(process.stderr.fd);
2631
2778
  }
2632
2779
  function formatArgs(args) {
2633
2780
  const { namespace: name, useColors: useColors2 } = this;
@@ -3677,8 +3824,8 @@ var require_cjs = __commonJS((exports) => {
3677
3824
  var require_picocolors = __commonJS((exports, module) => {
3678
3825
  var p = process || {};
3679
3826
  var argv = p.argv || [];
3680
- var env2 = p.env || {};
3681
- var isColorSupported = !(!!env2.NO_COLOR || argv.includes("--no-color")) && (!!env2.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env2.TERM !== "dumb" || !!env2.CI);
3827
+ var env3 = p.env || {};
3828
+ var isColorSupported = !(!!env3.NO_COLOR || argv.includes("--no-color")) && (!!env3.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env3.TERM !== "dumb" || !!env3.CI);
3682
3829
  var formatter = (open, close, replace = open) => (input) => {
3683
3830
  let string = "" + input, index = string.indexOf(close, open.length);
3684
3831
  return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
@@ -8864,7 +9011,7 @@ var require_tslib = __commonJS((exports, module) => {
8864
9011
  throw new TypeError("Cannot use 'in' operator on non-object");
8865
9012
  return typeof state === "function" ? receiver === state : state.has(receiver);
8866
9013
  };
8867
- __addDisposableResource = function(env2, value, async) {
9014
+ __addDisposableResource = function(env3, value, async) {
8868
9015
  if (value !== null && value !== undefined) {
8869
9016
  if (typeof value !== "object" && typeof value !== "function")
8870
9017
  throw new TypeError("Object expected.");
@@ -8891,9 +9038,9 @@ var require_tslib = __commonJS((exports, module) => {
8891
9038
  return Promise.reject(e);
8892
9039
  }
8893
9040
  };
8894
- env2.stack.push({ value, dispose, async });
9041
+ env3.stack.push({ value, dispose, async });
8895
9042
  } else if (async) {
8896
- env2.stack.push({ async: true });
9043
+ env3.stack.push({ async: true });
8897
9044
  }
8898
9045
  return value;
8899
9046
  };
@@ -8901,17 +9048,17 @@ var require_tslib = __commonJS((exports, module) => {
8901
9048
  var e = new Error(message);
8902
9049
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
8903
9050
  };
8904
- __disposeResources = function(env2) {
9051
+ __disposeResources = function(env3) {
8905
9052
  function fail(e) {
8906
- env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
8907
- env2.hasError = true;
9053
+ env3.error = env3.hasError ? new _SuppressedError(e, env3.error, "An error was suppressed during disposal.") : e;
9054
+ env3.hasError = true;
8908
9055
  }
8909
9056
  var r, s = 0;
8910
9057
  function next() {
8911
- while (r = env2.stack.pop()) {
9058
+ while (r = env3.stack.pop()) {
8912
9059
  try {
8913
9060
  if (!r.async && s === 1)
8914
- return s = 0, env2.stack.push(r), Promise.resolve().then(next);
9061
+ return s = 0, env3.stack.push(r), Promise.resolve().then(next);
8915
9062
  if (r.dispose) {
8916
9063
  var result = r.dispose.call(r.value);
8917
9064
  if (r.async)
@@ -8926,9 +9073,9 @@ var require_tslib = __commonJS((exports, module) => {
8926
9073
  }
8927
9074
  }
8928
9075
  if (s === 1)
8929
- return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
8930
- if (env2.hasError)
8931
- throw env2.error;
9076
+ return env3.hasError ? Promise.reject(env3.error) : Promise.resolve();
9077
+ if (env3.hasError)
9078
+ throw env3.error;
8932
9079
  }
8933
9080
  return next();
8934
9081
  };
@@ -81771,8 +81918,8 @@ var require_alg = __commonJS((exports) => {
81771
81918
  exports.jwkAlgorithms = jwkAlgorithms;
81772
81919
  var errors_js_1 = require_errors3();
81773
81920
  var jwk_js_1 = require_jwk();
81774
- var { process: process3 } = globalThis;
81775
- var IS_NODE_RUNTIME = typeof process3 !== "undefined" && typeof process3?.versions?.node === "string";
81921
+ var { process: process4 } = globalThis;
81922
+ var IS_NODE_RUNTIME = typeof process4 !== "undefined" && typeof process4?.versions?.node === "string";
81776
81923
  function* jwkAlgorithms(jwk) {
81777
81924
  if (typeof jwk.alg === "string") {
81778
81925
  yield jwk.alg;
@@ -87186,9 +87333,9 @@ var require_environment_user_agent = __commonJS((exports, module) => {
87186
87333
  var require_environment_v8_version = __commonJS((exports, module) => {
87187
87334
  var globalThis2 = require_global_this();
87188
87335
  var userAgent = require_environment_user_agent();
87189
- var process3 = globalThis2.process;
87336
+ var process4 = globalThis2.process;
87190
87337
  var Deno = globalThis2.Deno;
87191
- var versions = process3 && process3.versions || Deno && Deno.version;
87338
+ var versions = process4 && process4.versions || Deno && Deno.version;
87192
87339
  var v8 = versions && versions.v8;
87193
87340
  var match2;
87194
87341
  var version;
@@ -90721,7 +90868,7 @@ var require_runtime3 = __commonJS((exports) => {
90721
90868
 
90722
90869
  // ../../node_modules/.bun/@atproto+oauth-client@0.5.14/node_modules/@atproto/oauth-client/dist/session-getter.js
90723
90870
  var require_session_getter = __commonJS((exports) => {
90724
- var __addDisposableResource = exports && exports.__addDisposableResource || function(env2, value, async) {
90871
+ var __addDisposableResource = exports && exports.__addDisposableResource || function(env3, value, async) {
90725
90872
  if (value !== null && value !== undefined) {
90726
90873
  if (typeof value !== "object" && typeof value !== "function")
90727
90874
  throw new TypeError("Object expected.");
@@ -90748,24 +90895,24 @@ var require_session_getter = __commonJS((exports) => {
90748
90895
  return Promise.reject(e);
90749
90896
  }
90750
90897
  };
90751
- env2.stack.push({ value, dispose, async });
90898
+ env3.stack.push({ value, dispose, async });
90752
90899
  } else if (async) {
90753
- env2.stack.push({ async: true });
90900
+ env3.stack.push({ async: true });
90754
90901
  }
90755
90902
  return value;
90756
90903
  };
90757
90904
  var __disposeResources = exports && exports.__disposeResources || function(SuppressedError2) {
90758
- return function(env2) {
90905
+ return function(env3) {
90759
90906
  function fail(e) {
90760
- env2.error = env2.hasError ? new SuppressedError2(e, env2.error, "An error was suppressed during disposal.") : e;
90761
- env2.hasError = true;
90907
+ env3.error = env3.hasError ? new SuppressedError2(e, env3.error, "An error was suppressed during disposal.") : e;
90908
+ env3.hasError = true;
90762
90909
  }
90763
90910
  var r, s = 0;
90764
90911
  function next() {
90765
- while (r = env2.stack.pop()) {
90912
+ while (r = env3.stack.pop()) {
90766
90913
  try {
90767
90914
  if (!r.async && s === 1)
90768
- return s = 0, env2.stack.push(r), Promise.resolve().then(next);
90915
+ return s = 0, env3.stack.push(r), Promise.resolve().then(next);
90769
90916
  if (r.dispose) {
90770
90917
  var result = r.dispose.call(r.value);
90771
90918
  if (r.async)
@@ -90780,9 +90927,9 @@ var require_session_getter = __commonJS((exports) => {
90780
90927
  }
90781
90928
  }
90782
90929
  if (s === 1)
90783
- return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
90784
- if (env2.hasError)
90785
- throw env2.error;
90930
+ return env3.hasError ? Promise.reject(env3.error) : Promise.resolve();
90931
+ if (env3.hasError)
90932
+ throw env3.error;
90786
90933
  }
90787
90934
  return next();
90788
90935
  };
@@ -91504,14 +91651,14 @@ var init_is_inside_container = __esm(() => {
91504
91651
  });
91505
91652
 
91506
91653
  // ../../node_modules/.bun/is-wsl@3.1.0/node_modules/is-wsl/index.js
91507
- import process3 from "node:process";
91508
- import os4 from "node:os";
91654
+ import process4 from "node:process";
91655
+ import os5 from "node:os";
91509
91656
  import fs11 from "node:fs";
91510
91657
  var isWsl = () => {
91511
- if (process3.platform !== "linux") {
91658
+ if (process4.platform !== "linux") {
91512
91659
  return false;
91513
91660
  }
91514
- if (os4.release().toLowerCase().includes("microsoft")) {
91661
+ if (os5.release().toLowerCase().includes("microsoft")) {
91515
91662
  if (isInsideContainer()) {
91516
91663
  return false;
91517
91664
  }
@@ -91525,15 +91672,15 @@ var isWsl = () => {
91525
91672
  }, is_wsl_default;
91526
91673
  var init_is_wsl = __esm(() => {
91527
91674
  init_is_inside_container();
91528
- is_wsl_default = process3.env.__IS_WSL_TEST__ ? isWsl : isWsl();
91675
+ is_wsl_default = process4.env.__IS_WSL_TEST__ ? isWsl : isWsl();
91529
91676
  });
91530
91677
 
91531
91678
  // ../../node_modules/.bun/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
91532
- import process4 from "node:process";
91679
+ import process5 from "node:process";
91533
91680
  import { Buffer as Buffer2 } from "node:buffer";
91534
91681
  import { promisify } from "node:util";
91535
91682
  import childProcess from "node:child_process";
91536
- var execFile, powerShellPath = () => `${process4.env.SYSTEMROOT || process4.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command5, options = {}) => {
91683
+ var execFile, powerShellPath = () => `${process5.env.SYSTEMROOT || process5.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command5, options = {}) => {
91537
91684
  const {
91538
91685
  powerShellPath: psPath,
91539
91686
  ...execFileOptions
@@ -91663,10 +91810,10 @@ function defineLazyProperty(object, propertyName, valueGetter) {
91663
91810
 
91664
91811
  // ../../node_modules/.bun/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
91665
91812
  import { promisify as promisify3 } from "node:util";
91666
- import process5 from "node:process";
91813
+ import process6 from "node:process";
91667
91814
  import { execFile as execFile3 } from "node:child_process";
91668
91815
  async function defaultBrowserId() {
91669
- if (process5.platform !== "darwin") {
91816
+ if (process6.platform !== "darwin") {
91670
91817
  throw new Error("macOS only");
91671
91818
  }
91672
91819
  const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
@@ -91683,11 +91830,11 @@ var init_default_browser_id = __esm(() => {
91683
91830
  });
91684
91831
 
91685
91832
  // ../../node_modules/.bun/run-applescript@7.1.0/node_modules/run-applescript/index.js
91686
- import process6 from "node:process";
91833
+ import process7 from "node:process";
91687
91834
  import { promisify as promisify4 } from "node:util";
91688
91835
  import { execFile as execFile4, execFileSync } from "node:child_process";
91689
91836
  async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
91690
- if (process6.platform !== "darwin") {
91837
+ if (process7.platform !== "darwin") {
91691
91838
  throw new Error("macOS only");
91692
91839
  }
91693
91840
  const outputArguments = humanReadableOutput ? [] : ["-ss"];
@@ -91761,21 +91908,21 @@ var init_windows = __esm(() => {
91761
91908
 
91762
91909
  // ../../node_modules/.bun/default-browser@5.4.0/node_modules/default-browser/index.js
91763
91910
  import { promisify as promisify6 } from "node:util";
91764
- import process7 from "node:process";
91911
+ import process8 from "node:process";
91765
91912
  import { execFile as execFile6 } from "node:child_process";
91766
91913
  async function defaultBrowser2() {
91767
- if (process7.platform === "darwin") {
91914
+ if (process8.platform === "darwin") {
91768
91915
  const id = await defaultBrowserId();
91769
91916
  const name = await bundleName(id);
91770
91917
  return { name, id };
91771
91918
  }
91772
- if (process7.platform === "linux") {
91919
+ if (process8.platform === "linux") {
91773
91920
  const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
91774
91921
  const id = stdout.trim();
91775
91922
  const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
91776
91923
  return { name, id };
91777
91924
  }
91778
- if (process7.platform === "win32") {
91925
+ if (process8.platform === "win32") {
91779
91926
  return defaultBrowser();
91780
91927
  }
91781
91928
  throw new Error("Only macOS, Linux, and Windows are supported");
@@ -91790,10 +91937,10 @@ var init_default_browser = __esm(() => {
91790
91937
  });
91791
91938
 
91792
91939
  // ../../node_modules/.bun/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
91793
- import process8 from "node:process";
91940
+ import process9 from "node:process";
91794
91941
  var isInSsh, is_in_ssh_default;
91795
91942
  var init_is_in_ssh = __esm(() => {
91796
- isInSsh = Boolean(process8.env.SSH_CONNECTION || process8.env.SSH_CLIENT || process8.env.SSH_TTY);
91943
+ isInSsh = Boolean(process9.env.SSH_CONNECTION || process9.env.SSH_CLIENT || process9.env.SSH_TTY);
91797
91944
  is_in_ssh_default = isInSsh;
91798
91945
  });
91799
91946
 
@@ -91804,7 +91951,7 @@ __export(exports_open, {
91804
91951
  default: () => open_default,
91805
91952
  apps: () => apps
91806
91953
  });
91807
- import process9 from "node:process";
91954
+ import process10 from "node:process";
91808
91955
  import path10 from "node:path";
91809
91956
  import { fileURLToPath as fileURLToPath4 } from "node:url";
91810
91957
  import childProcess3 from "node:child_process";
@@ -91975,7 +92122,7 @@ var fallbackAttemptSymbol, __dirname3, localXdgOpenPath, platform, arch, tryEach
91975
92122
  await fs13.access(localXdgOpenPath, fsConstants2.X_OK);
91976
92123
  exeLocalXdgOpen = true;
91977
92124
  } catch {}
91978
- const useSystemXdgOpen = process9.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
92125
+ const useSystemXdgOpen = process10.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
91979
92126
  command5 = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
91980
92127
  }
91981
92128
  if (appArguments.length > 0) {
@@ -92062,7 +92209,7 @@ var init_open = __esm(() => {
92062
92209
  fallbackAttemptSymbol = Symbol("fallbackAttempt");
92063
92210
  __dirname3 = import.meta.url ? path10.dirname(fileURLToPath4(import.meta.url)) : "";
92064
92211
  localXdgOpenPath = path10.join(__dirname3, "xdg-open");
92065
- ({ platform, arch } = process9);
92212
+ ({ platform, arch } = process10);
92066
92213
  apps = {
92067
92214
  browser: "browser",
92068
92215
  browserPrivate: "browserPrivate"
@@ -93295,6 +93442,7 @@ async function loadConfig(configPath) {
93295
93442
  }
93296
93443
  function generateConfigTemplate(options) {
93297
93444
  const config = {
93445
+ $schema: "https://tangled.org/stevedylan.dev/sequoia/raw/main/sequoia.schema.json",
93298
93446
  siteUrl: options.siteUrl,
93299
93447
  contentDir: options.contentDir
93300
93448
  };
@@ -93332,6 +93480,9 @@ function generateConfigTemplate(options) {
93332
93480
  if (options.textContentField) {
93333
93481
  config.textContentField = options.textContentField;
93334
93482
  }
93483
+ if (options.publishContent) {
93484
+ config.publishContent = options.publishContent;
93485
+ }
93335
93486
  if (options.bluesky) {
93336
93487
  config.bluesky = options.bluesky;
93337
93488
  }
@@ -97935,7 +98086,7 @@ class PathScurryBase {
97935
98086
  const dirs = new Set;
97936
98087
  const queue = [entry];
97937
98088
  let processing = 0;
97938
- const process3 = () => {
98089
+ const process4 = () => {
97939
98090
  let paused = false;
97940
98091
  while (!paused) {
97941
98092
  const dir = queue.shift();
@@ -97976,9 +98127,9 @@ class PathScurryBase {
97976
98127
  }
97977
98128
  }
97978
98129
  if (paused && !results.flowing) {
97979
- results.once("drain", process3);
98130
+ results.once("drain", process4);
97980
98131
  } else if (!sync) {
97981
- process3();
98132
+ process4();
97982
98133
  }
97983
98134
  };
97984
98135
  let sync = true;
@@ -97986,7 +98137,7 @@ class PathScurryBase {
97986
98137
  sync = false;
97987
98138
  }
97988
98139
  };
97989
- process3();
98140
+ process4();
97990
98141
  return results;
97991
98142
  }
97992
98143
  streamSync(entry = this.cwd, opts = {}) {
@@ -98004,7 +98155,7 @@ class PathScurryBase {
98004
98155
  }
98005
98156
  const queue = [entry];
98006
98157
  let processing = 0;
98007
- const process3 = () => {
98158
+ const process4 = () => {
98008
98159
  let paused = false;
98009
98160
  while (!paused) {
98010
98161
  const dir = queue.shift();
@@ -98038,9 +98189,9 @@ class PathScurryBase {
98038
98189
  }
98039
98190
  }
98040
98191
  if (paused && !results.flowing)
98041
- results.once("drain", process3);
98192
+ results.once("drain", process4);
98042
98193
  };
98043
- process3();
98194
+ process4();
98044
98195
  return results;
98045
98196
  }
98046
98197
  chdir(path4 = this.cwd) {
@@ -102745,6 +102896,20 @@ function parseFrontmatter(content, mapping) {
102745
102896
  }
102746
102897
  }
102747
102898
  }
102899
+ const updatedAtField = mapping?.updatedAt;
102900
+ if (updatedAtField && raw[updatedAtField]) {
102901
+ frontmatter.updatedAt = raw[updatedAtField];
102902
+ } else if (raw.updatedAt) {
102903
+ frontmatter.updatedAt = raw.updatedAt;
102904
+ } else {
102905
+ const updatedAtFields = ["updated_at", "modifiedAt", "modified_at"];
102906
+ for (const field of updatedAtFields) {
102907
+ if (raw[field]) {
102908
+ frontmatter.updatedAt = raw[field];
102909
+ break;
102910
+ }
102911
+ }
102912
+ }
102748
102913
  const coverField = mapping?.coverImage || "ogImage";
102749
102914
  frontmatter.ogImage = raw[coverField] || raw.ogImage;
102750
102915
  const tagsField = mapping?.tags || "tags";
@@ -102916,9 +103081,9 @@ var import_oauth_client_node = __toESM(require_dist24(), 1);
102916
103081
 
102917
103082
  // src/lib/oauth-store.ts
102918
103083
  import * as fs4 from "node:fs/promises";
102919
- import * as os2 from "node:os";
103084
+ import * as os3 from "node:os";
102920
103085
  import * as path5 from "node:path";
102921
- var CONFIG_DIR = path5.join(os2.homedir(), ".config", "sequoia");
103086
+ var CONFIG_DIR = path5.join(os3.homedir(), ".config", "sequoia");
102922
103087
  var OAUTH_FILE = path5.join(CONFIG_DIR, "oauth.json");
102923
103088
  async function fileExists2(filePath) {
102924
103089
  try {
@@ -103087,7 +103252,7 @@ function isDocumentRecord(value) {
103087
103252
  if (!value || typeof value !== "object")
103088
103253
  return false;
103089
103254
  const v = value;
103090
- return v.$type === "site.standard.document" && typeof v.title === "string" && typeof v.site === "string" && typeof v.path === "string" && typeof v.textContent === "string" && typeof v.publishedAt === "string";
103255
+ return v.$type === "site.standard.document" && typeof v.title === "string" && typeof v.site === "string" && typeof v.path === "string" && typeof v.textContent === "string" && typeof v.publishedAt === "string" && (v.updatedAt === undefined || typeof v.updatedAt === "string");
103091
103256
  }
103092
103257
  async function fileExists3(filePath) {
103093
103258
  try {
@@ -103219,10 +103384,14 @@ async function resolveImagePath(ogImage, imagesDir, contentDir) {
103219
103384
  async function createDocument(agent, post, config, coverImage) {
103220
103385
  const postPath = resolvePostPath(post, config.pathPrefix, config.pathTemplate);
103221
103386
  const publishDate = new Date(post.frontmatter.publishDate);
103222
- let textContent;
103223
- if (config.textContentField && post.rawFrontmatter?.[config.textContentField]) {
103387
+ let updatedAt;
103388
+ if (post.frontmatter.updatedAt) {
103389
+ updatedAt = new Date(post.frontmatter.updatedAt);
103390
+ }
103391
+ let textContent = null;
103392
+ if (config.publishContent && config.textContentField && post.rawFrontmatter?.[config.textContentField]) {
103224
103393
  textContent = String(post.rawFrontmatter[config.textContentField]);
103225
- } else {
103394
+ } else if (config.publishContent) {
103226
103395
  textContent = stripMarkdownForText(post.content);
103227
103396
  }
103228
103397
  const record = {
@@ -103230,10 +103399,13 @@ async function createDocument(agent, post, config, coverImage) {
103230
103399
  title: post.frontmatter.title,
103231
103400
  site: config.publicationUri,
103232
103401
  path: postPath,
103233
- textContent: textContent.slice(0, 1e4),
103402
+ textContent: textContent?.slice(0, 1e4),
103234
103403
  publishedAt: publishDate.toISOString(),
103235
103404
  canonicalUrl: `${config.siteUrl}${postPath}`
103236
103405
  };
103406
+ if (updatedAt) {
103407
+ record.updatedAt = updatedAt.toISOString();
103408
+ }
103237
103409
  if (post.frontmatter.description) {
103238
103410
  record.description = post.frontmatter.description;
103239
103411
  }
@@ -103258,10 +103430,11 @@ async function updateDocument(agent, post, atUri, config, coverImage) {
103258
103430
  const [, , collection, rkey] = uriMatch;
103259
103431
  const postPath = resolvePostPath(post, config.pathPrefix, config.pathTemplate);
103260
103432
  const publishDate = new Date(post.frontmatter.publishDate);
103261
- let textContent;
103262
- if (config.textContentField && post.rawFrontmatter?.[config.textContentField]) {
103433
+ const updatedAt = post.frontmatter.updatedAt ? new Date(post.frontmatter.updatedAt) : undefined;
103434
+ let textContent = null;
103435
+ if (config.publishContent && config.textContentField && post.rawFrontmatter?.[config.textContentField]) {
103263
103436
  textContent = String(post.rawFrontmatter[config.textContentField]);
103264
- } else {
103437
+ } else if (config.publishContent) {
103265
103438
  textContent = stripMarkdownForText(post.content);
103266
103439
  }
103267
103440
  const existingResponse = await agent.com.atproto.repo.getRecord({
@@ -103276,10 +103449,13 @@ async function updateDocument(agent, post, atUri, config, coverImage) {
103276
103449
  title: post.frontmatter.title,
103277
103450
  site: config.publicationUri,
103278
103451
  path: postPath,
103279
- textContent: textContent.slice(0, 1e4),
103452
+ textContent: textContent?.slice(0, 1e4),
103280
103453
  publishedAt: publishDate.toISOString(),
103281
103454
  canonicalUrl: `${config.siteUrl}${postPath}`
103282
103455
  };
103456
+ if (updatedAt) {
103457
+ record.updatedAt = updatedAt.toISOString();
103458
+ }
103283
103459
  if (post.frontmatter.description) {
103284
103460
  record.description = post.frontmatter.description;
103285
103461
  }
@@ -103531,9 +103707,9 @@ async function addBskyPostRefToDocument(agent, documentAtUri, bskyPostRef) {
103531
103707
 
103532
103708
  // src/lib/credentials.ts
103533
103709
  import * as fs6 from "node:fs/promises";
103534
- import * as os3 from "node:os";
103710
+ import * as os4 from "node:os";
103535
103711
  import * as path7 from "node:path";
103536
- var CONFIG_DIR2 = path7.join(os3.homedir(), ".config", "sequoia");
103712
+ var CONFIG_DIR2 = path7.join(os4.homedir(), ".config", "sequoia");
103537
103713
  var CREDENTIALS_FILE = path7.join(CONFIG_DIR2, "credentials.json");
103538
103714
  async function fileExists4(filePath) {
103539
103715
  try {
@@ -103943,6 +104119,10 @@ var initCommand = import_cmd_ts3.command({
103943
104119
  pathPrefix: () => Qt({
103944
104120
  message: "URL path prefix for posts:",
103945
104121
  placeholder: "/posts, /blog, /articles, etc."
104122
+ }),
104123
+ publishContent: () => Mt2({
104124
+ message: "Publish the post content on the standard.site document?",
104125
+ initialValue: true
103946
104126
  })
103947
104127
  }, { onCancel });
103948
104128
  R2.info("Configure your frontmatter field mappings (press Enter to use defaults):");
@@ -104126,7 +104306,8 @@ var initCommand = import_cmd_ts3.command({
104126
104306
  publicationUri,
104127
104307
  pdsUrl,
104128
104308
  frontmatter: frontmatterMapping,
104129
- bluesky: blueskyConfig
104309
+ bluesky: blueskyConfig,
104310
+ publishContent: siteConfig.publishContent
104130
104311
  });
104131
104312
  const configPath = path8.join(process.cwd(), "sequoia.json");
104132
104313
  await fs7.writeFile(configPath, configContent);
@@ -105074,6 +105255,7 @@ async function updateConfigFlow(config, configPath) {
105074
105255
  stripDatePrefix: configUpdated.stripDatePrefix,
105075
105256
  pathTemplate: configUpdated.pathTemplate,
105076
105257
  textContentField: configUpdated.textContentField,
105258
+ publishContent: configUpdated.publishContent,
105077
105259
  bluesky: configUpdated.bluesky
105078
105260
  });
105079
105261
  await fs16.writeFile(configPath, configContent);
@@ -105210,6 +105392,10 @@ async function editAdvanced(config) {
105210
105392
  message: "Strip YYYY-MM-DD- prefix from filenames (Jekyll-style)?",
105211
105393
  initialValue: config.stripDatePrefix || false
105212
105394
  }));
105395
+ const publishContent = exitOnCancel(await Mt2({
105396
+ message: "Publish the post content on the standard.site document?",
105397
+ initialValue: config.publishContent ?? true
105398
+ }));
105213
105399
  const textContentField = exitOnCancel(await Qt({
105214
105400
  message: "Frontmatter field for textContent (leave empty to use markdown body):",
105215
105401
  initialValue: config.textContentField || ""
@@ -105222,7 +105408,8 @@ async function editAdvanced(config) {
105222
105408
  ignore: ignore && ignore.length > 0 ? ignore : undefined,
105223
105409
  removeIndexFromSlug: removeIndexFromSlug || undefined,
105224
105410
  stripDatePrefix: stripDatePrefix || undefined,
105225
- textContentField: textContentField || undefined
105411
+ textContentField: textContentField || undefined,
105412
+ publishContent: publishContent ?? true
105226
105413
  };
105227
105414
  }
105228
105415
  async function editBluesky(config) {
@@ -105418,7 +105605,7 @@ Publish evergreen content to the ATmosphere
105418
105605
 
105419
105606
  > https://tangled.org/stevedylan.dev/sequoia
105420
105607
  `,
105421
- version: "0.5.0",
105608
+ version: "0.5.1",
105422
105609
  cmds: {
105423
105610
  add: addCommand,
105424
105611
  auth: authCommand,
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "sequoia-cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "sequoia": "dist/index.js"
7
7
  },
8
8
  "files": [
9
9
  "dist",
10
- "README.md"
10
+ "README.md",
11
+ "sequoia.schema.json"
11
12
  ],
12
13
  "main": "./dist/index.js",
13
14
  "exports": {