hyperclayjs 1.19.3 → 1.19.5
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 +4 -4
- package/package.json +1 -1
- package/src/core/savePage.js +52 -0
- package/src/hyperclay.js +4 -2
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ import 'hyperclayjs/presets/standard.js';
|
|
|
63
63
|
| option-visibility | 7.8KB | Dynamic show/hide based on ancestor state with option:attribute="value" |
|
|
64
64
|
| persist | 2.4KB | Persist input/select/textarea values to the DOM with [persist] attribute |
|
|
65
65
|
| save-core | 8.9KB | Basic save function only - hyperclay.savePage() |
|
|
66
|
-
| save-system |
|
|
66
|
+
| save-system | 13.4KB | CMD+S, [trigger-save] button, savestatus attribute |
|
|
67
67
|
| save-toast | 0.9KB | Toast notifications for save events |
|
|
68
68
|
| snapshot | 10.8KB | Source of truth for page state - captures DOM snapshots for save and sync |
|
|
69
69
|
| tailwind-inject | 1.4KB | Injects tailwind CSS link with cache-bust on save |
|
|
@@ -132,17 +132,17 @@ import 'hyperclayjs/presets/standard.js';
|
|
|
132
132
|
|
|
133
133
|
## Presets
|
|
134
134
|
|
|
135
|
-
### Minimal (~
|
|
135
|
+
### Minimal (~52.6KB)
|
|
136
136
|
Essential features for basic editing
|
|
137
137
|
|
|
138
138
|
**Modules:** `save-core`, `snapshot`, `save-system`, `edit-mode-helpers`, `toast`, `save-toast`, `export-to-window`, `view-mode-excludes-edit-modules`
|
|
139
139
|
|
|
140
|
-
### Standard (~
|
|
140
|
+
### Standard (~74.9KB)
|
|
141
141
|
Standard feature set for most use cases
|
|
142
142
|
|
|
143
143
|
**Modules:** `save-core`, `snapshot`, `save-system`, `unsaved-warning`, `edit-mode-helpers`, `persist`, `option-visibility`, `event-attrs`, `dom-helpers`, `toast`, `save-toast`, `export-to-window`, `view-mode-excludes-edit-modules`
|
|
144
144
|
|
|
145
|
-
### Everything (~
|
|
145
|
+
### Everything (~208.7KB)
|
|
146
146
|
All available features
|
|
147
147
|
|
|
148
148
|
Includes all available modules across all categories.
|
package/package.json
CHANGED
package/src/core/savePage.js
CHANGED
|
@@ -196,6 +196,57 @@ export function savePage(callback = () => {}) {
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
export function savePageForce(callback = () => {}) {
|
|
200
|
+
if (!isEditMode && !window.hyperclay?.testMode) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (isSaveInProgress()) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const wasOffline = !navigator.onLine;
|
|
209
|
+
if (wasOffline) {
|
|
210
|
+
setOfflineStateQuiet();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
let forSave, forComparison;
|
|
214
|
+
try {
|
|
215
|
+
({ forSave, forComparison } = captureForSaveAndComparison());
|
|
216
|
+
} catch (err) {
|
|
217
|
+
console.error('savePageForce: captureForSaveAndComparison failed', err);
|
|
218
|
+
setSaveState('error', err.message);
|
|
219
|
+
if (typeof callback === 'function') {
|
|
220
|
+
callback({ msg: err.message, msgType: 'error' });
|
|
221
|
+
}
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
setSavingState();
|
|
226
|
+
|
|
227
|
+
saveHtml(forSave, (err, data) => {
|
|
228
|
+
if (!err) {
|
|
229
|
+
lastSavedContents = forComparison;
|
|
230
|
+
unsavedChanges = false;
|
|
231
|
+
setSaveState('saved', data?.msg || 'Saved');
|
|
232
|
+
logBaseline('updated after force save', `${lastSavedContents.length} chars`);
|
|
233
|
+
} else {
|
|
234
|
+
if (!navigator.onLine) {
|
|
235
|
+
setSaveState('offline', err.message);
|
|
236
|
+
} else {
|
|
237
|
+
setSaveState('error', err.message);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (typeof callback === 'function') {
|
|
242
|
+
callback({
|
|
243
|
+
msg: err?.message || data?.msg,
|
|
244
|
+
msgType: err ? 'error' : (data?.msgType || 'success')
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
199
250
|
/**
|
|
200
251
|
* Fetch HTML from a URL and save it, then reload
|
|
201
252
|
* Emits error event if save fails
|
|
@@ -378,6 +429,7 @@ export function init() {
|
|
|
378
429
|
if (!window.__hyperclayNoAutoExport) {
|
|
379
430
|
window.hyperclay = window.hyperclay || {};
|
|
380
431
|
window.hyperclay.savePage = savePage;
|
|
432
|
+
window.hyperclay.savePageForce = savePageForce;
|
|
381
433
|
window.hyperclay.savePageThrottled = savePageThrottled;
|
|
382
434
|
window.hyperclay.beforeSave = beforeSave;
|
|
383
435
|
window.hyperclay.replacePageWith = replacePageWith;
|
package/src/hyperclay.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DO NOT EDIT THIS FILE DIRECTLY — it is generated from build/hyperclay.template.js
|
|
3
3
|
*
|
|
4
|
-
* HyperclayJS v1.19.
|
|
4
|
+
* HyperclayJS v1.19.5 - Minimal Browser-Native Loader
|
|
5
5
|
*
|
|
6
6
|
* Modules auto-init when imported (no separate init call needed).
|
|
7
7
|
* Include `export-to-window` feature to export to window.hyperclay.
|
|
@@ -141,7 +141,8 @@ const PRESETS = {
|
|
|
141
141
|
"behavior-collector",
|
|
142
142
|
"send-message",
|
|
143
143
|
"file-upload",
|
|
144
|
-
"export-to-window"
|
|
144
|
+
"export-to-window",
|
|
145
|
+
"view-mode-excludes-edit-modules"
|
|
145
146
|
]
|
|
146
147
|
},
|
|
147
148
|
"everything": {
|
|
@@ -294,6 +295,7 @@ if (debug) console.log('HyperclayJS: Ready');
|
|
|
294
295
|
// ES module exports - allows destructuring from import()
|
|
295
296
|
export const savePage = window.hyperclayModules['save-core']?.savePage ?? window.hyperclayModules['save-core']?.default;
|
|
296
297
|
export const beforeSave = window.hyperclayModules['save-system']?.beforeSave ?? window.hyperclayModules['save-system']?.default;
|
|
298
|
+
export const savePageForce = window.hyperclayModules['save-system']?.savePageForce ?? window.hyperclayModules['save-system']?.default;
|
|
297
299
|
export const savePageThrottled = window.hyperclayModules['save-system']?.savePageThrottled ?? window.hyperclayModules['save-system']?.default;
|
|
298
300
|
export const replacePageWith = window.hyperclayModules['save-system']?.replacePageWith ?? window.hyperclayModules['save-system']?.default;
|
|
299
301
|
export const captureSnapshot = window.hyperclayModules['snapshot']?.captureSnapshot ?? window.hyperclayModules['snapshot']?.default;
|