hyperclayjs 1.19.2 → 1.19.4
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 +51 -0
- package/src/hyperclay.js +9 -1
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
|
package/src/hyperclay.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* DO NOT EDIT THIS FILE DIRECTLY — it is generated from build/hyperclay.template.js
|
|
3
|
+
*
|
|
4
|
+
* HyperclayJS v1.19.4 - Minimal Browser-Native Loader
|
|
3
5
|
*
|
|
4
6
|
* Modules auto-init when imported (no separate init call needed).
|
|
5
7
|
* Include `export-to-window` feature to export to window.hyperclay.
|
|
@@ -226,6 +228,11 @@ if (preset && PRESETS[preset]) {
|
|
|
226
228
|
requested = [...PRESETS.minimal.modules];
|
|
227
229
|
}
|
|
228
230
|
|
|
231
|
+
if (preset && features) {
|
|
232
|
+
const extras = features.split(',').map(f => f.trim());
|
|
233
|
+
extras.forEach(f => { if (!requested.includes(f)) requested.push(f); });
|
|
234
|
+
}
|
|
235
|
+
|
|
229
236
|
// Apply exclusions
|
|
230
237
|
if (exclude) {
|
|
231
238
|
const excluded = new Set(exclude.split(',').map(f => f.trim()));
|
|
@@ -287,6 +294,7 @@ if (debug) console.log('HyperclayJS: Ready');
|
|
|
287
294
|
// ES module exports - allows destructuring from import()
|
|
288
295
|
export const savePage = window.hyperclayModules['save-core']?.savePage ?? window.hyperclayModules['save-core']?.default;
|
|
289
296
|
export const beforeSave = window.hyperclayModules['save-system']?.beforeSave ?? window.hyperclayModules['save-system']?.default;
|
|
297
|
+
export const savePageForce = window.hyperclayModules['save-system']?.savePageForce ?? window.hyperclayModules['save-system']?.default;
|
|
290
298
|
export const savePageThrottled = window.hyperclayModules['save-system']?.savePageThrottled ?? window.hyperclayModules['save-system']?.default;
|
|
291
299
|
export const replacePageWith = window.hyperclayModules['save-system']?.replacePageWith ?? window.hyperclayModules['save-system']?.default;
|
|
292
300
|
export const captureSnapshot = window.hyperclayModules['snapshot']?.captureSnapshot ?? window.hyperclayModules['snapshot']?.default;
|