@jsenv/plugin-toolbar 0.0.1 → 0.1.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/dist/css/{toolbar_main.css → toolbar.css} +285 -319
- package/dist/html/toolbar.html +91 -80
- package/dist/js/toolbar_core.js +1792 -0
- package/dist/js/toolbar_injector.js +60 -121
- package/dist/jsenv_plugin_toolbar.js +18 -12
- package/package.json +10 -3
- package/src/client/core/animation_actions.js +8 -0
- package/src/client/core/animation_effects.js +12 -0
- package/src/client/core/animation_signals.js +12 -0
- package/src/client/core/changes_actions.js +9 -0
- package/src/client/core/changes_signals.js +3 -0
- package/src/client/core/execution_actions.js +50 -0
- package/src/client/core/execution_effects.js +22 -0
- package/src/client/core/execution_signals.js +19 -0
- package/src/client/core/notification_actions.js +71 -0
- package/src/client/core/notification_context.js +1 -0
- package/src/client/core/notification_effects.js +11 -0
- package/src/client/core/notification_signals.js +13 -0
- package/src/client/{communication/parent_window_communication.js → core/parent_window_actions.js} +10 -0
- package/src/client/core/parent_window_context.js +7 -0
- package/src/client/core/parent_window_effects.js +20 -0
- package/src/client/core/parent_window_signals.js +34 -0
- package/src/client/core/server_actions.js +9 -0
- package/src/client/core/server_effects.js +11 -0
- package/src/client/core/server_signals.js +12 -0
- package/src/client/core/settings_actions.js +9 -0
- package/src/client/core/settings_signals.js +3 -0
- package/src/client/core/theme_actions.js +9 -0
- package/src/client/core/theme_effects.js +8 -0
- package/src/client/core/theme_signals.js +12 -0
- package/src/client/core/toolbar_logger.js +29 -0
- package/src/client/core/toolbar_open_actions.js +9 -0
- package/src/client/core/toolbar_open_effects.js +5 -0
- package/src/client/core/toolbar_open_signals.js +12 -0
- package/src/client/core/toolbar_state_context.js +5 -0
- package/src/client/core/toolbar_state_effects.js +10 -0
- package/src/client/core/toolbar_state_signals.js +20 -0
- package/src/client/core/tooltip_actions.js +7 -0
- package/src/client/toolbar.html +116 -89
- package/src/client/toolbar_core.js +8 -0
- package/src/client/toolbar_injector.js +64 -39
- package/src/client/ui/changes_indicator/changes_indicator.js +66 -0
- package/src/client/{execution/execution.css → ui/document_execution_indicator/document_execution_indicator.css} +10 -14
- package/src/client/ui/document_execution_indicator/document_execution_indicator.js +66 -0
- package/src/client/ui/document_index_link/document_index_link.js +8 -0
- package/src/client/ui/globals.css +103 -0
- package/src/client/{jsenv_logo.svg → ui/jsenv_logo.svg} +0 -0
- package/src/client/{eventsource/eventsource.css → ui/server_indicator/server_indicator.css} +14 -24
- package/src/client/ui/server_indicator/server_indicator.js +62 -0
- package/src/client/ui/toolbar.css +76 -0
- package/src/client/ui/toolbar_close_button/toolbar_close_button.js +15 -0
- package/src/client/{responsive/overflow_menu.css → ui/toolbar_menu_overflow/toolbar_menu_overflow.css} +10 -11
- package/src/client/{responsive/toolbar_responsive.js → ui/toolbar_menu_overflow/toolbar_menu_overflow.js} +25 -31
- package/src/client/ui/toolbar_opening/toolbar_opening.js +73 -0
- package/src/client/ui/toolbar_overlay/toolbar_overlay.js +76 -0
- package/src/client/{theme → ui/toolbar_settings}/jsenv_theme.css +6 -6
- package/src/client/{theme/light_theme.css → ui/toolbar_settings/theme_light.css} +9 -10
- package/src/client/ui/toolbar_settings/toolbar_animation_setting.js +27 -0
- package/src/client/ui/toolbar_settings/toolbar_autoreload_setting.js +79 -0
- package/src/client/ui/toolbar_settings/toolbar_notification_setting.js +88 -0
- package/src/client/{settings/settings.css → ui/toolbar_settings/toolbar_settings.css} +24 -23
- package/src/client/ui/toolbar_settings/toolbar_settings.js +54 -0
- package/src/client/ui/toolbar_settings/toolbar_theme_setting.js +17 -0
- package/src/client/ui/toolbar_ui.js +21 -0
- package/src/client/{tooltip/tooltip.css → ui/tooltips/tooltips.css} +13 -7
- package/src/client/{util → ui/util}/animation.js +0 -0
- package/src/client/ui/util/dom.js +57 -0
- package/src/client/{util → ui/util}/fetch_using_xhr.js +0 -0
- package/src/client/{util → ui/util}/fetching.js +0 -0
- package/src/client/{util → ui/util}/iframe_to_parent_href.js +0 -0
- package/src/client/{util → ui/util}/responsive.js +0 -0
- package/src/client/{util → ui/util}/util.js +0 -0
- package/src/client/{variant → ui}/variant.js +0 -0
- package/src/jsenv_plugin_toolbar.js +19 -7
- package/dist/js/toolbar_main.js +0 -900
- package/scripts/build.mjs +0 -20
- package/src/client/animation/toolbar_animation_core.js +0 -30
- package/src/client/animation/toolbar_animation_ui.js +0 -21
- package/src/client/eventsource/toolbar_eventsource.js +0 -57
- package/src/client/execution/toolbar_execution.js +0 -88
- package/src/client/focus/focus.css +0 -61
- package/src/client/focus/toolbar_focus.js +0 -19
- package/src/client/notification/toolbar_notification.js +0 -181
- package/src/client/settings/toolbar_settings.js +0 -47
- package/src/client/theme/toolbar_theme.js +0 -34
- package/src/client/toolbar_main.css +0 -173
- package/src/client/toolbar_main.js +0 -174
- package/src/client/toolbar_state.js +0 -16
- package/src/client/tooltip/tooltip.js +0 -39
- package/src/client/util/dom.js +0 -108
- package/src/client/util/jsenv_logger.js +0 -28
- package/src/client/util/preferences.js +0 -10
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/ast/src/html/html_src_set.js +0 -18
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation.js +0 -45
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation_core.js +0 -32
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation_core.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation_ui.js +0 -23
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/animation/toolbar_animation_ui.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/communication/parent_window_communication.js +0 -33
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/eventsource/eventsource.css +0 -87
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/eventsource/toolbar_eventsource.js +0 -59
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/eventsource/toolbar_eventsource.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/execution/execution.css +0 -88
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/execution/toolbar_execution.js +0 -90
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/execution/toolbar_execution.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/focus/focus.css +0 -28
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/focus/toolbar_focus.js +0 -19
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/jsenv_logo.svg +0 -140
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/notification/toolbar_notification.js +0 -183
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/notification/toolbar_notification.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/responsive/overflow_menu.css +0 -60
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/responsive/toolbar_responsive.js +0 -105
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/responsive/toolbar_responsive.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/settings/settings.css +0 -200
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/settings/toolbar_settings.js +0 -49
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/settings/toolbar_settings.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/theme/light_theme.css +0 -110
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/theme/toolbar_theme.js +0 -36
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/theme/toolbar_theme.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar.html +0 -319
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_injector.js +0 -232
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_injector.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_main.css +0 -161
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_main.css.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_main.js +0 -176
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_main.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_state.js +0 -18
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/toolbar_state.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/tooltip/tooltip.css +0 -60
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/tooltip/tooltip.js +0 -41
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/tooltip/tooltip.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/animation.js +0 -307
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/animation.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/dom.js +0 -108
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/iframe_to_parent_href.js +0 -10
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/preferences.js +0 -10
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/util/responsive.js +0 -112
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/packages/jsenv-plugin-toolbar/src/client/variant/variant.js +0 -74
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/autoreload.js +0 -201
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/autoreload.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/autoreload_preference.js +0 -11
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/reload.js +0 -138
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/reload.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/url_helpers.js +0 -20
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html +0 -590
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L15C5-L20C12.js +0 -7
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L15C5-L20C12.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L368C5-L481C14.js +0 -114
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L482C5-L605C14.js +0 -124
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L69C5-L299C13.css +0 -227
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html@L8C5-L68C13.css +0 -28
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/import_meta_hot/client/import_meta_hot.js +0 -82
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/ribbon/client/ribbon.js +0 -51
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/connection_manager.js +0 -165
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/events_manager.js +0 -75
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/server_events_client.js +0 -20
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/server_events_client.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/web_socket_connection.js +0 -83
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/server_events/client/web_socket_connection.js.map +0 -12
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/supervisor/client/script_type_module_supervisor.js +0 -98
- package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/supervisor/client/supervisor.js +0 -966
- package/tests/toolbar_basic/main.html +0 -18
- package/tests/toolbar_basic/start_dev_server.mjs +0 -7
- package/todo.txt +0 -0
|
@@ -1,101 +1,12 @@
|
|
|
1
|
-
const updateIframeOverflowOnParentWindow = () => {
|
|
2
|
-
if (!window.parent) {
|
|
3
|
-
// can happen while parent iframe reloads
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
const aTooltipIsOpened = document.querySelector("[data-tooltip-visible]") || document.querySelector("[data-tooltip-auto-visible]");
|
|
7
|
-
const settingsAreOpened = document.querySelector("#settings[data-active]");
|
|
8
|
-
if (aTooltipIsOpened || settingsAreOpened) {
|
|
9
|
-
enableIframeOverflowOnParentWindow();
|
|
10
|
-
} else {
|
|
11
|
-
disableIframeOverflowOnParentWindow();
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
let iframeOverflowEnabled = false;
|
|
15
|
-
const enableIframeOverflowOnParentWindow = () => {
|
|
16
|
-
if (iframeOverflowEnabled) return;
|
|
17
|
-
iframeOverflowEnabled = true;
|
|
18
|
-
const iframe = getToolbarIframe();
|
|
19
|
-
const transitionDuration = iframe.style.transitionDuration;
|
|
20
|
-
setStyles(iframe, {
|
|
21
|
-
"height": "100%",
|
|
22
|
-
"transition-duration": "0ms"
|
|
23
|
-
});
|
|
24
|
-
if (transitionDuration) {
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
setStyles(iframe, {
|
|
27
|
-
"transition-duration": transitionDuration
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const disableIframeOverflowOnParentWindow = () => {
|
|
33
|
-
if (!iframeOverflowEnabled) return;
|
|
34
|
-
iframeOverflowEnabled = false;
|
|
35
|
-
const iframe = getToolbarIframe();
|
|
36
|
-
const transitionDuration = iframe.style.transitionDuration;
|
|
37
|
-
setStyles(iframe, {
|
|
38
|
-
"height": "40px",
|
|
39
|
-
"transition-duration": "0ms"
|
|
40
|
-
});
|
|
41
|
-
if (transitionDuration) {
|
|
42
|
-
setTimeout(() => {
|
|
43
|
-
setStyles(iframe, {
|
|
44
|
-
"transition-duration": transitionDuration
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const getToolbarIframe = () => {
|
|
50
|
-
const iframes = Array.from(window.parent.document.querySelectorAll("iframe"));
|
|
51
|
-
return iframes.find(iframe => iframe.contentWindow === window);
|
|
52
|
-
};
|
|
53
|
-
const forceHideElement = element => {
|
|
54
|
-
element.setAttribute("data-force-hide", "");
|
|
55
|
-
};
|
|
56
|
-
const removeForceHideElement = element => {
|
|
57
|
-
element.removeAttribute("data-force-hide");
|
|
58
|
-
};
|
|
59
|
-
const setStyles = (element, styles) => {
|
|
60
|
-
const elementStyle = element.style;
|
|
61
|
-
const restoreStyles = Object.keys(styles).map(styleName => {
|
|
62
|
-
let restore;
|
|
63
|
-
if (styleName in elementStyle) {
|
|
64
|
-
const currentStyle = elementStyle[styleName];
|
|
65
|
-
restore = () => {
|
|
66
|
-
elementStyle[styleName] = currentStyle;
|
|
67
|
-
};
|
|
68
|
-
} else {
|
|
69
|
-
restore = () => {
|
|
70
|
-
delete elementStyle[styleName];
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
elementStyle[styleName] = styles[styleName];
|
|
74
|
-
return restore;
|
|
75
|
-
});
|
|
76
|
-
return () => {
|
|
77
|
-
restoreStyles.forEach(restore => restore());
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
const setAttributes = (element, attributes) => {
|
|
81
|
-
Object.keys(attributes).forEach(name => {
|
|
82
|
-
element.setAttribute(name, attributes[name]);
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
const toolbarSectionIsActive = element => {
|
|
86
|
-
return element.hasAttribute("data-active");
|
|
87
|
-
};
|
|
88
|
-
const activateToolbarSection = element => {
|
|
89
|
-
element.setAttribute("data-active", "");
|
|
90
|
-
};
|
|
91
|
-
const deactivateToolbarSection = element => {
|
|
92
|
-
element.removeAttribute("data-active");
|
|
93
|
-
};
|
|
94
|
-
|
|
95
1
|
const jsenvLogoSvgUrl = new URL("../other/jsenv_logo.svg", import.meta.url);
|
|
96
2
|
const injectToolbar = async ({
|
|
97
3
|
toolbarUrl,
|
|
98
|
-
|
|
4
|
+
logLevel,
|
|
5
|
+
theme,
|
|
6
|
+
opened,
|
|
7
|
+
autoreload,
|
|
8
|
+
animationsEnabled,
|
|
9
|
+
notificationsEnabled
|
|
99
10
|
}) => {
|
|
100
11
|
if (document.readyState !== "complete") {
|
|
101
12
|
await new Promise(resolve => {
|
|
@@ -113,13 +24,11 @@ const injectToolbar = async ({
|
|
|
113
24
|
});
|
|
114
25
|
const placeholder = getToolbarPlaceholder();
|
|
115
26
|
const iframe = document.createElement("iframe");
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
setStyles(iframe, {
|
|
27
|
+
iframe.setAttribute("tabindex", -1);
|
|
28
|
+
iframe.setAttribute("allowtransparency", true);
|
|
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
|
+
// allow: "accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; microphone; midi; payment; vr",
|
|
31
|
+
Object.assign(iframe.style, {
|
|
123
32
|
"position": "fixed",
|
|
124
33
|
"zIndex": 1000,
|
|
125
34
|
"bottom": 0,
|
|
@@ -128,29 +37,56 @@ const injectToolbar = async ({
|
|
|
128
37
|
"height": 0,
|
|
129
38
|
/* ensure toolbar children are not focusable when hidden */
|
|
130
39
|
"visibility": "hidden",
|
|
131
|
-
"transition-duration": "
|
|
40
|
+
"transition-duration": "0",
|
|
132
41
|
"transition-property": "height, visibility",
|
|
133
42
|
"border": "none"
|
|
134
43
|
});
|
|
135
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
|
+
if (opened) {
|
|
49
|
+
toolbarUrlObject.searchParams.set("opened", "");
|
|
50
|
+
}
|
|
51
|
+
if (autoreload) {
|
|
52
|
+
toolbarUrlObject.searchParams.set("autoreload", "");
|
|
53
|
+
}
|
|
54
|
+
if (animationsEnabled) {
|
|
55
|
+
toolbarUrlObject.searchParams.set("animationsEnabled", "");
|
|
56
|
+
}
|
|
57
|
+
if (notificationsEnabled) {
|
|
58
|
+
toolbarUrlObject.searchParams.set("notificationsEnabled", "");
|
|
59
|
+
}
|
|
136
60
|
// set iframe src BEFORE putting it into the DOM (prevent firefox adding an history entry)
|
|
137
|
-
iframe.setAttribute("src",
|
|
61
|
+
iframe.setAttribute("src", toolbarUrlObject.href);
|
|
62
|
+
iframe.name = "jsenv toolbar";
|
|
138
63
|
placeholder.parentNode.replaceChild(iframe, placeholder);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
64
|
+
const listenToolbarStateChange = callback => {
|
|
65
|
+
return addToolbarEventCallback(iframe, "toolbar_state_change", callback);
|
|
66
|
+
};
|
|
67
|
+
const cleanupInitOnReady = addToolbarEventCallback(iframe, "toolbar_ready", () => {
|
|
68
|
+
cleanupInitOnReady();
|
|
69
|
+
sendCommandToToolbar(iframe, "initToolbar");
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
listenToolbarStateChange(({
|
|
72
|
+
animationsEnabled
|
|
73
|
+
}) => {
|
|
74
|
+
if (animationsEnabled) {
|
|
75
|
+
iframe.style.transitionDuration = "300ms";
|
|
76
|
+
} else {
|
|
77
|
+
iframe.style.transitionDuration = "0s";
|
|
78
|
+
}
|
|
79
|
+
});
|
|
142
80
|
});
|
|
143
81
|
});
|
|
144
|
-
await iframeLoadedPromise;
|
|
145
|
-
iframe.removeAttribute("tabindex");
|
|
146
82
|
const div = document.createElement("div");
|
|
147
83
|
div.innerHTML = `
|
|
148
|
-
<div id="
|
|
149
|
-
<svg id="
|
|
84
|
+
<div id="jsenv_toolbar_trigger" style="display:none">
|
|
85
|
+
<svg id="jsenv_toolbar_trigger_icon">
|
|
150
86
|
<use xlink:href="${jsenvLogoSvgUrl}#jsenv_logo"></use>
|
|
151
87
|
</svg>
|
|
152
88
|
<style>
|
|
153
|
-
#
|
|
89
|
+
#jsenv_toolbar_trigger {
|
|
154
90
|
display: block;
|
|
155
91
|
overflow: hidden;
|
|
156
92
|
position: fixed;
|
|
@@ -170,22 +106,22 @@ const injectToolbar = async ({
|
|
|
170
106
|
transition: 600ms;
|
|
171
107
|
}
|
|
172
108
|
|
|
173
|
-
#
|
|
109
|
+
#jsenv_toolbar_trigger:hover {
|
|
174
110
|
cursor: pointer;
|
|
175
111
|
}
|
|
176
112
|
|
|
177
|
-
#
|
|
113
|
+
#jsenv_toolbar_trigger[data-expanded] {
|
|
178
114
|
bottom: 0;
|
|
179
115
|
}
|
|
180
116
|
|
|
181
|
-
#
|
|
117
|
+
#jsenv_toolbar_trigger_icon {
|
|
182
118
|
width: 35px;
|
|
183
119
|
height: 35px;
|
|
184
120
|
opacity: 0;
|
|
185
121
|
transition: 600ms;
|
|
186
122
|
}
|
|
187
123
|
|
|
188
|
-
#
|
|
124
|
+
#jsenv_toolbar_trigger[data-expanded] #jsenv_toolbar_trigger_icon {
|
|
189
125
|
opacity: 1;
|
|
190
126
|
}
|
|
191
127
|
</style>
|
|
@@ -211,7 +147,7 @@ const injectToolbar = async ({
|
|
|
211
147
|
collapseToolbarTrigger();
|
|
212
148
|
};
|
|
213
149
|
toolbarTrigger.onclick = () => {
|
|
214
|
-
sendCommandToToolbar(iframe, "
|
|
150
|
+
sendCommandToToolbar(iframe, "openToolbar");
|
|
215
151
|
};
|
|
216
152
|
const showToolbarTrigger = () => {
|
|
217
153
|
toolbarTrigger.style.display = "block";
|
|
@@ -225,14 +161,17 @@ const injectToolbar = async ({
|
|
|
225
161
|
const collapseToolbarTrigger = () => {
|
|
226
162
|
toolbarTrigger.removeAttribute("data-expanded", "");
|
|
227
163
|
};
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
164
|
+
listenToolbarStateChange(({
|
|
165
|
+
opened
|
|
166
|
+
}) => {
|
|
167
|
+
if (opened) {
|
|
231
168
|
hideToolbarTrigger();
|
|
232
169
|
} else {
|
|
233
170
|
showToolbarTrigger();
|
|
234
171
|
}
|
|
235
172
|
});
|
|
173
|
+
await iframeLoadedPromise;
|
|
174
|
+
iframe.removeAttribute("tabindex");
|
|
236
175
|
return iframe;
|
|
237
176
|
};
|
|
238
177
|
const addToolbarEventCallback = (iframe, eventName, callback) => {
|
|
@@ -297,4 +236,4 @@ const iframeToLoadedPromise = iframe => {
|
|
|
297
236
|
});
|
|
298
237
|
};
|
|
299
238
|
|
|
300
|
-
export {
|
|
239
|
+
export { injectToolbar };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { parseHtmlString, injectScriptNodeAsEarlyAsPossible, createHtmlNode, stringifyHtmlAst } from "@jsenv/ast";
|
|
2
2
|
|
|
3
3
|
const jsenvPluginToolbar = ({
|
|
4
|
-
|
|
4
|
+
logLevel = "warn",
|
|
5
|
+
theme = "dark",
|
|
6
|
+
opened = false,
|
|
7
|
+
autoreload = true,
|
|
8
|
+
animationsEnabled = true,
|
|
9
|
+
notificationsEnabled = true
|
|
5
10
|
} = {}) => {
|
|
6
11
|
const toolbarInjectorClientFileUrl = new URL("./js/toolbar_injector.js", import.meta.url).href;
|
|
7
12
|
const toolbarHtmlClientFileUrl = new URL("./html/toolbar.html", import.meta.url).href;
|
|
@@ -9,22 +14,18 @@ const jsenvPluginToolbar = ({
|
|
|
9
14
|
name: "jsenv:toolbar",
|
|
10
15
|
appliesDuring: "dev",
|
|
11
16
|
transformUrlContent: {
|
|
12
|
-
html: ({
|
|
13
|
-
url
|
|
14
|
-
|
|
15
|
-
}, {
|
|
16
|
-
referenceUtils
|
|
17
|
-
}) => {
|
|
18
|
-
if (url === toolbarHtmlClientFileUrl) {
|
|
17
|
+
html: (urlInfo, context) => {
|
|
18
|
+
if (urlInfo.url.startsWith(toolbarHtmlClientFileUrl)) {
|
|
19
|
+
urlInfo.data.isJsenvToolbar = true;
|
|
19
20
|
return null;
|
|
20
21
|
}
|
|
21
|
-
const htmlAst = parseHtmlString(content);
|
|
22
|
-
const [toolbarInjectorReference] = referenceUtils.inject({
|
|
22
|
+
const htmlAst = parseHtmlString(urlInfo.content);
|
|
23
|
+
const [toolbarInjectorReference] = context.referenceUtils.inject({
|
|
23
24
|
type: "js_import",
|
|
24
25
|
expectedType: "js_module",
|
|
25
26
|
specifier: toolbarInjectorClientFileUrl
|
|
26
27
|
});
|
|
27
|
-
const [toolbarClientFileReference] = referenceUtils.inject({
|
|
28
|
+
const [toolbarClientFileReference] = context.referenceUtils.inject({
|
|
28
29
|
type: "iframe_src",
|
|
29
30
|
expectedType: "html",
|
|
30
31
|
specifier: toolbarHtmlClientFileUrl
|
|
@@ -36,7 +37,12 @@ const jsenvPluginToolbar = ({
|
|
|
36
37
|
import { injectToolbar } from ${toolbarInjectorReference.generatedSpecifier}
|
|
37
38
|
injectToolbar(${JSON.stringify({
|
|
38
39
|
toolbarUrl: toolbarClientFileReference.generatedSpecifier,
|
|
39
|
-
|
|
40
|
+
logLevel,
|
|
41
|
+
theme,
|
|
42
|
+
opened,
|
|
43
|
+
autoreload,
|
|
44
|
+
animationsEnabled,
|
|
45
|
+
notificationsEnabled
|
|
40
46
|
}, null, " ")})`
|
|
41
47
|
}), "jsenv:toolbar");
|
|
42
48
|
const htmlModified = stringifyHtmlAst(htmlAst);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/plugin-toolbar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,10 +21,17 @@
|
|
|
21
21
|
"./*": "./*"
|
|
22
22
|
},
|
|
23
23
|
"main": "./src/main.js",
|
|
24
|
+
"files": [
|
|
25
|
+
"/dist/",
|
|
26
|
+
"/src/"
|
|
27
|
+
],
|
|
24
28
|
"dependencies": {
|
|
25
|
-
"@jsenv/ast": "1.4.
|
|
29
|
+
"@jsenv/ast": "1.4.8",
|
|
30
|
+
"@preact/signals": "1.1.2"
|
|
26
31
|
},
|
|
27
32
|
"scripts": {
|
|
28
|
-
"
|
|
33
|
+
"eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
|
|
34
|
+
"build": "node ./scripts/build.mjs",
|
|
35
|
+
"prepublishOnly": "npm run build"
|
|
29
36
|
}
|
|
30
37
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { effect } from "@preact/signals"
|
|
2
|
+
|
|
3
|
+
import { animationsEnabledSignal } from "./animation_signals.js"
|
|
4
|
+
|
|
5
|
+
effect(() => {
|
|
6
|
+
const animationsEnabled = animationsEnabledSignal.value
|
|
7
|
+
if (animationsEnabled) {
|
|
8
|
+
document.documentElement.removeAttribute("data-animation-disabled")
|
|
9
|
+
} else {
|
|
10
|
+
document.documentElement.setAttribute("data-animation-disabled", "")
|
|
11
|
+
}
|
|
12
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { signal } from "@preact/signals"
|
|
2
|
+
|
|
3
|
+
import { paramsFromParentWindow } from "./parent_window_context.js"
|
|
4
|
+
import { stateFromLocalStorage } from "./toolbar_state_context.js"
|
|
5
|
+
|
|
6
|
+
export const animationsEnabledSignal = signal(
|
|
7
|
+
typeof stateFromLocalStorage.animationsEnabled === "boolean"
|
|
8
|
+
? stateFromLocalStorage.animationsEnabled
|
|
9
|
+
: typeof paramsFromParentWindow.animationsEnabled === "boolean"
|
|
10
|
+
? paramsFromParentWindow.animationsEnabled
|
|
11
|
+
: false,
|
|
12
|
+
)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { executionTooltipOpenedSignal } from "./execution_signals.js"
|
|
2
|
+
import { notify } from "./notification_actions.js"
|
|
3
|
+
|
|
4
|
+
export const openExecutionTooltip = () => {
|
|
5
|
+
executionTooltipOpenedSignal.value = true
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const closeExecutionTooltip = () => {
|
|
9
|
+
executionTooltipOpenedSignal.value = false
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const notifyExecutionResult = (execution, previousExecution) => {
|
|
13
|
+
const executedFileRelativeUrl = window.location.href
|
|
14
|
+
const notificationOptions = {
|
|
15
|
+
lang: "en",
|
|
16
|
+
icon: getFaviconHref(),
|
|
17
|
+
clickToFocus: true,
|
|
18
|
+
clickToClose: true,
|
|
19
|
+
}
|
|
20
|
+
if (execution.status === "errored") {
|
|
21
|
+
if (previousExecution) {
|
|
22
|
+
if (previousExecution.status === "completed") {
|
|
23
|
+
notify("Broken", {
|
|
24
|
+
...notificationOptions,
|
|
25
|
+
body: `${executedFileRelativeUrl} execution now failing.`,
|
|
26
|
+
})
|
|
27
|
+
} else {
|
|
28
|
+
notify("Still failing", {
|
|
29
|
+
...notificationOptions,
|
|
30
|
+
body: `${executedFileRelativeUrl} execution still failing.`,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
notify("Failing", {
|
|
35
|
+
...notificationOptions,
|
|
36
|
+
body: `${executedFileRelativeUrl} execution failed.`,
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
} else if (previousExecution && previousExecution.status === "errored") {
|
|
40
|
+
notify("Fixed", {
|
|
41
|
+
...notificationOptions,
|
|
42
|
+
body: `${executedFileRelativeUrl} execution fixed.`,
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const getFaviconHref = () => {
|
|
48
|
+
const link = document.querySelector('link[rel="icon"]')
|
|
49
|
+
return link ? link.href : undefined
|
|
50
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { effect } from "@preact/signals"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
executionSignal,
|
|
5
|
+
previousExecutionSignal,
|
|
6
|
+
} from "./execution_signals.js"
|
|
7
|
+
import { notifyExecutionResult } from "./execution_actions.js"
|
|
8
|
+
|
|
9
|
+
effect(() => {
|
|
10
|
+
const execution = executionSignal.value
|
|
11
|
+
if (execution) {
|
|
12
|
+
sessionStorage.setItem(window.location.href, JSON.stringify(execution))
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
effect(() => {
|
|
17
|
+
const execution = executionSignal.value
|
|
18
|
+
const previousExecution = previousExecutionSignal.value
|
|
19
|
+
if (execution) {
|
|
20
|
+
notifyExecutionResult(execution, previousExecution)
|
|
21
|
+
}
|
|
22
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { signal } from "@preact/signals"
|
|
2
|
+
|
|
3
|
+
export const executionTooltipOpenedSignal = signal(false)
|
|
4
|
+
|
|
5
|
+
export const executionSignal = signal({
|
|
6
|
+
status: "running",
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const previousExecutionSignal = signal(
|
|
10
|
+
sessionStorage.hasOwnProperty(window.location.href)
|
|
11
|
+
? JSON.parse(sessionStorage.getItem(window.location.href))
|
|
12
|
+
: null,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
window.parent.__supervisor__
|
|
16
|
+
.getDocumentExecutionResult()
|
|
17
|
+
.then(({ status, startTime, endTime }) => {
|
|
18
|
+
executionSignal.value = { status, startTime, endTime }
|
|
19
|
+
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { notificationAPIDetected } from "./notification_context.js"
|
|
2
|
+
import {
|
|
3
|
+
notificationsEnabledSignal,
|
|
4
|
+
notificationPermissionSignal,
|
|
5
|
+
} from "./notification_signals.js"
|
|
6
|
+
|
|
7
|
+
export const enableNotifications = () => {
|
|
8
|
+
notificationsEnabledSignal.value = true
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const disableNotifications = () => {
|
|
12
|
+
notificationsEnabledSignal.value = false
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const arrayOfOpenedNotifications = []
|
|
16
|
+
export const notify = notificationAPIDetected
|
|
17
|
+
? async (
|
|
18
|
+
title,
|
|
19
|
+
{ clickToFocus = false, clickToClose = false, ...options } = {},
|
|
20
|
+
) => {
|
|
21
|
+
const notificationsEnabled = notificationsEnabledSignal.value
|
|
22
|
+
if (!notificationsEnabled) {
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
if (Notification.permission !== "granted") {
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
const notification = new Notification(title, options)
|
|
29
|
+
arrayOfOpenedNotifications.push(notification)
|
|
30
|
+
notification.onclick = () => {
|
|
31
|
+
// but if the user navigated inbetween
|
|
32
|
+
// focusing window will show something else
|
|
33
|
+
// in that case it could be great to do something
|
|
34
|
+
// maybe like showing a message saying this execution
|
|
35
|
+
// is no longer visible
|
|
36
|
+
// we could also navigauate to this file execution but
|
|
37
|
+
// there is no guarantee re-executing the file would give same output
|
|
38
|
+
// and it would also trigger an other notification
|
|
39
|
+
if (clickToFocus) window.focus()
|
|
40
|
+
if (clickToClose) notification.close()
|
|
41
|
+
}
|
|
42
|
+
notification.onclose = () => {
|
|
43
|
+
const index = arrayOfOpenedNotifications.indexOf(notification)
|
|
44
|
+
if (index > -1) {
|
|
45
|
+
arrayOfOpenedNotifications.splice(index, 1)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return notification
|
|
49
|
+
}
|
|
50
|
+
: () => {}
|
|
51
|
+
|
|
52
|
+
export const closeAllNotifications = () => {
|
|
53
|
+
// slice because arrayOfOpenedNotifications can be mutated while looping
|
|
54
|
+
arrayOfOpenedNotifications.slice().forEach((notification) => {
|
|
55
|
+
notification.close()
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let requestPromise
|
|
60
|
+
export const requestPermission = notificationAPIDetected
|
|
61
|
+
? async () => {
|
|
62
|
+
if (requestPromise) {
|
|
63
|
+
await requestPromise
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
requestPromise = Notification.requestPermission()
|
|
67
|
+
await requestPromise
|
|
68
|
+
requestPromise = undefined
|
|
69
|
+
notificationPermissionSignal.value = Notification.permission
|
|
70
|
+
}
|
|
71
|
+
: () => Promise.resolve()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const notificationAPIDetected = typeof window.Notification === "function"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { effect } from "@preact/signals"
|
|
2
|
+
|
|
3
|
+
import { notificationsEnabledSignal } from "./notification_signals.js"
|
|
4
|
+
import { closeAllNotifications } from "./notification_actions.js"
|
|
5
|
+
|
|
6
|
+
effect(() => {
|
|
7
|
+
const notificationsEnabled = notificationsEnabledSignal.value
|
|
8
|
+
if (!notificationsEnabled) {
|
|
9
|
+
closeAllNotifications()
|
|
10
|
+
}
|
|
11
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { signal } from "@preact/signals"
|
|
2
|
+
|
|
3
|
+
import { paramsFromParentWindow } from "./parent_window_context.js"
|
|
4
|
+
import { stateFromLocalStorage } from "./toolbar_state_context.js"
|
|
5
|
+
|
|
6
|
+
export const notificationsEnabledSignal = signal(
|
|
7
|
+
typeof stateFromLocalStorage.notificationsEnabled === "boolean"
|
|
8
|
+
? stateFromLocalStorage.notificationsEnabled
|
|
9
|
+
: typeof paramsFromParentWindow.notificationsEnabled === "boolean"
|
|
10
|
+
? paramsFromParentWindow.notificationsEnabled
|
|
11
|
+
: false,
|
|
12
|
+
)
|
|
13
|
+
export const notificationPermissionSignal = signal(Notification.permission)
|
package/src/client/{communication/parent_window_communication.js → core/parent_window_actions.js}
RENAMED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { parentWindowReloader } from "./parent_window_context.js"
|
|
2
|
+
|
|
1
3
|
export const sendEventToParent = (name, data) => {
|
|
2
4
|
window.parent.postMessage(
|
|
3
5
|
{
|
|
@@ -31,3 +33,11 @@ export const addExternalCommandCallback = (command, callback) => {
|
|
|
31
33
|
window.removeEventListener("message", messageEventCallback)
|
|
32
34
|
}
|
|
33
35
|
}
|
|
36
|
+
|
|
37
|
+
export const enableAutoreload = () => {
|
|
38
|
+
parentWindowReloader.autoreload.enable()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const disableAutoreload = () => {
|
|
42
|
+
parentWindowReloader.autoreload.disable()
|
|
43
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const paramsFromParentWindow = {}
|
|
2
|
+
const searchParams = new URLSearchParams(window.location.search)
|
|
3
|
+
searchParams.forEach((value, key) => {
|
|
4
|
+
paramsFromParentWindow[key] = value === "" ? true : value
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
export const parentWindowReloader = window.parent.__reloader__
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addExternalCommandCallback,
|
|
3
|
+
sendEventToParent,
|
|
4
|
+
} from "./parent_window_actions.js"
|
|
5
|
+
import { animationsEnabledSignal } from "./animation_signals.js"
|
|
6
|
+
import { initToolbarUI } from "../ui/toolbar_ui.js"
|
|
7
|
+
|
|
8
|
+
addExternalCommandCallback("initToolbar", () => {
|
|
9
|
+
// for the first render, force disable animations
|
|
10
|
+
const animationsEnabled = animationsEnabledSignal.value
|
|
11
|
+
if (animationsEnabled) {
|
|
12
|
+
animationsEnabledSignal.value = false
|
|
13
|
+
}
|
|
14
|
+
initToolbarUI()
|
|
15
|
+
if (animationsEnabled) {
|
|
16
|
+
animationsEnabledSignal.value = true
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
sendEventToParent("toolbar_ready")
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { signal } from "@preact/signals"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
paramsFromParentWindow,
|
|
5
|
+
parentWindowReloader,
|
|
6
|
+
} from "./parent_window_context.js"
|
|
7
|
+
|
|
8
|
+
export const autoreloadEnabledSignal = signal(false)
|
|
9
|
+
export const reloaderStatusSignal = signal("idle")
|
|
10
|
+
export const changesSignal = signal(0)
|
|
11
|
+
|
|
12
|
+
if (parentWindowReloader) {
|
|
13
|
+
if (
|
|
14
|
+
!parentWindowReloader.autoreload.enabled &&
|
|
15
|
+
paramsFromParentWindow.autoreload
|
|
16
|
+
) {
|
|
17
|
+
autoreloadEnabledSignal.value = true
|
|
18
|
+
} else {
|
|
19
|
+
autoreloadEnabledSignal.value = parentWindowReloader.autoreload.enabled
|
|
20
|
+
}
|
|
21
|
+
parentWindowReloader.autoreload.onchange = () => {
|
|
22
|
+
autoreloadEnabledSignal.value = parentWindowReloader.autoreload.enabled
|
|
23
|
+
}
|
|
24
|
+
reloaderStatusSignal.value = parentWindowReloader.status.value
|
|
25
|
+
const onchange = parentWindowReloader.status.onchange
|
|
26
|
+
parentWindowReloader.status.onchange = () => {
|
|
27
|
+
onchange()
|
|
28
|
+
reloaderStatusSignal.value = parentWindowReloader.status.value
|
|
29
|
+
}
|
|
30
|
+
changesSignal.value = parentWindowReloader.changes.value
|
|
31
|
+
parentWindowReloader.changes.onchange = () => {
|
|
32
|
+
changesSignal.value = [...parentWindowReloader.changes.value]
|
|
33
|
+
}
|
|
34
|
+
}
|