hyperclayjs 1.1.0 → 1.1.2

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
@@ -93,7 +93,7 @@ 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 |
@@ -134,7 +134,7 @@ Standard feature set for most use cases
134
134
 
135
135
  **Modules:** `save-core`, `save`, `admin`, `persist`, `ajax`, `events`, `helpers`, `toast`
136
136
 
137
- ### Everything (~616.3KB)
137
+ ### Everything (~616.4KB)
138
138
  All available features
139
139
 
140
140
  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
@@ -25,13 +25,27 @@
25
25
  (async function() {
26
26
  'use strict';
27
27
 
28
+ // Create a promise that resolves when hyperclay is ready
29
+ let hyperclayReadyResolve;
30
+ window.hyperclayReady = new Promise(resolve => {
31
+ hyperclayReadyResolve = resolve;
32
+ });
33
+
34
+ // Initialize namespaces
35
+ window.hyperclay = window.hyperclay || {};
36
+
28
37
  // Module dependency map - AUTO-GENERATED
29
38
  const moduleDependencies = {
30
39
  "save-core": {
31
40
  "path": "./core/savePageCore.js",
32
41
  "dependencies": [
33
42
  "cookie"
34
- ]
43
+ ],
44
+ "exports": {
45
+ "savePage": [
46
+ "hyperclay"
47
+ ]
48
+ }
35
49
  },
36
50
  "save": {
37
51
  "path": "./core/savePage.js",
@@ -40,62 +54,120 @@
40
54
  "toast",
41
55
  "mutation",
42
56
  "throttle"
43
- ]
57
+ ],
58
+ "exports": {
59
+ "beforeSave": [
60
+ "hyperclay"
61
+ ],
62
+ "savePage": [
63
+ "hyperclay"
64
+ ],
65
+ "replacePageWith": [
66
+ "hyperclay"
67
+ ],
68
+ "initHyperclaySaveButton": [
69
+ "hyperclay"
70
+ ],
71
+ "initSaveKeyboardShortcut": [
72
+ "hyperclay"
73
+ ],
74
+ "initSavePageOnChange": [
75
+ "hyperclay"
76
+ ]
77
+ }
44
78
  },
45
79
  "admin": {
46
80
  "path": "./core/adminSystem.js",
47
81
  "dependencies": [
48
82
  "save",
49
83
  "dom-ready"
50
- ]
84
+ ],
85
+ "exports": {}
51
86
  },
52
87
  "persist": {
53
88
  "path": "./core/enablePersistentFormInputValues.js",
54
89
  "dependencies": [
55
90
  "save"
56
- ]
91
+ ],
92
+ "exports": {
93
+ "enablePersistentFormInputValues": [
94
+ "hyperclay"
95
+ ]
96
+ }
57
97
  },
58
98
  "options": {
59
99
  "path": "./core/optionVisibilityRuleGenerator.js",
60
100
  "dependencies": [
61
101
  "mutation"
62
- ]
102
+ ],
103
+ "exports": {
104
+ "optionVisibilityRuleGenerator": [
105
+ "window",
106
+ "hyperclay"
107
+ ]
108
+ }
63
109
  },
64
110
  "editmode": {
65
111
  "path": "./core/editmodeSystem.js",
66
112
  "dependencies": [
67
113
  "save",
68
114
  "dom-ready"
69
- ]
115
+ ],
116
+ "exports": {
117
+ "toggleEditMode": [
118
+ "hyperclay"
119
+ ],
120
+ "isEditMode": [
121
+ "hyperclay"
122
+ ],
123
+ "isOwner": [
124
+ "hyperclay"
125
+ ]
126
+ }
70
127
  },
71
128
  "events": {
72
129
  "path": "./custom-attributes/events.js",
73
130
  "dependencies": [
74
131
  "mutation",
75
132
  "window-load"
76
- ]
133
+ ],
134
+ "exports": {}
77
135
  },
78
136
  "ajax": {
79
137
  "path": "./custom-attributes/ajaxElements.js",
80
138
  "dependencies": [
81
139
  "get-data-from-form"
82
- ]
140
+ ],
141
+ "exports": {}
83
142
  },
84
143
  "sortable": {
85
144
  "path": "./custom-attributes/sortable.js",
86
145
  "dependencies": [
87
146
  "mutation"
88
- ]
147
+ ],
148
+ "exports": {
149
+ "Sortable": [
150
+ "window",
151
+ "hyperclay"
152
+ ]
153
+ }
89
154
  },
90
155
  "helpers": {
91
156
  "path": "./custom-attributes/domHelpers.js",
92
157
  "dependencies": [
93
158
  "nearest"
94
- ]
159
+ ],
160
+ "exports": {
161
+ "initCustomAttributes": [
162
+ "window",
163
+ "hyperclay"
164
+ ]
165
+ }
95
166
  },
96
167
  "inputs": {
97
168
  "path": "./custom-attributes/inputHelpers.js",
98
- "dependencies": []
169
+ "dependencies": [],
170
+ "exports": {}
99
171
  },
100
172
  "prompts": {
101
173
  "path": "./ui/prompts.js",
@@ -104,92 +176,219 @@
104
176
  "copy-to-clipboard",
105
177
  "modals",
106
178
  "toast"
107
- ]
179
+ ],
180
+ "exports": {
181
+ "ask": [
182
+ "window",
183
+ "hyperclay"
184
+ ],
185
+ "consent": [
186
+ "window",
187
+ "hyperclay"
188
+ ],
189
+ "tell": [
190
+ "window",
191
+ "hyperclay"
192
+ ],
193
+ "snippet": [
194
+ "hyperclay"
195
+ ],
196
+ "showApiKey": [
197
+ "hyperclay"
198
+ ]
199
+ }
108
200
  },
109
201
  "toast": {
110
202
  "path": "./ui/toast.js",
111
- "dependencies": []
203
+ "dependencies": [],
204
+ "exports": {
205
+ "toast": [
206
+ "window",
207
+ "hyperclay"
208
+ ]
209
+ }
112
210
  },
113
211
  "modals": {
114
212
  "path": "./ui/theModal.js",
115
- "dependencies": []
213
+ "dependencies": [],
214
+ "exports": {
215
+ "themodal": [
216
+ "window",
217
+ "hyperclay"
218
+ ]
219
+ }
116
220
  },
117
221
  "info": {
118
222
  "path": "./ui/info.js",
119
223
  "dependencies": [
120
224
  "dom-ready",
121
225
  "modals"
122
- ]
226
+ ],
227
+ "exports": {
228
+ "info": [
229
+ "window",
230
+ "hyperclay"
231
+ ]
232
+ }
123
233
  },
124
234
  "tailwind-play": {
125
235
  "path": "./vendor/tailwind-play.js",
126
236
  "dependencies": [
127
237
  "style-injection"
128
- ]
238
+ ],
239
+ "exports": {}
129
240
  },
130
241
  "mutation": {
131
242
  "path": "./utilities/mutation.js",
132
- "dependencies": []
243
+ "dependencies": [],
244
+ "exports": {
245
+ "Mutation": [
246
+ "window",
247
+ "hyperclay"
248
+ ]
249
+ }
133
250
  },
134
251
  "nearest": {
135
252
  "path": "./utilities/nearest.js",
136
- "dependencies": []
253
+ "dependencies": [],
254
+ "exports": {
255
+ "nearest": [
256
+ "window",
257
+ "hyperclay"
258
+ ]
259
+ }
137
260
  },
138
261
  "cookie": {
139
262
  "path": "./utilities/cookie.js",
140
- "dependencies": []
263
+ "dependencies": [],
264
+ "exports": {
265
+ "cookie": [
266
+ "window",
267
+ "hyperclay"
268
+ ]
269
+ }
141
270
  },
142
271
  "throttle": {
143
272
  "path": "./utilities/throttle.js",
144
- "dependencies": []
273
+ "dependencies": [],
274
+ "exports": {
275
+ "throttle": [
276
+ "hyperclay"
277
+ ]
278
+ }
145
279
  },
146
280
  "debounce": {
147
281
  "path": "./utilities/debounce.js",
148
- "dependencies": []
282
+ "dependencies": [],
283
+ "exports": {
284
+ "debounce": [
285
+ "hyperclay"
286
+ ]
287
+ }
149
288
  },
150
289
  "dom-ready": {
151
290
  "path": "./dom-utilities/onDomReady.js",
152
- "dependencies": []
291
+ "dependencies": [],
292
+ "exports": {
293
+ "onDomReady": [
294
+ "hyperclay"
295
+ ]
296
+ }
153
297
  },
154
298
  "window-load": {
155
299
  "path": "./dom-utilities/onLoad.js",
156
- "dependencies": []
300
+ "dependencies": [],
301
+ "exports": {
302
+ "onLoad": [
303
+ "hyperclay"
304
+ ]
305
+ }
157
306
  },
158
- "jquery-like": {
307
+ "alljs": {
159
308
  "path": "./dom-utilities/All.js",
160
- "dependencies": []
309
+ "dependencies": [],
310
+ "exports": {
311
+ "All": [
312
+ "window",
313
+ "hyperclay"
314
+ ]
315
+ }
161
316
  },
162
317
  "style-injection": {
163
318
  "path": "./dom-utilities/insertStyleTag.js",
164
- "dependencies": []
319
+ "dependencies": [],
320
+ "exports": {
321
+ "insertStyleTag": [
322
+ "window",
323
+ "hyperclay"
324
+ ]
325
+ }
165
326
  },
166
327
  "get-data-from-form": {
167
328
  "path": "./dom-utilities/getDataFromForm.js",
168
- "dependencies": []
329
+ "dependencies": [],
330
+ "exports": {
331
+ "getDataFromForm": [
332
+ "window",
333
+ "hyperclay"
334
+ ]
335
+ }
169
336
  },
170
337
  "dom-morphing": {
171
338
  "path": "./vendor/idiomorph.min.js",
172
- "dependencies": []
339
+ "dependencies": [],
340
+ "exports": {
341
+ "Idiomorph": [
342
+ "hyperclay"
343
+ ]
344
+ }
173
345
  },
174
346
  "slugify": {
175
347
  "path": "./string-utilities/slugify.js",
176
- "dependencies": []
348
+ "dependencies": [],
349
+ "exports": {
350
+ "slugify": [
351
+ "window",
352
+ "hyperclay"
353
+ ]
354
+ }
177
355
  },
178
356
  "emmet-html": {
179
357
  "path": "./string-utilities/emmet-html.js",
180
- "dependencies": []
358
+ "dependencies": [],
359
+ "exports": {
360
+ "emmet": [
361
+ "hyperclay"
362
+ ]
363
+ }
181
364
  },
182
365
  "copy-to-clipboard": {
183
366
  "path": "./string-utilities/copy-to-clipboard.js",
184
- "dependencies": []
367
+ "dependencies": [],
368
+ "exports": {
369
+ "copyToClipboard": [
370
+ "hyperclay"
371
+ ]
372
+ }
185
373
  },
186
374
  "query-parser": {
187
375
  "path": "./string-utilities/query.js",
188
- "dependencies": []
376
+ "dependencies": [],
377
+ "exports": {
378
+ "query": [
379
+ "window",
380
+ "hyperclay"
381
+ ]
382
+ }
189
383
  },
190
384
  "behavior-collector": {
191
385
  "path": "./communication/behaviorCollector.js",
192
- "dependencies": []
386
+ "dependencies": [],
387
+ "exports": {
388
+ "behaviorCollector": [
389
+ "hyperclay"
390
+ ]
391
+ }
193
392
  },
194
393
  "send-message": {
195
394
  "path": "./communication/sendMessage.js",
@@ -197,7 +396,12 @@
197
396
  "behavior-collector",
198
397
  "get-data-from-form",
199
398
  "toast"
200
- ]
399
+ ],
400
+ "exports": {
401
+ "sendMessage": [
402
+ "hyperclay"
403
+ ]
404
+ }
201
405
  },
202
406
  "file-upload": {
203
407
  "path": "./communication/uploadFile.js",
@@ -205,7 +409,18 @@
205
409
  "copy-to-clipboard",
206
410
  "toast",
207
411
  "debounce"
208
- ]
412
+ ],
413
+ "exports": {
414
+ "uploadFile": [
415
+ "hyperclay"
416
+ ],
417
+ "createFile": [
418
+ "hyperclay"
419
+ ],
420
+ "uploadFileBasic": [
421
+ "hyperclay"
422
+ ]
423
+ }
209
424
  }
210
425
  };
211
426
 
@@ -262,7 +477,7 @@
262
477
  "debounce",
263
478
  "dom-ready",
264
479
  "window-load",
265
- "jquery-like",
480
+ "alljs",
266
481
  "style-injection",
267
482
  "get-data-from-form",
268
483
  "dom-morphing",
@@ -387,11 +602,6 @@
387
602
  loaded.init();
388
603
  }
389
604
 
390
- // Make module available globally if it exports to window
391
- if (loaded.exportToWindow && typeof loaded.exportToWindow === 'function') {
392
- loaded.exportToWindow();
393
- }
394
-
395
605
  return loaded;
396
606
  } catch (error) {
397
607
  console.error(`HyperclayJS: Failed to load ${feature}:`, error);
@@ -426,6 +636,39 @@
426
636
  // Store loaded modules globally for access
427
637
  window.hyperclayModules = loadedModules;
428
638
 
639
+ // Attach exports to window based on module configuration
640
+ for (const feature of loadOrder) {
641
+ const module = loadedModules[feature];
642
+ const moduleConfig = moduleDependencies[feature];
643
+
644
+ if (!module || !moduleConfig.exports) continue;
645
+
646
+ // For each export in the module's configuration
647
+ for (const [exportName, locations] of Object.entries(moduleConfig.exports)) {
648
+ // Try to get the export - check both named export and default export
649
+ let exportValue = module[exportName];
650
+
651
+ // If not found as named export, try default export
652
+ if (!exportValue && module.default) {
653
+ exportValue = module.default;
654
+ }
655
+
656
+ if (!exportValue) continue;
657
+
658
+ // Attach to each configured location
659
+ locations.forEach(location => {
660
+ if (location === 'window') {
661
+ window[exportName] = exportValue;
662
+ } else if (location === 'hyperclay') {
663
+ window.hyperclay[exportName] = exportValue;
664
+ }
665
+ });
666
+ }
667
+ }
668
+
669
+ // Create window.h alias
670
+ window.h = window.hyperclay;
671
+
429
672
  // Fire custom event when loading is complete
430
673
  window.dispatchEvent(new CustomEvent('hyperclayReady', {
431
674
  detail: {
@@ -434,6 +677,11 @@
434
677
  }
435
678
  }));
436
679
 
680
+ // Resolve the ready promise
681
+ if (hyperclayReadyResolve) {
682
+ hyperclayReadyResolve(window.hyperclay);
683
+ }
684
+
437
685
  console.log('HyperclayJS: All modules loaded successfully');
438
686
 
439
687
  // Show feature summary - AUTO-GENERATED
@@ -461,7 +709,7 @@
461
709
  "debounce": 0.2,
462
710
  "dom-ready": 0.2,
463
711
  "window-load": 0.2,
464
- "jquery-like": 13.8,
712
+ "alljs": 13.9,
465
713
  "style-injection": 0.8,
466
714
  "get-data-from-form": 1.7,
467
715
  "dom-morphing": 7.9,
@@ -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",
@@ -511,10 +512,10 @@
511
512
  ]
512
513
  }
513
514
  },
514
- "jquery-like": {
515
+ "alljs": {
515
516
  "name": "All.js (jQuery-like)",
516
517
  "category": "dom-utilities",
517
- "size": 13.8,
518
+ "size": 13.9,
518
519
  "files": [
519
520
  "dom-utilities/All.js"
520
521
  ],
@@ -729,7 +730,7 @@
729
730
  "modules": [
730
731
  "dom-ready",
731
732
  "window-load",
732
- "jquery-like",
733
+ "alljs",
733
734
  "style-injection",
734
735
  "get-data-from-form"
735
736
  ]
@@ -813,7 +814,7 @@
813
814
  "debounce",
814
815
  "dom-ready",
815
816
  "window-load",
816
- "jquery-like",
817
+ "alljs",
817
818
  "style-injection",
818
819
  "get-data-from-form",
819
820
  "dom-morphing",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperclayjs",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Modular JavaScript library for building interactive HTML applications with Hyperclay",
5
5
  "type": "module",
6
6
  "main": "hyperclay.js",
@@ -33,17 +33,18 @@
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 .",
44
45
  "release": "./scripts/release.sh",
45
46
  "prepublishOnly": "npm run build && npm test",
46
- "postpublish": "open http://127.0.0.1:3535/load-jsdelivr.html"
47
+ "postpublish": "test -n \"$SKIP_POSTPUBLISH\" || open http://127.0.0.1:3535/load-jsdelivr.html"
47
48
  },
48
49
  "repository": {
49
50
  "type": "git",