@jsenv/plugin-toolbar 0.1.14 → 1.0.1
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 +3 -0
- package/dist/js/toolbar_core.js +17 -17
- package/dist/js/toolbar_injector.js +1 -46
- package/dist/jsenv_plugin_toolbar.js +1 -3
- package/package.json +2 -2
- package/src/client/core/animation_actions.js +5 -5
- package/src/client/core/animation_effects.js +6 -6
- package/src/client/core/animation_signals.js +4 -4
- package/src/client/core/changes_actions.js +5 -5
- package/src/client/core/changes_signals.js +2 -2
- package/src/client/core/execution_actions.js +16 -16
- package/src/client/core/execution_effects.js +10 -10
- package/src/client/core/execution_signals.js +6 -6
- package/src/client/core/notification_actions.js +31 -31
- package/src/client/core/notification_context.js +2 -1
- package/src/client/core/notification_effects.js +6 -6
- package/src/client/core/notification_signals.js +5 -5
- package/src/client/core/parent_window_actions.js +18 -18
- package/src/client/core/parent_window_context.js +5 -5
- package/src/client/core/parent_window_effects.js +9 -9
- package/src/client/core/parent_window_signals.js +17 -17
- package/src/client/core/server_actions.js +5 -5
- package/src/client/core/server_effects.js +6 -6
- package/src/client/core/server_signals.js +7 -7
- package/src/client/core/settings_actions.js +5 -5
- package/src/client/core/settings_signals.js +2 -2
- package/src/client/core/theme_actions.js +5 -5
- package/src/client/core/theme_effects.js +5 -5
- package/src/client/core/theme_signals.js +4 -4
- package/src/client/core/toolbar_logger.js +8 -8
- package/src/client/core/toolbar_open_actions.js +5 -5
- package/src/client/core/toolbar_open_effects.js +4 -4
- package/src/client/core/toolbar_open_signals.js +4 -4
- package/src/client/core/toolbar_state_context.js +1 -1
- package/src/client/core/toolbar_state_effects.js +7 -7
- package/src/client/core/toolbar_state_signals.js +11 -11
- package/src/client/core/tooltip_actions.js +5 -5
- package/src/client/toolbar_core.js +8 -8
- package/src/client/toolbar_injector.js +97 -97
- package/src/client/ui/changes_indicator/changes_indicator.js +33 -33
- package/src/client/ui/document_execution_indicator/document_execution_indicator.js +28 -28
- package/src/client/ui/document_index_link/document_index_link.js +3 -3
- package/src/client/ui/server_indicator/server_indicator.js +30 -30
- package/src/client/ui/toolbar_close_button/toolbar_close_button.js +6 -6
- package/src/client/ui/toolbar_menu_overflow/toolbar_menu_overflow.js +50 -50
- package/src/client/ui/toolbar_opening/toolbar_opening.js +35 -35
- package/src/client/ui/toolbar_overlay/toolbar_overlay.js +36 -36
- package/src/client/ui/toolbar_settings/toolbar_animation_setting.js +13 -13
- package/src/client/ui/toolbar_settings/toolbar_autoreload_setting.js +19 -19
- package/src/client/ui/toolbar_settings/toolbar_notification_setting.js +47 -47
- package/src/client/ui/toolbar_settings/toolbar_settings.js +29 -29
- package/src/client/ui/toolbar_settings/toolbar_theme_setting.js +8 -8
- package/src/client/ui/toolbar_ui.js +19 -19
- package/src/client/ui/util/animation.js +116 -116
- package/src/client/ui/util/dom.js +29 -29
- package/src/client/ui/util/fetch_using_xhr.js +184 -184
- package/src/client/ui/util/fetching.js +6 -6
- package/src/client/ui/util/iframe_to_parent_href.js +6 -6
- package/src/client/ui/util/responsive.js +48 -48
- package/src/client/ui/util/util.js +13 -13
- package/src/client/ui/variant.js +27 -27
- package/src/jsenv_plugin_toolbar.js +17 -17
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const jsenvLogoSvgUrl = new URL("./ui/jsenv_logo.svg", import.meta.url)
|
|
1
|
+
const jsenvLogoSvgUrl = new URL("./ui/jsenv_logo.svg", import.meta.url);
|
|
2
2
|
|
|
3
3
|
export const injectToolbar = async ({
|
|
4
4
|
toolbarUrl,
|
|
@@ -11,21 +11,21 @@ export const injectToolbar = async ({
|
|
|
11
11
|
}) => {
|
|
12
12
|
if (document.readyState !== "complete") {
|
|
13
13
|
await new Promise((resolve) => {
|
|
14
|
-
window.addEventListener("load", resolve)
|
|
15
|
-
})
|
|
14
|
+
window.addEventListener("load", resolve);
|
|
15
|
+
});
|
|
16
16
|
}
|
|
17
17
|
await new Promise((resolve) => {
|
|
18
18
|
if (window.requestIdleCallback) {
|
|
19
|
-
window.requestIdleCallback(resolve, { timeout: 400 })
|
|
19
|
+
window.requestIdleCallback(resolve, { timeout: 400 });
|
|
20
20
|
} else {
|
|
21
|
-
window.requestAnimationFrame(resolve)
|
|
21
|
+
window.requestAnimationFrame(resolve);
|
|
22
22
|
}
|
|
23
|
-
})
|
|
24
|
-
const placeholder = getToolbarPlaceholder()
|
|
23
|
+
});
|
|
24
|
+
const placeholder = getToolbarPlaceholder();
|
|
25
25
|
|
|
26
|
-
const iframe = document.createElement("iframe")
|
|
27
|
-
iframe.setAttribute("tabindex", -1)
|
|
28
|
-
iframe.setAttribute("allowtransparency", true)
|
|
26
|
+
const iframe = document.createElement("iframe");
|
|
27
|
+
iframe.setAttribute("tabindex", -1);
|
|
28
|
+
iframe.setAttribute("allowtransparency", true);
|
|
29
29
|
// sandbox: "allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation",
|
|
30
30
|
// allow: "accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; microphone; midi; payment; vr",
|
|
31
31
|
Object.assign(iframe.style, {
|
|
@@ -40,51 +40,51 @@ export const injectToolbar = async ({
|
|
|
40
40
|
"transition-duration": "0",
|
|
41
41
|
"transition-property": "height, visibility",
|
|
42
42
|
"border": "none",
|
|
43
|
-
})
|
|
44
|
-
const iframeLoadedPromise = iframeToLoadedPromise(iframe)
|
|
45
|
-
const toolbarUrlObject = new URL(toolbarUrl, window.location.href)
|
|
46
|
-
toolbarUrlObject.searchParams.set("logLevel", logLevel)
|
|
47
|
-
toolbarUrlObject.searchParams.set("theme", theme)
|
|
43
|
+
});
|
|
44
|
+
const iframeLoadedPromise = iframeToLoadedPromise(iframe);
|
|
45
|
+
const toolbarUrlObject = new URL(toolbarUrl, window.location.href);
|
|
46
|
+
toolbarUrlObject.searchParams.set("logLevel", logLevel);
|
|
47
|
+
toolbarUrlObject.searchParams.set("theme", theme);
|
|
48
48
|
if (opened) {
|
|
49
|
-
toolbarUrlObject.searchParams.set("opened", "")
|
|
49
|
+
toolbarUrlObject.searchParams.set("opened", "");
|
|
50
50
|
}
|
|
51
51
|
if (autoreload) {
|
|
52
|
-
toolbarUrlObject.searchParams.set("autoreload", "")
|
|
52
|
+
toolbarUrlObject.searchParams.set("autoreload", "");
|
|
53
53
|
}
|
|
54
54
|
if (animationsEnabled) {
|
|
55
|
-
toolbarUrlObject.searchParams.set("animationsEnabled", "")
|
|
55
|
+
toolbarUrlObject.searchParams.set("animationsEnabled", "");
|
|
56
56
|
}
|
|
57
57
|
if (notificationsEnabled) {
|
|
58
|
-
toolbarUrlObject.searchParams.set("notificationsEnabled", "")
|
|
58
|
+
toolbarUrlObject.searchParams.set("notificationsEnabled", "");
|
|
59
59
|
}
|
|
60
60
|
// set iframe src BEFORE putting it into the DOM (prevent firefox adding an history entry)
|
|
61
|
-
iframe.setAttribute("src", toolbarUrlObject.href)
|
|
62
|
-
iframe.name = "jsenv toolbar"
|
|
63
|
-
placeholder.parentNode.replaceChild(iframe, placeholder)
|
|
61
|
+
iframe.setAttribute("src", toolbarUrlObject.href);
|
|
62
|
+
iframe.name = "jsenv toolbar";
|
|
63
|
+
placeholder.parentNode.replaceChild(iframe, placeholder);
|
|
64
64
|
|
|
65
65
|
const listenToolbarStateChange = (callback) => {
|
|
66
|
-
return addToolbarEventCallback(iframe, "toolbar_state_change", callback)
|
|
67
|
-
}
|
|
66
|
+
return addToolbarEventCallback(iframe, "toolbar_state_change", callback);
|
|
67
|
+
};
|
|
68
68
|
|
|
69
69
|
const cleanupInitOnReady = addToolbarEventCallback(
|
|
70
70
|
iframe,
|
|
71
71
|
"toolbar_ready",
|
|
72
72
|
() => {
|
|
73
|
-
cleanupInitOnReady()
|
|
74
|
-
sendCommandToToolbar(iframe, "initToolbar")
|
|
73
|
+
cleanupInitOnReady();
|
|
74
|
+
sendCommandToToolbar(iframe, "initToolbar");
|
|
75
75
|
setTimeout(() => {
|
|
76
76
|
listenToolbarStateChange(({ animationsEnabled }) => {
|
|
77
77
|
if (animationsEnabled) {
|
|
78
|
-
iframe.style.transitionDuration = "300ms"
|
|
78
|
+
iframe.style.transitionDuration = "300ms";
|
|
79
79
|
} else {
|
|
80
|
-
iframe.style.transitionDuration = "0s"
|
|
80
|
+
iframe.style.transitionDuration = "0s";
|
|
81
81
|
}
|
|
82
|
-
})
|
|
83
|
-
})
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
84
|
},
|
|
85
|
-
)
|
|
85
|
+
);
|
|
86
86
|
|
|
87
|
-
const div = document.createElement("div")
|
|
87
|
+
const div = document.createElement("div");
|
|
88
88
|
div.innerHTML = `
|
|
89
89
|
<div id="jsenv_toolbar_trigger" style="display:none">
|
|
90
90
|
<svg id="jsenv_toolbar_trigger_icon">
|
|
@@ -130,82 +130,82 @@ export const injectToolbar = async ({
|
|
|
130
130
|
opacity: 1;
|
|
131
131
|
}
|
|
132
132
|
</style>
|
|
133
|
-
</div
|
|
134
|
-
const toolbarTrigger = div.firstElementChild
|
|
135
|
-
iframe.parentNode.appendChild(toolbarTrigger)
|
|
133
|
+
</div>`;
|
|
134
|
+
const toolbarTrigger = div.firstElementChild;
|
|
135
|
+
iframe.parentNode.appendChild(toolbarTrigger);
|
|
136
136
|
|
|
137
|
-
let timer
|
|
137
|
+
let timer;
|
|
138
138
|
toolbarTrigger.onmouseenter = () => {
|
|
139
|
-
toolbarTrigger.setAttribute("data-animate", "")
|
|
140
|
-
timer = setTimeout(expandToolbarTrigger, 500)
|
|
141
|
-
}
|
|
139
|
+
toolbarTrigger.setAttribute("data-animate", "");
|
|
140
|
+
timer = setTimeout(expandToolbarTrigger, 500);
|
|
141
|
+
};
|
|
142
142
|
toolbarTrigger.onmouseleave = () => {
|
|
143
|
-
clearTimeout(timer)
|
|
144
|
-
collapseToolbarTrigger()
|
|
145
|
-
}
|
|
143
|
+
clearTimeout(timer);
|
|
144
|
+
collapseToolbarTrigger();
|
|
145
|
+
};
|
|
146
146
|
toolbarTrigger.onfocus = () => {
|
|
147
|
-
toolbarTrigger.removeAttribute("data-animate")
|
|
148
|
-
expandToolbarTrigger()
|
|
149
|
-
}
|
|
147
|
+
toolbarTrigger.removeAttribute("data-animate");
|
|
148
|
+
expandToolbarTrigger();
|
|
149
|
+
};
|
|
150
150
|
toolbarTrigger.onblur = () => {
|
|
151
|
-
toolbarTrigger.removeAttribute("data-animate")
|
|
152
|
-
clearTimeout(timer)
|
|
153
|
-
collapseToolbarTrigger()
|
|
154
|
-
}
|
|
151
|
+
toolbarTrigger.removeAttribute("data-animate");
|
|
152
|
+
clearTimeout(timer);
|
|
153
|
+
collapseToolbarTrigger();
|
|
154
|
+
};
|
|
155
155
|
toolbarTrigger.onclick = () => {
|
|
156
|
-
sendCommandToToolbar(iframe, "openToolbar")
|
|
157
|
-
}
|
|
156
|
+
sendCommandToToolbar(iframe, "openToolbar");
|
|
157
|
+
};
|
|
158
158
|
|
|
159
159
|
const showToolbarTrigger = () => {
|
|
160
|
-
toolbarTrigger.style.display = "block"
|
|
161
|
-
}
|
|
160
|
+
toolbarTrigger.style.display = "block";
|
|
161
|
+
};
|
|
162
162
|
|
|
163
163
|
const hideToolbarTrigger = () => {
|
|
164
|
-
toolbarTrigger.style.display = "none"
|
|
165
|
-
}
|
|
164
|
+
toolbarTrigger.style.display = "none";
|
|
165
|
+
};
|
|
166
166
|
|
|
167
167
|
const expandToolbarTrigger = () => {
|
|
168
|
-
toolbarTrigger.setAttribute("data-expanded", "")
|
|
169
|
-
}
|
|
168
|
+
toolbarTrigger.setAttribute("data-expanded", "");
|
|
169
|
+
};
|
|
170
170
|
|
|
171
171
|
const collapseToolbarTrigger = () => {
|
|
172
|
-
toolbarTrigger.removeAttribute("data-expanded", "")
|
|
173
|
-
}
|
|
172
|
+
toolbarTrigger.removeAttribute("data-expanded", "");
|
|
173
|
+
};
|
|
174
174
|
|
|
175
175
|
listenToolbarStateChange(({ opened }) => {
|
|
176
176
|
if (opened) {
|
|
177
|
-
hideToolbarTrigger()
|
|
177
|
+
hideToolbarTrigger();
|
|
178
178
|
} else {
|
|
179
|
-
showToolbarTrigger()
|
|
179
|
+
showToolbarTrigger();
|
|
180
180
|
}
|
|
181
|
-
})
|
|
181
|
+
});
|
|
182
182
|
|
|
183
|
-
await iframeLoadedPromise
|
|
184
|
-
iframe.removeAttribute("tabindex")
|
|
183
|
+
await iframeLoadedPromise;
|
|
184
|
+
iframe.removeAttribute("tabindex");
|
|
185
185
|
|
|
186
|
-
return iframe
|
|
187
|
-
}
|
|
186
|
+
return iframe;
|
|
187
|
+
};
|
|
188
188
|
|
|
189
189
|
const addToolbarEventCallback = (iframe, eventName, callback) => {
|
|
190
190
|
const messageEventCallback = (messageEvent) => {
|
|
191
|
-
const { data } = messageEvent
|
|
191
|
+
const { data } = messageEvent;
|
|
192
192
|
if (typeof data !== "object") {
|
|
193
|
-
return
|
|
193
|
+
return;
|
|
194
194
|
}
|
|
195
|
-
const { __jsenv__ } = data
|
|
195
|
+
const { __jsenv__ } = data;
|
|
196
196
|
if (!__jsenv__) {
|
|
197
|
-
return
|
|
197
|
+
return;
|
|
198
198
|
}
|
|
199
199
|
if (__jsenv__.event !== eventName) {
|
|
200
|
-
return
|
|
200
|
+
return;
|
|
201
201
|
}
|
|
202
|
-
callback(__jsenv__.data)
|
|
203
|
-
}
|
|
204
|
-
window.addEventListener("message", messageEventCallback, false)
|
|
202
|
+
callback(__jsenv__.data);
|
|
203
|
+
};
|
|
204
|
+
window.addEventListener("message", messageEventCallback, false);
|
|
205
205
|
return () => {
|
|
206
|
-
window.removeEventListener("message", messageEventCallback, false)
|
|
207
|
-
}
|
|
208
|
-
}
|
|
206
|
+
window.removeEventListener("message", messageEventCallback, false);
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
209
|
|
|
210
210
|
const sendCommandToToolbar = (iframe, command, ...args) => {
|
|
211
211
|
iframe.contentWindow.postMessage(
|
|
@@ -216,40 +216,40 @@ const sendCommandToToolbar = (iframe, command, ...args) => {
|
|
|
216
216
|
},
|
|
217
217
|
},
|
|
218
218
|
window.origin,
|
|
219
|
-
)
|
|
220
|
-
}
|
|
219
|
+
);
|
|
220
|
+
};
|
|
221
221
|
|
|
222
222
|
const getToolbarPlaceholder = () => {
|
|
223
|
-
const placeholder = queryPlaceholder()
|
|
223
|
+
const placeholder = queryPlaceholder();
|
|
224
224
|
if (placeholder) {
|
|
225
225
|
if (document.body.contains(placeholder)) {
|
|
226
|
-
return placeholder
|
|
226
|
+
return placeholder;
|
|
227
227
|
}
|
|
228
228
|
// otherwise iframe would not be visible because in <head>
|
|
229
229
|
console.warn(
|
|
230
230
|
"element with [data-jsenv-toolbar-placeholder] must be inside document.body",
|
|
231
|
-
)
|
|
232
|
-
return createTooolbarPlaceholder()
|
|
231
|
+
);
|
|
232
|
+
return createTooolbarPlaceholder();
|
|
233
233
|
}
|
|
234
|
-
return createTooolbarPlaceholder()
|
|
235
|
-
}
|
|
234
|
+
return createTooolbarPlaceholder();
|
|
235
|
+
};
|
|
236
236
|
|
|
237
237
|
const queryPlaceholder = () => {
|
|
238
|
-
return document.querySelector("[data-jsenv-toolbar-placeholder]")
|
|
239
|
-
}
|
|
238
|
+
return document.querySelector("[data-jsenv-toolbar-placeholder]");
|
|
239
|
+
};
|
|
240
240
|
|
|
241
241
|
const createTooolbarPlaceholder = () => {
|
|
242
|
-
const placeholder = document.createElement("span")
|
|
243
|
-
document.body.appendChild(placeholder)
|
|
244
|
-
return placeholder
|
|
245
|
-
}
|
|
242
|
+
const placeholder = document.createElement("span");
|
|
243
|
+
document.body.appendChild(placeholder);
|
|
244
|
+
return placeholder;
|
|
245
|
+
};
|
|
246
246
|
|
|
247
247
|
const iframeToLoadedPromise = (iframe) => {
|
|
248
248
|
return new Promise((resolve) => {
|
|
249
249
|
const onload = () => {
|
|
250
|
-
iframe.removeEventListener("load", onload, true)
|
|
251
|
-
resolve()
|
|
252
|
-
}
|
|
253
|
-
iframe.addEventListener("load", onload, true)
|
|
254
|
-
})
|
|
255
|
-
}
|
|
250
|
+
iframe.removeEventListener("load", onload, true);
|
|
251
|
+
resolve();
|
|
252
|
+
};
|
|
253
|
+
iframe.addEventListener("load", onload, true);
|
|
254
|
+
});
|
|
255
|
+
};
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { effect } from "@preact/signals"
|
|
1
|
+
import { effect } from "@preact/signals";
|
|
2
2
|
|
|
3
|
-
import { parentWindowReloader } from "../../core/parent_window_context.js"
|
|
3
|
+
import { parentWindowReloader } from "../../core/parent_window_context.js";
|
|
4
4
|
import {
|
|
5
5
|
autoreloadEnabledSignal,
|
|
6
6
|
changesSignal,
|
|
7
|
-
} from "../../core/parent_window_signals.js"
|
|
8
|
-
import { changesTooltipOpenedSignal } from "../../core/changes_signals.js"
|
|
7
|
+
} from "../../core/parent_window_signals.js";
|
|
8
|
+
import { changesTooltipOpenedSignal } from "../../core/changes_signals.js";
|
|
9
9
|
import {
|
|
10
10
|
openChangesToolip,
|
|
11
11
|
closeChangesToolip,
|
|
12
|
-
} from "../../core/changes_actions.js"
|
|
13
|
-
import { enableVariant } from "../variant.js"
|
|
12
|
+
} from "../../core/changes_actions.js";
|
|
13
|
+
import { enableVariant } from "../variant.js";
|
|
14
14
|
|
|
15
|
-
const changesIndicator = document.querySelector("#changes_indicator")
|
|
15
|
+
const changesIndicator = document.querySelector("#changes_indicator");
|
|
16
16
|
|
|
17
17
|
export const renderChangesIndicator = () => {
|
|
18
18
|
effect(() => {
|
|
19
|
-
const autoreloadEnabled = autoreloadEnabledSignal.value
|
|
20
|
-
const changes = changesSignal.value
|
|
21
|
-
const changeCount = changes.length
|
|
19
|
+
const autoreloadEnabled = autoreloadEnabledSignal.value;
|
|
20
|
+
const changes = changesSignal.value;
|
|
21
|
+
const changeCount = changes.length;
|
|
22
22
|
enableVariant(changesIndicator, {
|
|
23
23
|
changes: !autoreloadEnabled && changeCount ? "yes" : "no",
|
|
24
|
-
})
|
|
24
|
+
});
|
|
25
25
|
if (changeCount) {
|
|
26
26
|
changesIndicator.querySelector(".tooltip_text").innerHTML =
|
|
27
|
-
computeTooltipText({ changes })
|
|
27
|
+
computeTooltipText({ changes });
|
|
28
28
|
changesIndicator.querySelector(".tooltip_text a").onclick = () => {
|
|
29
29
|
// eslint-disable-next-line no-alert
|
|
30
|
-
window.alert(JSON.stringify(changes, null, " "))
|
|
31
|
-
console.log(changes)
|
|
32
|
-
}
|
|
33
|
-
changesIndicator.querySelector(".changes_text").innerHTML = changeCount
|
|
30
|
+
window.alert(JSON.stringify(changes, null, " "));
|
|
31
|
+
console.log(changes);
|
|
32
|
+
};
|
|
33
|
+
changesIndicator.querySelector(".changes_text").innerHTML = changeCount;
|
|
34
34
|
}
|
|
35
|
-
})
|
|
35
|
+
});
|
|
36
36
|
|
|
37
37
|
changesIndicator.querySelector(".tooltip_action").onclick = () => {
|
|
38
|
-
parentWindowReloader.reload()
|
|
39
|
-
}
|
|
38
|
+
parentWindowReloader.reload();
|
|
39
|
+
};
|
|
40
40
|
|
|
41
41
|
effect(() => {
|
|
42
|
-
const changesTooltipOpened = changesTooltipOpenedSignal.value
|
|
42
|
+
const changesTooltipOpened = changesTooltipOpenedSignal.value;
|
|
43
43
|
if (changesTooltipOpened) {
|
|
44
|
-
changesIndicator.setAttribute("data-tooltip-visible", "")
|
|
44
|
+
changesIndicator.setAttribute("data-tooltip-visible", "");
|
|
45
45
|
} else {
|
|
46
|
-
changesIndicator.removeAttribute("data-tooltip-visible")
|
|
46
|
+
changesIndicator.removeAttribute("data-tooltip-visible");
|
|
47
47
|
}
|
|
48
|
-
})
|
|
49
|
-
const button = changesIndicator.querySelector("button")
|
|
48
|
+
});
|
|
49
|
+
const button = changesIndicator.querySelector("button");
|
|
50
50
|
button.onclick = () => {
|
|
51
|
-
const changesTooltipOpened = changesTooltipOpenedSignal.value
|
|
51
|
+
const changesTooltipOpened = changesTooltipOpenedSignal.value;
|
|
52
52
|
if (changesTooltipOpened) {
|
|
53
|
-
closeChangesToolip()
|
|
53
|
+
closeChangesToolip();
|
|
54
54
|
} else {
|
|
55
|
-
openChangesToolip()
|
|
55
|
+
openChangesToolip();
|
|
56
56
|
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
59
|
|
|
60
60
|
const computeTooltipText = ({ changes }) => {
|
|
61
|
-
const changesCount = changes.length
|
|
61
|
+
const changesCount = changes.length;
|
|
62
62
|
if (changesCount === 1) {
|
|
63
|
-
return `There is <a href="javascript:void(0)">1</a> change to apply
|
|
63
|
+
return `There is <a href="javascript:void(0)">1</a> change to apply`;
|
|
64
64
|
}
|
|
65
|
-
return `There is <a href="javascript:void(0)">${changesCount}<a> changes to apply
|
|
66
|
-
}
|
|
65
|
+
return `There is <a href="javascript:void(0)">${changesCount}<a> changes to apply`;
|
|
66
|
+
};
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { effect } from "@preact/signals"
|
|
1
|
+
import { effect } from "@preact/signals";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
executionSignal,
|
|
5
5
|
executionTooltipOpenedSignal,
|
|
6
|
-
} from "../../core/execution_signals.js"
|
|
6
|
+
} from "../../core/execution_signals.js";
|
|
7
7
|
import {
|
|
8
8
|
closeExecutionTooltip,
|
|
9
9
|
openExecutionTooltip,
|
|
10
|
-
} from "../../core/execution_actions.js"
|
|
11
|
-
import { removeForceHideElement } from "../util/dom.js"
|
|
12
|
-
import { enableVariant } from "../variant.js"
|
|
10
|
+
} from "../../core/execution_actions.js";
|
|
11
|
+
import { removeForceHideElement } from "../util/dom.js";
|
|
12
|
+
import { enableVariant } from "../variant.js";
|
|
13
13
|
|
|
14
14
|
const executionIndicator = document.querySelector(
|
|
15
15
|
"#document_execution_indicator",
|
|
16
|
-
)
|
|
16
|
+
);
|
|
17
17
|
|
|
18
18
|
export const renderDocumentExecutionIndicator = async () => {
|
|
19
19
|
removeForceHideElement(
|
|
20
20
|
document.querySelector("#document_execution_indicator"),
|
|
21
|
-
)
|
|
21
|
+
);
|
|
22
22
|
effect(() => {
|
|
23
|
-
const execution = executionSignal.value
|
|
24
|
-
updateExecutionIndicator(execution)
|
|
25
|
-
})
|
|
23
|
+
const execution = executionSignal.value;
|
|
24
|
+
updateExecutionIndicator(execution);
|
|
25
|
+
});
|
|
26
26
|
effect(() => {
|
|
27
|
-
const executionTooltipOpened = executionTooltipOpenedSignal.value
|
|
27
|
+
const executionTooltipOpened = executionTooltipOpenedSignal.value;
|
|
28
28
|
if (executionTooltipOpened) {
|
|
29
|
-
executionIndicator.setAttribute("data-tooltip-visible", "")
|
|
29
|
+
executionIndicator.setAttribute("data-tooltip-visible", "");
|
|
30
30
|
} else {
|
|
31
|
-
executionIndicator.removeAttribute("data-tooltip-visible")
|
|
31
|
+
executionIndicator.removeAttribute("data-tooltip-visible");
|
|
32
32
|
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
35
|
|
|
36
36
|
const updateExecutionIndicator = ({ status, startTime, endTime } = {}) => {
|
|
37
|
-
enableVariant(executionIndicator, { execution: status })
|
|
38
|
-
const variantNode = executionIndicator.querySelector("[data-when-active]")
|
|
37
|
+
enableVariant(executionIndicator, { execution: status });
|
|
38
|
+
const variantNode = executionIndicator.querySelector("[data-when-active]");
|
|
39
39
|
variantNode.querySelector("button").onclick = () => {
|
|
40
|
-
const executionTooltipOpened = executionTooltipOpenedSignal.value
|
|
40
|
+
const executionTooltipOpened = executionTooltipOpenedSignal.value;
|
|
41
41
|
if (executionTooltipOpened) {
|
|
42
|
-
closeExecutionTooltip()
|
|
42
|
+
closeExecutionTooltip();
|
|
43
43
|
} else {
|
|
44
|
-
openExecutionTooltip()
|
|
44
|
+
openExecutionTooltip();
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
};
|
|
47
47
|
variantNode.querySelector(".tooltip").textContent = computeText({
|
|
48
48
|
status,
|
|
49
49
|
startTime,
|
|
50
50
|
endTime,
|
|
51
|
-
})
|
|
52
|
-
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
53
|
|
|
54
54
|
// relative time: https://github.com/tc39/proposal-intl-relative-time/issues/118
|
|
55
55
|
const computeText = ({ status, startTime, endTime }) => {
|
|
56
56
|
if (status === "completed") {
|
|
57
|
-
return `Execution completed in ${endTime - startTime}ms
|
|
57
|
+
return `Execution completed in ${endTime - startTime}ms`;
|
|
58
58
|
}
|
|
59
59
|
if (status === "failed") {
|
|
60
|
-
return `Execution failed in ${endTime - startTime}ms
|
|
60
|
+
return `Execution failed in ${endTime - startTime}ms`;
|
|
61
61
|
}
|
|
62
62
|
if (status === "running") {
|
|
63
|
-
return "Executing..."
|
|
63
|
+
return "Executing...";
|
|
64
64
|
}
|
|
65
|
-
return ""
|
|
66
|
-
}
|
|
65
|
+
return "";
|
|
66
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { setLinkHrefForParentWindow } from "../util/iframe_to_parent_href.js"
|
|
1
|
+
import { setLinkHrefForParentWindow } from "../util/iframe_to_parent_href.js";
|
|
2
2
|
|
|
3
3
|
export const renderDocumentIndexLink = () => {
|
|
4
4
|
setLinkHrefForParentWindow(
|
|
5
5
|
document.querySelector("#document_index_link"),
|
|
6
6
|
"/",
|
|
7
|
-
)
|
|
8
|
-
}
|
|
7
|
+
);
|
|
8
|
+
};
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { effect } from "@preact/signals"
|
|
1
|
+
import { effect } from "@preact/signals";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
serverConnectionSignal,
|
|
5
5
|
serverTooltipOpenedSignal,
|
|
6
|
-
} from "../../core/server_signals.js"
|
|
6
|
+
} from "../../core/server_signals.js";
|
|
7
7
|
import {
|
|
8
8
|
openServerTooltip,
|
|
9
9
|
closeServerTooltip,
|
|
10
|
-
} from "../../core/server_actions.js"
|
|
11
|
-
import { removeForceHideElement } from "../util/dom.js"
|
|
12
|
-
import { enableVariant } from "../variant.js"
|
|
10
|
+
} from "../../core/server_actions.js";
|
|
11
|
+
import { removeForceHideElement } from "../util/dom.js";
|
|
12
|
+
import { enableVariant } from "../variant.js";
|
|
13
13
|
|
|
14
|
-
const parentServerEvents = window.parent.__server_events__
|
|
15
|
-
const serverEvents = window.__server_events__
|
|
16
|
-
const serverIndicator = document.querySelector("#server_indicator")
|
|
14
|
+
const parentServerEvents = window.parent.__server_events__;
|
|
15
|
+
const serverEvents = window.__server_events__;
|
|
16
|
+
const serverIndicator = document.querySelector("#server_indicator");
|
|
17
17
|
|
|
18
18
|
export const renderServerIndicator = () => {
|
|
19
|
-
removeForceHideElement(document.querySelector("#server_indicator"))
|
|
19
|
+
removeForceHideElement(document.querySelector("#server_indicator"));
|
|
20
20
|
effect(() => {
|
|
21
|
-
const serverConnection = serverConnectionSignal.value
|
|
22
|
-
updateServerIndicator(serverConnection)
|
|
23
|
-
})
|
|
21
|
+
const serverConnection = serverConnectionSignal.value;
|
|
22
|
+
updateServerIndicator(serverConnection);
|
|
23
|
+
});
|
|
24
24
|
effect(() => {
|
|
25
|
-
const serverTooltipOpened = serverTooltipOpenedSignal.value
|
|
25
|
+
const serverTooltipOpened = serverTooltipOpenedSignal.value;
|
|
26
26
|
if (serverTooltipOpened) {
|
|
27
|
-
serverIndicator.setAttribute("data-tooltip-visible", "")
|
|
27
|
+
serverIndicator.setAttribute("data-tooltip-visible", "");
|
|
28
28
|
} else {
|
|
29
|
-
serverIndicator.removeAttribute("data-tooltip-visible")
|
|
29
|
+
serverIndicator.removeAttribute("data-tooltip-visible");
|
|
30
30
|
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
33
|
|
|
34
34
|
const updateServerIndicator = (connectionState) => {
|
|
35
|
-
enableVariant(serverIndicator, { connectionState })
|
|
35
|
+
enableVariant(serverIndicator, { connectionState });
|
|
36
36
|
const variantNode = document.querySelector(
|
|
37
37
|
"#server_indicator > [data-when-active]",
|
|
38
|
-
)
|
|
38
|
+
);
|
|
39
39
|
variantNode.querySelector("button").onclick = () => {
|
|
40
|
-
const serverTooltipOpened = serverTooltipOpenedSignal.value
|
|
40
|
+
const serverTooltipOpened = serverTooltipOpenedSignal.value;
|
|
41
41
|
if (serverTooltipOpened) {
|
|
42
|
-
closeServerTooltip()
|
|
42
|
+
closeServerTooltip();
|
|
43
43
|
} else {
|
|
44
|
-
openServerTooltip()
|
|
44
|
+
openServerTooltip();
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
};
|
|
47
47
|
if (connectionState === "connecting") {
|
|
48
48
|
variantNode.querySelector("a").onclick = () => {
|
|
49
49
|
if (parentServerEvents) {
|
|
50
|
-
parentServerEvents.disconnect()
|
|
50
|
+
parentServerEvents.disconnect();
|
|
51
51
|
}
|
|
52
|
-
serverEvents.disconnect()
|
|
53
|
-
}
|
|
52
|
+
serverEvents.disconnect();
|
|
53
|
+
};
|
|
54
54
|
} else if (connectionState === "closed") {
|
|
55
55
|
variantNode.querySelector("a").onclick = () => {
|
|
56
56
|
if (parentServerEvents) {
|
|
57
|
-
parentServerEvents.connect()
|
|
57
|
+
parentServerEvents.connect();
|
|
58
58
|
}
|
|
59
|
-
serverEvents.connect()
|
|
60
|
-
}
|
|
59
|
+
serverEvents.connect();
|
|
60
|
+
};
|
|
61
61
|
}
|
|
62
|
-
}
|
|
62
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { openedSignal } from "../../core/toolbar_open_signals.js"
|
|
2
|
-
import { openToolbar, closeToolbar } from "../../core/toolbar_open_actions.js"
|
|
1
|
+
import { openedSignal } from "../../core/toolbar_open_signals.js";
|
|
2
|
+
import { openToolbar, closeToolbar } from "../../core/toolbar_open_actions.js";
|
|
3
3
|
|
|
4
4
|
export const renderToolbarCloseButton = () => {
|
|
5
5
|
// if user click enter or space quickly while closing toolbar
|
|
@@ -7,9 +7,9 @@ export const renderToolbarCloseButton = () => {
|
|
|
7
7
|
// that's why I used toggleToolbar and not hideToolbar
|
|
8
8
|
document.querySelector("#toolbar_close_button").onclick = () => {
|
|
9
9
|
if (openedSignal.value) {
|
|
10
|
-
closeToolbar()
|
|
10
|
+
closeToolbar();
|
|
11
11
|
} else {
|
|
12
|
-
openToolbar()
|
|
12
|
+
openToolbar();
|
|
13
13
|
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
14
|
+
};
|
|
15
|
+
};
|