hyperclayjs 1.0.0
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/LICENSE +21 -0
- package/README.md +360 -0
- package/README.template.md +276 -0
- package/communication/behaviorCollector.js +230 -0
- package/communication/sendMessage.js +48 -0
- package/communication/uploadFile.js +348 -0
- package/core/adminContenteditable.js +36 -0
- package/core/adminInputs.js +58 -0
- package/core/adminOnClick.js +31 -0
- package/core/adminResources.js +33 -0
- package/core/adminSystem.js +15 -0
- package/core/editmode.js +8 -0
- package/core/editmodeSystem.js +18 -0
- package/core/enablePersistentFormInputValues.js +62 -0
- package/core/isAdminOfCurrentResource.js +13 -0
- package/core/optionVisibilityRuleGenerator.js +160 -0
- package/core/savePage.js +196 -0
- package/core/savePageCore.js +236 -0
- package/core/setPageTypeOnDocumentElement.js +23 -0
- package/custom-attributes/ajaxElements.js +94 -0
- package/custom-attributes/autosize.js +17 -0
- package/custom-attributes/domHelpers.js +175 -0
- package/custom-attributes/events.js +15 -0
- package/custom-attributes/inputHelpers.js +11 -0
- package/custom-attributes/onclickaway.js +27 -0
- package/custom-attributes/onclone.js +35 -0
- package/custom-attributes/onpagemutation.js +20 -0
- package/custom-attributes/onrender.js +30 -0
- package/custom-attributes/preventEnter.js +13 -0
- package/custom-attributes/sortable.js +76 -0
- package/dom-utilities/All.js +412 -0
- package/dom-utilities/getDataFromForm.js +60 -0
- package/dom-utilities/insertStyleTag.js +28 -0
- package/dom-utilities/onDomReady.js +7 -0
- package/dom-utilities/onLoad.js +7 -0
- package/hyperclay.js +465 -0
- package/module-dependency-graph.json +612 -0
- package/package.json +95 -0
- package/string-utilities/copy-to-clipboard.js +35 -0
- package/string-utilities/emmet-html.js +54 -0
- package/string-utilities/query.js +1 -0
- package/string-utilities/slugify.js +21 -0
- package/ui/info.js +39 -0
- package/ui/prompts.js +179 -0
- package/ui/theModal.js +677 -0
- package/ui/toast.js +273 -0
- package/utilities/cookie.js +45 -0
- package/utilities/debounce.js +12 -0
- package/utilities/mutation.js +403 -0
- package/utilities/nearest.js +97 -0
- package/utilities/pipe.js +1 -0
- package/utilities/throttle.js +21 -0
- package/vendor/Sortable.js +3351 -0
- package/vendor/idiomorph.min.js +8 -0
- package/vendor/tailwind-base.css +1471 -0
- package/vendor/tailwind-play.js +169 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Hyperclay
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
# HyperclayJS
|
|
2
|
+
|
|
3
|
+
A modular JavaScript library for building interactive HTML applications with Hyperclay. Load only what you need with automatic dependency resolution.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎯 **Modular Design** - Pick exactly the features you need
|
|
8
|
+
- 🚀 **Self-detecting Loader** - Automatic dependency resolution from URL params
|
|
9
|
+
- 📦 **Tree-shakeable** - Optimized for modern bundlers
|
|
10
|
+
- 🎨 **Rich Feature Set** - From basic save to advanced UI components
|
|
11
|
+
- 💪 **Zero Dependencies** - Core modules have no external dependencies
|
|
12
|
+
- 🔧 **Visual Configurator** - Interactive tool to build your custom bundle
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### Using CDN (Self-detecting Loader)
|
|
17
|
+
|
|
18
|
+
The self-detecting loader reads URL parameters and automatically loads the requested features with all dependencies:
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<!-- Minimal setup -->
|
|
22
|
+
<script src="https://hyperclay.com/js/hyperclay.js?preset=minimal" type="module"></script>
|
|
23
|
+
|
|
24
|
+
<!-- Standard setup -->
|
|
25
|
+
<script src="https://hyperclay.com/js/hyperclay.js?preset=standard" type="module"></script>
|
|
26
|
+
|
|
27
|
+
<!-- Custom features -->
|
|
28
|
+
<script src="https://hyperclay.com/js/hyperclay.js?features=save,admin,toast,ajax" type="module"></script>
|
|
29
|
+
|
|
30
|
+
<!-- Everything -->
|
|
31
|
+
<script src="https://hyperclay.com/js/hyperclay.js?preset=everything" type="module"></script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Using NPM
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install hyperclayjs
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
// Import specific modules
|
|
42
|
+
import { savePage } from 'hyperclayjs/core/savePage.js';
|
|
43
|
+
import toast from 'hyperclayjs/ui/toast.js';
|
|
44
|
+
|
|
45
|
+
// Or use presets
|
|
46
|
+
import 'hyperclayjs/presets/standard.js';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Available Modules
|
|
50
|
+
|
|
51
|
+
### Core Features (Essential functionality)
|
|
52
|
+
|
|
53
|
+
| Module | Size | Description |
|
|
54
|
+
|--------|------|-------------|
|
|
55
|
+
| Admin Features | 5.3KB | Hides admin inputs, scripts, contenteditable, onclick for regular viewers |
|
|
56
|
+
| Edit Mode | 1.4KB | Toggle edit mode on/off |
|
|
57
|
+
| Form Persistence | 2.2KB | Persist form values to the DOM with [persist] attribute |
|
|
58
|
+
| Option Visibility | 4.4KB | Dynamic show/hide based on page state with option:attribute="value" |
|
|
59
|
+
| Save Core | 5.9KB | Basic save function only - hyperclay.savePage() |
|
|
60
|
+
| Save System | 4.9KB | Full save: save button, keyboard shortcut, auto-save, change tracking |
|
|
61
|
+
|
|
62
|
+
### Custom Attributes (HTML enhancements)
|
|
63
|
+
|
|
64
|
+
| Module | Size | Description |
|
|
65
|
+
|--------|------|-------------|
|
|
66
|
+
| AJAX Elements | 2.7KB | [ajax-form], [ajax-button] for async form submissions |
|
|
67
|
+
| DOM Helpers | 5.4KB | el.nearest, el.val, el.text, el.exec, el.cycle |
|
|
68
|
+
| Event Attributes | 3.5KB | [onclickaway], [onclone], [onpagemutation], [onrender] |
|
|
69
|
+
| Input Helpers | 1.2KB | [prevent-enter], [autosize] for textareas |
|
|
70
|
+
| Sortable | 117.9KB | Drag-drop sorting with [sortable] - includes Sortable.js vendor library |
|
|
71
|
+
|
|
72
|
+
### UI Components (User interface elements)
|
|
73
|
+
|
|
74
|
+
| Module | Size | Description |
|
|
75
|
+
|--------|------|-------------|
|
|
76
|
+
| Dialog Functions | 7.7KB | ask(), consent(), tell(), snippet() functions |
|
|
77
|
+
| Info Dialog | 3.2KB | Info dialog component |
|
|
78
|
+
| Modal System | 18.4KB | Full modal window creation system - window.theModal |
|
|
79
|
+
| Tailwind Play | 362.3KB | Live Tailwind CSS editing - updates styles based on classes in your HTML |
|
|
80
|
+
| Toast Notifications | 7.3KB | Success/error message notifications - toast(msg, msgType) |
|
|
81
|
+
|
|
82
|
+
### Utilities (Core utilities (often auto-included))
|
|
83
|
+
|
|
84
|
+
| Module | Size | Description |
|
|
85
|
+
|--------|------|-------------|
|
|
86
|
+
| Cookie Helper | 1.3KB | Cookie management (often auto-included) |
|
|
87
|
+
| Debounce | 0.2KB | Function debouncing |
|
|
88
|
+
| Mutation Observer | 12.8KB | DOM mutation observation (often auto-included) |
|
|
89
|
+
| Nearest Element | 3.2KB | Find nearest elements (often auto-included) |
|
|
90
|
+
| Throttle | 0.6KB | Function throttling |
|
|
91
|
+
|
|
92
|
+
### DOM Utilities (DOM manipulation helpers)
|
|
93
|
+
|
|
94
|
+
| Module | Size | Description |
|
|
95
|
+
|--------|------|-------------|
|
|
96
|
+
| All.js (jQuery-like) | 13.8KB | Full DOM manipulation library |
|
|
97
|
+
| DOM Ready | 0.2KB | DOM ready callback |
|
|
98
|
+
| Style Injection | 0.8KB | Dynamic stylesheet injection |
|
|
99
|
+
| Window Load | 0.2KB | Window load callback |
|
|
100
|
+
|
|
101
|
+
### String Utilities (String manipulation helpers)
|
|
102
|
+
|
|
103
|
+
| Module | Size | Description |
|
|
104
|
+
|--------|------|-------------|
|
|
105
|
+
| Copy to Clipboard | 0.9KB | Clipboard utility |
|
|
106
|
+
| Emmet HTML | 1.4KB | Emmet-like HTML generation |
|
|
107
|
+
| Slugify | 0.7KB | URL-friendly slug generator |
|
|
108
|
+
| URL Query Parser | 0.1KB | Parse URL search params |
|
|
109
|
+
|
|
110
|
+
### Communication & Files (File handling and messaging)
|
|
111
|
+
|
|
112
|
+
| Module | Size | Description |
|
|
113
|
+
|--------|------|-------------|
|
|
114
|
+
| Behavior Collector | 5.2KB | Tracks user interactions (mouse, scroll, keyboard) |
|
|
115
|
+
| File Upload to App Owner | 10.4KB | File upload with progress |
|
|
116
|
+
| Send Message to App Owner | 1.2KB | Message sending utility |
|
|
117
|
+
|
|
118
|
+
### Vendor Libraries (Third-party libraries)
|
|
119
|
+
|
|
120
|
+
| Module | Size | Description |
|
|
121
|
+
|--------|------|-------------|
|
|
122
|
+
| DOM Morphing | 7.9KB | Efficient DOM updates |
|
|
123
|
+
|
|
124
|
+
## Presets
|
|
125
|
+
|
|
126
|
+
### Minimal (~23.4KB)
|
|
127
|
+
Essential features for basic editing
|
|
128
|
+
|
|
129
|
+
**Modules:** `save-core`, `save`, `admin`, `toast`
|
|
130
|
+
|
|
131
|
+
### Standard (~37.2KB)
|
|
132
|
+
Standard feature set for most use cases
|
|
133
|
+
|
|
134
|
+
**Modules:** `save-core`, `save`, `admin`, `persist`, `ajax`, `events`, `helpers`, `toast`
|
|
135
|
+
|
|
136
|
+
### Everything (~614.6KB)
|
|
137
|
+
All available features
|
|
138
|
+
|
|
139
|
+
Includes all available modules across all categories.
|
|
140
|
+
|
|
141
|
+
## Visual Configurator
|
|
142
|
+
|
|
143
|
+
Explore features and build your custom bundle with our interactive configurator:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npm run dev
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
This will:
|
|
150
|
+
1. Generate fresh dependency data
|
|
151
|
+
2. Start a local server on port 3535
|
|
152
|
+
3. Open the configurator in your browser
|
|
153
|
+
|
|
154
|
+
The configurator shows:
|
|
155
|
+
- Real-time bundle size calculation
|
|
156
|
+
- Automatic dependency resolution
|
|
157
|
+
- Generated CDN URL
|
|
158
|
+
- Feature descriptions and categories
|
|
159
|
+
|
|
160
|
+
## Development
|
|
161
|
+
|
|
162
|
+
### Project Structure
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
hyperclayjs/
|
|
166
|
+
├── hyperclay.js # Self-detecting module loader
|
|
167
|
+
├── core/ # Core hyperclay features
|
|
168
|
+
├── custom-attributes/ # HTML attribute enhancements
|
|
169
|
+
├── ui/ # UI components (toast, modals, prompts)
|
|
170
|
+
├── utilities/ # General utilities (mutation, cookie, etc.)
|
|
171
|
+
├── dom-utilities/ # DOM manipulation helpers
|
|
172
|
+
├── string-utilities/ # String manipulation tools
|
|
173
|
+
├── communication/ # File upload and messaging
|
|
174
|
+
├── vendor/ # Third-party libraries (Sortable.js, etc.)
|
|
175
|
+
├── scripts/ # Build and generation scripts
|
|
176
|
+
└── starter-kit-configurator.html # Interactive configurator
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Setup
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Install dependencies
|
|
183
|
+
npm install
|
|
184
|
+
|
|
185
|
+
# Generate dependency graph
|
|
186
|
+
npm run generate:deps
|
|
187
|
+
|
|
188
|
+
# Start development server with configurator
|
|
189
|
+
npm run dev
|
|
190
|
+
|
|
191
|
+
# Build bundles
|
|
192
|
+
npm run build
|
|
193
|
+
|
|
194
|
+
# Run tests
|
|
195
|
+
npm test
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Automatic Dependency Graph
|
|
199
|
+
|
|
200
|
+
The project uses Madge to automatically analyze dependencies and generate rich metadata:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
npm run generate:deps
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
This creates `module-dependency-graph.json` with:
|
|
207
|
+
- Complete dependency tree
|
|
208
|
+
- Actual file sizes
|
|
209
|
+
- Category assignments
|
|
210
|
+
- Preset configurations
|
|
211
|
+
|
|
212
|
+
The configurator dynamically loads this file to always show accurate information.
|
|
213
|
+
|
|
214
|
+
## Browser Support
|
|
215
|
+
|
|
216
|
+
- Chrome 90+
|
|
217
|
+
- Firefox 88+
|
|
218
|
+
- Safari 14+
|
|
219
|
+
- Edge 90+
|
|
220
|
+
|
|
221
|
+
All features use modern JavaScript (ES2020+). For older browser support, use a transpiler.
|
|
222
|
+
|
|
223
|
+
## API Examples
|
|
224
|
+
|
|
225
|
+
### Save System
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
// Manually save the page
|
|
229
|
+
hyperclay.savePage();
|
|
230
|
+
|
|
231
|
+
// Initialize auto-save
|
|
232
|
+
hyperclay.initSavePageOnChange();
|
|
233
|
+
|
|
234
|
+
// Add save button
|
|
235
|
+
hyperclay.initHyperclaySaveButton(); // Looks for [trigger-save]
|
|
236
|
+
|
|
237
|
+
// Keyboard shortcut
|
|
238
|
+
hyperclay.initSaveKeyboardShortcut(); // CMD/CTRL+S
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Toast Notifications
|
|
242
|
+
|
|
243
|
+
```javascript
|
|
244
|
+
toast("Operation successful!", "success");
|
|
245
|
+
toast("Something went wrong", "error");
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Dialog Prompts
|
|
249
|
+
|
|
250
|
+
```javascript
|
|
251
|
+
// Ask for input
|
|
252
|
+
const name = await ask("What's your name?");
|
|
253
|
+
|
|
254
|
+
// Get consent
|
|
255
|
+
const agreed = await consent("Do you agree to terms?");
|
|
256
|
+
|
|
257
|
+
// Show message
|
|
258
|
+
tell("Welcome to Hyperclay!");
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Custom Attributes
|
|
262
|
+
|
|
263
|
+
```html
|
|
264
|
+
<!-- AJAX form submission -->
|
|
265
|
+
<form ajax-form="/api/submit">
|
|
266
|
+
<input name="email" type="email">
|
|
267
|
+
<button>Submit</button>
|
|
268
|
+
</form>
|
|
269
|
+
|
|
270
|
+
<!-- Auto-resize textarea -->
|
|
271
|
+
<textarea autosize></textarea>
|
|
272
|
+
|
|
273
|
+
<!-- Drag-drop sorting -->
|
|
274
|
+
<ul sortable>
|
|
275
|
+
<li>Item 1</li>
|
|
276
|
+
<li>Item 2</li>
|
|
277
|
+
<li>Item 3</li>
|
|
278
|
+
</ul>
|
|
279
|
+
|
|
280
|
+
<!-- Run code when clicked away -->
|
|
281
|
+
<div onclickaway="console.log('Clicked outside')">
|
|
282
|
+
Click outside this div
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
<!-- Persist form values -->
|
|
286
|
+
<input type="text" name="username" persist>
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Admin Features
|
|
290
|
+
|
|
291
|
+
```html
|
|
292
|
+
<!-- Only visible/editable in edit mode -->
|
|
293
|
+
<div contenteditable edit-mode-contenteditable>Admin can edit this</div>
|
|
294
|
+
<input type="text" edit-mode-input>
|
|
295
|
+
<script edit-mode-resource>console.log('Admin only');</script>
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Module Creation
|
|
299
|
+
|
|
300
|
+
Each module should be a self-contained ES module:
|
|
301
|
+
|
|
302
|
+
```javascript
|
|
303
|
+
// features/my-feature.js
|
|
304
|
+
import dependency from '../utilities/dependency.js';
|
|
305
|
+
|
|
306
|
+
export default function myFeature() {
|
|
307
|
+
// Feature implementation
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Export initialization function
|
|
311
|
+
export function init() {
|
|
312
|
+
if (typeof window !== 'undefined') {
|
|
313
|
+
// Auto-initialize on import
|
|
314
|
+
myFeature();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Auto-run if needed
|
|
319
|
+
if (typeof window !== 'undefined') {
|
|
320
|
+
init();
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Migration from Monolithic Script
|
|
325
|
+
|
|
326
|
+
### Before
|
|
327
|
+
```html
|
|
328
|
+
<script src="/js/old-hyperclay.js"></script>
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### After
|
|
332
|
+
```html
|
|
333
|
+
<!-- Use preset -->
|
|
334
|
+
<script src="/js/hyperclay.js?preset=standard" type="module"></script>
|
|
335
|
+
|
|
336
|
+
<!-- Or specific features -->
|
|
337
|
+
<script src="/js/hyperclay.js?features=save,admin,toast" type="module"></script>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Contributing
|
|
341
|
+
|
|
342
|
+
1. Fork the repository
|
|
343
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
344
|
+
3. Make your changes
|
|
345
|
+
4. Run `npm run generate:deps` to update the dependency graph
|
|
346
|
+
5. Test your changes with `npm run dev`
|
|
347
|
+
6. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
348
|
+
7. Push to the branch (`git push origin feature/amazing-feature`)
|
|
349
|
+
8. Open a Pull Request
|
|
350
|
+
|
|
351
|
+
## License
|
|
352
|
+
|
|
353
|
+
MIT © Hyperclay
|
|
354
|
+
|
|
355
|
+
## Links
|
|
356
|
+
|
|
357
|
+
- [Documentation](https://hyperclay.com/docs)
|
|
358
|
+
- [Examples](https://hyperclay.com/examples)
|
|
359
|
+
- [Configurator](https://hyperclay.com/configurator)
|
|
360
|
+
- [GitHub Issues](https://github.com/hyperclay/hyperclayjs/issues)
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# HyperclayJS
|
|
2
|
+
|
|
3
|
+
A modular JavaScript library for building interactive HTML applications with Hyperclay. Load only what you need with automatic dependency resolution.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎯 **Modular Design** - Pick exactly the features you need
|
|
8
|
+
- 🚀 **Self-detecting Loader** - Automatic dependency resolution from URL params
|
|
9
|
+
- 📦 **Tree-shakeable** - Optimized for modern bundlers
|
|
10
|
+
- 🎨 **Rich Feature Set** - From basic save to advanced UI components
|
|
11
|
+
- 💪 **Zero Dependencies** - Core modules have no external dependencies
|
|
12
|
+
- 🔧 **Visual Configurator** - Interactive tool to build your custom bundle
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### Using CDN (Self-detecting Loader)
|
|
17
|
+
|
|
18
|
+
The self-detecting loader reads URL parameters and automatically loads the requested features with all dependencies:
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<!-- Minimal setup -->
|
|
22
|
+
<script src="https://hyperclay.com/js/hyperclay.js?preset=minimal" type="module"></script>
|
|
23
|
+
|
|
24
|
+
<!-- Standard setup -->
|
|
25
|
+
<script src="https://hyperclay.com/js/hyperclay.js?preset=standard" type="module"></script>
|
|
26
|
+
|
|
27
|
+
<!-- Custom features -->
|
|
28
|
+
<script src="https://hyperclay.com/js/hyperclay.js?features=save,admin,toast,ajax" type="module"></script>
|
|
29
|
+
|
|
30
|
+
<!-- Everything -->
|
|
31
|
+
<script src="https://hyperclay.com/js/hyperclay.js?preset=everything" type="module"></script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Using NPM
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install hyperclayjs
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
// Import specific modules
|
|
42
|
+
import { savePage } from 'hyperclayjs/core/savePage.js';
|
|
43
|
+
import toast from 'hyperclayjs/ui/toast.js';
|
|
44
|
+
|
|
45
|
+
// Or use presets
|
|
46
|
+
import 'hyperclayjs/presets/standard.js';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Available Modules
|
|
50
|
+
|
|
51
|
+
{{MODULE_TABLES}}
|
|
52
|
+
|
|
53
|
+
## Presets
|
|
54
|
+
|
|
55
|
+
{{PRESET_DESCRIPTIONS}}
|
|
56
|
+
|
|
57
|
+
## Visual Configurator
|
|
58
|
+
|
|
59
|
+
Explore features and build your custom bundle with our interactive configurator:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm run dev
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This will:
|
|
66
|
+
1. Generate fresh dependency data
|
|
67
|
+
2. Start a local server on port 3535
|
|
68
|
+
3. Open the configurator in your browser
|
|
69
|
+
|
|
70
|
+
The configurator shows:
|
|
71
|
+
- Real-time bundle size calculation
|
|
72
|
+
- Automatic dependency resolution
|
|
73
|
+
- Generated CDN URL
|
|
74
|
+
- Feature descriptions and categories
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
### Project Structure
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
hyperclayjs/
|
|
82
|
+
├── hyperclay.js # Self-detecting module loader
|
|
83
|
+
├── core/ # Core hyperclay features
|
|
84
|
+
├── custom-attributes/ # HTML attribute enhancements
|
|
85
|
+
├── ui/ # UI components (toast, modals, prompts)
|
|
86
|
+
├── utilities/ # General utilities (mutation, cookie, etc.)
|
|
87
|
+
├── dom-utilities/ # DOM manipulation helpers
|
|
88
|
+
├── string-utilities/ # String manipulation tools
|
|
89
|
+
├── communication/ # File upload and messaging
|
|
90
|
+
├── vendor/ # Third-party libraries (Sortable.js, etc.)
|
|
91
|
+
├── scripts/ # Build and generation scripts
|
|
92
|
+
└── starter-kit-configurator.html # Interactive configurator
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Setup
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Install dependencies
|
|
99
|
+
npm install
|
|
100
|
+
|
|
101
|
+
# Generate dependency graph
|
|
102
|
+
npm run generate:deps
|
|
103
|
+
|
|
104
|
+
# Start development server with configurator
|
|
105
|
+
npm run dev
|
|
106
|
+
|
|
107
|
+
# Build bundles
|
|
108
|
+
npm run build
|
|
109
|
+
|
|
110
|
+
# Run tests
|
|
111
|
+
npm test
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Automatic Dependency Graph
|
|
115
|
+
|
|
116
|
+
The project uses Madge to automatically analyze dependencies and generate rich metadata:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm run generate:deps
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
This creates `module-dependency-graph.json` with:
|
|
123
|
+
- Complete dependency tree
|
|
124
|
+
- Actual file sizes
|
|
125
|
+
- Category assignments
|
|
126
|
+
- Preset configurations
|
|
127
|
+
|
|
128
|
+
The configurator dynamically loads this file to always show accurate information.
|
|
129
|
+
|
|
130
|
+
## Browser Support
|
|
131
|
+
|
|
132
|
+
- Chrome 90+
|
|
133
|
+
- Firefox 88+
|
|
134
|
+
- Safari 14+
|
|
135
|
+
- Edge 90+
|
|
136
|
+
|
|
137
|
+
All features use modern JavaScript (ES2020+). For older browser support, use a transpiler.
|
|
138
|
+
|
|
139
|
+
## API Examples
|
|
140
|
+
|
|
141
|
+
### Save System
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
// Manually save the page
|
|
145
|
+
hyperclay.savePage();
|
|
146
|
+
|
|
147
|
+
// Initialize auto-save
|
|
148
|
+
hyperclay.initSavePageOnChange();
|
|
149
|
+
|
|
150
|
+
// Add save button
|
|
151
|
+
hyperclay.initHyperclaySaveButton(); // Looks for [trigger-save]
|
|
152
|
+
|
|
153
|
+
// Keyboard shortcut
|
|
154
|
+
hyperclay.initSaveKeyboardShortcut(); // CMD/CTRL+S
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Toast Notifications
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
toast("Operation successful!", "success");
|
|
161
|
+
toast("Something went wrong", "error");
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Dialog Prompts
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
// Ask for input
|
|
168
|
+
const name = await ask("What's your name?");
|
|
169
|
+
|
|
170
|
+
// Get consent
|
|
171
|
+
const agreed = await consent("Do you agree to terms?");
|
|
172
|
+
|
|
173
|
+
// Show message
|
|
174
|
+
tell("Welcome to Hyperclay!");
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Custom Attributes
|
|
178
|
+
|
|
179
|
+
```html
|
|
180
|
+
<!-- AJAX form submission -->
|
|
181
|
+
<form ajax-form="/api/submit">
|
|
182
|
+
<input name="email" type="email">
|
|
183
|
+
<button>Submit</button>
|
|
184
|
+
</form>
|
|
185
|
+
|
|
186
|
+
<!-- Auto-resize textarea -->
|
|
187
|
+
<textarea autosize></textarea>
|
|
188
|
+
|
|
189
|
+
<!-- Drag-drop sorting -->
|
|
190
|
+
<ul sortable>
|
|
191
|
+
<li>Item 1</li>
|
|
192
|
+
<li>Item 2</li>
|
|
193
|
+
<li>Item 3</li>
|
|
194
|
+
</ul>
|
|
195
|
+
|
|
196
|
+
<!-- Run code when clicked away -->
|
|
197
|
+
<div onclickaway="console.log('Clicked outside')">
|
|
198
|
+
Click outside this div
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<!-- Persist form values -->
|
|
202
|
+
<input type="text" name="username" persist>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Admin Features
|
|
206
|
+
|
|
207
|
+
```html
|
|
208
|
+
<!-- Only visible/editable in edit mode -->
|
|
209
|
+
<div contenteditable edit-mode-contenteditable>Admin can edit this</div>
|
|
210
|
+
<input type="text" edit-mode-input>
|
|
211
|
+
<script edit-mode-resource>console.log('Admin only');</script>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Module Creation
|
|
215
|
+
|
|
216
|
+
Each module should be a self-contained ES module:
|
|
217
|
+
|
|
218
|
+
```javascript
|
|
219
|
+
// features/my-feature.js
|
|
220
|
+
import dependency from '../utilities/dependency.js';
|
|
221
|
+
|
|
222
|
+
export default function myFeature() {
|
|
223
|
+
// Feature implementation
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Export initialization function
|
|
227
|
+
export function init() {
|
|
228
|
+
if (typeof window !== 'undefined') {
|
|
229
|
+
// Auto-initialize on import
|
|
230
|
+
myFeature();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Auto-run if needed
|
|
235
|
+
if (typeof window !== 'undefined') {
|
|
236
|
+
init();
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Migration from Monolithic Script
|
|
241
|
+
|
|
242
|
+
### Before
|
|
243
|
+
```html
|
|
244
|
+
<script src="/js/old-hyperclay.js"></script>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### After
|
|
248
|
+
```html
|
|
249
|
+
<!-- Use preset -->
|
|
250
|
+
<script src="/js/hyperclay.js?preset=standard" type="module"></script>
|
|
251
|
+
|
|
252
|
+
<!-- Or specific features -->
|
|
253
|
+
<script src="/js/hyperclay.js?features=save,admin,toast" type="module"></script>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Contributing
|
|
257
|
+
|
|
258
|
+
1. Fork the repository
|
|
259
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
260
|
+
3. Make your changes
|
|
261
|
+
4. Run `npm run generate:deps` to update the dependency graph
|
|
262
|
+
5. Test your changes with `npm run dev`
|
|
263
|
+
6. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
264
|
+
7. Push to the branch (`git push origin feature/amazing-feature`)
|
|
265
|
+
8. Open a Pull Request
|
|
266
|
+
|
|
267
|
+
## License
|
|
268
|
+
|
|
269
|
+
MIT © Hyperclay
|
|
270
|
+
|
|
271
|
+
## Links
|
|
272
|
+
|
|
273
|
+
- [Documentation](https://hyperclay.com/docs)
|
|
274
|
+
- [Examples](https://hyperclay.com/examples)
|
|
275
|
+
- [Configurator](https://hyperclay.com/configurator)
|
|
276
|
+
- [GitHub Issues](https://github.com/hyperclay/hyperclayjs/issues)
|