@absolutejs/absolute 0.15.22 → 0.15.23
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.
|
@@ -18,17 +18,10 @@ import { hmrState } from '../../../../types/client';
|
|
|
18
18
|
export const handleScriptUpdate = (message: {
|
|
19
19
|
data: { framework?: string; scriptPath?: string };
|
|
20
20
|
}) => {
|
|
21
|
-
console.log('[HMR] Received script-update message');
|
|
22
21
|
const scriptFramework = message.data.framework;
|
|
23
22
|
const currentFw = detectCurrentFramework();
|
|
24
23
|
|
|
25
24
|
if (currentFw !== scriptFramework) {
|
|
26
|
-
console.log(
|
|
27
|
-
'[HMR] Skipping script update - different framework:',
|
|
28
|
-
currentFw,
|
|
29
|
-
'vs',
|
|
30
|
-
scriptFramework
|
|
31
|
-
);
|
|
32
25
|
return;
|
|
33
26
|
}
|
|
34
27
|
|
|
@@ -38,8 +31,6 @@ export const handleScriptUpdate = (message: {
|
|
|
38
31
|
return;
|
|
39
32
|
}
|
|
40
33
|
|
|
41
|
-
console.log('[HMR] Hot-reloading script:', scriptPath);
|
|
42
|
-
|
|
43
34
|
const interactiveSelectors =
|
|
44
35
|
'button, [onclick], [onchange], [oninput], details, input, select, textarea';
|
|
45
36
|
document.body.querySelectorAll(interactiveSelectors).forEach(function (el) {
|
|
@@ -59,7 +50,7 @@ export const handleScriptUpdate = (message: {
|
|
|
59
50
|
const cacheBustedPath = scriptPath + '?t=' + Date.now();
|
|
60
51
|
import(/* @vite-ignore */ cacheBustedPath)
|
|
61
52
|
.then(function () {
|
|
62
|
-
|
|
53
|
+
/* script reloaded */
|
|
63
54
|
})
|
|
64
55
|
.catch(function (err: unknown) {
|
|
65
56
|
console.error(
|
|
@@ -75,11 +66,8 @@ export const handleHTMLUpdate = (message: {
|
|
|
75
66
|
html?: string | { body?: string; head?: string } | null;
|
|
76
67
|
};
|
|
77
68
|
}) => {
|
|
78
|
-
console.log('[HMR] Received html-update message');
|
|
79
69
|
const htmlFrameworkCheck = detectCurrentFramework();
|
|
80
|
-
console.log('[HMR] Current framework:', htmlFrameworkCheck);
|
|
81
70
|
if (htmlFrameworkCheck !== 'html') {
|
|
82
|
-
console.log('[HMR] Skipping - not on HTML page');
|
|
83
71
|
return;
|
|
84
72
|
}
|
|
85
73
|
|
|
@@ -99,40 +87,25 @@ export const handleHTMLUpdate = (message: {
|
|
|
99
87
|
htmlBody = message.data.html.body || null;
|
|
100
88
|
htmlHead = message.data.html.head || null;
|
|
101
89
|
}
|
|
102
|
-
console.log('[HMR] htmlBody length:', htmlBody ? htmlBody.length : 'null');
|
|
103
|
-
console.log('[HMR] htmlHead:', htmlHead ? 'present' : 'null');
|
|
104
|
-
|
|
105
90
|
if (htmlBody) {
|
|
106
|
-
console.log('[HMR] Processing htmlBody');
|
|
107
91
|
if (htmlHead) {
|
|
108
|
-
console.log('[HMR] Has htmlHead, patching head elements');
|
|
109
|
-
|
|
110
92
|
const doPatchHead = function () {
|
|
111
93
|
patchHeadInPlace(htmlHead!);
|
|
112
94
|
};
|
|
113
95
|
if (hmrState.isFirstHMRUpdate) {
|
|
114
|
-
console.log(
|
|
115
|
-
'[HMR] First update - adding head patch stabilization delay'
|
|
116
|
-
);
|
|
117
96
|
setTimeout(doPatchHead, 50);
|
|
118
97
|
} else {
|
|
119
98
|
doPatchHead();
|
|
120
99
|
}
|
|
121
100
|
|
|
122
|
-
console.log('[HMR] Processing CSS links');
|
|
123
101
|
const cssResult = processCSSLinks(htmlHead);
|
|
124
102
|
|
|
125
103
|
const updateBodyAfterCSS = function () {
|
|
126
104
|
updateHTMLBody(htmlBody!, htmlDomState, document.body);
|
|
127
105
|
};
|
|
128
106
|
|
|
129
|
-
console.log(
|
|
130
|
-
'[HMR] linksToWaitFor count:',
|
|
131
|
-
cssResult.linksToWaitFor.length
|
|
132
|
-
);
|
|
133
107
|
waitForCSSAndUpdate(cssResult, updateBodyAfterCSS);
|
|
134
108
|
} else {
|
|
135
|
-
console.log('[HMR] No htmlHead, patching body directly');
|
|
136
109
|
const container = document.body;
|
|
137
110
|
if (container) {
|
|
138
111
|
updateHTMLBodyDirect(htmlBody, htmlDomState, container);
|
|
@@ -151,9 +124,7 @@ const updateHTMLBody = (
|
|
|
151
124
|
htmlDomState: ReturnType<typeof saveDOMState>,
|
|
152
125
|
container: HTMLElement
|
|
153
126
|
) => {
|
|
154
|
-
console.log('[HMR] updateBodyAfterCSS called');
|
|
155
127
|
if (!container) {
|
|
156
|
-
console.log('[HMR] ERROR: document.body not found');
|
|
157
128
|
return;
|
|
158
129
|
}
|
|
159
130
|
|
|
@@ -186,7 +157,6 @@ const updateHTMLBody = (
|
|
|
186
157
|
const htmlStructureChanged = didHTMLStructureChange(container, tempDiv);
|
|
187
158
|
|
|
188
159
|
if (!htmlStructureChanged && !scriptsChanged) {
|
|
189
|
-
console.log('[HMR] CSS-only change detected - skipping body patch');
|
|
190
160
|
} else {
|
|
191
161
|
patchDOMInPlace(container, body);
|
|
192
162
|
}
|
|
@@ -48,21 +48,15 @@ export const handleHTMXUpdate = (message: {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
if (htmxHead) {
|
|
51
|
-
console.log('[HMR] Has htmxHead, patching head elements');
|
|
52
|
-
|
|
53
51
|
const doPatchHead = function () {
|
|
54
52
|
patchHeadInPlace(htmxHead!);
|
|
55
53
|
};
|
|
56
54
|
if (hmrState.isFirstHMRUpdate) {
|
|
57
|
-
console.log(
|
|
58
|
-
'[HMR] First update - adding head patch stabilization delay'
|
|
59
|
-
);
|
|
60
55
|
setTimeout(doPatchHead, 50);
|
|
61
56
|
} else {
|
|
62
57
|
doPatchHead();
|
|
63
58
|
}
|
|
64
59
|
|
|
65
|
-
console.log('[HMR] Processing CSS links');
|
|
66
60
|
const cssResult = processCSSLinks(htmxHead);
|
|
67
61
|
|
|
68
62
|
waitForCSSAndUpdate(cssResult, updateHTMXBodyAfterCSS);
|
|
@@ -53,18 +53,15 @@ export const handleSvelteUpdate = (message: {
|
|
|
53
53
|
|
|
54
54
|
/* CSS-only update: hot-swap stylesheet, no remount needed */
|
|
55
55
|
if (message.data.updateType === 'css-only' && message.data.cssUrl) {
|
|
56
|
-
console.log('[HMR] Svelte CSS-only update');
|
|
57
56
|
swapStylesheet(
|
|
58
57
|
message.data.cssUrl,
|
|
59
58
|
message.data.cssBaseName || '',
|
|
60
59
|
'svelte'
|
|
61
60
|
);
|
|
62
|
-
console.log('[HMR] Svelte CSS updated');
|
|
63
61
|
return;
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
/* Component update: preserve state, re-import (bootstrap handles unmount + mount) */
|
|
67
|
-
console.log('[HMR] Svelte update - remounting component');
|
|
68
65
|
|
|
69
66
|
/* Save DOM state and scroll position */
|
|
70
67
|
const domState = saveDOMState(document.body);
|
|
@@ -90,11 +87,6 @@ export const handleSvelteUpdate = (message: {
|
|
|
90
87
|
} catch (_err) {
|
|
91
88
|
/* ignore */
|
|
92
89
|
}
|
|
93
|
-
console.log(
|
|
94
|
-
'[HMR] Svelte state preserved:',
|
|
95
|
-
JSON.stringify(preservedState)
|
|
96
|
-
);
|
|
97
|
-
|
|
98
90
|
/* CSS pre-update: swap stylesheet BEFORE unmounting to prevent FOUC */
|
|
99
91
|
if (message.data.cssUrl) {
|
|
100
92
|
swapStylesheet(
|
|
@@ -120,7 +112,6 @@ export const handleSvelteUpdate = (message: {
|
|
|
120
112
|
.then(function () {
|
|
121
113
|
restoreDOMState(document.body, domState);
|
|
122
114
|
restoreScrollState(scrollState);
|
|
123
|
-
console.log('[HMR] Svelte component updated (state preserved)');
|
|
124
115
|
})
|
|
125
116
|
.catch(function (err: unknown) {
|
|
126
117
|
console.warn('[HMR] Svelte import failed, reloading:', err);
|
|
@@ -69,7 +69,6 @@ export const handleVueUpdate = (message: {
|
|
|
69
69
|
if (vueFrameworkCheck !== 'vue') return;
|
|
70
70
|
|
|
71
71
|
if (message.data.updateType === 'css-only' && message.data.cssUrl) {
|
|
72
|
-
console.log('[HMR] Vue CSS-only update (state preserved)');
|
|
73
72
|
const cssBaseName = message.data.cssBaseName || '';
|
|
74
73
|
let existingLink: HTMLLinkElement | null = null;
|
|
75
74
|
document
|
|
@@ -91,14 +90,12 @@ export const handleVueUpdate = (message: {
|
|
|
91
90
|
if (capturedExisting && capturedExisting.parentNode) {
|
|
92
91
|
capturedExisting.remove();
|
|
93
92
|
}
|
|
94
|
-
console.log('[HMR] Vue CSS updated');
|
|
95
93
|
};
|
|
96
94
|
document.head.appendChild(newLink);
|
|
97
95
|
}
|
|
98
96
|
return;
|
|
99
97
|
}
|
|
100
98
|
|
|
101
|
-
console.log('[HMR] Vue update - remounting component');
|
|
102
99
|
sessionStorage.setItem('__HMR_ACTIVE__', 'true');
|
|
103
100
|
|
|
104
101
|
const vueRoot = document.getElementById('root');
|
|
@@ -165,10 +162,6 @@ export const handleVueUpdate = (message: {
|
|
|
165
162
|
}
|
|
166
163
|
|
|
167
164
|
window.__HMR_PRESERVED_STATE__ = vuePreservedState;
|
|
168
|
-
console.log(
|
|
169
|
-
'[HMR] Vue state preserved:',
|
|
170
|
-
JSON.stringify(vuePreservedState)
|
|
171
|
-
);
|
|
172
165
|
|
|
173
166
|
/* CSS pre-update: swap stylesheet BEFORE unmounting to prevent FOUC */
|
|
174
167
|
if (message.data.cssUrl) {
|
|
@@ -244,7 +237,6 @@ export const handleVueUpdate = (message: {
|
|
|
244
237
|
restoreDOMState(vueRoot, vueDomState);
|
|
245
238
|
}
|
|
246
239
|
sessionStorage.removeItem('__HMR_ACTIVE__');
|
|
247
|
-
console.log('[HMR] Vue updated (state preserved)');
|
|
248
240
|
})
|
|
249
241
|
.catch(function (err: unknown) {
|
|
250
242
|
console.warn('[HMR] Vue import failed:', err);
|
|
@@ -64,7 +64,6 @@ const updateHeadElement = (oldEl: Element, newEl: Element, key: string) => {
|
|
|
64
64
|
if (oldEl.textContent !== newTitle) {
|
|
65
65
|
oldEl.textContent = newTitle;
|
|
66
66
|
document.title = newTitle;
|
|
67
|
-
console.log('[HMR] Updated title to:', newTitle);
|
|
68
67
|
}
|
|
69
68
|
return;
|
|
70
69
|
}
|
|
@@ -74,7 +73,6 @@ const updateHeadElement = (oldEl: Element, newEl: Element, key: string) => {
|
|
|
74
73
|
const oldContent = oldEl.getAttribute('content');
|
|
75
74
|
if (oldContent !== newContent && newContent !== null) {
|
|
76
75
|
oldEl.setAttribute('content', newContent);
|
|
77
|
-
console.log('[HMR] Updated meta', key, 'to:', newContent);
|
|
78
76
|
}
|
|
79
77
|
if (newEl.hasAttribute('charset')) {
|
|
80
78
|
const newCharset = newEl.getAttribute('charset');
|
|
@@ -105,12 +103,10 @@ const updateHeadElement = (oldEl: Element, newEl: Element, key: string) => {
|
|
|
105
103
|
't=' +
|
|
106
104
|
Date.now();
|
|
107
105
|
oldEl.setAttribute('href', cacheBustedHref);
|
|
108
|
-
console.log('[HMR] Updated favicon to:', newBase);
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
108
|
} else if (newHref && oldHref !== newHref) {
|
|
112
109
|
oldEl.setAttribute('href', newHref);
|
|
113
|
-
console.log('[HMR] Updated link', rel, 'to:', newHref);
|
|
114
110
|
}
|
|
115
111
|
|
|
116
112
|
const attrsToCheck = ['type', 'sizes', 'crossorigin', 'as', 'media'];
|
|
@@ -163,7 +159,6 @@ const addHeadElement = (newEl: Element, key: string) => {
|
|
|
163
159
|
} else {
|
|
164
160
|
head.appendChild(clone);
|
|
165
161
|
}
|
|
166
|
-
console.log('[HMR] Added head element:', key);
|
|
167
162
|
};
|
|
168
163
|
|
|
169
164
|
export const patchHeadInPlace = (newHeadHTML: string) => {
|
|
@@ -206,7 +201,6 @@ export const patchHeadInPlace = (newHeadHTML: string) => {
|
|
|
206
201
|
const rel = existingEl.getAttribute('rel') || '';
|
|
207
202
|
if (tag === 'link' && rel === 'stylesheet') return;
|
|
208
203
|
existingEl.remove();
|
|
209
|
-
console.log('[HMR] Removed head element:', key);
|
|
210
204
|
}
|
|
211
205
|
}
|
|
212
206
|
});
|
package/package.json
CHANGED