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.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +360 -0
  3. package/README.template.md +276 -0
  4. package/communication/behaviorCollector.js +230 -0
  5. package/communication/sendMessage.js +48 -0
  6. package/communication/uploadFile.js +348 -0
  7. package/core/adminContenteditable.js +36 -0
  8. package/core/adminInputs.js +58 -0
  9. package/core/adminOnClick.js +31 -0
  10. package/core/adminResources.js +33 -0
  11. package/core/adminSystem.js +15 -0
  12. package/core/editmode.js +8 -0
  13. package/core/editmodeSystem.js +18 -0
  14. package/core/enablePersistentFormInputValues.js +62 -0
  15. package/core/isAdminOfCurrentResource.js +13 -0
  16. package/core/optionVisibilityRuleGenerator.js +160 -0
  17. package/core/savePage.js +196 -0
  18. package/core/savePageCore.js +236 -0
  19. package/core/setPageTypeOnDocumentElement.js +23 -0
  20. package/custom-attributes/ajaxElements.js +94 -0
  21. package/custom-attributes/autosize.js +17 -0
  22. package/custom-attributes/domHelpers.js +175 -0
  23. package/custom-attributes/events.js +15 -0
  24. package/custom-attributes/inputHelpers.js +11 -0
  25. package/custom-attributes/onclickaway.js +27 -0
  26. package/custom-attributes/onclone.js +35 -0
  27. package/custom-attributes/onpagemutation.js +20 -0
  28. package/custom-attributes/onrender.js +30 -0
  29. package/custom-attributes/preventEnter.js +13 -0
  30. package/custom-attributes/sortable.js +76 -0
  31. package/dom-utilities/All.js +412 -0
  32. package/dom-utilities/getDataFromForm.js +60 -0
  33. package/dom-utilities/insertStyleTag.js +28 -0
  34. package/dom-utilities/onDomReady.js +7 -0
  35. package/dom-utilities/onLoad.js +7 -0
  36. package/hyperclay.js +465 -0
  37. package/module-dependency-graph.json +612 -0
  38. package/package.json +95 -0
  39. package/string-utilities/copy-to-clipboard.js +35 -0
  40. package/string-utilities/emmet-html.js +54 -0
  41. package/string-utilities/query.js +1 -0
  42. package/string-utilities/slugify.js +21 -0
  43. package/ui/info.js +39 -0
  44. package/ui/prompts.js +179 -0
  45. package/ui/theModal.js +677 -0
  46. package/ui/toast.js +273 -0
  47. package/utilities/cookie.js +45 -0
  48. package/utilities/debounce.js +12 -0
  49. package/utilities/mutation.js +403 -0
  50. package/utilities/nearest.js +97 -0
  51. package/utilities/pipe.js +1 -0
  52. package/utilities/throttle.js +21 -0
  53. package/vendor/Sortable.js +3351 -0
  54. package/vendor/idiomorph.min.js +8 -0
  55. package/vendor/tailwind-base.css +1471 -0
  56. package/vendor/tailwind-play.js +169 -0
package/hyperclay.js ADDED
@@ -0,0 +1,465 @@
1
+ /**
2
+ * Hyperclay Starter Kit - Self-detecting module loader
3
+ * Automatically loads requested features with dependency resolution
4
+ *
5
+ * AUTO-GENERATED FILE - Do not edit directly
6
+ * Generated from module-dependency-graph.json
7
+ */
8
+
9
+ (async function() {
10
+ 'use strict';
11
+
12
+ // Module dependency map - AUTO-GENERATED
13
+ const moduleDependencies = {
14
+ "save-core": {
15
+ "path": "./core/savePageCore.js",
16
+ "dependencies": [
17
+ "cookie"
18
+ ]
19
+ },
20
+ "save": {
21
+ "path": "./core/savePage.js",
22
+ "dependencies": [
23
+ "save-core",
24
+ "toast",
25
+ "mutation",
26
+ "throttle"
27
+ ]
28
+ },
29
+ "admin": {
30
+ "path": "./core/adminSystem.js",
31
+ "dependencies": [
32
+ "save",
33
+ "dom-ready"
34
+ ]
35
+ },
36
+ "persist": {
37
+ "path": "./core/enablePersistentFormInputValues.js",
38
+ "dependencies": [
39
+ "save"
40
+ ]
41
+ },
42
+ "options": {
43
+ "path": "./core/optionVisibilityRuleGenerator.js",
44
+ "dependencies": [
45
+ "mutation"
46
+ ]
47
+ },
48
+ "editmode": {
49
+ "path": "./core/editmodeSystem.js",
50
+ "dependencies": [
51
+ "save",
52
+ "dom-ready"
53
+ ]
54
+ },
55
+ "events": {
56
+ "path": "./custom-attributes/events.js",
57
+ "dependencies": [
58
+ "mutation",
59
+ "window-load"
60
+ ]
61
+ },
62
+ "ajax": {
63
+ "path": "./custom-attributes/ajaxElements.js",
64
+ "dependencies": []
65
+ },
66
+ "sortable": {
67
+ "path": "./custom-attributes/sortable.js",
68
+ "dependencies": [
69
+ "mutation"
70
+ ]
71
+ },
72
+ "helpers": {
73
+ "path": "./custom-attributes/domHelpers.js",
74
+ "dependencies": [
75
+ "nearest"
76
+ ]
77
+ },
78
+ "inputs": {
79
+ "path": "./custom-attributes/inputHelpers.js",
80
+ "dependencies": []
81
+ },
82
+ "prompts": {
83
+ "path": "./ui/prompts.js",
84
+ "dependencies": [
85
+ "dom-ready",
86
+ "copy-to-clipboard",
87
+ "modals",
88
+ "toast"
89
+ ]
90
+ },
91
+ "toast": {
92
+ "path": "./ui/toast.js",
93
+ "dependencies": []
94
+ },
95
+ "modals": {
96
+ "path": "./ui/theModal.js",
97
+ "dependencies": []
98
+ },
99
+ "info": {
100
+ "path": "./ui/info.js",
101
+ "dependencies": [
102
+ "dom-ready",
103
+ "modals"
104
+ ]
105
+ },
106
+ "tailwind-play": {
107
+ "path": "./vendor/tailwind-play.js",
108
+ "dependencies": [
109
+ "style-injection"
110
+ ]
111
+ },
112
+ "mutation": {
113
+ "path": "./utilities/mutation.js",
114
+ "dependencies": []
115
+ },
116
+ "nearest": {
117
+ "path": "./utilities/nearest.js",
118
+ "dependencies": []
119
+ },
120
+ "cookie": {
121
+ "path": "./utilities/cookie.js",
122
+ "dependencies": []
123
+ },
124
+ "throttle": {
125
+ "path": "./utilities/throttle.js",
126
+ "dependencies": []
127
+ },
128
+ "debounce": {
129
+ "path": "./utilities/debounce.js",
130
+ "dependencies": []
131
+ },
132
+ "dom-ready": {
133
+ "path": "./dom-utilities/onDomReady.js",
134
+ "dependencies": []
135
+ },
136
+ "window-load": {
137
+ "path": "./dom-utilities/onLoad.js",
138
+ "dependencies": []
139
+ },
140
+ "jquery-like": {
141
+ "path": "./dom-utilities/All.js",
142
+ "dependencies": []
143
+ },
144
+ "style-injection": {
145
+ "path": "./dom-utilities/insertStyleTag.js",
146
+ "dependencies": []
147
+ },
148
+ "dom-morphing": {
149
+ "path": "./vendor/idiomorph.min.js",
150
+ "dependencies": []
151
+ },
152
+ "slugify": {
153
+ "path": "./string-utilities/slugify.js",
154
+ "dependencies": []
155
+ },
156
+ "emmet-html": {
157
+ "path": "./string-utilities/emmet-html.js",
158
+ "dependencies": []
159
+ },
160
+ "copy-to-clipboard": {
161
+ "path": "./string-utilities/copy-to-clipboard.js",
162
+ "dependencies": []
163
+ },
164
+ "query-parser": {
165
+ "path": "./string-utilities/query.js",
166
+ "dependencies": []
167
+ },
168
+ "behavior-collector": {
169
+ "path": "./communication/behaviorCollector.js",
170
+ "dependencies": []
171
+ },
172
+ "send-message": {
173
+ "path": "./communication/sendMessage.js",
174
+ "dependencies": [
175
+ "behavior-collector",
176
+ "toast"
177
+ ]
178
+ },
179
+ "file-upload": {
180
+ "path": "./communication/uploadFile.js",
181
+ "dependencies": [
182
+ "copy-to-clipboard",
183
+ "toast",
184
+ "debounce"
185
+ ]
186
+ }
187
+ };
188
+
189
+ // Preset configurations - AUTO-GENERATED
190
+ const presets = {
191
+ "minimal": {
192
+ "name": "Minimal",
193
+ "description": "Essential features for basic editing",
194
+ "modules": [
195
+ "save-core",
196
+ "save",
197
+ "admin",
198
+ "toast"
199
+ ]
200
+ },
201
+ "standard": {
202
+ "name": "Standard",
203
+ "description": "Standard feature set for most use cases",
204
+ "modules": [
205
+ "save-core",
206
+ "save",
207
+ "admin",
208
+ "persist",
209
+ "ajax",
210
+ "events",
211
+ "helpers",
212
+ "toast"
213
+ ]
214
+ },
215
+ "everything": {
216
+ "name": "Everything",
217
+ "description": "All available features",
218
+ "modules": [
219
+ "save-core",
220
+ "save",
221
+ "admin",
222
+ "persist",
223
+ "options",
224
+ "editmode",
225
+ "events",
226
+ "ajax",
227
+ "sortable",
228
+ "helpers",
229
+ "inputs",
230
+ "prompts",
231
+ "toast",
232
+ "modals",
233
+ "info",
234
+ "tailwind-play",
235
+ "mutation",
236
+ "nearest",
237
+ "cookie",
238
+ "throttle",
239
+ "debounce",
240
+ "dom-ready",
241
+ "window-load",
242
+ "jquery-like",
243
+ "style-injection",
244
+ "dom-morphing",
245
+ "slugify",
246
+ "emmet-html",
247
+ "copy-to-clipboard",
248
+ "query-parser",
249
+ "behavior-collector",
250
+ "send-message",
251
+ "file-upload"
252
+ ]
253
+ }
254
+ };
255
+
256
+ // Find our script tag
257
+ const currentScript = document.currentScript ||
258
+ Array.from(document.scripts).find(s =>
259
+ s.src && (s.src.includes('hyperclay.js') || s.src.includes('hyperclay-starter-kit.js'))
260
+ );
261
+
262
+ if (!currentScript) {
263
+ console.error('HyperclayJS: Could not find script tag');
264
+ return;
265
+ }
266
+
267
+ // Parse URL parameters
268
+ const scriptUrl = new URL(currentScript.src);
269
+ const featuresParam = scriptUrl.searchParams.get('features');
270
+ const presetParam = scriptUrl.searchParams.get('preset');
271
+
272
+ // Determine requested features
273
+ let requestedFeatures = [];
274
+
275
+ if (presetParam && presets[presetParam]) {
276
+ requestedFeatures = presets[presetParam].modules;
277
+ console.log(`HyperclayJS: Loading preset "${presetParam}"`);
278
+ } else if (featuresParam) {
279
+ requestedFeatures = featuresParam.split(',').map(f => f.trim());
280
+ console.log(`HyperclayJS: Loading features:`, requestedFeatures);
281
+ } else {
282
+ // Default to minimal preset
283
+ requestedFeatures = presets.minimal.modules;
284
+ console.log('HyperclayJS: No features specified, loading minimal preset');
285
+ }
286
+
287
+ // Resolve all dependencies
288
+ function resolveDependencies(features) {
289
+ const resolved = new Set();
290
+ const queue = [...features];
291
+
292
+ while (queue.length > 0) {
293
+ const feature = queue.shift();
294
+
295
+ if (resolved.has(feature)) continue;
296
+
297
+ const module = moduleDependencies[feature];
298
+ if (!module) {
299
+ console.warn(`HyperclayJS: Unknown feature "${feature}"`);
300
+ continue;
301
+ }
302
+
303
+ // Add dependencies to queue
304
+ if (module.dependencies && module.dependencies.length > 0) {
305
+ module.dependencies.forEach(dep => {
306
+ if (!resolved.has(dep)) {
307
+ queue.push(dep);
308
+ }
309
+ });
310
+ }
311
+
312
+ // Mark this feature as resolved
313
+ resolved.add(feature);
314
+ }
315
+
316
+ return Array.from(resolved);
317
+ }
318
+
319
+ // Topological sort for correct load order
320
+ function topologicalSort(features) {
321
+ const visited = new Set();
322
+ const result = [];
323
+
324
+ function visit(feature) {
325
+ if (visited.has(feature)) return;
326
+ visited.add(feature);
327
+
328
+ const module = moduleDependencies[feature];
329
+ if (module && module.dependencies) {
330
+ module.dependencies.forEach(dep => {
331
+ if (features.includes(dep)) {
332
+ visit(dep);
333
+ }
334
+ });
335
+ }
336
+
337
+ result.push(feature);
338
+ }
339
+
340
+ features.forEach(feature => visit(feature));
341
+ return result;
342
+ }
343
+
344
+ // Get base URL for module imports
345
+ function getBaseUrl() {
346
+ const scriptDir = scriptUrl.href.substring(0, scriptUrl.href.lastIndexOf('/'));
347
+ return scriptDir;
348
+ }
349
+
350
+ // Load a module
351
+ async function loadModule(feature, baseUrl) {
352
+ const module = moduleDependencies[feature];
353
+ if (!module) return null;
354
+
355
+ const modulePath = `${baseUrl}/${module.path}`;
356
+
357
+ try {
358
+ console.log(`HyperclayJS: Loading ${feature}...`);
359
+ const loaded = await import(modulePath);
360
+
361
+ // Auto-initialize if the module exports an init function
362
+ if (loaded.init && typeof loaded.init === 'function') {
363
+ loaded.init();
364
+ }
365
+
366
+ // Make module available globally if it exports to window
367
+ if (loaded.exportToWindow && typeof loaded.exportToWindow === 'function') {
368
+ loaded.exportToWindow();
369
+ }
370
+
371
+ return loaded;
372
+ } catch (error) {
373
+ console.error(`HyperclayJS: Failed to load ${feature}:`, error);
374
+ return null;
375
+ }
376
+ }
377
+
378
+ // Main execution
379
+ try {
380
+ // Resolve all dependencies
381
+ const allFeatures = resolveDependencies(requestedFeatures);
382
+
383
+ // Sort in correct load order
384
+ const loadOrder = topologicalSort(allFeatures);
385
+
386
+ console.log('HyperclayJS: Load order:', loadOrder);
387
+
388
+ // Get base URL
389
+ const baseUrl = getBaseUrl();
390
+
391
+ // Track loaded modules
392
+ const loadedModules = {};
393
+
394
+ // Load modules in order
395
+ for (const feature of loadOrder) {
396
+ const module = await loadModule(feature, baseUrl);
397
+ if (module) {
398
+ loadedModules[feature] = module;
399
+ }
400
+ }
401
+
402
+ // Store loaded modules globally for access
403
+ window.hyperclayModules = loadedModules;
404
+
405
+ // Fire custom event when loading is complete
406
+ window.dispatchEvent(new CustomEvent('hyperclayReady', {
407
+ detail: {
408
+ features: loadOrder,
409
+ modules: loadedModules
410
+ }
411
+ }));
412
+
413
+ console.log('HyperclayJS: All modules loaded successfully');
414
+
415
+ // Show feature summary - AUTO-GENERATED
416
+ const sizes = {
417
+ "save-core": 5.9,
418
+ "save": 4.9,
419
+ "admin": 5.300000000000001,
420
+ "persist": 2.2,
421
+ "options": 4.4,
422
+ "editmode": 1.4,
423
+ "events": 3.5,
424
+ "ajax": 2.7,
425
+ "sortable": 117.89999999999999,
426
+ "helpers": 5.4,
427
+ "inputs": 1.2,
428
+ "prompts": 7.7,
429
+ "toast": 7.3,
430
+ "modals": 18.4,
431
+ "info": 3.2,
432
+ "tailwind-play": 362.3,
433
+ "mutation": 12.8,
434
+ "nearest": 3.2,
435
+ "cookie": 1.3,
436
+ "throttle": 0.6,
437
+ "debounce": 0.2,
438
+ "dom-ready": 0.2,
439
+ "window-load": 0.2,
440
+ "jquery-like": 13.8,
441
+ "style-injection": 0.8,
442
+ "dom-morphing": 7.9,
443
+ "slugify": 0.7,
444
+ "emmet-html": 1.4,
445
+ "copy-to-clipboard": 0.9,
446
+ "query-parser": 0.1,
447
+ "behavior-collector": 5.2,
448
+ "send-message": 1.2,
449
+ "file-upload": 10.4
450
+ };
451
+ const totalSize = loadOrder.reduce((sum, feature) => {
452
+ return sum + (sizes[feature] || 0);
453
+ }, 0);
454
+
455
+ console.log(`HyperclayJS: Loaded ${loadOrder.length} modules (~${totalSize.toFixed(1)}KB)`);
456
+
457
+ } catch (error) {
458
+ console.error('HyperclayJS: Fatal error during initialization:', error);
459
+ }
460
+ })();
461
+
462
+ // Export for use in build tools
463
+ if (typeof module !== 'undefined' && module.exports) {
464
+ module.exports = { version: '1.0.0' };
465
+ }