@absolutejs/absolute 0.17.13 → 0.17.15-beta.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.
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"src/dev/client/handlers/angularRuntime.ts": "2953p2hoftx5u",
|
|
62
62
|
"src/dev/client/handlers/vue.ts": "1q7sk9jnhk8gc",
|
|
63
63
|
"src/dev/client/handlers/htmx.ts": "3njirexjzjfbd",
|
|
64
|
-
"src/dev/client/handlers/svelte.ts": "
|
|
64
|
+
"src/dev/client/handlers/svelte.ts": "3egd9ql8o82ko",
|
|
65
65
|
"src/utils/escapeScriptContent.ts": "1gg8nciaxrh5v",
|
|
66
66
|
"src/utils/logger.ts": "2bxszbbyp39u9",
|
|
67
67
|
"src/utils/ssrErrorPage.ts": "2oxyhfys2xq0i",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"example/angular/compiled/mm51rigw/components/counter.component.js": "26dxmwf0w68tf",
|
|
134
134
|
"eslint.config.mjs": "3jvlmsyhtijzc",
|
|
135
135
|
"tsconfig.json": "7ocytjowy50m",
|
|
136
|
-
"package.json": "
|
|
136
|
+
"package.json": "1m3pid2yuj5bw",
|
|
137
137
|
"tsconfig.build.json": "976e92rva922",
|
|
138
138
|
"example/svelte/pages/SvelteExample.svelte": "1um210xkshf8o",
|
|
139
139
|
"example/svelte/components/Counter.svelte": "1p92uo1pko0wo",
|
|
@@ -107,29 +107,88 @@ export const handleSvelteUpdate = (message: {
|
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
/* Preserve
|
|
111
|
-
Svelte removes <svelte:head> content (including
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
110
|
+
/* Preserve styles as inline <style> elements so they survive the
|
|
111
|
+
unmount/mount cycle. Svelte removes <svelte:head> content (including
|
|
112
|
+
<link> tags) on unmount. Inline styles apply synchronously — unlike
|
|
113
|
+
cloned <link> tags which need to re-fetch even from cache. */
|
|
114
|
+
const preservedStyles: HTMLStyleElement[] = [];
|
|
115
|
+
document
|
|
116
|
+
.querySelectorAll<HTMLLinkElement>('head link[rel="stylesheet"]')
|
|
117
|
+
.forEach(function (link) {
|
|
118
|
+
try {
|
|
119
|
+
const sheet = link.sheet;
|
|
120
|
+
if (sheet && sheet.cssRules.length > 0) {
|
|
121
|
+
const style = document.createElement('style');
|
|
122
|
+
style.dataset.hmrPreserved = 'true';
|
|
123
|
+
let rules = '';
|
|
124
|
+
for (let idx = 0; idx < sheet.cssRules.length; idx++) {
|
|
125
|
+
rules += sheet.cssRules[idx]!.cssText + '\n';
|
|
126
|
+
}
|
|
127
|
+
style.textContent = rules;
|
|
128
|
+
document.head.appendChild(style);
|
|
129
|
+
preservedStyles.push(style);
|
|
130
|
+
}
|
|
131
|
+
} catch (_err) {
|
|
132
|
+
/* Cross-origin sheets (e.g. Google Fonts) — clone as fallback */
|
|
133
|
+
const clone = link.cloneNode(true) as HTMLLinkElement;
|
|
134
|
+
clone.dataset.hmrPreserved = 'true';
|
|
135
|
+
document.head.appendChild(clone);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
/* Also preserve Svelte injected <style> tags (css: 'injected' mode) */
|
|
140
|
+
document
|
|
141
|
+
.querySelectorAll<HTMLStyleElement>(
|
|
142
|
+
'head style:not([data-hmr-preserved])'
|
|
143
|
+
)
|
|
144
|
+
.forEach(function (style) {
|
|
145
|
+
const clone = document.createElement('style');
|
|
146
|
+
clone.dataset.hmrPreserved = 'true';
|
|
147
|
+
clone.textContent = style.textContent;
|
|
148
|
+
document.head.appendChild(clone);
|
|
149
|
+
});
|
|
121
150
|
|
|
122
151
|
const modulePath = indexPath + '?t=' + Date.now();
|
|
123
152
|
import(/* @vite-ignore */ modulePath)
|
|
124
153
|
.then(function () {
|
|
125
|
-
/*
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
154
|
+
/* Wait for new <link> stylesheets (re-added by svelte:head in mount)
|
|
155
|
+
to fully load before removing preserved styles. Without this,
|
|
156
|
+
removing inline preserved styles leaves a gap until <link> loads. */
|
|
157
|
+
const newLinks = document.querySelectorAll<HTMLLinkElement>(
|
|
158
|
+
'head link[rel="stylesheet"]:not([data-hmr-preserved])'
|
|
159
|
+
);
|
|
160
|
+
const loadPromises: Promise<void>[] = [];
|
|
161
|
+
newLinks.forEach(function (link) {
|
|
162
|
+
if (!link.sheet || link.sheet.cssRules.length === 0) {
|
|
163
|
+
loadPromises.push(
|
|
164
|
+
new Promise<void>(function (resolve) {
|
|
165
|
+
link.onload = function () {
|
|
166
|
+
resolve();
|
|
167
|
+
};
|
|
168
|
+
link.onerror = function () {
|
|
169
|
+
resolve();
|
|
170
|
+
};
|
|
171
|
+
setTimeout(resolve, 500);
|
|
172
|
+
})
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const cleanup = function () {
|
|
178
|
+
document
|
|
179
|
+
.querySelectorAll('[data-hmr-preserved="true"]')
|
|
180
|
+
.forEach(function (element) {
|
|
181
|
+
element.remove();
|
|
182
|
+
});
|
|
183
|
+
restoreDOMState(document.body, domState);
|
|
184
|
+
restoreScrollState(scrollState);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
if (loadPromises.length > 0) {
|
|
188
|
+
Promise.all(loadPromises).then(cleanup);
|
|
189
|
+
} else {
|
|
190
|
+
cleanup();
|
|
191
|
+
}
|
|
133
192
|
})
|
|
134
193
|
.catch(function (err: unknown) {
|
|
135
194
|
console.warn('[HMR] Svelte import failed, reloading:', err);
|
package/package.json
CHANGED