tailwind-hyperclay 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/index.js +17 -13
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -80,16 +80,12 @@ export function extractCandidates(html) {
80
80
  return Array.from(candidates);
81
81
  }
82
82
 
83
- function parseTailwindUrl(urlString) {
84
- try {
85
- const url = new URL(urlString);
86
- if (url.host === 'hyperclay.com' &&
87
- url.pathname.startsWith('/tailwindcss/') &&
88
- url.pathname.endsWith('.css')) {
89
- return url.pathname.slice(13, -4); // extract app name between /tailwindcss/ and .css
90
- }
91
- } catch {}
92
- return null;
83
+ function getTailwindName(urlString) {
84
+ // Match relative path: /tailwindcss/name.css
85
+ // Or full URL: https://hyperclay.com/tailwindcss/name.css
86
+ // With optional query params (?v=123) or fragments (#section)
87
+ const match = urlString.match(/^(?:https:\/\/hyperclay\.com)?\/tailwindcss\/([^?#]+)\.css(?:[?#].*)?$/);
88
+ return match ? match[1] : null;
93
89
  }
94
90
 
95
91
  function extractHrefs(html) {
@@ -102,19 +98,27 @@ function extractHrefs(html) {
102
98
  return hrefs;
103
99
  }
104
100
 
101
+ export function getTailwindCssName(html) {
102
+ for (const href of extractHrefs(html)) {
103
+ const name = getTailwindName(href);
104
+ if (name) return name;
105
+ }
106
+ return null;
107
+ }
108
+
105
109
  export function hasTailwindLink(html, appName) {
106
- return extractHrefs(html).some(url => parseTailwindUrl(url) === appName);
110
+ return extractHrefs(html).some(url => getTailwindName(url) === appName);
107
111
  }
108
112
 
109
113
  export function hasAnyTailwindLink(html) {
110
- return extractHrefs(html).some(url => parseTailwindUrl(url) !== null);
114
+ return extractHrefs(html).some(url => getTailwindName(url) !== null);
111
115
  }
112
116
 
113
117
  export function replaceTailwindLink(html, newName) {
114
118
  return html.replace(
115
119
  /(href\s*=\s*["'])([^"']+)(["'])/gi,
116
120
  (match, prefix, url, suffix) => {
117
- if (parseTailwindUrl(url) !== null) {
121
+ if (getTailwindName(url) !== null) {
118
122
  return `${prefix}https://hyperclay.com/tailwindcss/${newName}.css${suffix}`;
119
123
  }
120
124
  return match;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-hyperclay",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "On-save Tailwind CSS generator for Hyperclay",
5
5
  "type": "module",
6
6
  "main": "index.js",