hyperclayjs 1.1.1 → 1.2.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/README.md CHANGED
@@ -55,7 +55,7 @@ import 'hyperclayjs/presets/standard.js';
55
55
  | Admin Features | 5.3KB | Hides admin inputs, scripts, contenteditable, onclick for regular viewers |
56
56
  | Edit Mode | 1.4KB | Toggle edit mode on/off |
57
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" |
58
+ | Option Visibility | 4.4KB | Dynamic show/hide based on ancestor state with option:attribute="value" |
59
59
  | Save Core | 5.9KB | Basic save function only - hyperclay.savePage() |
60
60
  | Save System | 4.9KB | Full save: save button, keyboard shortcut, auto-save, change tracking |
61
61
 
@@ -76,7 +76,7 @@ import 'hyperclayjs/presets/standard.js';
76
76
  | Dialog Functions | 7.7KB | ask(), consent(), tell(), snippet() functions |
77
77
  | Info Dialog | 3.2KB | Info dialog component |
78
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 |
79
+ | Tailwind Play | 362.3KB | Live Tailwind CSS editing - no need for a build system |
80
80
  | Toast Notifications | 7.3KB | Success/error message notifications - toast(msg, msgType) |
81
81
 
82
82
  ### Utilities (Core utilities (often auto-included))
@@ -93,11 +93,10 @@ import 'hyperclayjs/presets/standard.js';
93
93
 
94
94
  | Module | Size | Description |
95
95
  |--------|------|-------------|
96
- | All.js (jQuery-like) | 13.8KB | Full DOM manipulation library |
96
+ | All.js (jQuery-like) | 13.9KB | Full DOM manipulation library |
97
97
  | DOM Ready | 0.2KB | DOM ready callback |
98
98
  | Get Data From Form | 1.7KB | Extract form data as an object |
99
99
  | Style Injection | 0.8KB | Dynamic stylesheet injection |
100
- | Window Load | 0.2KB | Window load callback |
101
100
 
102
101
  ### String Utilities (String manipulation helpers)
103
102
 
@@ -112,7 +111,6 @@ import 'hyperclayjs/presets/standard.js';
112
111
 
113
112
  | Module | Size | Description |
114
113
  |--------|------|-------------|
115
- | Behavior Collector | 5.2KB | Tracks user interactions (mouse, scroll, keyboard) |
116
114
  | File Upload to App Owner | 10.4KB | File upload with progress |
117
115
  | Send Message to App Owner | 1.2KB | Message sending utility |
118
116
 
@@ -120,7 +118,7 @@ import 'hyperclayjs/presets/standard.js';
120
118
 
121
119
  | Module | Size | Description |
122
120
  |--------|------|-------------|
123
- | DOM Morphing | 7.9KB | Efficient DOM updates |
121
+ | Idiomorph | 7.9KB | Efficient DOM morphing library |
124
122
 
125
123
  ## Presets
126
124
 
@@ -134,7 +132,7 @@ Standard feature set for most use cases
134
132
 
135
133
  **Modules:** `save-core`, `save`, `admin`, `persist`, `ajax`, `events`, `helpers`, `toast`
136
134
 
137
- ### Everything (~616.3KB)
135
+ ### Everything (~624.4KB)
138
136
  All available features
139
137
 
140
138
  Includes all available modules across all categories.
@@ -343,13 +343,15 @@ const defaultPlugins = {
343
343
  const All = new Proxy(function (selectorOrElements, contextSelector) {
344
344
  // If there's a context selector, search within that context
345
345
  if (arguments.length === 2) {
346
- if (typeof contextSelector !== 'string') {
347
- throw new TypeError('Context selector must be a string');
346
+ // Support both string selectors and element references as context
347
+ let contextElements;
348
+ if (typeof contextSelector === 'string') {
349
+ contextElements = Array.from(document.querySelectorAll(contextSelector));
350
+ } else {
351
+ // Convert element/array/document to element array
352
+ contextElements = toElementArray(contextSelector);
348
353
  }
349
354
 
350
- // Get the context element(s)
351
- const contextElements = Array.from(document.querySelectorAll(contextSelector));
352
-
353
355
  // If first arg is a string selector, search within each context
354
356
  if (typeof selectorOrElements === 'string') {
355
357
  const elements = contextElements.flatMap(context => {
package/hyperclay.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * HyperclayJS - Self-detecting module loader
2
+ * HyperclayJS v1.2.0 - Self-detecting module loader
3
3
  * Automatically loads requested features with dependency resolution
4
4
  *
5
5
  * USAGE:
@@ -52,6 +52,7 @@
52
52
  "dependencies": [
53
53
  "save-core",
54
54
  "toast",
55
+ "toast-hyperclay",
55
56
  "mutation",
56
57
  "throttle"
57
58
  ],
@@ -175,7 +176,8 @@
175
176
  "dom-ready",
176
177
  "copy-to-clipboard",
177
178
  "modals",
178
- "toast"
179
+ "toast",
180
+ "toast-hyperclay"
179
181
  ],
180
182
  "exports": {
181
183
  "ask": [
@@ -208,6 +210,18 @@
208
210
  ]
209
211
  }
210
212
  },
213
+ "toast-hyperclay": {
214
+ "path": "./ui/toast-hyperclay.js",
215
+ "dependencies": [
216
+ "toast"
217
+ ],
218
+ "exports": {
219
+ "toast": [
220
+ "window",
221
+ "hyperclay"
222
+ ]
223
+ }
224
+ },
211
225
  "modals": {
212
226
  "path": "./ui/theModal.js",
213
227
  "dependencies": [],
@@ -304,7 +318,7 @@
304
318
  ]
305
319
  }
306
320
  },
307
- "jquery-like": {
321
+ "alljs": {
308
322
  "path": "./dom-utilities/All.js",
309
323
  "dependencies": [],
310
324
  "exports": {
@@ -334,7 +348,7 @@
334
348
  ]
335
349
  }
336
350
  },
337
- "dom-morphing": {
351
+ "idiomorph": {
338
352
  "path": "./vendor/idiomorph.min.js",
339
353
  "dependencies": [],
340
354
  "exports": {
@@ -395,7 +409,8 @@
395
409
  "dependencies": [
396
410
  "behavior-collector",
397
411
  "get-data-from-form",
398
- "toast"
412
+ "toast",
413
+ "toast-hyperclay"
399
414
  ],
400
415
  "exports": {
401
416
  "sendMessage": [
@@ -408,6 +423,7 @@
408
423
  "dependencies": [
409
424
  "copy-to-clipboard",
410
425
  "toast",
426
+ "toast-hyperclay",
411
427
  "debounce"
412
428
  ],
413
429
  "exports": {
@@ -467,6 +483,7 @@
467
483
  "inputs",
468
484
  "prompts",
469
485
  "toast",
486
+ "toast-hyperclay",
470
487
  "modals",
471
488
  "info",
472
489
  "tailwind-play",
@@ -477,10 +494,10 @@
477
494
  "debounce",
478
495
  "dom-ready",
479
496
  "window-load",
480
- "jquery-like",
497
+ "alljs",
481
498
  "style-injection",
482
499
  "get-data-from-form",
483
- "dom-morphing",
500
+ "idiomorph",
484
501
  "slugify",
485
502
  "emmet-html",
486
503
  "copy-to-clipboard",
@@ -507,20 +524,21 @@
507
524
  const scriptUrl = new URL(currentScript.src);
508
525
  const featuresParam = scriptUrl.searchParams.get('features');
509
526
  const presetParam = scriptUrl.searchParams.get('preset');
527
+ const debugMode = scriptUrl.searchParams.get('debug') === 'true';
510
528
 
511
529
  // Determine requested features
512
530
  let requestedFeatures = [];
513
531
 
514
532
  if (presetParam && presets[presetParam]) {
515
533
  requestedFeatures = presets[presetParam].modules;
516
- console.log(`HyperclayJS: Loading preset "${presetParam}"`);
534
+ if (debugMode) console.log(`HyperclayJS: Loading preset "${presetParam}"`);
517
535
  } else if (featuresParam) {
518
536
  requestedFeatures = featuresParam.split(',').map(f => f.trim());
519
- console.log(`HyperclayJS: Loading features:`, requestedFeatures);
537
+ if (debugMode) console.log(`HyperclayJS: Loading features:`, requestedFeatures);
520
538
  } else {
521
539
  // Default to minimal preset
522
540
  requestedFeatures = presets.minimal.modules;
523
- console.log('HyperclayJS: No features specified, loading minimal preset');
541
+ if (debugMode) console.log('HyperclayJS: No features specified, loading minimal preset');
524
542
  }
525
543
 
526
544
  // Resolve all dependencies
@@ -594,7 +612,7 @@
594
612
  const modulePath = `${baseUrl}/${module.path}`;
595
613
 
596
614
  try {
597
- console.log(`HyperclayJS: Loading ${feature}...`);
615
+ if (debugMode) console.log(`HyperclayJS: Loading ${feature}...`);
598
616
  const loaded = await import(modulePath);
599
617
 
600
618
  // Auto-initialize if the module exports an init function
@@ -617,7 +635,7 @@
617
635
  // Sort in correct load order
618
636
  const loadOrder = topologicalSort(allFeatures);
619
637
 
620
- console.log('HyperclayJS: Load order:', loadOrder);
638
+ if (debugMode) console.log('HyperclayJS: Load order:', loadOrder);
621
639
 
622
640
  // Get base URL
623
641
  const baseUrl = getBaseUrl();
@@ -682,10 +700,11 @@
682
700
  hyperclayReadyResolve(window.hyperclay);
683
701
  }
684
702
 
685
- console.log('HyperclayJS: All modules loaded successfully');
703
+ if (debugMode) {
704
+ console.log('HyperclayJS: All modules loaded successfully');
686
705
 
687
- // Show feature summary - AUTO-GENERATED
688
- const sizes = {
706
+ // Show feature summary - AUTO-GENERATED
707
+ const sizes = {
689
708
  "save-core": 5.9,
690
709
  "save": 4.9,
691
710
  "admin": 5.300000000000001,
@@ -699,6 +718,7 @@
699
718
  "inputs": 1.2,
700
719
  "prompts": 7.7,
701
720
  "toast": 7.3,
721
+ "toast-hyperclay": 8,
702
722
  "modals": 18.4,
703
723
  "info": 3.2,
704
724
  "tailwind-play": 362.3,
@@ -709,10 +729,10 @@
709
729
  "debounce": 0.2,
710
730
  "dom-ready": 0.2,
711
731
  "window-load": 0.2,
712
- "jquery-like": 13.8,
732
+ "alljs": 13.9,
713
733
  "style-injection": 0.8,
714
734
  "get-data-from-form": 1.7,
715
- "dom-morphing": 7.9,
735
+ "idiomorph": 7.9,
716
736
  "slugify": 0.7,
717
737
  "emmet-html": 1.4,
718
738
  "copy-to-clipboard": 0.9,
@@ -721,11 +741,12 @@
721
741
  "send-message": 1.2,
722
742
  "file-upload": 10.4
723
743
  };
724
- const totalSize = loadOrder.reduce((sum, feature) => {
725
- return sum + (sizes[feature] || 0);
726
- }, 0);
744
+ const totalSize = loadOrder.reduce((sum, feature) => {
745
+ return sum + (sizes[feature] || 0);
746
+ }, 0);
727
747
 
728
- console.log(`HyperclayJS: Loaded ${loadOrder.length} modules (~${totalSize.toFixed(1)}KB)`);
748
+ console.log(`HyperclayJS: Loaded ${loadOrder.length} modules (~${totalSize.toFixed(1)}KB)`);
749
+ }
729
750
 
730
751
  } catch (error) {
731
752
  console.error('HyperclayJS: Fatal error during initialization:', error);
@@ -9,6 +9,7 @@
9
9
  "build/generate-load-jsdelivr.js": [],
10
10
  "build/generate-readme.js": [],
11
11
  "build/hyperclay.template.js": [],
12
+ "build/update-index-url.js": [],
12
13
  "communication/behaviorCollector.js": [],
13
14
  "communication/sendMessage.js": [
14
15
  "communication/behaviorCollector.js",
@@ -137,6 +138,9 @@
137
138
  "ui/toast.js"
138
139
  ],
139
140
  "ui/theModal.js": [],
141
+ "ui/toast-hyperclay.js": [
142
+ "ui/toast.js"
143
+ ],
140
144
  "ui/toast.js": [],
141
145
  "utilities/cookie.js": [],
142
146
  "utilities/debounce.js": [],
@@ -229,7 +233,7 @@
229
233
  "files": [
230
234
  "core/optionVisibilityRuleGenerator.js"
231
235
  ],
232
- "description": "Dynamic show/hide based on page state with option:attribute=\"value\"",
236
+ "description": "Dynamic show/hide based on ancestor state with option:attribute=\"value\"",
233
237
  "exports": {
234
238
  "optionVisibilityRuleGenerator": [
235
239
  "window",
@@ -370,6 +374,22 @@
370
374
  ]
371
375
  }
372
376
  },
377
+ "toast-hyperclay": {
378
+ "name": "Toast Hyperclay (Legacy)",
379
+ "category": "ui",
380
+ "size": 8,
381
+ "files": [
382
+ "ui/toast-hyperclay.js",
383
+ "ui/toast.js"
384
+ ],
385
+ "description": "Toast with legacy Hyperclay platform styling (hidden feature)",
386
+ "exports": {
387
+ "toast": [
388
+ "window",
389
+ "hyperclay"
390
+ ]
391
+ }
392
+ },
373
393
  "modals": {
374
394
  "name": "Modal System",
375
395
  "category": "ui",
@@ -407,7 +427,7 @@
407
427
  "files": [
408
428
  "vendor/tailwind-play.js"
409
429
  ],
410
- "description": "Live Tailwind CSS editing - updates styles based on classes in your HTML",
430
+ "description": "Live Tailwind CSS editing - no need for a build system",
411
431
  "exports": {}
412
432
  },
413
433
  "mutation": {
@@ -511,10 +531,10 @@
511
531
  ]
512
532
  }
513
533
  },
514
- "jquery-like": {
534
+ "alljs": {
515
535
  "name": "All.js (jQuery-like)",
516
536
  "category": "dom-utilities",
517
- "size": 13.8,
537
+ "size": 13.9,
518
538
  "files": [
519
539
  "dom-utilities/All.js"
520
540
  ],
@@ -556,14 +576,14 @@
556
576
  ]
557
577
  }
558
578
  },
559
- "dom-morphing": {
560
- "name": "DOM Morphing",
579
+ "idiomorph": {
580
+ "name": "Idiomorph",
561
581
  "category": "vendor",
562
582
  "size": 7.9,
563
583
  "files": [
564
584
  "vendor/idiomorph.min.js"
565
585
  ],
566
- "description": "Efficient DOM updates",
586
+ "description": "Efficient DOM morphing library",
567
587
  "exports": {
568
588
  "Idiomorph": [
569
589
  "hyperclay"
@@ -728,8 +748,7 @@
728
748
  "description": "DOM manipulation helpers",
729
749
  "modules": [
730
750
  "dom-ready",
731
- "window-load",
732
- "jquery-like",
751
+ "alljs",
733
752
  "style-injection",
734
753
  "get-data-from-form"
735
754
  ]
@@ -748,7 +767,6 @@
748
767
  "name": "Communication & Files",
749
768
  "description": "File handling and messaging",
750
769
  "modules": [
751
- "behavior-collector",
752
770
  "send-message",
753
771
  "file-upload"
754
772
  ]
@@ -757,7 +775,7 @@
757
775
  "name": "Vendor Libraries",
758
776
  "description": "Third-party libraries",
759
777
  "modules": [
760
- "dom-morphing"
778
+ "idiomorph"
761
779
  ]
762
780
  }
763
781
  },
@@ -803,6 +821,7 @@
803
821
  "inputs",
804
822
  "prompts",
805
823
  "toast",
824
+ "toast-hyperclay",
806
825
  "modals",
807
826
  "info",
808
827
  "tailwind-play",
@@ -813,10 +832,10 @@
813
832
  "debounce",
814
833
  "dom-ready",
815
834
  "window-load",
816
- "jquery-like",
835
+ "alljs",
817
836
  "style-injection",
818
837
  "get-data-from-form",
819
- "dom-morphing",
838
+ "idiomorph",
820
839
  "slugify",
821
840
  "emmet-html",
822
841
  "copy-to-clipboard",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperclayjs",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Modular JavaScript library for building interactive HTML applications with Hyperclay",
5
5
  "type": "module",
6
6
  "main": "hyperclay.js",
@@ -33,11 +33,12 @@
33
33
  ],
34
34
  "scripts": {
35
35
  "dev": "npm run build && http-server -p 3535 -o /index.html",
36
- "build": "npm run generate:deps && npm run build:loader && npm run build:readme && npm run build:load-jsdelivr",
36
+ "build": "npm run generate:deps && npm run build:loader && npm run build:readme && npm run build:load-jsdelivr && npm run build:index-url",
37
37
  "generate:deps": "node build/generate-dependency-graph.js",
38
38
  "build:loader": "node build/build-loader.js",
39
39
  "build:readme": "node build/generate-readme.js",
40
40
  "build:load-jsdelivr": "node build/generate-load-jsdelivr.js",
41
+ "build:index-url": "node build/update-index-url.js",
41
42
  "test": "jest",
42
43
  "lint": "eslint .",
43
44
  "format": "prettier --write .",
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Toast Hyperclay - Legacy toast for Hyperclay platform
3
+ *
4
+ * This is a wrapper that loads the toast module and automatically
5
+ * calls toast.useLegacy() to enable the legacy Hyperclay platform styling.
6
+ *
7
+ * This is a hidden feature not exposed in the UI - used internally by
8
+ * the Hyperclay platform for backward compatibility.
9
+ */
10
+
11
+ import toast from './toast.js';
12
+
13
+ // Automatically apply legacy styling for Hyperclay platform
14
+ toast.useLegacy();
15
+
16
+ // Re-export toast with legacy config already applied
17
+ export default toast;
18
+
19
+ // Export to window for global access
20
+ export function exportToWindow() {
21
+ if (!window.hyperclay) {
22
+ window.hyperclay = {};
23
+ }
24
+ window.hyperclay.toast = toast;
25
+ }