tailwind-hyperclay 0.1.14 → 0.1.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.16] - 2026-04-02
4
+
5
+ ### Changed
6
+ - `getTailwindName` now matches any domain instead of a hardcoded list, and `replaceTailwindLink` preserves the domain prefix in generated links
7
+
8
+
9
+
3
10
  ## [0.1.14] - 2026-01-31
4
11
 
5
12
  ### Changed
package/index.js CHANGED
@@ -129,12 +129,18 @@ function extractCandidates(html) {
129
129
 
130
130
  function getTailwindName(urlString) {
131
131
  // Match relative path: /tailwindcss/name.css
132
- // Or full URL: https://hyperclay.com/tailwindcss/name.css
132
+ // Or full URL with any domain: https://example.com/tailwindcss/name.css
133
133
  // With optional query params (?v=123) or fragments (#section)
134
- const match = urlString.match(/^(?:https:\/\/hyperclay\.com)?\/tailwindcss\/([^?#]+)\.css(?:[?#].*)?$/);
134
+ const match = urlString.match(/^(?:https?:\/\/[^/]+)?\/tailwindcss\/([^?#]+)\.css(?:[?#].*)?$/);
135
135
  return match ? match[1] : null;
136
136
  }
137
137
 
138
+ function getTailwindPrefix(urlString) {
139
+ // Extract the domain prefix (e.g. "https://hyperclay.com") or empty string for relative URLs
140
+ const match = urlString.match(/^(https?:\/\/[^/]+)?\/tailwindcss\//);
141
+ return match?.[1] || '';
142
+ }
143
+
138
144
  function extractHrefs(html) {
139
145
  const hrefs = [];
140
146
  const regex = /href\s*=\s*["']([^"']+)["']/gi;
@@ -153,20 +159,18 @@ function getTailwindCssName(html) {
153
159
  return null;
154
160
  }
155
161
 
156
- function hasTailwindLink(html, appName) {
157
- return extractHrefs(html).some(url => getTailwindName(url) === appName);
158
- }
159
-
160
162
  function hasAnyTailwindLink(html) {
161
163
  return extractHrefs(html).some(url => getTailwindName(url) !== null);
162
164
  }
163
165
 
164
- function replaceTailwindLink(html, newName) {
166
+ function replaceTailwindLink(html, newName, sitePath) {
167
+ const scopedName = sitePath ? `${sitePath}/${newName}` : newName;
165
168
  return html.replace(
166
169
  /(href\s*=\s*["'])([^"']+)(["'])/gi,
167
170
  (match, prefix, url, suffix) => {
168
171
  if (getTailwindName(url) !== null) {
169
- return `${prefix}https://hyperclay.com/tailwindcss/${newName}.css${suffix}`;
172
+ const domainPrefix = getTailwindPrefix(url);
173
+ return `${prefix}${domainPrefix}/tailwindcss/${scopedName}.css${suffix}`;
170
174
  }
171
175
  return match;
172
176
  }
@@ -178,7 +182,6 @@ module.exports = {
178
182
  compileTailwind,
179
183
  extractCandidates,
180
184
  getTailwindCssName,
181
- hasTailwindLink,
182
185
  hasAnyTailwindLink,
183
186
  replaceTailwindLink
184
187
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-hyperclay",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "On-save Tailwind CSS generator for Hyperclay",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test/test.js CHANGED
@@ -1,4 +1,4 @@
1
- const { compileTailwind, hasTailwindLink, hasAnyTailwindLink, replaceTailwindLink } = require('../index.js');
1
+ const { compileTailwind, hasAnyTailwindLink, replaceTailwindLink, getTailwindCssName } = require('../index.js');
2
2
 
3
3
  const testHTML = `
4
4
  <!DOCTYPE html>
@@ -42,11 +42,11 @@ function test(name, actual, expected) {
42
42
  }
43
43
 
44
44
  async function runTests() {
45
- console.log('Testing hasTailwindLink...');
46
- test('myApp found', hasTailwindLink(testHTML, 'myApp'), true);
47
- test('other not found', hasTailwindLink(testHTML, 'other'), false);
48
- test('myApp with query params', hasTailwindLink(testHTMLWithQueryParams, 'myApp'), true);
49
- test('myApp with fragment', hasTailwindLink(testHTMLWithFragment, 'myApp'), true);
45
+ console.log('Testing getTailwindCssName...');
46
+ test('myApp found', getTailwindCssName(testHTML), 'myApp');
47
+ test('myApp with query params', getTailwindCssName(testHTMLWithQueryParams), 'myApp');
48
+ test('myApp with fragment', getTailwindCssName(testHTMLWithFragment), 'myApp');
49
+ test('no link returns null', getTailwindCssName('<html></html>'), null);
50
50
 
51
51
  console.log('\nTesting hasAnyTailwindLink...');
52
52
  test('finds link', hasAnyTailwindLink(testHTML), true);