@absolutejs/absolute 0.19.0-beta.704 → 0.19.0-beta.706
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/dist/angular/browser.js +6 -4
- package/dist/angular/browser.js.map +3 -3
- package/dist/angular/index.js +71 -82
- package/dist/angular/index.js.map +10 -10
- package/dist/angular/server.js +70 -81
- package/dist/angular/server.js.map +10 -10
- package/dist/build.js +152 -84
- package/dist/build.js.map +15 -15
- package/dist/cli/index.js +330 -296
- package/dist/client/index.js +7 -4
- package/dist/client/index.js.map +3 -3
- package/dist/index.js +253 -153
- package/dist/index.js.map +24 -24
- package/dist/islands/index.js +9 -6
- package/dist/islands/index.js.map +5 -5
- package/dist/react/browser.js +7 -7
- package/dist/react/browser.js.map +2 -2
- package/dist/react/components/browser/index.js +101 -101
- package/dist/react/components/index.js +104 -104
- package/dist/react/components/index.js.map +2 -2
- package/dist/react/index.js +77 -88
- package/dist/react/index.js.map +10 -10
- package/dist/react/jsxDevRuntimeCompat.js +1 -6
- package/dist/react/jsxDevRuntimeCompat.js.map +3 -3
- package/dist/react/server.js +57 -71
- package/dist/react/server.js.map +8 -8
- package/dist/src/angular/components/defer-slot-templates.directive.d.ts +0 -7
- package/dist/src/angular/components/defer-slot.component.d.ts +2 -5
- package/dist/src/angular/components/image.component.d.ts +2 -5
- package/dist/src/angular/components/index.d.ts +4 -4
- package/dist/src/angular/components/stream-slot.component.d.ts +0 -3
- package/dist/src/angular/pageHandler.d.ts +6 -1
- package/dist/src/angular/ssrRender.d.ts +1 -1
- package/dist/src/build/buildAngularVendor.d.ts +3 -4
- package/dist/src/constants.d.ts +21 -0
- package/dist/src/core/ssrCache.d.ts +1 -1
- package/dist/src/core/wrapPageHandlerWithStreamingSlots.d.ts +1 -1
- package/dist/src/react/jsxDevRuntimeCompat.d.ts +3 -6
- package/dist/src/react/pageHandler.d.ts +2 -1
- package/dist/src/svelte/pageHandler.d.ts +2 -2
- package/dist/src/utils/defineConfig.d.ts +2 -2
- package/dist/src/utils/imageProcessing.d.ts +1 -1
- package/dist/src/utils/loadConfig.d.ts +38 -2
- package/dist/src/vue/components/Image.d.ts +3 -3
- package/dist/src/vue/components/index.d.ts +1 -1
- package/dist/src/vue/index.d.ts +1 -1
- package/dist/src/vue/pageHandler.d.ts +2 -1
- package/dist/svelte/index.js +52 -58
- package/dist/svelte/index.js.map +10 -10
- package/dist/svelte/server.js +46 -55
- package/dist/svelte/server.js.map +9 -9
- package/dist/vue/components/Image.js +18 -18
- package/dist/vue/components/Image.js.map +3 -3
- package/dist/vue/components/index.js +77 -62
- package/dist/vue/components/index.js.map +5 -5
- package/dist/vue/index.js +137 -142
- package/dist/vue/index.js.map +13 -13
- package/dist/vue/server.js +54 -77
- package/dist/vue/server.js.map +8 -8
- package/package.json +42 -42
- package/dist/angular/components/constants.js +0 -56
- package/dist/angular/components/core/streamingSlotRegistrar.js +0 -58
- package/dist/angular/components/core/streamingSlotRegistry.js +0 -114
- package/dist/angular/components/defer-slot-payload.js +0 -6
- package/dist/angular/components/defer-slot-templates.directive.js +0 -44
- package/dist/angular/components/defer-slot.component.js +0 -149
- package/dist/angular/components/image.component.js +0 -202
- package/dist/angular/components/index.js +0 -4
- package/dist/angular/components/stream-slot.component.js +0 -103
- package/dist/dev/client/constants.ts +0 -26
- package/dist/dev/client/cssUtils.ts +0 -307
- package/dist/dev/client/domDiff.ts +0 -226
- package/dist/dev/client/domState.ts +0 -421
- package/dist/dev/client/domTracker.ts +0 -61
- package/dist/dev/client/errorOverlay.ts +0 -184
- package/dist/dev/client/frameworkDetect.ts +0 -63
- package/dist/dev/client/handlers/angular.ts +0 -551
- package/dist/dev/client/handlers/angularRuntime.ts +0 -206
- package/dist/dev/client/handlers/html.ts +0 -363
- package/dist/dev/client/handlers/htmx.ts +0 -272
- package/dist/dev/client/handlers/react.ts +0 -108
- package/dist/dev/client/handlers/rebuild.ts +0 -153
- package/dist/dev/client/handlers/svelte.ts +0 -332
- package/dist/dev/client/handlers/vue.ts +0 -292
- package/dist/dev/client/headPatch.ts +0 -233
- package/dist/dev/client/hmrClient.ts +0 -251
- package/dist/dev/client/hmrState.ts +0 -14
- package/dist/dev/client/moduleVersions.ts +0 -62
- package/dist/dev/client/reactRefreshSetup.ts +0 -33
- package/dist/src/angular/components/constants.d.ts +0 -53
- package/dist/svelte/components/AwaitSlot.svelte +0 -39
- package/dist/svelte/components/AwaitSlot.svelte.d.ts +0 -2
- package/dist/svelte/components/Head.svelte +0 -144
- package/dist/svelte/components/Head.svelte.d.ts +0 -2
- package/dist/svelte/components/Image.svelte +0 -164
- package/dist/svelte/components/Image.svelte.d.ts +0 -5
- package/dist/svelte/components/Island.svelte +0 -71
- package/dist/svelte/components/Island.svelte.d.ts +0 -5
- package/dist/svelte/components/JsonLd.svelte +0 -21
- package/dist/svelte/components/JsonLd.svelte.d.ts +0 -2
- package/dist/svelte/components/StreamSlot.svelte +0 -41
- package/dist/svelte/components/StreamSlot.svelte.d.ts +0 -2
- package/dist/types/globals.d.ts +0 -121
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import type {} from '../../types/globals';
|
|
2
|
-
/* Head element patching for HMR updates (title, meta, favicon, etc.) */
|
|
3
|
-
|
|
4
|
-
const getLinkElementKey = (elem: Element) => {
|
|
5
|
-
const rel = (elem.getAttribute('rel') || '').toLowerCase();
|
|
6
|
-
if (rel === 'icon' || rel === 'shortcut icon' || rel === 'apple-touch-icon')
|
|
7
|
-
return `link:icon:${rel}`;
|
|
8
|
-
if (rel === 'stylesheet') return null;
|
|
9
|
-
if (rel === 'preconnect')
|
|
10
|
-
return `link:preconnect:${elem.getAttribute('href') || ''}`;
|
|
11
|
-
if (rel === 'preload')
|
|
12
|
-
return `link:preload:${elem.getAttribute('href') || ''}`;
|
|
13
|
-
if (rel === 'canonical') return 'link:canonical';
|
|
14
|
-
if (rel === 'dns-prefetch')
|
|
15
|
-
return `link:dns-prefetch:${elem.getAttribute('href') || ''}`;
|
|
16
|
-
|
|
17
|
-
return null;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const getHeadElementKey = (elem: Element) => {
|
|
21
|
-
const tag = elem.tagName.toLowerCase();
|
|
22
|
-
|
|
23
|
-
if (tag === 'title') return 'title';
|
|
24
|
-
if (tag === 'meta' && elem.hasAttribute('charset')) return 'meta:charset';
|
|
25
|
-
if (tag === 'meta' && elem.hasAttribute('name'))
|
|
26
|
-
return `meta:name:${elem.getAttribute('name')}`;
|
|
27
|
-
if (tag === 'meta' && elem.hasAttribute('property'))
|
|
28
|
-
return `meta:property:${elem.getAttribute('property')}`;
|
|
29
|
-
if (tag === 'meta' && elem.hasAttribute('http-equiv'))
|
|
30
|
-
return `meta:http-equiv:${elem.getAttribute('http-equiv')}`;
|
|
31
|
-
|
|
32
|
-
if (tag === 'link') return getLinkElementKey(elem);
|
|
33
|
-
|
|
34
|
-
if (tag === 'script' && elem.hasAttribute('data-hmr-id'))
|
|
35
|
-
return `script:hmr:${elem.getAttribute('data-hmr-id')}`;
|
|
36
|
-
if (tag === 'script') return null;
|
|
37
|
-
if (tag === 'base') return 'base';
|
|
38
|
-
|
|
39
|
-
return null;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const shouldPreserveElement = (elem: Element) => {
|
|
43
|
-
if (elem.hasAttribute('data-hmr-import-map')) return true;
|
|
44
|
-
if (elem.hasAttribute('data-hmr-client')) return true;
|
|
45
|
-
if (elem.hasAttribute('data-react-refresh-setup')) return true;
|
|
46
|
-
|
|
47
|
-
const attrs = Array.from(elem.attributes);
|
|
48
|
-
for (let idx = 0; idx < attrs.length; idx++) {
|
|
49
|
-
if (attrs[idx]?.name.startsWith('data-hmr-')) return true;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (elem.tagName === 'SCRIPT') {
|
|
53
|
-
const src = elem.getAttribute('src') || '';
|
|
54
|
-
if (src.includes('htmx.min.js') || src.includes('htmx.js')) return true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return false;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const updateTitleElement = (oldEl: Element, newEl: Element) => {
|
|
61
|
-
const newTitle = newEl.textContent || '';
|
|
62
|
-
if (oldEl.textContent === newTitle) return;
|
|
63
|
-
oldEl.textContent = newTitle;
|
|
64
|
-
document.title = newTitle;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const updateMetaElement = (oldEl: Element, newEl: Element) => {
|
|
68
|
-
const newContent = newEl.getAttribute('content');
|
|
69
|
-
const oldContent = oldEl.getAttribute('content');
|
|
70
|
-
if (oldContent !== newContent && newContent !== null) {
|
|
71
|
-
oldEl.setAttribute('content', newContent);
|
|
72
|
-
}
|
|
73
|
-
if (!newEl.hasAttribute('charset')) return;
|
|
74
|
-
const newCharset = newEl.getAttribute('charset');
|
|
75
|
-
if (oldEl.getAttribute('charset') !== newCharset && newCharset !== null) {
|
|
76
|
-
oldEl.setAttribute('charset', newCharset);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const updateFaviconHref = (
|
|
81
|
-
oldEl: Element,
|
|
82
|
-
newHref: string,
|
|
83
|
-
oldHref: string
|
|
84
|
-
) => {
|
|
85
|
-
const [oldBase] = oldHref.split('?');
|
|
86
|
-
const [newBase] = newHref.split('?');
|
|
87
|
-
if (oldBase === newBase) return;
|
|
88
|
-
const cacheBustedHref = `${
|
|
89
|
-
newHref + (newHref.includes('?') ? '&' : '?')
|
|
90
|
-
}t=${Date.now()}`;
|
|
91
|
-
oldEl.setAttribute('href', cacheBustedHref);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const updateLinkElement = (oldEl: Element, newEl: Element) => {
|
|
95
|
-
const rel = (oldEl.getAttribute('rel') || '').toLowerCase();
|
|
96
|
-
const newHref = newEl.getAttribute('href');
|
|
97
|
-
const oldHref = oldEl.getAttribute('href');
|
|
98
|
-
|
|
99
|
-
const isIcon =
|
|
100
|
-
rel === 'icon' || rel === 'shortcut icon' || rel === 'apple-touch-icon';
|
|
101
|
-
|
|
102
|
-
if (isIcon && newHref && oldHref) {
|
|
103
|
-
updateFaviconHref(oldEl, newHref, oldHref);
|
|
104
|
-
} else if (!isIcon && newHref && oldHref !== newHref) {
|
|
105
|
-
oldEl.setAttribute('href', newHref);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const attrsToCheck = ['type', 'sizes', 'crossorigin', 'as', 'media'];
|
|
109
|
-
attrsToCheck.forEach((attr) => {
|
|
110
|
-
const newVal = newEl.getAttribute(attr);
|
|
111
|
-
const oldVal = oldEl.getAttribute(attr);
|
|
112
|
-
if (newVal !== null && oldVal !== newVal) {
|
|
113
|
-
oldEl.setAttribute(attr, newVal);
|
|
114
|
-
} else if (newVal === null && oldVal !== null) {
|
|
115
|
-
oldEl.removeAttribute(attr);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const updateBaseElement = (oldEl: Element, newEl: Element) => {
|
|
121
|
-
const newHref = newEl.getAttribute('href');
|
|
122
|
-
const newTarget = newEl.getAttribute('target');
|
|
123
|
-
if (newHref && oldEl.getAttribute('href') !== newHref) {
|
|
124
|
-
oldEl.setAttribute('href', newHref);
|
|
125
|
-
}
|
|
126
|
-
if (newTarget && oldEl.getAttribute('target') !== newTarget) {
|
|
127
|
-
oldEl.setAttribute('target', newTarget);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const updateHeadElement = (oldEl: Element, newEl: Element) => {
|
|
132
|
-
const tag = oldEl.tagName.toLowerCase();
|
|
133
|
-
|
|
134
|
-
if (tag === 'title') {
|
|
135
|
-
updateTitleElement(oldEl, newEl);
|
|
136
|
-
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (tag === 'meta') {
|
|
141
|
-
updateMetaElement(oldEl, newEl);
|
|
142
|
-
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (tag === 'link') {
|
|
147
|
-
updateLinkElement(oldEl, newEl);
|
|
148
|
-
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (tag === 'base') {
|
|
153
|
-
updateBaseElement(oldEl, newEl);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const addHeadElement = (newEl: Element) => {
|
|
158
|
-
const clone = document.createElement(newEl.tagName.toLowerCase());
|
|
159
|
-
for (const attr of Array.from(newEl.attributes)) {
|
|
160
|
-
clone.setAttribute(attr.name, attr.value);
|
|
161
|
-
}
|
|
162
|
-
clone.textContent = newEl.textContent;
|
|
163
|
-
clone.setAttribute('data-hmr-source', 'patched');
|
|
164
|
-
|
|
165
|
-
const tag = newEl.tagName.toLowerCase();
|
|
166
|
-
const { head } = document;
|
|
167
|
-
let insertBefore: Node | null = null;
|
|
168
|
-
|
|
169
|
-
if (tag === 'title') {
|
|
170
|
-
insertBefore = head.firstChild;
|
|
171
|
-
} else if (tag === 'meta') {
|
|
172
|
-
const firstLink = head.querySelector('link');
|
|
173
|
-
const firstScript = head.querySelector('script');
|
|
174
|
-
insertBefore = firstLink || firstScript;
|
|
175
|
-
} else if (tag === 'link') {
|
|
176
|
-
const firstScript = head.querySelector('script');
|
|
177
|
-
insertBefore = firstScript;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (insertBefore) {
|
|
181
|
-
head.insertBefore(clone, insertBefore);
|
|
182
|
-
} else {
|
|
183
|
-
head.appendChild(clone);
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const removeStaleElement = (existingEl: Element) => {
|
|
188
|
-
if (shouldPreserveElement(existingEl)) return;
|
|
189
|
-
const tag = existingEl.tagName.toLowerCase();
|
|
190
|
-
const rel = existingEl.getAttribute('rel') || '';
|
|
191
|
-
if (tag === 'link' && rel === 'stylesheet') return;
|
|
192
|
-
existingEl.remove();
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
export const patchHeadInPlace = (newHeadHTML: string) => {
|
|
196
|
-
if (!newHeadHTML) return;
|
|
197
|
-
|
|
198
|
-
const tempDiv = document.createElement('div');
|
|
199
|
-
tempDiv.innerHTML = newHeadHTML;
|
|
200
|
-
|
|
201
|
-
const existingMap = new Map<string, Element>();
|
|
202
|
-
const newMap = new Map<string, Element>();
|
|
203
|
-
|
|
204
|
-
Array.from(document.head.children).forEach((elem) => {
|
|
205
|
-
if (shouldPreserveElement(elem)) return;
|
|
206
|
-
const key = getHeadElementKey(elem);
|
|
207
|
-
if (key) {
|
|
208
|
-
existingMap.set(key, elem);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
Array.from(tempDiv.children).forEach((elem) => {
|
|
213
|
-
const key = getHeadElementKey(elem);
|
|
214
|
-
if (key) {
|
|
215
|
-
newMap.set(key, elem);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
newMap.forEach((newEl, key) => {
|
|
220
|
-
const existingEl = existingMap.get(key);
|
|
221
|
-
if (existingEl) {
|
|
222
|
-
updateHeadElement(existingEl, newEl);
|
|
223
|
-
} else {
|
|
224
|
-
addHeadElement(newEl);
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
existingMap.forEach((existingEl, key) => {
|
|
229
|
-
if (!newMap.has(key)) {
|
|
230
|
-
removeStaleElement(existingEl);
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
};
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import type {} from '../../types/globals';
|
|
2
|
-
/* AbsoluteJS HMR Client - Entry point
|
|
3
|
-
Initializes WebSocket connection, dispatches messages to framework handlers */
|
|
4
|
-
|
|
5
|
-
import { hmrState } from './hmrState';
|
|
6
|
-
import {
|
|
7
|
-
HMR_UPDATE_TIMEOUT_MS,
|
|
8
|
-
MAX_RECONNECT_ATTEMPTS,
|
|
9
|
-
PING_INTERVAL_MS,
|
|
10
|
-
RECONNECT_INITIAL_DELAY_MS,
|
|
11
|
-
RECONNECT_POLL_INTERVAL_MS,
|
|
12
|
-
WEBSOCKET_NORMAL_CLOSURE
|
|
13
|
-
} from './constants';
|
|
14
|
-
import { detectCurrentFramework } from './frameworkDetect';
|
|
15
|
-
import { hideErrorOverlay, showErrorOverlay } from './errorOverlay';
|
|
16
|
-
import { handleAngularUpdate } from './handlers/angular';
|
|
17
|
-
import { handleReactUpdate } from './handlers/react';
|
|
18
|
-
import { handleHTMLUpdate, handleScriptUpdate } from './handlers/html';
|
|
19
|
-
import { handleHTMXUpdate } from './handlers/htmx';
|
|
20
|
-
import { handleSvelteUpdate } from './handlers/svelte';
|
|
21
|
-
import { handleVueUpdate } from './handlers/vue';
|
|
22
|
-
import { reloadCSSStylesheets } from './cssUtils';
|
|
23
|
-
import {
|
|
24
|
-
handleFullReload,
|
|
25
|
-
handleManifest,
|
|
26
|
-
handleModuleUpdate,
|
|
27
|
-
handleRebuildComplete,
|
|
28
|
-
handleRebuildError
|
|
29
|
-
} from './handlers/rebuild';
|
|
30
|
-
|
|
31
|
-
// Initialize HMR globals
|
|
32
|
-
if (typeof window !== 'undefined') {
|
|
33
|
-
if (!window.__HMR_MANIFEST__) {
|
|
34
|
-
window.__HMR_MANIFEST__ = {};
|
|
35
|
-
}
|
|
36
|
-
if (!window.__HMR_MODULE_UPDATES__) {
|
|
37
|
-
window.__HMR_MODULE_UPDATES__ = [];
|
|
38
|
-
}
|
|
39
|
-
if (!window.__HMR_MODULE_VERSIONS__) {
|
|
40
|
-
window.__HMR_MODULE_VERSIONS__ = {};
|
|
41
|
-
}
|
|
42
|
-
if (!window.__HMR_SERVER_VERSIONS__) {
|
|
43
|
-
window.__HMR_SERVER_VERSIONS__ = {};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Catch uncaught runtime errors and show the error overlay
|
|
48
|
-
window.addEventListener('error', (evt) => {
|
|
49
|
-
if (!evt.error) return;
|
|
50
|
-
showErrorOverlay({
|
|
51
|
-
framework: detectCurrentFramework() || undefined,
|
|
52
|
-
kind: 'runtime',
|
|
53
|
-
message:
|
|
54
|
-
evt.error instanceof Error
|
|
55
|
-
? evt.error.stack || evt.error.message
|
|
56
|
-
: String(evt.error)
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
window.addEventListener('unhandledrejection', (evt) => {
|
|
61
|
-
if (!evt.reason) return;
|
|
62
|
-
showErrorOverlay({
|
|
63
|
-
framework: detectCurrentFramework() || undefined,
|
|
64
|
-
kind: 'runtime',
|
|
65
|
-
message:
|
|
66
|
-
evt.reason instanceof Error
|
|
67
|
-
? evt.reason.stack || evt.reason.message
|
|
68
|
-
: String(evt.reason)
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const hmrUpdateTypes = new Set([
|
|
73
|
-
'angular-update',
|
|
74
|
-
'react-update',
|
|
75
|
-
'html-update',
|
|
76
|
-
'htmx-update',
|
|
77
|
-
'vue-update',
|
|
78
|
-
'svelte-update',
|
|
79
|
-
'style-update',
|
|
80
|
-
'module-update',
|
|
81
|
-
'rebuild-start'
|
|
82
|
-
]);
|
|
83
|
-
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
-
const handleHMRMessage = (message: any) => {
|
|
86
|
-
if (hmrUpdateTypes.has(message.type)) {
|
|
87
|
-
hmrState.isHMRUpdating = true;
|
|
88
|
-
setTimeout(() => {
|
|
89
|
-
hmrState.isHMRUpdating = false;
|
|
90
|
-
}, HMR_UPDATE_TIMEOUT_MS);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
switch (message.type) {
|
|
94
|
-
case 'manifest':
|
|
95
|
-
handleManifest(message);
|
|
96
|
-
break;
|
|
97
|
-
case 'rebuild-start':
|
|
98
|
-
break;
|
|
99
|
-
case 'rebuild-complete':
|
|
100
|
-
handleRebuildComplete(message);
|
|
101
|
-
break;
|
|
102
|
-
case 'framework-update':
|
|
103
|
-
break;
|
|
104
|
-
case 'module-update':
|
|
105
|
-
hideErrorOverlay();
|
|
106
|
-
handleModuleUpdate(message);
|
|
107
|
-
break;
|
|
108
|
-
case 'react-update':
|
|
109
|
-
handleReactUpdate(message);
|
|
110
|
-
break;
|
|
111
|
-
case 'script-update':
|
|
112
|
-
hideErrorOverlay();
|
|
113
|
-
handleScriptUpdate(message);
|
|
114
|
-
break;
|
|
115
|
-
case 'html-update':
|
|
116
|
-
hideErrorOverlay();
|
|
117
|
-
handleHTMLUpdate(message);
|
|
118
|
-
break;
|
|
119
|
-
case 'htmx-update':
|
|
120
|
-
hideErrorOverlay();
|
|
121
|
-
handleHTMXUpdate(message);
|
|
122
|
-
break;
|
|
123
|
-
case 'svelte-update':
|
|
124
|
-
hideErrorOverlay();
|
|
125
|
-
handleSvelteUpdate(message);
|
|
126
|
-
break;
|
|
127
|
-
case 'vue-update':
|
|
128
|
-
hideErrorOverlay();
|
|
129
|
-
handleVueUpdate(message);
|
|
130
|
-
break;
|
|
131
|
-
case 'angular-update':
|
|
132
|
-
hideErrorOverlay();
|
|
133
|
-
handleAngularUpdate(message);
|
|
134
|
-
break;
|
|
135
|
-
case 'rebuild-error':
|
|
136
|
-
handleRebuildError(message);
|
|
137
|
-
break;
|
|
138
|
-
case 'full-reload':
|
|
139
|
-
handleFullReload();
|
|
140
|
-
break;
|
|
141
|
-
case 'pong':
|
|
142
|
-
break;
|
|
143
|
-
case 'style-update':
|
|
144
|
-
reloadCSSStylesheets(message.data.manifest);
|
|
145
|
-
break;
|
|
146
|
-
default:
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// Prevent multiple WebSocket connections
|
|
152
|
-
if (!(window.__HMR_WS__ && window.__HMR_WS__.readyState === WebSocket.OPEN)) {
|
|
153
|
-
// Determine WebSocket URL
|
|
154
|
-
const wsHost = location.hostname;
|
|
155
|
-
const wsPort =
|
|
156
|
-
location.port || (location.protocol === 'https:' ? '443' : '80');
|
|
157
|
-
const wsProtocol = location.protocol === 'https:' ? 'wss' : 'ws';
|
|
158
|
-
const wsUrl = `${wsProtocol}://${wsHost}:${wsPort}/hmr`;
|
|
159
|
-
|
|
160
|
-
const wsc = new WebSocket(wsUrl);
|
|
161
|
-
window.__HMR_WS__ = wsc;
|
|
162
|
-
|
|
163
|
-
wsc.onopen = function () {
|
|
164
|
-
hmrState.isConnected = true;
|
|
165
|
-
sessionStorage.setItem('__HMR_CONNECTED__', 'true');
|
|
166
|
-
|
|
167
|
-
const currentFramework = detectCurrentFramework();
|
|
168
|
-
wsc.send(
|
|
169
|
-
JSON.stringify({
|
|
170
|
-
framework: currentFramework,
|
|
171
|
-
type: 'ready'
|
|
172
|
-
})
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
if (hmrState.reconnectTimeout) {
|
|
176
|
-
clearTimeout(hmrState.reconnectTimeout);
|
|
177
|
-
hmrState.reconnectTimeout = null;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
hmrState.pingInterval = setInterval(() => {
|
|
181
|
-
if (wsc.readyState === WebSocket.OPEN && hmrState.isConnected) {
|
|
182
|
-
wsc.send(JSON.stringify({ type: 'ping' }));
|
|
183
|
-
}
|
|
184
|
-
}, PING_INTERVAL_MS);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
wsc.onmessage = function (event: MessageEvent) {
|
|
188
|
-
let message;
|
|
189
|
-
try {
|
|
190
|
-
message = JSON.parse(event.data);
|
|
191
|
-
} catch {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
handleHMRMessage(message);
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
wsc.onclose = function (event: CloseEvent) {
|
|
199
|
-
hmrState.isConnected = false;
|
|
200
|
-
|
|
201
|
-
if (hmrState.pingInterval) {
|
|
202
|
-
clearInterval(hmrState.pingInterval);
|
|
203
|
-
hmrState.pingInterval = null;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (event.code !== WEBSOCKET_NORMAL_CLOSURE) {
|
|
207
|
-
let attempts = 0;
|
|
208
|
-
hmrState.reconnectTimeout = setTimeout(function pollServer() {
|
|
209
|
-
attempts++;
|
|
210
|
-
if (attempts > MAX_RECONNECT_ATTEMPTS) return;
|
|
211
|
-
|
|
212
|
-
fetch('/hmr-status', { cache: 'no-store' })
|
|
213
|
-
.then((res) => {
|
|
214
|
-
if (res.ok) {
|
|
215
|
-
window.location.reload();
|
|
216
|
-
} else {
|
|
217
|
-
hmrState.reconnectTimeout = setTimeout(
|
|
218
|
-
pollServer,
|
|
219
|
-
RECONNECT_POLL_INTERVAL_MS
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return undefined;
|
|
224
|
-
})
|
|
225
|
-
.catch(() => {
|
|
226
|
-
hmrState.reconnectTimeout = setTimeout(
|
|
227
|
-
pollServer,
|
|
228
|
-
RECONNECT_POLL_INTERVAL_MS
|
|
229
|
-
);
|
|
230
|
-
});
|
|
231
|
-
}, RECONNECT_INITIAL_DELAY_MS);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
wsc.onerror = function () {
|
|
236
|
-
hmrState.isConnected = false;
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
window.addEventListener('beforeunload', () => {
|
|
240
|
-
if (hmrState.isHMRUpdating) {
|
|
241
|
-
if (hmrState.pingInterval) clearInterval(hmrState.pingInterval);
|
|
242
|
-
if (hmrState.reconnectTimeout)
|
|
243
|
-
clearTimeout(hmrState.reconnectTimeout);
|
|
244
|
-
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (hmrState.pingInterval) clearInterval(hmrState.pingInterval);
|
|
249
|
-
if (hmrState.reconnectTimeout) clearTimeout(hmrState.reconnectTimeout);
|
|
250
|
-
});
|
|
251
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type {} from '../../types/globals';
|
|
2
|
-
export const hmrState: {
|
|
3
|
-
isConnected: boolean;
|
|
4
|
-
isFirstHMRUpdate: boolean;
|
|
5
|
-
isHMRUpdating: boolean;
|
|
6
|
-
pingInterval: ReturnType<typeof setInterval> | null;
|
|
7
|
-
reconnectTimeout: ReturnType<typeof setTimeout> | null;
|
|
8
|
-
} = {
|
|
9
|
-
isConnected: false,
|
|
10
|
-
isFirstHMRUpdate: true,
|
|
11
|
-
isHMRUpdating: false,
|
|
12
|
-
pingInterval: null,
|
|
13
|
-
reconnectTimeout: null
|
|
14
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type {} from '../../types/globals';
|
|
2
|
-
/* Module version validation and sync */
|
|
3
|
-
|
|
4
|
-
export const checkModuleVersions = (
|
|
5
|
-
serverVersions: Record<string, number> | undefined,
|
|
6
|
-
clientVersions: Record<string, number> | undefined
|
|
7
|
-
) => {
|
|
8
|
-
if (!serverVersions || !clientVersions) {
|
|
9
|
-
return { needsSync: false, stale: [] };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const stale = Object.entries(serverVersions)
|
|
13
|
-
.filter(([modulePath, serverVersion]) => {
|
|
14
|
-
const clientVersion = clientVersions[modulePath];
|
|
15
|
-
|
|
16
|
-
return clientVersion === undefined || clientVersion < serverVersion;
|
|
17
|
-
})
|
|
18
|
-
.map(([modulePath]) => modulePath);
|
|
19
|
-
|
|
20
|
-
return { needsSync: stale.length > 0, stale };
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const resolveManifestPath = (
|
|
24
|
-
modulePath: string,
|
|
25
|
-
manifest: Record<string, string> | undefined
|
|
26
|
-
) => {
|
|
27
|
-
if (!manifest) {
|
|
28
|
-
return modulePath;
|
|
29
|
-
}
|
|
30
|
-
for (const key of Object.keys(manifest)) {
|
|
31
|
-
const path = manifest[key] ?? modulePath;
|
|
32
|
-
if (path === modulePath || path.includes(modulePath)) {
|
|
33
|
-
return path;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return modulePath;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const prefetchModules = (
|
|
41
|
-
modulePaths: string[],
|
|
42
|
-
manifest: Record<string, string> | undefined
|
|
43
|
-
) => {
|
|
44
|
-
const prefetchPromises: Promise<unknown>[] = [];
|
|
45
|
-
|
|
46
|
-
for (const modulePath of modulePaths) {
|
|
47
|
-
const manifestPath = resolveManifestPath(modulePath, manifest);
|
|
48
|
-
|
|
49
|
-
const cacheBuster = `?t=${Date.now()}`;
|
|
50
|
-
const fullPath = manifestPath.startsWith('/')
|
|
51
|
-
? manifestPath + cacheBuster
|
|
52
|
-
: `/${manifestPath}${cacheBuster}`;
|
|
53
|
-
|
|
54
|
-
prefetchPromises.push(
|
|
55
|
-
import(fullPath).catch(() => {
|
|
56
|
-
/* ignore */
|
|
57
|
-
})
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return Promise.all(prefetchPromises);
|
|
62
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type {} from '../../types/globals';
|
|
2
|
-
/* React Refresh runtime setup — must be imported before any component modules.
|
|
3
|
-
Bun's reactFastRefresh flag injects $RefreshSig$/$RefreshReg$ calls into
|
|
4
|
-
component code. This module ensures those globals exist before components
|
|
5
|
-
initialize.
|
|
6
|
-
|
|
7
|
-
IMPORTANT: This module is idempotent. On HMR re-import the existing runtime
|
|
8
|
-
is preserved so new component registrations feed into the SAME RefreshRuntime
|
|
9
|
-
instance that owns the current React tree. */
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
12
|
-
// @ts-ignore — react-refresh has no type declarations
|
|
13
|
-
import RefreshRuntime from 'react-refresh/runtime';
|
|
14
|
-
|
|
15
|
-
if (!window.$RefreshRuntime$) {
|
|
16
|
-
RefreshRuntime.injectIntoGlobalHook(window);
|
|
17
|
-
window.$RefreshRuntime$ = RefreshRuntime;
|
|
18
|
-
window.$RefreshReg$ = (type: unknown, id: string) =>
|
|
19
|
-
RefreshRuntime.register(type, id);
|
|
20
|
-
window.$RefreshSig$ = () =>
|
|
21
|
-
RefreshRuntime.createSignatureFunctionForTransform();
|
|
22
|
-
|
|
23
|
-
// Replay buffered registrations from the bootstrap script.
|
|
24
|
-
// The SSR HTML injects a buffering $RefreshReg$ that captures
|
|
25
|
-
// registrations before the runtime is ready.
|
|
26
|
-
const buffer = window.__REFRESH_BUFFER__;
|
|
27
|
-
if (buffer) {
|
|
28
|
-
for (const [type, id] of buffer) {
|
|
29
|
-
RefreshRuntime.register(type, id);
|
|
30
|
-
}
|
|
31
|
-
window.__REFRESH_BUFFER__ = undefined;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export declare const ANGULAR_INIT_TIMEOUT_MS = 500;
|
|
2
|
-
export declare const ANSI_ESCAPE_LENGTH = 3;
|
|
3
|
-
export declare const ASCII_SPACE = 32;
|
|
4
|
-
export declare const BASE_36_RADIX = 36;
|
|
5
|
-
export declare const BUN_BUILD_WARNING_SUPPRESSION = "wildcard sideEffects are not supported yet";
|
|
6
|
-
export declare const BODY_SLICE_LENGTH = 2000;
|
|
7
|
-
export declare const BYTES_PER_KILOBYTE = 1024;
|
|
8
|
-
export declare const CLI_ARGS_OFFSET = 3;
|
|
9
|
-
export declare const CSS_ERROR_RESOLVE_DELAY_MS = 50;
|
|
10
|
-
export declare const CSS_MAX_CHECK_ATTEMPTS = 10;
|
|
11
|
-
export declare const CSS_MAX_PARSE_TIMEOUT_MS = 500;
|
|
12
|
-
export declare const CSS_SHEET_READY_TIMEOUT_MS = 100;
|
|
13
|
-
export declare const DEFAULT_CHUNK_SIZE = 16384;
|
|
14
|
-
export declare const DEFAULT_DEBOUNCE_MS = 15;
|
|
15
|
-
export declare const DEFAULT_PORT = 3000;
|
|
16
|
-
export declare const DEV_SERVER_RESTART_DEBOUNCE_MS = 100;
|
|
17
|
-
export declare const DOM_UPDATE_DELAY_MS = 50;
|
|
18
|
-
export declare const FILE_PROTOCOL_PREFIX_LENGTH = 7;
|
|
19
|
-
export declare const FOCUS_ID_PREFIX_LENGTH = 3;
|
|
20
|
-
export declare const FOCUS_IDX_PREFIX_LENGTH = 4;
|
|
21
|
-
export declare const FOCUS_NAME_PREFIX_LENGTH = 5;
|
|
22
|
-
export declare const HMR_UPDATE_TIMEOUT_MS = 2000;
|
|
23
|
-
export declare const HOOK_SIGNATURE_LENGTH = 12;
|
|
24
|
-
export declare const EXCLUDE_LAST_OFFSET = -1;
|
|
25
|
-
export declare const HTTP_STATUS_OK = 200;
|
|
26
|
-
export declare const HTTP_STATUS_BAD_REQUEST = 400;
|
|
27
|
-
export declare const HTTP_STATUS_NOT_FOUND = 404;
|
|
28
|
-
export declare const HOURS_IN_DAY = 24;
|
|
29
|
-
export declare const HOURS_IN_HALF_DAY = 12;
|
|
30
|
-
export declare const MAX_ERROR_LENGTH = 200;
|
|
31
|
-
export declare const MAX_RECONNECT_ATTEMPTS = 60;
|
|
32
|
-
export declare const MILLISECONDS_IN_A_SECOND = 1000;
|
|
33
|
-
export declare const MINUTES_IN_AN_HOUR = 60;
|
|
34
|
-
export declare const SECONDS_IN_A_MINUTE = 60;
|
|
35
|
-
export declare const MILLISECONDS_IN_A_MINUTE: number;
|
|
36
|
-
export declare const MILLISECONDS_IN_A_DAY: number;
|
|
37
|
-
export declare const OVERLAY_FADE_DURATION_MS = 150;
|
|
38
|
-
export declare const PING_INTERVAL_MS = 30000;
|
|
39
|
-
export declare const RAF_BATCH_COUNT = 3;
|
|
40
|
-
export declare const RANDOM_ID_END_INDEX = 11;
|
|
41
|
-
export declare const REBUILD_BATCH_DELAY_MS = 10;
|
|
42
|
-
export declare const REBUILD_RELOAD_DELAY_MS = 200;
|
|
43
|
-
export declare const RECONNECT_INITIAL_DELAY_MS = 500;
|
|
44
|
-
export declare const RECONNECT_POLL_INTERVAL_MS = 300;
|
|
45
|
-
export declare const REACT_STREAM_SLOT_FAST_DELAY_MS = 5;
|
|
46
|
-
export declare const REACT_STREAM_SLOT_SLOW_DELAY_MS = 20;
|
|
47
|
-
export declare const SIGINT_EXIT_CODE = 130;
|
|
48
|
-
export declare const SIGTERM_EXIT_CODE = 143;
|
|
49
|
-
export declare const SVELTE_CSS_LOAD_TIMEOUT_MS = 500;
|
|
50
|
-
export declare const TIME_PRECISION = 2;
|
|
51
|
-
export declare const TWO_THIRDS: number;
|
|
52
|
-
export declare const UNFOUND_INDEX = -1;
|
|
53
|
-
export declare const WEBSOCKET_NORMAL_CLOSURE = 1000;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import StreamSlot from './StreamSlot.svelte';
|
|
3
|
-
|
|
4
|
-
type Resolver = () => Promise<string> | string;
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
className,
|
|
8
|
-
errorHtml,
|
|
9
|
-
fallbackHtml = '',
|
|
10
|
-
id,
|
|
11
|
-
promise,
|
|
12
|
-
resolve,
|
|
13
|
-
timeoutMs
|
|
14
|
-
}: {
|
|
15
|
-
className?: string;
|
|
16
|
-
errorHtml?: string;
|
|
17
|
-
fallbackHtml?: string;
|
|
18
|
-
id: string;
|
|
19
|
-
promise?: Promise<string>;
|
|
20
|
-
resolve?: Resolver;
|
|
21
|
-
timeoutMs?: number;
|
|
22
|
-
} = $props();
|
|
23
|
-
|
|
24
|
-
const slotResolver = () => {
|
|
25
|
-
if (resolve) return resolve();
|
|
26
|
-
if (promise) return promise;
|
|
27
|
-
|
|
28
|
-
return '';
|
|
29
|
-
};
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
<StreamSlot
|
|
33
|
-
{className}
|
|
34
|
-
{errorHtml}
|
|
35
|
-
{fallbackHtml}
|
|
36
|
-
{id}
|
|
37
|
-
resolve={slotResolver}
|
|
38
|
-
{timeoutMs}
|
|
39
|
-
/>
|