@jsenv/plugin-toolbar 0.1.13 → 0.1.15
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/html/toolbar.html +5 -4
- package/dist/jsenv_plugin_toolbar.js +30 -7
- package/package.json +3 -3
- 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 +55 -30
package/dist/html/toolbar.html
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
<!DOCTYPE html
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
2
4
|
<title>Jsenv toolbar</title>
|
|
3
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
4
6
|
<meta charset="utf-8">
|
|
@@ -311,6 +313,5 @@
|
|
|
311
313
|
</svg>
|
|
312
314
|
</div>
|
|
313
315
|
<script type="module" src="../js/toolbar_core.js" data-jsenv-force-inline="" no-html-supervisor=""></script>
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
</body></html>
|
|
316
|
+
</body>
|
|
317
|
+
</html>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseHtmlString,
|
|
1
|
+
import { parseHtmlString, injectHtmlNodeAsEarlyAsPossible, createHtmlNode, stringifyHtmlAst } from "@jsenv/ast";
|
|
2
2
|
|
|
3
3
|
const jsenvPluginToolbar = ({
|
|
4
4
|
logLevel = "warn",
|
|
@@ -30,20 +30,19 @@ const jsenvPluginToolbar = ({
|
|
|
30
30
|
expectedType: "html",
|
|
31
31
|
specifier: toolbarHtmlClientFileUrl
|
|
32
32
|
});
|
|
33
|
-
|
|
33
|
+
injectHtmlNodeAsEarlyAsPossible(htmlAst, createHtmlNode({
|
|
34
34
|
tagName: "script",
|
|
35
35
|
type: "module",
|
|
36
|
-
textContent:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
toolbarUrl: toolbarClientFileReference.generatedSpecifier,
|
|
36
|
+
textContent: generateCodeToInjectToolbar({
|
|
37
|
+
toolbarInjectorReference,
|
|
38
|
+
toolbarClientFileReference,
|
|
40
39
|
logLevel,
|
|
41
40
|
theme,
|
|
42
41
|
opened,
|
|
43
42
|
autoreload,
|
|
44
43
|
animationsEnabled,
|
|
45
44
|
notificationsEnabled
|
|
46
|
-
}
|
|
45
|
+
})
|
|
47
46
|
}), "jsenv:toolbar");
|
|
48
47
|
const htmlModified = stringifyHtmlAst(htmlAst);
|
|
49
48
|
return {
|
|
@@ -53,5 +52,29 @@ injectToolbar(${JSON.stringify({
|
|
|
53
52
|
}
|
|
54
53
|
};
|
|
55
54
|
};
|
|
55
|
+
const generateCodeToInjectToolbar = ({
|
|
56
|
+
toolbarInjectorReference,
|
|
57
|
+
toolbarClientFileReference,
|
|
58
|
+
logLevel,
|
|
59
|
+
theme,
|
|
60
|
+
opened,
|
|
61
|
+
autoreload,
|
|
62
|
+
animationsEnabled,
|
|
63
|
+
notificationsEnabled
|
|
64
|
+
}) => {
|
|
65
|
+
const from = toolbarInjectorReference.generatedSpecifier;
|
|
66
|
+
const paramsSource = JSON.stringify({
|
|
67
|
+
toolbarUrl: toolbarClientFileReference.generatedSpecifier,
|
|
68
|
+
logLevel,
|
|
69
|
+
theme,
|
|
70
|
+
opened,
|
|
71
|
+
autoreload,
|
|
72
|
+
animationsEnabled,
|
|
73
|
+
notificationsEnabled
|
|
74
|
+
}, null, " ");
|
|
75
|
+
return `import { injectToolbar } from ${from}
|
|
76
|
+
|
|
77
|
+
injectToolbar(${paramsSource});`;
|
|
78
|
+
};
|
|
56
79
|
|
|
57
80
|
export { jsenvPluginToolbar };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/plugin-toolbar",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/jsenv/
|
|
7
|
+
"url": "https://github.com/jsenv/core",
|
|
8
8
|
"directory": "packages/jsenv-plugin-toolbar"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"/src/"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@jsenv/ast": "3.0.
|
|
29
|
+
"@jsenv/ast": "3.0.8",
|
|
30
30
|
"@preact/signals": "1.1.3"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { animationsEnabledSignal } from "./animation_signals.js"
|
|
1
|
+
import { animationsEnabledSignal } from "./animation_signals.js";
|
|
2
2
|
|
|
3
3
|
export const enableAnimations = () => {
|
|
4
|
-
animationsEnabledSignal.value = true
|
|
5
|
-
}
|
|
4
|
+
animationsEnabledSignal.value = true;
|
|
5
|
+
};
|
|
6
6
|
export const disableAnimations = () => {
|
|
7
|
-
animationsEnabledSignal.value = false
|
|
8
|
-
}
|
|
7
|
+
animationsEnabledSignal.value = false;
|
|
8
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { effect } from "@preact/signals"
|
|
1
|
+
import { effect } from "@preact/signals";
|
|
2
2
|
|
|
3
|
-
import { animationsEnabledSignal } from "./animation_signals.js"
|
|
3
|
+
import { animationsEnabledSignal } from "./animation_signals.js";
|
|
4
4
|
|
|
5
5
|
effect(() => {
|
|
6
|
-
const animationsEnabled = animationsEnabledSignal.value
|
|
6
|
+
const animationsEnabled = animationsEnabledSignal.value;
|
|
7
7
|
if (animationsEnabled) {
|
|
8
|
-
document.documentElement.removeAttribute("data-animation-disabled")
|
|
8
|
+
document.documentElement.removeAttribute("data-animation-disabled");
|
|
9
9
|
} else {
|
|
10
|
-
document.documentElement.setAttribute("data-animation-disabled", "")
|
|
10
|
+
document.documentElement.setAttribute("data-animation-disabled", "");
|
|
11
11
|
}
|
|
12
|
-
})
|
|
12
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { signal } from "@preact/signals"
|
|
1
|
+
import { signal } from "@preact/signals";
|
|
2
2
|
|
|
3
|
-
import { paramsFromParentWindow } from "./parent_window_context.js"
|
|
4
|
-
import { stateFromLocalStorage } from "./toolbar_state_context.js"
|
|
3
|
+
import { paramsFromParentWindow } from "./parent_window_context.js";
|
|
4
|
+
import { stateFromLocalStorage } from "./toolbar_state_context.js";
|
|
5
5
|
|
|
6
6
|
export const animationsEnabledSignal = signal(
|
|
7
7
|
typeof stateFromLocalStorage.animationsEnabled === "boolean"
|
|
@@ -9,4 +9,4 @@ export const animationsEnabledSignal = signal(
|
|
|
9
9
|
: typeof paramsFromParentWindow.animationsEnabled === "boolean"
|
|
10
10
|
? paramsFromParentWindow.animationsEnabled
|
|
11
11
|
: false,
|
|
12
|
-
)
|
|
12
|
+
);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { changesTooltipOpenedSignal } from "./changes_signals.js"
|
|
1
|
+
import { changesTooltipOpenedSignal } from "./changes_signals.js";
|
|
2
2
|
|
|
3
3
|
export const openChangesToolip = () => {
|
|
4
|
-
changesTooltipOpenedSignal.value = true
|
|
5
|
-
}
|
|
4
|
+
changesTooltipOpenedSignal.value = true;
|
|
5
|
+
};
|
|
6
6
|
|
|
7
7
|
export const closeChangesToolip = () => {
|
|
8
|
-
changesTooltipOpenedSignal.value = false
|
|
9
|
-
}
|
|
8
|
+
changesTooltipOpenedSignal.value = false;
|
|
9
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { signal } from "@preact/signals"
|
|
1
|
+
import { signal } from "@preact/signals";
|
|
2
2
|
|
|
3
|
-
export const changesTooltipOpenedSignal = signal(false)
|
|
3
|
+
export const changesTooltipOpenedSignal = signal(false);
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { executionTooltipOpenedSignal } from "./execution_signals.js"
|
|
2
|
-
import { notify } from "./notification_actions.js"
|
|
1
|
+
import { executionTooltipOpenedSignal } from "./execution_signals.js";
|
|
2
|
+
import { notify } from "./notification_actions.js";
|
|
3
3
|
|
|
4
4
|
export const openExecutionTooltip = () => {
|
|
5
|
-
executionTooltipOpenedSignal.value = true
|
|
6
|
-
}
|
|
5
|
+
executionTooltipOpenedSignal.value = true;
|
|
6
|
+
};
|
|
7
7
|
|
|
8
8
|
export const closeExecutionTooltip = () => {
|
|
9
|
-
executionTooltipOpenedSignal.value = false
|
|
10
|
-
}
|
|
9
|
+
executionTooltipOpenedSignal.value = false;
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
export const notifyExecutionResult = (execution, previousExecution) => {
|
|
13
|
-
const executedFileRelativeUrl = window.location.href
|
|
13
|
+
const executedFileRelativeUrl = window.location.href;
|
|
14
14
|
const notificationOptions = {
|
|
15
15
|
lang: "en",
|
|
16
16
|
icon: getFaviconHref(),
|
|
17
17
|
clickToFocus: true,
|
|
18
18
|
clickToClose: true,
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
20
|
if (execution.status === "failed") {
|
|
21
21
|
if (previousExecution) {
|
|
22
22
|
if (previousExecution.status === "completed") {
|
|
23
23
|
notify("Broken", {
|
|
24
24
|
...notificationOptions,
|
|
25
25
|
body: `${executedFileRelativeUrl} execution now failing.`,
|
|
26
|
-
})
|
|
26
|
+
});
|
|
27
27
|
} else {
|
|
28
28
|
notify("Still failing", {
|
|
29
29
|
...notificationOptions,
|
|
30
30
|
body: `${executedFileRelativeUrl} execution still failing.`,
|
|
31
|
-
})
|
|
31
|
+
});
|
|
32
32
|
}
|
|
33
33
|
} else {
|
|
34
34
|
notify("Failing", {
|
|
35
35
|
...notificationOptions,
|
|
36
36
|
body: `${executedFileRelativeUrl} execution failed.`,
|
|
37
|
-
})
|
|
37
|
+
});
|
|
38
38
|
}
|
|
39
39
|
} else if (previousExecution && previousExecution.status === "failed") {
|
|
40
40
|
notify("Fixed", {
|
|
41
41
|
...notificationOptions,
|
|
42
42
|
body: `${executedFileRelativeUrl} execution fixed.`,
|
|
43
|
-
})
|
|
43
|
+
});
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
};
|
|
46
46
|
|
|
47
47
|
const getFaviconHref = () => {
|
|
48
|
-
const link = document.querySelector('link[rel="icon"]')
|
|
49
|
-
return link ? link.href : undefined
|
|
50
|
-
}
|
|
48
|
+
const link = document.querySelector('link[rel="icon"]');
|
|
49
|
+
return link ? link.href : undefined;
|
|
50
|
+
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { effect } from "@preact/signals"
|
|
1
|
+
import { effect } from "@preact/signals";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
executionSignal,
|
|
5
5
|
previousExecutionSignal,
|
|
6
|
-
} from "./execution_signals.js"
|
|
7
|
-
import { notifyExecutionResult } from "./execution_actions.js"
|
|
6
|
+
} from "./execution_signals.js";
|
|
7
|
+
import { notifyExecutionResult } from "./execution_actions.js";
|
|
8
8
|
|
|
9
9
|
effect(() => {
|
|
10
|
-
const execution = executionSignal.value
|
|
10
|
+
const execution = executionSignal.value;
|
|
11
11
|
if (execution) {
|
|
12
|
-
sessionStorage.setItem(window.location.href, JSON.stringify(execution))
|
|
12
|
+
sessionStorage.setItem(window.location.href, JSON.stringify(execution));
|
|
13
13
|
}
|
|
14
|
-
})
|
|
14
|
+
});
|
|
15
15
|
|
|
16
16
|
effect(() => {
|
|
17
|
-
const execution = executionSignal.value
|
|
18
|
-
const previousExecution = previousExecutionSignal.value
|
|
17
|
+
const execution = executionSignal.value;
|
|
18
|
+
const previousExecution = previousExecutionSignal.value;
|
|
19
19
|
if (execution) {
|
|
20
|
-
notifyExecutionResult(execution, previousExecution)
|
|
20
|
+
notifyExecutionResult(execution, previousExecution);
|
|
21
21
|
}
|
|
22
|
-
})
|
|
22
|
+
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { signal } from "@preact/signals"
|
|
1
|
+
import { signal } from "@preact/signals";
|
|
2
2
|
|
|
3
|
-
export const executionTooltipOpenedSignal = signal(false)
|
|
3
|
+
export const executionTooltipOpenedSignal = signal(false);
|
|
4
4
|
|
|
5
5
|
export const executionSignal = signal({
|
|
6
6
|
status: "running",
|
|
7
|
-
})
|
|
7
|
+
});
|
|
8
8
|
|
|
9
9
|
export const previousExecutionSignal = signal(
|
|
10
10
|
sessionStorage.hasOwnProperty(window.location.href)
|
|
11
11
|
? JSON.parse(sessionStorage.getItem(window.location.href))
|
|
12
12
|
: null,
|
|
13
|
-
)
|
|
13
|
+
);
|
|
14
14
|
|
|
15
15
|
window.parent.__supervisor__
|
|
16
16
|
.getDocumentExecutionResult()
|
|
17
17
|
.then(({ status, startTime, endTime }) => {
|
|
18
|
-
executionSignal.value = { status, startTime, endTime }
|
|
19
|
-
})
|
|
18
|
+
executionSignal.value = { status, startTime, endTime };
|
|
19
|
+
});
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { notificationAPIDetected } from "./notification_context.js"
|
|
1
|
+
import { notificationAPIDetected } from "./notification_context.js";
|
|
2
2
|
import {
|
|
3
3
|
notificationsEnabledSignal,
|
|
4
4
|
notificationPermissionSignal,
|
|
5
|
-
} from "./notification_signals.js"
|
|
5
|
+
} from "./notification_signals.js";
|
|
6
6
|
|
|
7
7
|
export const enableNotifications = () => {
|
|
8
|
-
notificationsEnabledSignal.value = true
|
|
9
|
-
}
|
|
8
|
+
notificationsEnabledSignal.value = true;
|
|
9
|
+
};
|
|
10
10
|
|
|
11
11
|
export const disableNotifications = () => {
|
|
12
|
-
notificationsEnabledSignal.value = false
|
|
13
|
-
}
|
|
12
|
+
notificationsEnabledSignal.value = false;
|
|
13
|
+
};
|
|
14
14
|
|
|
15
|
-
const arrayOfOpenedNotifications = []
|
|
15
|
+
const arrayOfOpenedNotifications = [];
|
|
16
16
|
export const notify = notificationAPIDetected
|
|
17
17
|
? async (
|
|
18
18
|
title,
|
|
19
19
|
{ clickToFocus = false, clickToClose = false, ...options } = {},
|
|
20
20
|
) => {
|
|
21
|
-
const notificationsEnabled = notificationsEnabledSignal.value
|
|
21
|
+
const notificationsEnabled = notificationsEnabledSignal.value;
|
|
22
22
|
if (!notificationsEnabled) {
|
|
23
|
-
return null
|
|
23
|
+
return null;
|
|
24
24
|
}
|
|
25
25
|
if (Notification.permission !== "granted") {
|
|
26
|
-
return null
|
|
26
|
+
return null;
|
|
27
27
|
}
|
|
28
|
-
const notification = new Notification(title, options)
|
|
29
|
-
arrayOfOpenedNotifications.push(notification)
|
|
28
|
+
const notification = new Notification(title, options);
|
|
29
|
+
arrayOfOpenedNotifications.push(notification);
|
|
30
30
|
notification.onclick = () => {
|
|
31
31
|
// but if the user navigated inbetween
|
|
32
32
|
// focusing window will show something else
|
|
@@ -36,36 +36,36 @@ export const notify = notificationAPIDetected
|
|
|
36
36
|
// we could also navigauate to this file execution but
|
|
37
37
|
// there is no guarantee re-executing the file would give same output
|
|
38
38
|
// and it would also trigger an other notification
|
|
39
|
-
if (clickToFocus) window.focus()
|
|
40
|
-
if (clickToClose) notification.close()
|
|
41
|
-
}
|
|
39
|
+
if (clickToFocus) window.focus();
|
|
40
|
+
if (clickToClose) notification.close();
|
|
41
|
+
};
|
|
42
42
|
notification.onclose = () => {
|
|
43
|
-
const index = arrayOfOpenedNotifications.indexOf(notification)
|
|
43
|
+
const index = arrayOfOpenedNotifications.indexOf(notification);
|
|
44
44
|
if (index > -1) {
|
|
45
|
-
arrayOfOpenedNotifications.splice(index, 1)
|
|
45
|
+
arrayOfOpenedNotifications.splice(index, 1);
|
|
46
46
|
}
|
|
47
|
-
}
|
|
48
|
-
return notification
|
|
47
|
+
};
|
|
48
|
+
return notification;
|
|
49
49
|
}
|
|
50
|
-
: () => {}
|
|
50
|
+
: () => {};
|
|
51
51
|
|
|
52
52
|
export const closeAllNotifications = () => {
|
|
53
53
|
// slice because arrayOfOpenedNotifications can be mutated while looping
|
|
54
54
|
arrayOfOpenedNotifications.slice().forEach((notification) => {
|
|
55
|
-
notification.close()
|
|
56
|
-
})
|
|
57
|
-
}
|
|
55
|
+
notification.close();
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
58
|
|
|
59
|
-
let requestPromise
|
|
59
|
+
let requestPromise;
|
|
60
60
|
export const requestPermission = notificationAPIDetected
|
|
61
61
|
? async () => {
|
|
62
62
|
if (requestPromise) {
|
|
63
|
-
await requestPromise
|
|
64
|
-
return
|
|
63
|
+
await requestPromise;
|
|
64
|
+
return;
|
|
65
65
|
}
|
|
66
|
-
requestPromise = Notification.requestPermission()
|
|
67
|
-
await requestPromise
|
|
68
|
-
requestPromise = undefined
|
|
69
|
-
notificationPermissionSignal.value = Notification.permission
|
|
66
|
+
requestPromise = Notification.requestPermission();
|
|
67
|
+
await requestPromise;
|
|
68
|
+
requestPromise = undefined;
|
|
69
|
+
notificationPermissionSignal.value = Notification.permission;
|
|
70
70
|
}
|
|
71
|
-
: () => Promise.resolve()
|
|
71
|
+
: () => Promise.resolve();
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export const notificationAPIDetected =
|
|
1
|
+
export const notificationAPIDetected =
|
|
2
|
+
typeof window.Notification === "function";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { effect } from "@preact/signals"
|
|
1
|
+
import { effect } from "@preact/signals";
|
|
2
2
|
|
|
3
|
-
import { notificationsEnabledSignal } from "./notification_signals.js"
|
|
4
|
-
import { closeAllNotifications } from "./notification_actions.js"
|
|
3
|
+
import { notificationsEnabledSignal } from "./notification_signals.js";
|
|
4
|
+
import { closeAllNotifications } from "./notification_actions.js";
|
|
5
5
|
|
|
6
6
|
effect(() => {
|
|
7
|
-
const notificationsEnabled = notificationsEnabledSignal.value
|
|
7
|
+
const notificationsEnabled = notificationsEnabledSignal.value;
|
|
8
8
|
if (!notificationsEnabled) {
|
|
9
|
-
closeAllNotifications()
|
|
9
|
+
closeAllNotifications();
|
|
10
10
|
}
|
|
11
|
-
})
|
|
11
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { signal } from "@preact/signals"
|
|
1
|
+
import { signal } from "@preact/signals";
|
|
2
2
|
|
|
3
|
-
import { paramsFromParentWindow } from "./parent_window_context.js"
|
|
4
|
-
import { stateFromLocalStorage } from "./toolbar_state_context.js"
|
|
3
|
+
import { paramsFromParentWindow } from "./parent_window_context.js";
|
|
4
|
+
import { stateFromLocalStorage } from "./toolbar_state_context.js";
|
|
5
5
|
|
|
6
6
|
export const notificationsEnabledSignal = signal(
|
|
7
7
|
typeof stateFromLocalStorage.notificationsEnabled === "boolean"
|
|
@@ -9,5 +9,5 @@ export const notificationsEnabledSignal = signal(
|
|
|
9
9
|
: typeof paramsFromParentWindow.notificationsEnabled === "boolean"
|
|
10
10
|
? paramsFromParentWindow.notificationsEnabled
|
|
11
11
|
: false,
|
|
12
|
-
)
|
|
13
|
-
export const notificationPermissionSignal = signal(Notification.permission)
|
|
12
|
+
);
|
|
13
|
+
export const notificationPermissionSignal = signal(Notification.permission);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parentWindowReloader } from "./parent_window_context.js"
|
|
1
|
+
import { parentWindowReloader } from "./parent_window_context.js";
|
|
2
2
|
|
|
3
3
|
export const sendEventToParent = (name, data) => {
|
|
4
4
|
window.parent.postMessage(
|
|
@@ -9,35 +9,35 @@ export const sendEventToParent = (name, data) => {
|
|
|
9
9
|
},
|
|
10
10
|
},
|
|
11
11
|
"*",
|
|
12
|
-
)
|
|
13
|
-
}
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
14
|
|
|
15
15
|
export const addExternalCommandCallback = (command, callback) => {
|
|
16
16
|
const messageEventCallback = (messageEvent) => {
|
|
17
|
-
const { data } = messageEvent
|
|
17
|
+
const { data } = messageEvent;
|
|
18
18
|
if (typeof data !== "object") {
|
|
19
|
-
return
|
|
19
|
+
return;
|
|
20
20
|
}
|
|
21
|
-
const { __jsenv__ } = data
|
|
21
|
+
const { __jsenv__ } = data;
|
|
22
22
|
if (!__jsenv__) {
|
|
23
|
-
return
|
|
23
|
+
return;
|
|
24
24
|
}
|
|
25
25
|
if (__jsenv__.command !== command) {
|
|
26
|
-
return
|
|
26
|
+
return;
|
|
27
27
|
}
|
|
28
|
-
callback(...__jsenv__.args)
|
|
29
|
-
}
|
|
28
|
+
callback(...__jsenv__.args);
|
|
29
|
+
};
|
|
30
30
|
|
|
31
|
-
window.addEventListener("message", messageEventCallback)
|
|
31
|
+
window.addEventListener("message", messageEventCallback);
|
|
32
32
|
return () => {
|
|
33
|
-
window.removeEventListener("message", messageEventCallback)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
33
|
+
window.removeEventListener("message", messageEventCallback);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
36
|
|
|
37
37
|
export const enableAutoreload = () => {
|
|
38
|
-
parentWindowReloader.autoreload.enable()
|
|
39
|
-
}
|
|
38
|
+
parentWindowReloader.autoreload.enable();
|
|
39
|
+
};
|
|
40
40
|
|
|
41
41
|
export const disableAutoreload = () => {
|
|
42
|
-
parentWindowReloader.autoreload.disable()
|
|
43
|
-
}
|
|
42
|
+
parentWindowReloader.autoreload.disable();
|
|
43
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export const paramsFromParentWindow = {}
|
|
2
|
-
const searchParams = new URLSearchParams(window.location.search)
|
|
1
|
+
export const paramsFromParentWindow = {};
|
|
2
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
3
3
|
searchParams.forEach((value, key) => {
|
|
4
|
-
paramsFromParentWindow[key] = value === "" ? true : value
|
|
5
|
-
})
|
|
4
|
+
paramsFromParentWindow[key] = value === "" ? true : value;
|
|
5
|
+
});
|
|
6
6
|
|
|
7
|
-
export const parentWindowReloader = window.parent.__reloader__
|
|
7
|
+
export const parentWindowReloader = window.parent.__reloader__;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addExternalCommandCallback,
|
|
3
3
|
sendEventToParent,
|
|
4
|
-
} from "./parent_window_actions.js"
|
|
5
|
-
import { animationsEnabledSignal } from "./animation_signals.js"
|
|
6
|
-
import { initToolbarUI } from "../ui/toolbar_ui.js"
|
|
4
|
+
} from "./parent_window_actions.js";
|
|
5
|
+
import { animationsEnabledSignal } from "./animation_signals.js";
|
|
6
|
+
import { initToolbarUI } from "../ui/toolbar_ui.js";
|
|
7
7
|
|
|
8
8
|
addExternalCommandCallback("initToolbar", () => {
|
|
9
9
|
// for the first render, force disable animations
|
|
10
|
-
const animationsEnabled = animationsEnabledSignal.value
|
|
10
|
+
const animationsEnabled = animationsEnabledSignal.value;
|
|
11
11
|
if (animationsEnabled) {
|
|
12
|
-
animationsEnabledSignal.value = false
|
|
12
|
+
animationsEnabledSignal.value = false;
|
|
13
13
|
}
|
|
14
|
-
initToolbarUI()
|
|
14
|
+
initToolbarUI();
|
|
15
15
|
if (animationsEnabled) {
|
|
16
|
-
animationsEnabledSignal.value = true
|
|
16
|
+
animationsEnabledSignal.value = true;
|
|
17
17
|
}
|
|
18
|
-
})
|
|
18
|
+
});
|
|
19
19
|
|
|
20
|
-
sendEventToParent("toolbar_ready")
|
|
20
|
+
sendEventToParent("toolbar_ready");
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { signal } from "@preact/signals"
|
|
1
|
+
import { signal } from "@preact/signals";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
paramsFromParentWindow,
|
|
5
5
|
parentWindowReloader,
|
|
6
|
-
} from "./parent_window_context.js"
|
|
6
|
+
} from "./parent_window_context.js";
|
|
7
7
|
|
|
8
|
-
export const autoreloadEnabledSignal = signal(false)
|
|
9
|
-
export const reloaderStatusSignal = signal("idle")
|
|
10
|
-
export const changesSignal = signal(0)
|
|
8
|
+
export const autoreloadEnabledSignal = signal(false);
|
|
9
|
+
export const reloaderStatusSignal = signal("idle");
|
|
10
|
+
export const changesSignal = signal(0);
|
|
11
11
|
|
|
12
12
|
if (parentWindowReloader) {
|
|
13
13
|
if (
|
|
14
14
|
!parentWindowReloader.autoreload.enabled &&
|
|
15
15
|
paramsFromParentWindow.autoreload
|
|
16
16
|
) {
|
|
17
|
-
autoreloadEnabledSignal.value = true
|
|
17
|
+
autoreloadEnabledSignal.value = true;
|
|
18
18
|
} else {
|
|
19
|
-
autoreloadEnabledSignal.value = parentWindowReloader.autoreload.enabled
|
|
19
|
+
autoreloadEnabledSignal.value = parentWindowReloader.autoreload.enabled;
|
|
20
20
|
}
|
|
21
21
|
parentWindowReloader.autoreload.onchange = () => {
|
|
22
|
-
autoreloadEnabledSignal.value = parentWindowReloader.autoreload.enabled
|
|
23
|
-
}
|
|
24
|
-
reloaderStatusSignal.value = parentWindowReloader.status.value
|
|
25
|
-
const onchange = parentWindowReloader.status.onchange
|
|
22
|
+
autoreloadEnabledSignal.value = parentWindowReloader.autoreload.enabled;
|
|
23
|
+
};
|
|
24
|
+
reloaderStatusSignal.value = parentWindowReloader.status.value;
|
|
25
|
+
const onchange = parentWindowReloader.status.onchange;
|
|
26
26
|
parentWindowReloader.status.onchange = () => {
|
|
27
|
-
onchange()
|
|
28
|
-
reloaderStatusSignal.value = parentWindowReloader.status.value
|
|
29
|
-
}
|
|
30
|
-
changesSignal.value = parentWindowReloader.changes.value
|
|
27
|
+
onchange();
|
|
28
|
+
reloaderStatusSignal.value = parentWindowReloader.status.value;
|
|
29
|
+
};
|
|
30
|
+
changesSignal.value = parentWindowReloader.changes.value;
|
|
31
31
|
parentWindowReloader.changes.onchange = () => {
|
|
32
|
-
changesSignal.value = [...parentWindowReloader.changes.value]
|
|
33
|
-
}
|
|
32
|
+
changesSignal.value = [...parentWindowReloader.changes.value];
|
|
33
|
+
};
|
|
34
34
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { serverTooltipOpenedSignal } from "./server_signals.js"
|
|
1
|
+
import { serverTooltipOpenedSignal } from "./server_signals.js";
|
|
2
2
|
|
|
3
3
|
export const openServerTooltip = () => {
|
|
4
|
-
serverTooltipOpenedSignal.value = true
|
|
5
|
-
}
|
|
4
|
+
serverTooltipOpenedSignal.value = true;
|
|
5
|
+
};
|
|
6
6
|
|
|
7
7
|
export const closeServerTooltip = () => {
|
|
8
|
-
serverTooltipOpenedSignal.value = false
|
|
9
|
-
}
|
|
8
|
+
serverTooltipOpenedSignal.value = false;
|
|
9
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { effect } from "@preact/signals"
|
|
1
|
+
import { effect } from "@preact/signals";
|
|
2
2
|
|
|
3
|
-
import { serverConnectionSignal } from "./server_signals.js"
|
|
4
|
-
import { openServerTooltip } from "./server_actions.js"
|
|
3
|
+
import { serverConnectionSignal } from "./server_signals.js";
|
|
4
|
+
import { openServerTooltip } from "./server_actions.js";
|
|
5
5
|
|
|
6
6
|
effect(() => {
|
|
7
|
-
const serverConnection = serverConnectionSignal.value
|
|
7
|
+
const serverConnection = serverConnectionSignal.value;
|
|
8
8
|
if (serverConnection === "connecting" || serverConnection === "closed") {
|
|
9
|
-
openServerTooltip()
|
|
9
|
+
openServerTooltip();
|
|
10
10
|
}
|
|
11
|
-
})
|
|
11
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { signal } from "@preact/signals"
|
|
1
|
+
import { signal } from "@preact/signals";
|
|
2
2
|
|
|
3
|
-
export const serverTooltipOpenedSignal = signal(false)
|
|
3
|
+
export const serverTooltipOpenedSignal = signal(false);
|
|
4
4
|
|
|
5
|
-
export const serverConnectionSignal = signal("default")
|
|
6
|
-
const serverEvents = window.__server_events__
|
|
5
|
+
export const serverConnectionSignal = signal("default");
|
|
6
|
+
const serverEvents = window.__server_events__;
|
|
7
7
|
if (serverEvents) {
|
|
8
8
|
serverEvents.readyState.onchange = () => {
|
|
9
|
-
serverConnectionSignal.value = serverEvents.readyState.value
|
|
10
|
-
}
|
|
11
|
-
serverConnectionSignal.value = serverEvents.readyState.value
|
|
9
|
+
serverConnectionSignal.value = serverEvents.readyState.value;
|
|
10
|
+
};
|
|
11
|
+
serverConnectionSignal.value = serverEvents.readyState.value;
|
|
12
12
|
}
|