@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.
Files changed (165) hide show
  1. package/dist/css/{toolbar_main.css → toolbar.css} +285 -319
  2. package/dist/html/toolbar.html +91 -80
  3. package/dist/js/toolbar_core.js +1792 -0
  4. package/dist/js/toolbar_injector.js +60 -121
  5. package/dist/jsenv_plugin_toolbar.js +18 -12
  6. package/package.json +10 -3
  7. package/src/client/core/animation_actions.js +8 -0
  8. package/src/client/core/animation_effects.js +12 -0
  9. package/src/client/core/animation_signals.js +12 -0
  10. package/src/client/core/changes_actions.js +9 -0
  11. package/src/client/core/changes_signals.js +3 -0
  12. package/src/client/core/execution_actions.js +50 -0
  13. package/src/client/core/execution_effects.js +22 -0
  14. package/src/client/core/execution_signals.js +19 -0
  15. package/src/client/core/notification_actions.js +71 -0
  16. package/src/client/core/notification_context.js +1 -0
  17. package/src/client/core/notification_effects.js +11 -0
  18. package/src/client/core/notification_signals.js +13 -0
  19. package/src/client/{communication/parent_window_communication.js → core/parent_window_actions.js} +10 -0
  20. package/src/client/core/parent_window_context.js +7 -0
  21. package/src/client/core/parent_window_effects.js +20 -0
  22. package/src/client/core/parent_window_signals.js +34 -0
  23. package/src/client/core/server_actions.js +9 -0
  24. package/src/client/core/server_effects.js +11 -0
  25. package/src/client/core/server_signals.js +12 -0
  26. package/src/client/core/settings_actions.js +9 -0
  27. package/src/client/core/settings_signals.js +3 -0
  28. package/src/client/core/theme_actions.js +9 -0
  29. package/src/client/core/theme_effects.js +8 -0
  30. package/src/client/core/theme_signals.js +12 -0
  31. package/src/client/core/toolbar_logger.js +29 -0
  32. package/src/client/core/toolbar_open_actions.js +9 -0
  33. package/src/client/core/toolbar_open_effects.js +5 -0
  34. package/src/client/core/toolbar_open_signals.js +12 -0
  35. package/src/client/core/toolbar_state_context.js +5 -0
  36. package/src/client/core/toolbar_state_effects.js +10 -0
  37. package/src/client/core/toolbar_state_signals.js +20 -0
  38. package/src/client/core/tooltip_actions.js +7 -0
  39. package/src/client/toolbar.html +116 -89
  40. package/src/client/toolbar_core.js +8 -0
  41. package/src/client/toolbar_injector.js +64 -39
  42. package/src/client/ui/changes_indicator/changes_indicator.js +66 -0
  43. package/src/client/{execution/execution.css → ui/document_execution_indicator/document_execution_indicator.css} +10 -14
  44. package/src/client/ui/document_execution_indicator/document_execution_indicator.js +66 -0
  45. package/src/client/ui/document_index_link/document_index_link.js +8 -0
  46. package/src/client/ui/globals.css +103 -0
  47. package/src/client/{jsenv_logo.svg → ui/jsenv_logo.svg} +0 -0
  48. package/src/client/{eventsource/eventsource.css → ui/server_indicator/server_indicator.css} +14 -24
  49. package/src/client/ui/server_indicator/server_indicator.js +62 -0
  50. package/src/client/ui/toolbar.css +76 -0
  51. package/src/client/ui/toolbar_close_button/toolbar_close_button.js +15 -0
  52. package/src/client/{responsive/overflow_menu.css → ui/toolbar_menu_overflow/toolbar_menu_overflow.css} +10 -11
  53. package/src/client/{responsive/toolbar_responsive.js → ui/toolbar_menu_overflow/toolbar_menu_overflow.js} +25 -31
  54. package/src/client/ui/toolbar_opening/toolbar_opening.js +73 -0
  55. package/src/client/ui/toolbar_overlay/toolbar_overlay.js +76 -0
  56. package/src/client/{theme → ui/toolbar_settings}/jsenv_theme.css +6 -6
  57. package/src/client/{theme/light_theme.css → ui/toolbar_settings/theme_light.css} +9 -10
  58. package/src/client/ui/toolbar_settings/toolbar_animation_setting.js +27 -0
  59. package/src/client/ui/toolbar_settings/toolbar_autoreload_setting.js +79 -0
  60. package/src/client/ui/toolbar_settings/toolbar_notification_setting.js +88 -0
  61. package/src/client/{settings/settings.css → ui/toolbar_settings/toolbar_settings.css} +24 -23
  62. package/src/client/ui/toolbar_settings/toolbar_settings.js +54 -0
  63. package/src/client/ui/toolbar_settings/toolbar_theme_setting.js +17 -0
  64. package/src/client/ui/toolbar_ui.js +21 -0
  65. package/src/client/{tooltip/tooltip.css → ui/tooltips/tooltips.css} +13 -7
  66. package/src/client/{util → ui/util}/animation.js +0 -0
  67. package/src/client/ui/util/dom.js +57 -0
  68. package/src/client/{util → ui/util}/fetch_using_xhr.js +0 -0
  69. package/src/client/{util → ui/util}/fetching.js +0 -0
  70. package/src/client/{util → ui/util}/iframe_to_parent_href.js +0 -0
  71. package/src/client/{util → ui/util}/responsive.js +0 -0
  72. package/src/client/{util → ui/util}/util.js +0 -0
  73. package/src/client/{variant → ui}/variant.js +0 -0
  74. package/src/jsenv_plugin_toolbar.js +19 -7
  75. package/dist/js/toolbar_main.js +0 -900
  76. package/scripts/build.mjs +0 -20
  77. package/src/client/animation/toolbar_animation_core.js +0 -30
  78. package/src/client/animation/toolbar_animation_ui.js +0 -21
  79. package/src/client/eventsource/toolbar_eventsource.js +0 -57
  80. package/src/client/execution/toolbar_execution.js +0 -88
  81. package/src/client/focus/focus.css +0 -61
  82. package/src/client/focus/toolbar_focus.js +0 -19
  83. package/src/client/notification/toolbar_notification.js +0 -181
  84. package/src/client/settings/toolbar_settings.js +0 -47
  85. package/src/client/theme/toolbar_theme.js +0 -34
  86. package/src/client/toolbar_main.css +0 -173
  87. package/src/client/toolbar_main.js +0 -174
  88. package/src/client/toolbar_state.js +0 -16
  89. package/src/client/tooltip/tooltip.js +0 -39
  90. package/src/client/util/dom.js +0 -108
  91. package/src/client/util/jsenv_logger.js +0 -28
  92. package/src/client/util/preferences.js +0 -10
  93. 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
  94. 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
  95. 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
  96. 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
  97. 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
  98. 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
  99. 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
  100. 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
  101. 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
  102. 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
  103. 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
  104. 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
  105. 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
  106. 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
  107. 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
  108. 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
  109. 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
  110. 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
  111. 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
  112. 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
  113. 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
  114. 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
  115. 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
  116. 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
  117. 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
  118. 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
  119. 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
  120. 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
  121. 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
  122. 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
  123. 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
  124. 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
  125. 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
  126. 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
  127. 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
  128. 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
  129. 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
  130. 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
  131. 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
  132. 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
  133. 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
  134. 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
  135. 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
  136. 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
  137. 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
  138. 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
  139. 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
  140. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/autoreload.js +0 -201
  141. 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
  142. 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
  143. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/autoreload/client/reload.js +0 -138
  144. 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
  145. 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
  146. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/explorer/client/explorer.html +0 -590
  147. 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
  148. 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
  149. 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
  150. 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
  151. 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
  152. 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
  153. 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
  154. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/ribbon/client/ribbon.js +0 -51
  155. 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
  156. 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
  157. 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
  158. 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
  159. 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
  160. 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
  161. 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
  162. package/tests/toolbar_basic/.jsenv/chrome@107.00/@fs/Users/d.maillard/dev/jsenv/jsenv-core/src/plugins/supervisor/client/supervisor.js +0 -966
  163. package/tests/toolbar_basic/main.html +0 -18
  164. package/tests/toolbar_basic/start_dev_server.mjs +0 -7
  165. package/todo.txt +0 -0
package/scripts/build.mjs DELETED
@@ -1,20 +0,0 @@
1
- import { build } from "@jsenv/core"
2
-
3
- build({
4
- rootDirectoryUrl: new URL("../", import.meta.url),
5
- buildDirectoryUrl: new URL("../dist/", import.meta.url),
6
- entryPoints: {
7
- "./src/jsenv_plugin_toolbar.js": "jsenv_plugin_toolbar.js",
8
- },
9
- runtimeCompat: {
10
- node: "16.14",
11
- },
12
- urlAnalysis: {
13
- include: {
14
- "/**/*": true,
15
- "/**/node_modules/@jsenv/ast/": false, // cannot inline "parse5", "@babel/core" and "postcss"
16
- },
17
- },
18
- minification: false,
19
- versioning: false,
20
- })
@@ -1,30 +0,0 @@
1
- import { toolbarState, updateToolbarState } from "../toolbar_state.js"
2
- import { createPreference } from "../util/preferences.js"
3
-
4
- const animationPreference = createPreference("jsenv_toolbar_animation")
5
-
6
- export const animationsAreEnabled = () => {
7
- return toolbarState.animationsEnabled
8
- }
9
-
10
- export const enableAnimations = () => {
11
- updateToolbarState({
12
- animationsEnabled: true,
13
- })
14
- animationPreference.set(true)
15
- document.documentElement.removeAttribute("data-animation-disabled")
16
- }
17
-
18
- export const disableAnimations = () => {
19
- updateToolbarState({
20
- animationsEnabled: false,
21
- })
22
- animationPreference.set(false)
23
- document.documentElement.setAttribute("data-animation-disabled", "")
24
- }
25
-
26
- updateToolbarState({
27
- animationsEnabled: animationPreference.has()
28
- ? animationPreference.get()
29
- : true,
30
- })
@@ -1,21 +0,0 @@
1
- import {
2
- animationsAreEnabled,
3
- enableAnimations,
4
- disableAnimations,
5
- } from "./toolbar_animation_core.js"
6
-
7
- export const renderToolbarAnimation = () => {
8
- const animCheckbox = document.querySelector("#toggle-anims")
9
- animCheckbox.checked = animationsAreEnabled()
10
- animCheckbox.onchange = () => {
11
- if (animCheckbox.checked) {
12
- enableAnimations()
13
- } else {
14
- disableAnimations()
15
- }
16
- }
17
- // enable toolbar transition only after first render
18
- setTimeout(() => {
19
- document.querySelector("#toolbar").setAttribute("data-animate", "")
20
- })
21
- }
@@ -1,57 +0,0 @@
1
- import { removeForceHideElement } from "../util/dom.js"
2
- import { enableVariant } from "../variant/variant.js"
3
- import {
4
- toggleTooltip,
5
- removeAutoShowTooltip,
6
- autoShowTooltip,
7
- } from "../tooltip/tooltip.js"
8
-
9
- const parentEventSourceClient = window.parent.__jsenv_event_source_client__
10
-
11
- export const initToolbarEventSource = () => {
12
- removeForceHideElement(document.querySelector("#eventsource-indicator"))
13
- if (!parentEventSourceClient) {
14
- disableAutoreloadSetting()
15
- return
16
- }
17
- parentEventSourceClient.status.onchange = () => {
18
- updateEventSourceIndicator()
19
- }
20
- updateEventSourceIndicator()
21
- }
22
-
23
- const updateEventSourceIndicator = () => {
24
- const eventSourceIndicator = document.querySelector("#eventsource-indicator")
25
- const eventSourceConnectionState = parentEventSourceClient.status.value
26
- enableVariant(eventSourceIndicator, {
27
- eventsource: eventSourceConnectionState,
28
- })
29
- const variantNode = document.querySelector(
30
- "#eventsource-indicator > [data-when-active]",
31
- )
32
- variantNode.querySelector("button").onclick = () => {
33
- toggleTooltip(eventSourceIndicator)
34
- }
35
- if (eventSourceConnectionState === "connecting") {
36
- variantNode.querySelector("a").onclick = () => {
37
- parentEventSourceClient.disconnect()
38
- }
39
- } else if (eventSourceConnectionState === "connected") {
40
- removeAutoShowTooltip(eventSourceIndicator)
41
- } else if (eventSourceConnectionState === "disconnected") {
42
- autoShowTooltip(eventSourceIndicator)
43
- variantNode.querySelector("a").onclick = () => {
44
- parentEventSourceClient.connect()
45
- }
46
- }
47
- }
48
-
49
- const disableAutoreloadSetting = () => {
50
- document
51
- .querySelector(".settings-autoreload")
52
- .setAttribute("data-disabled", "true")
53
- document
54
- .querySelector(".settings-autoreload")
55
- .setAttribute("title", `Autoreload not available: disabled by server`)
56
- document.querySelector("#toggle-autoreload").disabled = true
57
- }
@@ -1,88 +0,0 @@
1
- import { removeForceHideElement } from "../util/dom.js"
2
- import { enableVariant } from "../variant/variant.js"
3
- import { toggleTooltip } from "../tooltip/tooltip.js"
4
- import { notifyExecutionResult } from "../notification/toolbar_notification.js"
5
-
6
- export const renderExecutionInToolbar = async () => {
7
- // reset file execution indicator ui
8
- applyExecutionIndicator()
9
- removeForceHideElement(document.querySelector("#execution-indicator"))
10
-
11
- const { status, startTime, endTime } =
12
- await window.parent.__supervisor__.getDocumentExecutionResult()
13
- const execution = { status, startTime, endTime }
14
- applyExecutionIndicator(execution)
15
- const executionStorageKey = window.location.href
16
- const previousExecution = sessionStorage.hasOwnProperty(executionStorageKey)
17
- ? JSON.parse(sessionStorage.getItem(executionStorageKey))
18
- : undefined
19
- notifyExecutionResult(executionStorageKey, execution, previousExecution)
20
- sessionStorage.setItem(executionStorageKey, JSON.stringify(execution))
21
- }
22
-
23
- // const changeLink = variantNode.querySelector(".eventsource-changes-link")
24
- // changeLink.innerHTML = reloadMessageCount
25
- // changeLink.onclick = () => {
26
- // console.log(reloadMessages)
27
- // // eslint-disable-next-line no-alert
28
- // window.parent.alert(JSON.stringify(reloadMessages, null, " "))
29
- // }
30
-
31
- // const someFailed = reloadMessages.some((m) => m.status === "failed")
32
- // const somePending = reloadMessages.some((m) => m.status === "pending")
33
- // const applyLink = variantNode.querySelector(".eventsource-reload-link")
34
- // applyLink.innerHTML = someFailed
35
- // ? "failed"
36
- // : somePending
37
- // ? "applying..."
38
- // : "apply changes"
39
- // applyLink.onclick = someFailed
40
- // ? () => {
41
- // parentEventSourceClient.applyReloadMessageEffects()
42
- // }
43
- // : somePending
44
- // ? () => {}
45
- // : () => {
46
- // parentEventSourceClient.applyReloadMessageEffects()
47
- // }
48
-
49
- // parentEventSourceClient.reloadMessagesSignal.onchange = () => {
50
- // updateEventSourceIndicator()
51
- // }
52
- // const autoreloadCheckbox = document.querySelector("#toggle-autoreload")
53
- // autoreloadCheckbox.checked = parentEventSourceClient.isAutoreloadEnabled()
54
- // autoreloadCheckbox.onchange = () => {
55
- // parentEventSourceClient.setAutoreloadPreference(autoreloadCheckbox.checked)
56
- // updateEventSourceIndicator()
57
- // }
58
-
59
- const applyExecutionIndicator = ({
60
- status = "running",
61
- startTime,
62
- endTime,
63
- } = {}) => {
64
- const executionIndicator = document.querySelector("#execution-indicator")
65
- enableVariant(executionIndicator, { execution: status })
66
- const variantNode = executionIndicator.querySelector("[data-when-active]")
67
- variantNode.querySelector("button").onclick = () =>
68
- toggleTooltip(executionIndicator)
69
- variantNode.querySelector(".tooltip").textContent = computeText({
70
- status,
71
- startTime,
72
- endTime,
73
- })
74
- }
75
-
76
- // relative time: https://github.com/tc39/proposal-intl-relative-time/issues/118
77
- const computeText = ({ status, startTime, endTime }) => {
78
- if (status === "completed") {
79
- return `Execution completed in ${endTime - startTime}ms`
80
- }
81
- if (status === "errored") {
82
- return `Execution failed in ${endTime - startTime}ms`
83
- }
84
- if (status === "running") {
85
- return "Executing..."
86
- }
87
- return ""
88
- }
@@ -1,61 +0,0 @@
1
- button:focus,
2
- a:focus,
3
- input:focus,
4
- *[data-contains-hidden-input] input:focus + * {
5
- outline-style: none;
6
- outline-offset: -2px;
7
- }
8
-
9
- *[data-contains-hidden-input] input:focus + * {
10
- outline-width: 4px;
11
- outline-offset: -2px;
12
- }
13
-
14
- html[data-last-interaction="keyboard"] button:focus,
15
- html[data-last-interaction="keyboard"] a:focus,
16
- html[data-last-interaction="keyboard"] input:focus,
17
- html[data-last-interaction="keyboard"]
18
- *[data-contains-hidden-input]
19
- input:focus
20
- + * {
21
- outline-style: auto;
22
- }
23
-
24
- html[data-last-interaction="keyboard"]
25
- *[data-contains-hidden-input]
26
- input:focus
27
- + * {
28
- outline-color: rgb(0, 150, 255);
29
- }
30
-
31
- /*
32
- Don't try to replace @-moz-document url-prefix() this by
33
-
34
- -moz-outline or -moz-outline-color
35
- Because firefox would take into account outline instead of -moz-outline
36
-
37
- :moz-focus-ring
38
- Because for some element we set the focus outline on a div which would not match :focusring
39
- */
40
- @-moz-document url-prefix() {
41
- html[data-last-interaction="keyboard"] button:focus,
42
- html[data-last-interaction="keyboard"] a:focus,
43
- html[data-last-interaction="keyboard"] input:focus,
44
- html[data-last-interaction="keyboard"]
45
- *[data-input-customized]
46
- input:focus
47
- + * {
48
- outline-width: 2px;
49
- outline-offset: 0;
50
- outline-style: solid;
51
- /*
52
- force a blue color for firefox otherwise
53
- it uses outline-color: inherit
54
- making it unpredictible and sometimes hard to see
55
- */
56
- outline-color: rgb(0, 150, 255);
57
- }
58
- }
59
- ::-moz-focus-inner {
60
- border: 0;
61
- }
@@ -1,19 +0,0 @@
1
- // handle data-last-interaction attr on html (focusring)
2
- window.addEventListener("mousedown", (mousedownEvent) => {
3
- if (mousedownEvent.defaultPrevented) {
4
- return
5
- }
6
- document.documentElement.setAttribute("data-last-interaction", "mouse")
7
- })
8
- window.addEventListener("touchstart", (touchstartEvent) => {
9
- if (touchstartEvent.defaultPrevented) {
10
- return
11
- }
12
- document.documentElement.setAttribute("data-last-interaction", "mouse")
13
- })
14
- window.addEventListener("keydown", (keydownEvent) => {
15
- if (keydownEvent.defaultPrevented) {
16
- return
17
- }
18
- document.documentElement.setAttribute("data-last-interaction", "keyboard")
19
- })
@@ -1,181 +0,0 @@
1
- import { createPreference } from "../util/preferences.js"
2
- import { enableVariant } from "../variant/variant.js"
3
-
4
- const notificationAvailable = typeof window.Notification === "function"
5
- const notificationPreference = createPreference("notification")
6
-
7
- const arrayOfOpenedNotifications = []
8
- export const renderToolbarNotification = () => {
9
- if (!notificationAvailable) {
10
- applyNotificationNotAvailableEffects()
11
- return
12
- }
13
- updatePermission()
14
- }
15
-
16
- const updatePermission = () => {
17
- const notifPermission = Notification.permission
18
- if (notifPermission === "default") {
19
- applyNotificationDefaultEffects()
20
- return
21
- }
22
- if (notifPermission === "denied") {
23
- applyNotificationDeniedEffects()
24
- return
25
- }
26
- if (notifPermission === "granted") {
27
- applyNotificationGrantedEffects()
28
- return
29
- }
30
- }
31
-
32
- const notifCheckbox = document.querySelector("#toggle-notifs")
33
-
34
- const applyNotificationNotAvailableEffects = () => {
35
- const notifSetting = document.querySelector(".settings-notification")
36
- notifSetting.setAttribute("data-disabled", "true")
37
- notifSetting.setAttribute(
38
- "title",
39
- `Notification not available in the browser`,
40
- )
41
- notifCheckbox.disabled = true
42
- }
43
- const applyNotificationDefaultEffects = () => {
44
- applyNotificationNOTGrantedEffects()
45
- const notifSetting = document.querySelector(".settings-notification")
46
- notifSetting.removeAttribute("data-disabled")
47
- notifSetting.removeAttribute("title")
48
- }
49
- const applyNotificationDeniedEffects = () => {
50
- applyNotificationNOTGrantedEffects()
51
- const notifSetting = document.querySelector(".settings-notification")
52
- notifSetting.setAttribute("data-disabled", "true")
53
- notifSetting.setAttribute("title", `Notification denied`)
54
- }
55
- const applyNotificationGrantedEffects = () => {
56
- enableVariant(document.querySelector(".notification-text"), {
57
- notif_granted: "yes",
58
- })
59
- notifCheckbox.disabled = false
60
- notifCheckbox.checked = getNotificationPreference()
61
- notifCheckbox.onchange = () => {
62
- setNotificationPreference(notifCheckbox.checked)
63
- if (!notifCheckbox.checked) {
64
- // slice because arrayOfOpenedNotifications can be mutated while looping
65
- arrayOfOpenedNotifications.slice().forEach((notification) => {
66
- notification.close()
67
- })
68
- }
69
- }
70
- }
71
- const applyNotificationNOTGrantedEffects = () => {
72
- enableVariant(document.querySelector(".notification-text"), {
73
- notif_granted: "no",
74
- })
75
- notifCheckbox.disabled = true
76
- notifCheckbox.checked = false
77
- document.querySelector("a.request_notification_permission").onclick = () => {
78
- requestPermission().then(() => {
79
- setNotificationPreference(true)
80
- updatePermission()
81
- })
82
- }
83
- }
84
-
85
- export const notifyExecutionResult = (
86
- executedFileRelativeUrl,
87
- execution,
88
- previousExecution,
89
- ) => {
90
- const notificationEnabled = getNotificationPreference()
91
- if (!notificationEnabled) return
92
-
93
- const notificationOptions = {
94
- lang: "en",
95
- icon: getFaviconHref(),
96
- clickToFocus: true,
97
- clickToClose: true,
98
- }
99
-
100
- if (execution.status === "errored") {
101
- if (previousExecution) {
102
- if (previousExecution.status === "completed") {
103
- notify("Broken", {
104
- ...notificationOptions,
105
- body: `${executedFileRelativeUrl} execution now failing.`,
106
- })
107
- } else {
108
- notify("Still failing", {
109
- ...notificationOptions,
110
- body: `${executedFileRelativeUrl} execution still failing.`,
111
- })
112
- }
113
- } else {
114
- notify("Failing", {
115
- ...notificationOptions,
116
- body: `${executedFileRelativeUrl} execution failed.`,
117
- })
118
- }
119
- } else if (previousExecution && previousExecution.status === "errored") {
120
- notify("Fixed", {
121
- ...notificationOptions,
122
- body: `${executedFileRelativeUrl} execution fixed.`,
123
- })
124
- }
125
- }
126
-
127
- const getNotificationPreference = () =>
128
- notificationPreference.has() ? notificationPreference.get() : true
129
-
130
- const setNotificationPreference = (value) => notificationPreference.set(value)
131
-
132
- const getFaviconHref = () => {
133
- const link = document.querySelector('link[rel="icon"]')
134
- return link ? link.href : undefined
135
- }
136
-
137
- let permission = "default"
138
-
139
- const notify = notificationAvailable
140
- ? async (
141
- title,
142
- { clickToFocus = false, clickToClose = false, ...options } = {},
143
- ) => {
144
- if (permission !== "granted") {
145
- return null
146
- }
147
-
148
- const notification = new Notification(title, options)
149
- arrayOfOpenedNotifications.push(notification)
150
- notification.onclick = () => {
151
- // but if the user navigated inbetween
152
- // focusing window will show something else
153
- // in that case it could be great to do something
154
- // maybe like showing a message saying this execution
155
- // is no longer visible
156
- // we could also navigauate to this file execution but
157
- // there is no guarantee re-executing the file would give same output
158
- // and it would also trigger an other notification
159
- if (clickToFocus) window.focus()
160
- if (clickToClose) notification.close()
161
- }
162
- notification.onclose = () => {
163
- const index = arrayOfOpenedNotifications.indexOf(notification)
164
- if (index > -1) {
165
- arrayOfOpenedNotifications.splice(index, 1)
166
- }
167
- }
168
- return notification
169
- }
170
- : () => {}
171
-
172
- let requestPromise
173
- const requestPermission = notificationAvailable
174
- ? async () => {
175
- if (requestPromise) return requestPromise
176
- requestPromise = Notification.requestPermission()
177
- permission = await requestPromise
178
- requestPromise = undefined
179
- return permission
180
- }
181
- : () => Promise.resolve("default")
@@ -1,47 +0,0 @@
1
- import {
2
- toolbarSectionIsActive,
3
- deactivateToolbarSection,
4
- activateToolbarSection,
5
- updateIframeOverflowOnParentWindow,
6
- } from "../util/dom.js"
7
- import { enableVariant } from "../variant/variant.js"
8
-
9
- export const renderToolbarSettings = () => {
10
- document.querySelector("#settings-button").onclick = toggleSettings
11
- document.querySelector("#button-close-settings").onclick = toggleSettings
12
- disableWarningStyle()
13
- }
14
-
15
- const toggleSettings = () => {
16
- if (settingsAreVisible()) {
17
- hideSettings()
18
- } else {
19
- showSettings()
20
- }
21
- }
22
-
23
- export const enableWarningStyle = () => {
24
- enableVariant(document.querySelector("#settings-button"), {
25
- has_warning: "yes",
26
- })
27
- }
28
-
29
- export const disableWarningStyle = () => {
30
- enableVariant(document.querySelector("#settings-button"), {
31
- has_warning: "no",
32
- })
33
- }
34
-
35
- export const settingsAreVisible = () => {
36
- return toolbarSectionIsActive(document.querySelector(`#settings`))
37
- }
38
-
39
- export const hideSettings = () => {
40
- deactivateToolbarSection(document.querySelector(`#settings`))
41
- updateIframeOverflowOnParentWindow()
42
- }
43
-
44
- export const showSettings = () => {
45
- activateToolbarSection(document.querySelector(`#settings`))
46
- updateIframeOverflowOnParentWindow()
47
- }
@@ -1,34 +0,0 @@
1
- import { createPreference } from "../util/preferences.js"
2
-
3
- const DARK_THEME = "dark"
4
- const LIGHT_THEME = "light"
5
- const themePreference = createPreference("jsenv_toolbar_theme")
6
-
7
- export const renderToolbarTheme = () => {
8
- const theme = getThemePreference()
9
- const checkbox = document.querySelector("#checkbox-dark-theme")
10
- checkbox.checked = theme === DARK_THEME
11
- setTheme(theme)
12
- checkbox.onchange = () => {
13
- if (checkbox.checked) {
14
- setThemePreference(DARK_THEME)
15
- setTheme(DARK_THEME)
16
- } else {
17
- setThemePreference(LIGHT_THEME)
18
- setTheme(LIGHT_THEME)
19
- }
20
- }
21
- }
22
-
23
- const getThemePreference = () => {
24
- return themePreference.has() ? themePreference.get() : DARK_THEME
25
- }
26
-
27
- const setThemePreference = (value) => {
28
- themePreference.set(value)
29
- setTheme(value)
30
- }
31
-
32
- const setTheme = (theme) => {
33
- document.querySelector("html").setAttribute("data-theme", theme)
34
- }