tailwind-hyperclay 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. package/PLAN.md +86 -0
  2. package/index.js +11 -0
  3. package/package.json +6 -2
package/PLAN.md ADDED
@@ -0,0 +1,86 @@
1
+ # Plan: Integrate tailwind-hyperclay into ./hyperclay
2
+
3
+ ## Overview
4
+ When a user saves an HTML file that references `https://hyperclay.com/tailwindcss/{siteName}.css`, automatically generate the CSS file using Tailwind v4.
5
+
6
+ ## Steps
7
+
8
+ ### 1. Install dependency
9
+ ```bash
10
+ cd ./hyperclay
11
+ npm install tailwind-hyperclay
12
+ ```
13
+
14
+ ### 2. Add static route for generated CSS
15
+ In `hey.js`, add static serving for tailwind CSS files:
16
+ ```js
17
+ '/tailwindcss' → public-assets/tailwindcss
18
+ ```
19
+
20
+ ### 3. Create the directory
21
+ ```bash
22
+ mkdir -p ./hyperclay/public-assets/tailwindcss
23
+ ```
24
+
25
+ ### 4. Hook into saveHTML
26
+ In `server-lib/state-actions.js`, after HTML is saved (~line 703):
27
+
28
+ ```js
29
+ import { compileTailwind, hasTailwindLink } from 'tailwind-hyperclay';
30
+
31
+ // After successful save...
32
+ if (hasTailwindLink(formattedHtml, node.name)) {
33
+ const css = await compileTailwind(formattedHtml);
34
+ await dx('public-assets/tailwindcss').createFileOverwrite(`${node.name}.css`, css);
35
+ }
36
+ ```
37
+
38
+ ### 5. Hook into uploadSyncFile
39
+ In `server-lib/sync-actions.js`, after file is written (~line 311):
40
+
41
+ ```js
42
+ import { compileTailwind, hasTailwindLink } from 'tailwind-hyperclay';
43
+
44
+ // After file write...
45
+ if (hasTailwindLink(content, siteName)) {
46
+ const css = await compileTailwind(content);
47
+ await dx('public-assets/tailwindcss').createFileOverwrite(`${siteName}.css`, css);
48
+ }
49
+ ```
50
+
51
+ ### 6. Hook into restoreBackup
52
+ In `server-lib/state-actions.js`, after backup is restored (~line 909):
53
+
54
+ ```js
55
+ // After restore...
56
+ if (hasTailwindLink(html, siteName)) {
57
+ const css = await compileTailwind(html);
58
+ await dx('public-assets/tailwindcss').createFileOverwrite(`${siteName}.css`, css);
59
+ }
60
+ ```
61
+
62
+ ### 7. Hook into copySite
63
+ In `server-lib/state-actions.js`, modify the copy logic (~line 399):
64
+
65
+ ```js
66
+ import { compileTailwind, hasAnyTailwindLink, replaceTailwindLink } from 'tailwind-hyperclay';
67
+
68
+ // Before writing the file, update the tailwind link to use new name
69
+ let contentToWrite = siteContent;
70
+ if (hasAnyTailwindLink(siteContent)) {
71
+ contentToWrite = replaceTailwindLink(siteContent, newSiteName);
72
+ const css = await compileTailwind(contentToWrite);
73
+ await dx('public-assets/tailwindcss').createFileOverwrite(`${newSiteName}.css`, css);
74
+ }
75
+
76
+ await dx('sites').createFileOverwrite(`${newSiteName}.html`, contentToWrite);
77
+ ```
78
+
79
+ ## Files to modify
80
+ 1. `hyperclay/package.json` - add dependency
81
+ 2. `hyperclay/hey.js` - add static route (~line 185)
82
+ 3. `hyperclay/server-lib/state-actions.js` - hooks at:
83
+ - `saveHTML` (~line 703)
84
+ - `copySite` (~line 399)
85
+ - `restoreBackup` (~line 909)
86
+ 4. `hyperclay/server-lib/sync-actions.js` - add post-sync hook (~line 311)
package/index.js CHANGED
@@ -84,3 +84,14 @@ export function hasTailwindLink(html, appName) {
84
84
  const pattern = new RegExp(`https://hyperclay\\.com/tailwindcss/${appName}\\.css`);
85
85
  return pattern.test(html);
86
86
  }
87
+
88
+ export function hasAnyTailwindLink(html) {
89
+ return /https:\/\/hyperclay\.com\/tailwindcss\/[^"']+\.css/.test(html);
90
+ }
91
+
92
+ export function replaceTailwindLink(html, newName) {
93
+ return html.replace(
94
+ /https:\/\/hyperclay\.com\/tailwindcss\/[^"']+\.css/g,
95
+ `https://hyperclay.com/tailwindcss/${newName}.css`
96
+ );
97
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-hyperclay",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "On-save Tailwind CSS generator for Hyperclay",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -11,7 +11,11 @@
11
11
  "test": "node test/test.js",
12
12
  "release": "./scripts/release.sh"
13
13
  },
14
- "keywords": ["tailwind", "hyperclay", "css"],
14
+ "keywords": [
15
+ "tailwind",
16
+ "hyperclay",
17
+ "css"
18
+ ],
15
19
  "author": "",
16
20
  "license": "MIT",
17
21
  "dependencies": {