@jsenv/core 27.4.0 → 27.5.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.
- package/dist/js/autoreload.js +359 -0
- package/dist/js/execute_using_dynamic_import.js +1 -1
- package/dist/js/html_supervisor_installer.js +221 -73
- package/dist/js/html_supervisor_setup.js +3 -4
- package/dist/js/new_stylesheet.js +26 -58
- package/dist/js/server_events_client.js +307 -0
- package/dist/main.js +7483 -7281
- package/package.json +11 -10
- package/{README.md → readme.md} +8 -9
- package/src/build/build.js +12 -16
- package/src/build/start_build_server.js +24 -28
- package/src/dev/start_dev_server.js +30 -94
- package/src/execute/execute.js +17 -35
- package/src/omega/errors.js +20 -18
- package/src/omega/kitchen.js +7 -6
- package/src/omega/omega_server.js +96 -127
- package/src/omega/server/file_service.js +247 -46
- package/src/omega/url_graph.js +33 -20
- package/src/plugins/autoreload/client/autoreload.js +201 -0
- package/src/plugins/autoreload/{dev_sse/client → client}/autoreload_preference.js +0 -0
- package/src/plugins/autoreload/{dev_sse/client → client}/reload.js +29 -10
- package/src/plugins/autoreload/{dev_sse/client → client}/url_helpers.js +0 -0
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +4 -4
- package/src/plugins/autoreload/{dev_sse/jsenv_plugin_dev_sse_client.js → jsenv_plugin_autoreload_client.js} +8 -8
- package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +196 -0
- package/src/{dev/plugins → plugins}/explorer/client/explorer.html +0 -0
- package/src/{dev/plugins → plugins}/explorer/client/jsenv.png +0 -0
- package/src/{dev/plugins → plugins}/explorer/jsenv_plugin_explorer.js +1 -3
- package/src/plugins/html_supervisor/client/{error_in_document.js → error_overlay.js} +73 -17
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +127 -54
- package/src/plugins/html_supervisor/client/html_supervisor_setup.js +3 -4
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +19 -12
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +97 -117
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +66 -58
- package/src/plugins/plugin_controller.js +102 -67
- package/src/plugins/plugins.js +10 -8
- package/src/{helpers/event_source/event_source.js → plugins/server_events/client/event_source_connection.js} +102 -31
- package/src/plugins/server_events/client/server_events_client.js +17 -0
- package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +48 -0
- package/src/plugins/server_events/server_events_dispatcher.js +69 -0
- package/src/{dev/plugins → plugins}/toolbar/client/animation/toolbar_animation.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/eventsource/eventsource.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/eventsource/toolbar_eventsource.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/execution/execution.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/execution/toolbar_execution.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/focus/focus.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/focus/toolbar_focus.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/jsenv_logo.svg +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/notification/toolbar_notification.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/responsive/overflow_menu.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/responsive/toolbar_responsive.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/settings/settings.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/settings/toolbar_settings.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/theme/jsenv_theme.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/theme/light_theme.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/theme/toolbar_theme.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar.html +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar_injector.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar_main.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar_main.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/tooltip/tooltip.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/tooltip/tooltip.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/animation.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/dom.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/fetch_using_xhr.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/fetching.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/iframe_to_parent_href.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/jsenv_logger.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/preferences.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/responsive.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/util.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/variant/variant.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/jsenv_plugin_toolbar.js +0 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +4 -3
- package/src/plugins/transpilation/babel/new_stylesheet/client/new_stylesheet.js +25 -55
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +44 -24
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +6 -1
- package/src/plugins/url_analysis/html/html_urls.js +8 -8
- package/src/test/execute_plan.js +36 -54
- package/src/test/execute_test_plan.js +2 -2
- package/dist/js/event_source_client.js +0 -549
- package/src/helpers/event_source/sse_service.js +0 -53
- package/src/plugins/autoreload/dev_sse/client/event_source_client.js +0 -193
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js +0 -192
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { createEventSourceConnection } from "@jsenv/core/src/helpers/event_source/event_source.js"
|
|
2
|
-
import { urlHotMetas } from "../../../import_meta_hot/client/import_meta_hot.js"
|
|
3
|
-
import {
|
|
4
|
-
isAutoreloadEnabled,
|
|
5
|
-
setAutoreloadPreference,
|
|
6
|
-
} from "./autoreload_preference.js"
|
|
7
|
-
import { compareTwoUrlPaths } from "./url_helpers.js"
|
|
8
|
-
import {
|
|
9
|
-
reloadHtmlPage,
|
|
10
|
-
reloadDOMNodesUsingUrl,
|
|
11
|
-
reloadJsImport,
|
|
12
|
-
} from "./reload.js"
|
|
13
|
-
|
|
14
|
-
const reloadMessages = []
|
|
15
|
-
const reloadMessagesSignal = { onchange: () => {} }
|
|
16
|
-
let pendingCallbacks = []
|
|
17
|
-
let running = false
|
|
18
|
-
const addToHotQueue = async (callback) => {
|
|
19
|
-
pendingCallbacks.push(callback)
|
|
20
|
-
dequeue()
|
|
21
|
-
}
|
|
22
|
-
const dequeue = async () => {
|
|
23
|
-
if (running) {
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
const callbacks = pendingCallbacks.slice()
|
|
27
|
-
pendingCallbacks = []
|
|
28
|
-
running = true
|
|
29
|
-
try {
|
|
30
|
-
await callbacks.reduce(async (previous, callback) => {
|
|
31
|
-
await previous
|
|
32
|
-
await callback()
|
|
33
|
-
}, Promise.resolve())
|
|
34
|
-
} finally {
|
|
35
|
-
running = false
|
|
36
|
-
if (pendingCallbacks.length) {
|
|
37
|
-
dequeue()
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const applyReloadMessageEffects = async () => {
|
|
43
|
-
const someEffectIsFullReload = reloadMessages.some(
|
|
44
|
-
(reloadMessage) => reloadMessage.type === "full",
|
|
45
|
-
)
|
|
46
|
-
if (someEffectIsFullReload) {
|
|
47
|
-
reloadHtmlPage()
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const onApplied = (reloadMessage) => {
|
|
52
|
-
const index = reloadMessages.indexOf(reloadMessage)
|
|
53
|
-
reloadMessages.splice(index, 1)
|
|
54
|
-
reloadMessagesSignal.onchange()
|
|
55
|
-
}
|
|
56
|
-
const setReloadMessagePromise = (reloadMessage, promise) => {
|
|
57
|
-
reloadMessage.status = "pending"
|
|
58
|
-
promise.then(
|
|
59
|
-
() => {
|
|
60
|
-
onApplied(reloadMessage)
|
|
61
|
-
},
|
|
62
|
-
(e) => {
|
|
63
|
-
// TODO: reuse error display from html supervisor
|
|
64
|
-
console.error(e)
|
|
65
|
-
console.error(
|
|
66
|
-
`[hmr] Failed to reload after ${reloadMessage.reason}.
|
|
67
|
-
This could be due to syntax errors or importing non-existent modules (see errors above)`,
|
|
68
|
-
)
|
|
69
|
-
reloadMessage.status = "failed"
|
|
70
|
-
reloadMessagesSignal.onchange()
|
|
71
|
-
},
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
reloadMessages.forEach((reloadMessage) => {
|
|
75
|
-
if (reloadMessage.type === "hot") {
|
|
76
|
-
const promise = addToHotQueue(() => {
|
|
77
|
-
return applyHotReload(reloadMessage)
|
|
78
|
-
})
|
|
79
|
-
setReloadMessagePromise(reloadMessage, promise)
|
|
80
|
-
} else {
|
|
81
|
-
setReloadMessagePromise(reloadMessage, Promise.resolve())
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
reloadMessagesSignal.onchange() // reload status is "pending"
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const applyHotReload = async ({ hotInstructions }) => {
|
|
88
|
-
await hotInstructions.reduce(
|
|
89
|
-
async (previous, { type, boundary, acceptedBy }) => {
|
|
90
|
-
await previous
|
|
91
|
-
|
|
92
|
-
const urlToFetch = new URL(boundary, `${window.location.origin}/`).href
|
|
93
|
-
const urlHotMeta = urlHotMetas[urlToFetch]
|
|
94
|
-
// TODO: we should return when there is no url hot meta because
|
|
95
|
-
// it means code was not executed (code splitting with dynamic import)
|
|
96
|
-
// if (!urlHotMeta) {return }
|
|
97
|
-
|
|
98
|
-
if (type === "prune") {
|
|
99
|
-
console.groupCollapsed(
|
|
100
|
-
`[jsenv] prune: ${boundary} (inside ${acceptedBy})`,
|
|
101
|
-
)
|
|
102
|
-
} else if (acceptedBy === boundary) {
|
|
103
|
-
console.groupCollapsed(`[jsenv] hot reloading: ${boundary}`)
|
|
104
|
-
} else {
|
|
105
|
-
console.groupCollapsed(
|
|
106
|
-
`[jsenv] hot reloading: ${acceptedBy} inside ${boundary}`,
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
if (urlHotMeta && urlHotMeta.disposeCallback) {
|
|
110
|
-
console.log(`call dispose callback`)
|
|
111
|
-
await urlHotMeta.disposeCallback()
|
|
112
|
-
}
|
|
113
|
-
if (type === "prune") {
|
|
114
|
-
delete urlHotMetas[urlToFetch]
|
|
115
|
-
console.log(`cleanup pruned url`)
|
|
116
|
-
console.groupEnd()
|
|
117
|
-
return null
|
|
118
|
-
}
|
|
119
|
-
if (type === "js_module") {
|
|
120
|
-
console.log(`importing js module`)
|
|
121
|
-
const namespace = await reloadJsImport(urlToFetch)
|
|
122
|
-
if (urlHotMeta && urlHotMeta.acceptCallback) {
|
|
123
|
-
await urlHotMeta.acceptCallback(namespace)
|
|
124
|
-
}
|
|
125
|
-
console.log(`js module import done`)
|
|
126
|
-
console.groupEnd()
|
|
127
|
-
return namespace
|
|
128
|
-
}
|
|
129
|
-
if (type === "html") {
|
|
130
|
-
if (!compareTwoUrlPaths(urlToFetch, window.location.href)) {
|
|
131
|
-
// we are not in that HTML page
|
|
132
|
-
return null
|
|
133
|
-
}
|
|
134
|
-
console.log(`reloading url`)
|
|
135
|
-
const urlToReload = new URL(acceptedBy, `${window.location.origin}/`)
|
|
136
|
-
.href
|
|
137
|
-
reloadDOMNodesUsingUrl(urlToReload)
|
|
138
|
-
console.log(`url reloaded`)
|
|
139
|
-
console.groupEnd()
|
|
140
|
-
return null
|
|
141
|
-
}
|
|
142
|
-
console.warn(`unknown update type: "${type}"`)
|
|
143
|
-
return null
|
|
144
|
-
},
|
|
145
|
-
Promise.resolve(),
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const addReloadMessage = (reloadMessage) => {
|
|
150
|
-
reloadMessages.push(reloadMessage)
|
|
151
|
-
if (isAutoreloadEnabled()) {
|
|
152
|
-
applyReloadMessageEffects()
|
|
153
|
-
} else {
|
|
154
|
-
reloadMessagesSignal.onchange()
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const eventsourceConnection = createEventSourceConnection(
|
|
159
|
-
document.location.href,
|
|
160
|
-
{
|
|
161
|
-
retryMaxAttempt: Infinity,
|
|
162
|
-
retryAllocatedMs: 20 * 1000,
|
|
163
|
-
},
|
|
164
|
-
)
|
|
165
|
-
const { status, connect, addEventCallbacks, disconnect } = eventsourceConnection
|
|
166
|
-
eventsourceConnection.addEventCallbacks({
|
|
167
|
-
reload: ({ data }) => {
|
|
168
|
-
const reloadMessage = JSON.parse(data)
|
|
169
|
-
addReloadMessage(reloadMessage)
|
|
170
|
-
},
|
|
171
|
-
})
|
|
172
|
-
connect()
|
|
173
|
-
window.__jsenv_event_source_client__ = {
|
|
174
|
-
addEventCallbacks,
|
|
175
|
-
status,
|
|
176
|
-
connect,
|
|
177
|
-
disconnect,
|
|
178
|
-
isAutoreloadEnabled,
|
|
179
|
-
setAutoreloadPreference,
|
|
180
|
-
urlHotMetas,
|
|
181
|
-
reloadMessages,
|
|
182
|
-
reloadMessagesSignal,
|
|
183
|
-
applyReloadMessageEffects,
|
|
184
|
-
addReloadMessage,
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// const findHotMetaUrl = (originalFileRelativeUrl) => {
|
|
188
|
-
// return Object.keys(urlHotMetas).find((compileUrl) => {
|
|
189
|
-
// return (
|
|
190
|
-
// parseCompiledUrl(compileUrl).fileRelativeUrl === originalFileRelativeUrl
|
|
191
|
-
// )
|
|
192
|
-
// })
|
|
193
|
-
// }
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { urlToRelativeUrl } from "@jsenv/urls"
|
|
2
|
-
|
|
3
|
-
export const jsenvPluginDevSSEServer = ({
|
|
4
|
-
clientFileChangeCallbackList,
|
|
5
|
-
clientFilesPruneCallbackList,
|
|
6
|
-
}) => {
|
|
7
|
-
return {
|
|
8
|
-
name: "jsenv:sse_server",
|
|
9
|
-
appliesDuring: { dev: true },
|
|
10
|
-
registerServerEvents: (
|
|
11
|
-
{ sendServerEvent },
|
|
12
|
-
{ rootDirectoryUrl, urlGraph },
|
|
13
|
-
) => {
|
|
14
|
-
const notifyDeclined = ({ cause, reason, declinedBy }) => {
|
|
15
|
-
sendServerEvent({
|
|
16
|
-
type: "reload",
|
|
17
|
-
data: {
|
|
18
|
-
cause,
|
|
19
|
-
type: "full",
|
|
20
|
-
typeReason: reason,
|
|
21
|
-
declinedBy,
|
|
22
|
-
},
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
const notifyAccepted = ({ cause, reason, instructions }) => {
|
|
26
|
-
sendServerEvent({
|
|
27
|
-
type: "reload",
|
|
28
|
-
data: {
|
|
29
|
-
cause,
|
|
30
|
-
type: "hot",
|
|
31
|
-
typeReason: reason,
|
|
32
|
-
hotInstructions: instructions,
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
const propagateUpdate = (firstUrlInfo) => {
|
|
37
|
-
const iterate = (urlInfo, seen) => {
|
|
38
|
-
if (urlInfo.data.hotAcceptSelf) {
|
|
39
|
-
return {
|
|
40
|
-
accepted: true,
|
|
41
|
-
reason:
|
|
42
|
-
urlInfo === firstUrlInfo
|
|
43
|
-
? `file accepts hot reload`
|
|
44
|
-
: `a dependent file accepts hot reload`,
|
|
45
|
-
instructions: [
|
|
46
|
-
{
|
|
47
|
-
type: urlInfo.type,
|
|
48
|
-
boundary: urlToRelativeUrl(urlInfo.url, rootDirectoryUrl),
|
|
49
|
-
acceptedBy: urlToRelativeUrl(urlInfo.url, rootDirectoryUrl),
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const { dependents } = urlInfo
|
|
55
|
-
const instructions = []
|
|
56
|
-
for (const dependentUrl of dependents) {
|
|
57
|
-
const dependentUrlInfo = urlGraph.getUrlInfo(dependentUrl)
|
|
58
|
-
if (dependentUrlInfo.data.hotDecline) {
|
|
59
|
-
return {
|
|
60
|
-
declined: true,
|
|
61
|
-
reason: `a dependent file declines hot reload`,
|
|
62
|
-
declinedBy: dependentUrl,
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const { hotAcceptDependencies = [] } = dependentUrlInfo.data
|
|
66
|
-
if (hotAcceptDependencies.includes(urlInfo.url)) {
|
|
67
|
-
instructions.push({
|
|
68
|
-
type: dependentUrlInfo.type,
|
|
69
|
-
boundary: urlToRelativeUrl(dependentUrl, rootDirectoryUrl),
|
|
70
|
-
acceptedBy: urlToRelativeUrl(urlInfo.url, rootDirectoryUrl),
|
|
71
|
-
})
|
|
72
|
-
continue
|
|
73
|
-
}
|
|
74
|
-
if (seen.includes(dependentUrl)) {
|
|
75
|
-
return {
|
|
76
|
-
declined: true,
|
|
77
|
-
reason: "circular dependency",
|
|
78
|
-
declinedBy: urlToRelativeUrl(dependentUrl, rootDirectoryUrl),
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const dependentPropagationResult = iterate(dependentUrlInfo, [
|
|
82
|
-
...seen,
|
|
83
|
-
dependentUrl,
|
|
84
|
-
])
|
|
85
|
-
if (dependentPropagationResult.accepted) {
|
|
86
|
-
instructions.push(...dependentPropagationResult.instructions)
|
|
87
|
-
continue
|
|
88
|
-
}
|
|
89
|
-
if (
|
|
90
|
-
// declined explicitely by an other file, it must decline the whole update
|
|
91
|
-
dependentPropagationResult.declinedBy
|
|
92
|
-
) {
|
|
93
|
-
return dependentPropagationResult
|
|
94
|
-
}
|
|
95
|
-
// declined by absence of boundary, we can keep searching
|
|
96
|
-
continue
|
|
97
|
-
}
|
|
98
|
-
if (instructions.length === 0) {
|
|
99
|
-
return {
|
|
100
|
-
declined: true,
|
|
101
|
-
reason: `there is no file accepting hot reload while propagating update`,
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
accepted: true,
|
|
106
|
-
reason: `${instructions.length} dependent file(s) accepts hot reload`,
|
|
107
|
-
instructions,
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const seen = []
|
|
111
|
-
return iterate(firstUrlInfo, seen)
|
|
112
|
-
}
|
|
113
|
-
clientFileChangeCallbackList.push(({ url, event }) => {
|
|
114
|
-
const urlInfo = urlGraph.getUrlInfo(url)
|
|
115
|
-
// file not part of dependency graph
|
|
116
|
-
if (!urlInfo) {
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
const relativeUrl = urlToRelativeUrl(url, rootDirectoryUrl)
|
|
120
|
-
const hotUpdate = propagateUpdate(urlInfo)
|
|
121
|
-
if (hotUpdate.declined) {
|
|
122
|
-
notifyDeclined({
|
|
123
|
-
cause: `${relativeUrl} ${event}`,
|
|
124
|
-
reason: hotUpdate.reason,
|
|
125
|
-
declinedBy: hotUpdate.declinedBy,
|
|
126
|
-
})
|
|
127
|
-
} else {
|
|
128
|
-
notifyAccepted({
|
|
129
|
-
cause: `${relativeUrl} ${event}`,
|
|
130
|
-
reason: hotUpdate.reason,
|
|
131
|
-
instructions: hotUpdate.instructions,
|
|
132
|
-
})
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
clientFilesPruneCallbackList.push(({ prunedUrlInfos, firstUrlInfo }) => {
|
|
136
|
-
const mainHotUpdate = propagateUpdate(firstUrlInfo)
|
|
137
|
-
const cause = `following files are no longer referenced: ${prunedUrlInfos.map(
|
|
138
|
-
(prunedUrlInfo) =>
|
|
139
|
-
urlToRelativeUrl(prunedUrlInfo.url, rootDirectoryUrl),
|
|
140
|
-
)}`
|
|
141
|
-
// now check if we can hot update the main ressource
|
|
142
|
-
// then if we can hot update all dependencies
|
|
143
|
-
if (mainHotUpdate.declined) {
|
|
144
|
-
notifyDeclined({
|
|
145
|
-
cause,
|
|
146
|
-
reason: mainHotUpdate.reason,
|
|
147
|
-
declinedBy: mainHotUpdate.declinedBy,
|
|
148
|
-
})
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
// main can hot update
|
|
152
|
-
let i = 0
|
|
153
|
-
const instructions = []
|
|
154
|
-
while (i < prunedUrlInfos.length) {
|
|
155
|
-
const prunedUrlInfo = prunedUrlInfos[i++]
|
|
156
|
-
if (prunedUrlInfo.data.hotDecline) {
|
|
157
|
-
notifyDeclined({
|
|
158
|
-
cause,
|
|
159
|
-
reason: `a pruned file declines hot reload`,
|
|
160
|
-
declinedBy: urlToRelativeUrl(prunedUrlInfo.url, rootDirectoryUrl),
|
|
161
|
-
})
|
|
162
|
-
return
|
|
163
|
-
}
|
|
164
|
-
instructions.push({
|
|
165
|
-
type: "prune",
|
|
166
|
-
boundary: urlToRelativeUrl(prunedUrlInfo.url, rootDirectoryUrl),
|
|
167
|
-
acceptedBy: urlToRelativeUrl(firstUrlInfo.url, rootDirectoryUrl),
|
|
168
|
-
})
|
|
169
|
-
}
|
|
170
|
-
notifyAccepted({
|
|
171
|
-
cause,
|
|
172
|
-
reason: mainHotUpdate.reason,
|
|
173
|
-
instructions,
|
|
174
|
-
})
|
|
175
|
-
})
|
|
176
|
-
},
|
|
177
|
-
serve: (request, { rootDirectoryUrl, urlGraph }) => {
|
|
178
|
-
if (request.ressource === "/__graph__") {
|
|
179
|
-
const graphJson = JSON.stringify(urlGraph.toJSON(rootDirectoryUrl))
|
|
180
|
-
return {
|
|
181
|
-
status: 200,
|
|
182
|
-
headers: {
|
|
183
|
-
"content-type": "application/json",
|
|
184
|
-
"content-length": Buffer.byteLength(graphJson),
|
|
185
|
-
},
|
|
186
|
-
body: graphJson,
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return null
|
|
190
|
-
},
|
|
191
|
-
}
|
|
192
|
-
}
|