@jsenv/plugin-toolbar 0.1.2 → 0.1.3
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.css +683 -7
- package/dist/js/toolbar_core.js +1792 -8
- package/dist/js/toolbar_injector.js +4 -2
- package/dist/jsenv_plugin_toolbar.js +6 -3
- package/package.json +1 -1
- package/dist/css/document_execution_indicator.css +0 -87
- package/dist/css/globals.css +0 -75
- package/dist/css/server_indicator.css +0 -83
- package/dist/css/theme_light.css +0 -110
- package/dist/css/toolbar_menu_overflow.css +0 -59
- package/dist/css/toolbar_settings.css +0 -202
- package/dist/css/tooltips.css +0 -67
- package/dist/js/animation.js +0 -282
- package/dist/js/animation_actions.js +0 -7
- package/dist/js/animation_effects.js +0 -10
- package/dist/js/animation_signals.js +0 -4
- package/dist/js/changes_actions.js +0 -7
- package/dist/js/changes_indicator.js +0 -57
- package/dist/js/changes_signals.js +0 -2
- package/dist/js/document_execution_indicator.js +0 -62
- package/dist/js/document_index_link.js +0 -4
- package/dist/js/dom.js +0 -48
- package/dist/js/execution_actions.js +0 -46
- package/dist/js/execution_effects.js +0 -16
- package/dist/js/execution_signals.js +0 -17
- package/dist/js/hooks.mjs +0 -185
- package/dist/js/iframe_to_parent_href.js +0 -10
- package/dist/js/notification_actions.js +0 -60
- package/dist/js/notification_context.js +0 -1
- package/dist/js/notification_effects.js +0 -9
- package/dist/js/notification_signals.js +0 -5
- package/dist/js/parent_window_actions.js +0 -39
- package/dist/js/parent_window_context.js +0 -6
- package/dist/js/parent_window_effects.js +0 -15
- package/dist/js/parent_window_signals.js +0 -25
- package/dist/js/preact.mjs +0 -316
- package/dist/js/responsive.js +0 -104
- package/dist/js/server_actions.js +0 -7
- package/dist/js/server_effects.js +0 -9
- package/dist/js/server_indicator.js +0 -52
- package/dist/js/server_signals.js +0 -10
- package/dist/js/settings_actions.js +0 -7
- package/dist/js/settings_signals.js +0 -2
- package/dist/js/signals-core.mjs +0 -339
- package/dist/js/signals.mjs +0 -202
- package/dist/js/theme_actions.js +0 -7
- package/dist/js/theme_effects.js +0 -6
- package/dist/js/theme_signals.js +0 -4
- package/dist/js/toolbar_animation_setting.js +0 -21
- package/dist/js/toolbar_autoreload_setting.js +0 -67
- package/dist/js/toolbar_close_button.js +0 -14
- package/dist/js/toolbar_menu_overflow.js +0 -81
- package/dist/js/toolbar_notification_setting.js +0 -72
- package/dist/js/toolbar_open_actions.js +0 -7
- package/dist/js/toolbar_open_effects.js +0 -4
- package/dist/js/toolbar_open_signals.js +0 -4
- package/dist/js/toolbar_opening.js +0 -65
- package/dist/js/toolbar_overlay.js +0 -69
- package/dist/js/toolbar_settings.js +0 -44
- package/dist/js/toolbar_state_context.js +0 -1
- package/dist/js/toolbar_state_effects.js +0 -8
- package/dist/js/toolbar_state_signals.js +0 -17
- package/dist/js/toolbar_theme_setting.js +0 -13
- package/dist/js/toolbar_ui.js +0 -20
- package/dist/js/tooltip_actions.js +0 -6
- package/dist/js/variant.js +0 -53
package/dist/js/animation.js
DELETED
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import { setStyles } from "./dom.js";
|
|
2
|
-
const animateFallback = () => {
|
|
3
|
-
return Promise.resolve();
|
|
4
|
-
};
|
|
5
|
-
const animateNative = (node, keyframes, {
|
|
6
|
-
signal,
|
|
7
|
-
...options
|
|
8
|
-
} = {}) => {
|
|
9
|
-
const animation = node.animate(keyframes, options);
|
|
10
|
-
if (signal) {
|
|
11
|
-
signal.addEventListener("abort", () => {
|
|
12
|
-
animation.cancel();
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
return new Promise(resolve => {
|
|
16
|
-
animation.onfinish = resolve;
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
export const canUseAnimation = () => typeof HTMLElement.prototype.animate === "function";
|
|
20
|
-
export const animateElement = canUseAnimation() ? animateNative : animateFallback;
|
|
21
|
-
export const fadeIn = (node, options) => animateElement(node, [{
|
|
22
|
-
opacity: 0
|
|
23
|
-
}, {
|
|
24
|
-
opacity: 1
|
|
25
|
-
}], options);
|
|
26
|
-
export const fadeOut = (node, options) => animateElement(node, [{
|
|
27
|
-
opacity: 1
|
|
28
|
-
}, {
|
|
29
|
-
opacity: 0
|
|
30
|
-
}], options);
|
|
31
|
-
export const move = (fromNode, toNode, options) => {
|
|
32
|
-
const fromComputedStyle = window.getComputedStyle(fromNode);
|
|
33
|
-
const toComputedStyle = window.getComputedStyle(toNode);
|
|
34
|
-
// get positions of input in toolbar and aElement
|
|
35
|
-
const fromPosition = fromNode.getBoundingClientRect();
|
|
36
|
-
const toPosition = toNode.getBoundingClientRect();
|
|
37
|
-
|
|
38
|
-
// we'll do the animation in a div preventing overflow and pointer events
|
|
39
|
-
const div = document.createElement("div");
|
|
40
|
-
div.style.position = "absolute";
|
|
41
|
-
div.style.left = 0;
|
|
42
|
-
div.style.top = 0;
|
|
43
|
-
div.style.width = `${document.documentElement.scrollWidth}px`;
|
|
44
|
-
div.style.height = `${document.documentElement.scrollHeight}px`;
|
|
45
|
-
div.style.overflow = "hidden";
|
|
46
|
-
div.style.pointerEvents = "none";
|
|
47
|
-
const documentScroll = {
|
|
48
|
-
left: window.pageXOffset || document.documentElement.scrollLeft,
|
|
49
|
-
top: window.pageYOffset || document.documentElement.scrollTop
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// clone node and style it
|
|
53
|
-
const copy = fromNode.cloneNode(true);
|
|
54
|
-
copy.style.position = "absolute";
|
|
55
|
-
copy.style.left = `${documentScroll.left + fromPosition.left}px`;
|
|
56
|
-
copy.style.top = `${documentScroll.top + fromPosition.top}px`;
|
|
57
|
-
copy.style.maxWidth = `${fromPosition.right - fromPosition.left}px`;
|
|
58
|
-
copy.style.overflow = toComputedStyle.overflow;
|
|
59
|
-
copy.style.textOverflow = toComputedStyle.textOverflow;
|
|
60
|
-
div.appendChild(copy);
|
|
61
|
-
document.body.appendChild(div);
|
|
62
|
-
const left = toPosition.left - fromPosition.left - (parseInt(fromComputedStyle.paddingLeft) || 0);
|
|
63
|
-
const top = toPosition.top - fromPosition.top - (parseInt(fromComputedStyle.paddingTop) || 0);
|
|
64
|
-
// define final position of new element and the duration
|
|
65
|
-
const translate = `translate(${left}px, ${top}px)`;
|
|
66
|
-
|
|
67
|
-
// animate new element
|
|
68
|
-
return animateElement(copy, [{
|
|
69
|
-
transform: "translate(0px, 0px)",
|
|
70
|
-
backgroundColor: fromComputedStyle.backgroundColor,
|
|
71
|
-
color: fromComputedStyle.color,
|
|
72
|
-
fontSize: fromComputedStyle.fontSize,
|
|
73
|
-
height: `${fromPosition.bottom - fromPosition.top}px`,
|
|
74
|
-
width: "100%"
|
|
75
|
-
}, {
|
|
76
|
-
offset: 0.9,
|
|
77
|
-
backgroundColor: fromComputedStyle.backgroundColor,
|
|
78
|
-
color: fromComputedStyle.color
|
|
79
|
-
}, {
|
|
80
|
-
transform: translate,
|
|
81
|
-
backgroundColor: toComputedStyle.backgroundColor,
|
|
82
|
-
color: toComputedStyle.color,
|
|
83
|
-
fontSize: toComputedStyle.fontSize,
|
|
84
|
-
height: `${toPosition.bottom - toPosition.top}px`,
|
|
85
|
-
width: toComputedStyle.width
|
|
86
|
-
}], options).then(() => {
|
|
87
|
-
div.parentNode.removeChild(div);
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// the whole point of this toolbar animation wass to flight a visual imperfection when it's done by css transition.
|
|
92
|
-
// This imperfection is a white line sometimes flickering at the bottom of the page.
|
|
93
|
-
// It got fixed by removing the usage of calc(100vh - 40px)
|
|
94
|
-
// It was hapenning in chrome, safari but not inside Firefox
|
|
95
|
-
// I assume it's because Firefox does not read parent element min-height while
|
|
96
|
-
// chrome use it to compute min-height: 100%
|
|
97
|
-
export const createToolbarAnimation = () => {
|
|
98
|
-
const collapsedState = {
|
|
99
|
-
"#page": {
|
|
100
|
-
paddingBottom: 0
|
|
101
|
-
},
|
|
102
|
-
"footer": {
|
|
103
|
-
height: 0
|
|
104
|
-
},
|
|
105
|
-
"#toolbar": {
|
|
106
|
-
visibility: "hidden"
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
const expandedState = {
|
|
110
|
-
"#page": {
|
|
111
|
-
paddingBottom: "40px"
|
|
112
|
-
},
|
|
113
|
-
"footer": {
|
|
114
|
-
height: "40px"
|
|
115
|
-
},
|
|
116
|
-
"#toolbar": {
|
|
117
|
-
visibility: "visible"
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const expandTransition = transit(collapsedState, expandedState, {
|
|
121
|
-
duration: 300
|
|
122
|
-
});
|
|
123
|
-
const expand = () => {
|
|
124
|
-
expandTransition.play();
|
|
125
|
-
};
|
|
126
|
-
const collapse = () => {
|
|
127
|
-
expandTransition.reverse();
|
|
128
|
-
};
|
|
129
|
-
return {
|
|
130
|
-
expand,
|
|
131
|
-
collapse
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
export const transit = (fromState, toState, {
|
|
135
|
-
commitStyles = true,
|
|
136
|
-
fill = "both",
|
|
137
|
-
duration = 300
|
|
138
|
-
} = {}) => {
|
|
139
|
-
const steps = [];
|
|
140
|
-
Object.keys(fromState).forEach(selector => {
|
|
141
|
-
const fromStyles = {};
|
|
142
|
-
const toStyles = {};
|
|
143
|
-
const element = document.querySelector(selector);
|
|
144
|
-
const keyframes = [];
|
|
145
|
-
const fromProperties = fromState[selector];
|
|
146
|
-
const toProperties = toState[selector];
|
|
147
|
-
Object.keys(fromProperties).forEach(propertyName => {
|
|
148
|
-
const from = fromProperties[propertyName];
|
|
149
|
-
const to = toProperties[propertyName];
|
|
150
|
-
fromStyles[propertyName] = from;
|
|
151
|
-
toStyles[propertyName] = to;
|
|
152
|
-
});
|
|
153
|
-
keyframes.push(fromStyles, toStyles);
|
|
154
|
-
let animation;
|
|
155
|
-
if (canUseAnimation()) {
|
|
156
|
-
const effect = new KeyframeEffect(element, keyframes, {
|
|
157
|
-
fill,
|
|
158
|
-
duration
|
|
159
|
-
});
|
|
160
|
-
animation = new Animation(effect);
|
|
161
|
-
} else {
|
|
162
|
-
animation = {
|
|
163
|
-
playbackRate: 1,
|
|
164
|
-
play: () => {
|
|
165
|
-
animation.onfinish();
|
|
166
|
-
},
|
|
167
|
-
reverse: () => {
|
|
168
|
-
animation.playbackRate = -1;
|
|
169
|
-
animation.onfinish();
|
|
170
|
-
},
|
|
171
|
-
finish: () => {},
|
|
172
|
-
onfinish: () => {}
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
steps.push({
|
|
176
|
-
element,
|
|
177
|
-
animation,
|
|
178
|
-
fromStyles,
|
|
179
|
-
toStyles
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
const play = async () => {
|
|
183
|
-
await Promise.all(steps.map(({
|
|
184
|
-
animation,
|
|
185
|
-
element,
|
|
186
|
-
toStyles
|
|
187
|
-
}) => {
|
|
188
|
-
return new Promise(resolve => {
|
|
189
|
-
animation.onfinish = () => {
|
|
190
|
-
if (commitStyles) {
|
|
191
|
-
setStyles(element, toStyles);
|
|
192
|
-
}
|
|
193
|
-
resolve();
|
|
194
|
-
};
|
|
195
|
-
if (animation.playbackRate === -1) {
|
|
196
|
-
animation.reverse();
|
|
197
|
-
} else {
|
|
198
|
-
animation.play();
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}));
|
|
202
|
-
};
|
|
203
|
-
const reverse = async () => {
|
|
204
|
-
await Promise.all(steps.map(({
|
|
205
|
-
animation,
|
|
206
|
-
element,
|
|
207
|
-
fromStyles
|
|
208
|
-
}) => {
|
|
209
|
-
return new Promise(resolve => {
|
|
210
|
-
animation.onfinish = () => {
|
|
211
|
-
if (commitStyles) {
|
|
212
|
-
setStyles(element, fromStyles);
|
|
213
|
-
}
|
|
214
|
-
resolve();
|
|
215
|
-
};
|
|
216
|
-
animation.reverse();
|
|
217
|
-
});
|
|
218
|
-
}));
|
|
219
|
-
};
|
|
220
|
-
const finish = async () => {
|
|
221
|
-
steps.forEach(({
|
|
222
|
-
animation
|
|
223
|
-
}) => {
|
|
224
|
-
animation.finish();
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
|
-
return {
|
|
228
|
-
play,
|
|
229
|
-
reverse,
|
|
230
|
-
finish
|
|
231
|
-
};
|
|
232
|
-
};
|
|
233
|
-
export const startJavaScriptAnimation = ({
|
|
234
|
-
duration = 300,
|
|
235
|
-
timingFunction = t => t,
|
|
236
|
-
onProgress = () => {},
|
|
237
|
-
onCancel = () => {},
|
|
238
|
-
onComplete = () => {}
|
|
239
|
-
}) => {
|
|
240
|
-
if (isNaN(duration)) {
|
|
241
|
-
// console.warn(`duration must be a number, received ${duration}`)
|
|
242
|
-
return () => {};
|
|
243
|
-
}
|
|
244
|
-
duration = parseInt(duration, 10);
|
|
245
|
-
const startMs = performance.now();
|
|
246
|
-
let currentRequestAnimationFrameId;
|
|
247
|
-
let done = false;
|
|
248
|
-
let rawProgress = 0;
|
|
249
|
-
let progress = 0;
|
|
250
|
-
const handler = () => {
|
|
251
|
-
currentRequestAnimationFrameId = null;
|
|
252
|
-
const nowMs = performance.now();
|
|
253
|
-
rawProgress = Math.min((nowMs - startMs) / duration, 1);
|
|
254
|
-
progress = timingFunction(rawProgress);
|
|
255
|
-
done = rawProgress === 1;
|
|
256
|
-
onProgress({
|
|
257
|
-
done,
|
|
258
|
-
rawProgress,
|
|
259
|
-
progress
|
|
260
|
-
});
|
|
261
|
-
if (done) {
|
|
262
|
-
onComplete();
|
|
263
|
-
} else {
|
|
264
|
-
currentRequestAnimationFrameId = window.requestAnimationFrame(handler);
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
handler();
|
|
268
|
-
const stop = () => {
|
|
269
|
-
if (currentRequestAnimationFrameId) {
|
|
270
|
-
window.cancelAnimationFrame(currentRequestAnimationFrameId);
|
|
271
|
-
currentRequestAnimationFrameId = null;
|
|
272
|
-
}
|
|
273
|
-
if (!done) {
|
|
274
|
-
done = true;
|
|
275
|
-
onCancel({
|
|
276
|
-
rawProgress,
|
|
277
|
-
progress
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
return stop;
|
|
282
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { effect } from "./signals.mjs";
|
|
2
|
-
import { animationsEnabledSignal } from "./animation_signals.js";
|
|
3
|
-
effect(() => {
|
|
4
|
-
const animationsEnabled = animationsEnabledSignal.value;
|
|
5
|
-
if (animationsEnabled) {
|
|
6
|
-
document.documentElement.removeAttribute("data-animation-disabled");
|
|
7
|
-
} else {
|
|
8
|
-
document.documentElement.setAttribute("data-animation-disabled", "");
|
|
9
|
-
}
|
|
10
|
-
});
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { signal } from "./signals.mjs";
|
|
2
|
-
import { paramsFromParentWindow } from "./parent_window_context.js";
|
|
3
|
-
import { stateFromLocalStorage } from "./toolbar_state_context.js";
|
|
4
|
-
export const animationsEnabledSignal = signal(typeof stateFromLocalStorage.animationsEnabled === "boolean" ? stateFromLocalStorage.animationsEnabled : typeof paramsFromParentWindow.animationsEnabled === "boolean" ? paramsFromParentWindow.animationsEnabled : false);
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { effect } from "./signals.mjs";
|
|
2
|
-
import { parentWindowReloader } from "./parent_window_context.js";
|
|
3
|
-
import { autoreloadEnabledSignal, changesSignal } from "./parent_window_signals.js";
|
|
4
|
-
import { changesTooltipOpenedSignal } from "./changes_signals.js";
|
|
5
|
-
import { openChangesToolip, closeChangesToolip } from "./changes_actions.js";
|
|
6
|
-
import { enableVariant } from "./variant.js";
|
|
7
|
-
const changesIndicator = document.querySelector("#changes_indicator");
|
|
8
|
-
export const renderChangesIndicator = () => {
|
|
9
|
-
effect(() => {
|
|
10
|
-
const autoreloadEnabled = autoreloadEnabledSignal.value;
|
|
11
|
-
const changes = changesSignal.value;
|
|
12
|
-
const changeCount = changes.length;
|
|
13
|
-
enableVariant(changesIndicator, {
|
|
14
|
-
changes: !autoreloadEnabled && changeCount ? "yes" : "no"
|
|
15
|
-
});
|
|
16
|
-
if (changeCount) {
|
|
17
|
-
changesIndicator.querySelector(".tooltip_text").innerHTML = computeTooltipText({
|
|
18
|
-
changes
|
|
19
|
-
});
|
|
20
|
-
changesIndicator.querySelector(".tooltip_text a").onclick = () => {
|
|
21
|
-
// eslint-disable-next-line no-alert
|
|
22
|
-
window.alert(JSON.stringify(changes, null, " "));
|
|
23
|
-
console.log(changes);
|
|
24
|
-
};
|
|
25
|
-
changesIndicator.querySelector(".changes_text").innerHTML = changeCount;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
changesIndicator.querySelector(".tooltip_action").onclick = () => {
|
|
29
|
-
parentWindowReloader.reload();
|
|
30
|
-
};
|
|
31
|
-
effect(() => {
|
|
32
|
-
const changesTooltipOpened = changesTooltipOpenedSignal.value;
|
|
33
|
-
if (changesTooltipOpened) {
|
|
34
|
-
changesIndicator.setAttribute("data-tooltip-visible", "");
|
|
35
|
-
} else {
|
|
36
|
-
changesIndicator.removeAttribute("data-tooltip-visible");
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
const button = changesIndicator.querySelector("button");
|
|
40
|
-
button.onclick = () => {
|
|
41
|
-
const changesTooltipOpened = changesTooltipOpenedSignal.value;
|
|
42
|
-
if (changesTooltipOpened) {
|
|
43
|
-
closeChangesToolip();
|
|
44
|
-
} else {
|
|
45
|
-
openChangesToolip();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
const computeTooltipText = ({
|
|
50
|
-
changes
|
|
51
|
-
}) => {
|
|
52
|
-
const changesCount = changes.length;
|
|
53
|
-
if (changesCount === 1) {
|
|
54
|
-
return `There is <a href="javascript:void(0)">1</a> change to apply`;
|
|
55
|
-
}
|
|
56
|
-
return `There is <a href="javascript:void(0)">${changesCount}<a> changes to apply`;
|
|
57
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { effect } from "./signals.mjs";
|
|
2
|
-
import { executionSignal, executionTooltipOpenedSignal } from "./execution_signals.js";
|
|
3
|
-
import { closeExecutionTooltip, openExecutionTooltip } from "./execution_actions.js";
|
|
4
|
-
import { removeForceHideElement } from "./dom.js";
|
|
5
|
-
import { enableVariant } from "./variant.js";
|
|
6
|
-
const executionIndicator = document.querySelector("#document_execution_indicator");
|
|
7
|
-
export const renderDocumentExecutionIndicator = async () => {
|
|
8
|
-
removeForceHideElement(document.querySelector("#document_execution_indicator"));
|
|
9
|
-
effect(() => {
|
|
10
|
-
const execution = executionSignal.value;
|
|
11
|
-
updateExecutionIndicator(execution);
|
|
12
|
-
});
|
|
13
|
-
effect(() => {
|
|
14
|
-
const executionTooltipOpened = executionTooltipOpenedSignal.value;
|
|
15
|
-
if (executionTooltipOpened) {
|
|
16
|
-
executionIndicator.setAttribute("data-tooltip-visible", "");
|
|
17
|
-
} else {
|
|
18
|
-
executionIndicator.removeAttribute("data-tooltip-visible");
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
const updateExecutionIndicator = ({
|
|
23
|
-
status,
|
|
24
|
-
startTime,
|
|
25
|
-
endTime
|
|
26
|
-
} = {}) => {
|
|
27
|
-
enableVariant(executionIndicator, {
|
|
28
|
-
execution: status
|
|
29
|
-
});
|
|
30
|
-
const variantNode = executionIndicator.querySelector("[data-when-active]");
|
|
31
|
-
variantNode.querySelector("button").onclick = () => {
|
|
32
|
-
const executionTooltipOpened = executionTooltipOpenedSignal.value;
|
|
33
|
-
if (executionTooltipOpened) {
|
|
34
|
-
closeExecutionTooltip();
|
|
35
|
-
} else {
|
|
36
|
-
openExecutionTooltip();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
variantNode.querySelector(".tooltip").textContent = computeText({
|
|
40
|
-
status,
|
|
41
|
-
startTime,
|
|
42
|
-
endTime
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// relative time: https://github.com/tc39/proposal-intl-relative-time/issues/118
|
|
47
|
-
const computeText = ({
|
|
48
|
-
status,
|
|
49
|
-
startTime,
|
|
50
|
-
endTime
|
|
51
|
-
}) => {
|
|
52
|
-
if (status === "completed") {
|
|
53
|
-
return `Execution completed in ${endTime - startTime}ms`;
|
|
54
|
-
}
|
|
55
|
-
if (status === "errored") {
|
|
56
|
-
return `Execution failed in ${endTime - startTime}ms`;
|
|
57
|
-
}
|
|
58
|
-
if (status === "running") {
|
|
59
|
-
return "Executing...";
|
|
60
|
-
}
|
|
61
|
-
return "";
|
|
62
|
-
};
|
package/dist/js/dom.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export const getToolbarIframe = () => {
|
|
2
|
-
const iframes = Array.from(window.parent.document.querySelectorAll("iframe"));
|
|
3
|
-
return iframes.find(iframe => iframe.contentWindow === window);
|
|
4
|
-
};
|
|
5
|
-
export const forceHideElement = element => {
|
|
6
|
-
element.setAttribute("data-force-hide", "");
|
|
7
|
-
};
|
|
8
|
-
export const removeForceHideElement = element => {
|
|
9
|
-
element.removeAttribute("data-force-hide");
|
|
10
|
-
};
|
|
11
|
-
export const setStyles = (element, styles) => {
|
|
12
|
-
const elementStyle = element.style;
|
|
13
|
-
const restoreStyles = Object.keys(styles).map(styleName => {
|
|
14
|
-
let restore;
|
|
15
|
-
if (styleName in elementStyle) {
|
|
16
|
-
const currentStyle = elementStyle[styleName];
|
|
17
|
-
restore = () => {
|
|
18
|
-
elementStyle[styleName] = currentStyle;
|
|
19
|
-
};
|
|
20
|
-
} else {
|
|
21
|
-
restore = () => {
|
|
22
|
-
delete elementStyle[styleName];
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
elementStyle[styleName] = styles[styleName];
|
|
26
|
-
return restore;
|
|
27
|
-
});
|
|
28
|
-
return () => {
|
|
29
|
-
restoreStyles.forEach(restore => restore());
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export const setAttributes = (element, attributes) => {
|
|
33
|
-
Object.keys(attributes).forEach(name => {
|
|
34
|
-
element.setAttribute(name, attributes[name]);
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
export const getDocumentScroll = () => {
|
|
38
|
-
return {
|
|
39
|
-
x: document.documentElement.scrollLeft,
|
|
40
|
-
y: document.documentElement.scrollTop
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
export const activateToolbarSection = element => {
|
|
44
|
-
element.setAttribute("data-active", "");
|
|
45
|
-
};
|
|
46
|
-
export const deactivateToolbarSection = element => {
|
|
47
|
-
element.removeAttribute("data-active");
|
|
48
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { executionTooltipOpenedSignal } from "./execution_signals.js";
|
|
2
|
-
import { notify } from "./notification_actions.js";
|
|
3
|
-
export const openExecutionTooltip = () => {
|
|
4
|
-
executionTooltipOpenedSignal.value = true;
|
|
5
|
-
};
|
|
6
|
-
export const closeExecutionTooltip = () => {
|
|
7
|
-
executionTooltipOpenedSignal.value = false;
|
|
8
|
-
};
|
|
9
|
-
export const notifyExecutionResult = (execution, previousExecution) => {
|
|
10
|
-
const executedFileRelativeUrl = window.location.href;
|
|
11
|
-
const notificationOptions = {
|
|
12
|
-
lang: "en",
|
|
13
|
-
icon: getFaviconHref(),
|
|
14
|
-
clickToFocus: true,
|
|
15
|
-
clickToClose: true
|
|
16
|
-
};
|
|
17
|
-
if (execution.status === "errored") {
|
|
18
|
-
if (previousExecution) {
|
|
19
|
-
if (previousExecution.status === "completed") {
|
|
20
|
-
notify("Broken", {
|
|
21
|
-
...notificationOptions,
|
|
22
|
-
body: `${executedFileRelativeUrl} execution now failing.`
|
|
23
|
-
});
|
|
24
|
-
} else {
|
|
25
|
-
notify("Still failing", {
|
|
26
|
-
...notificationOptions,
|
|
27
|
-
body: `${executedFileRelativeUrl} execution still failing.`
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
notify("Failing", {
|
|
32
|
-
...notificationOptions,
|
|
33
|
-
body: `${executedFileRelativeUrl} execution failed.`
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
} else if (previousExecution && previousExecution.status === "errored") {
|
|
37
|
-
notify("Fixed", {
|
|
38
|
-
...notificationOptions,
|
|
39
|
-
body: `${executedFileRelativeUrl} execution fixed.`
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const getFaviconHref = () => {
|
|
44
|
-
const link = document.querySelector('link[rel="icon"]');
|
|
45
|
-
return link ? link.href : undefined;
|
|
46
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { effect } from "./signals.mjs";
|
|
2
|
-
import { executionSignal, previousExecutionSignal } from "./execution_signals.js";
|
|
3
|
-
import { notifyExecutionResult } from "./execution_actions.js";
|
|
4
|
-
effect(() => {
|
|
5
|
-
const execution = executionSignal.value;
|
|
6
|
-
if (execution) {
|
|
7
|
-
sessionStorage.setItem(window.location.href, JSON.stringify(execution));
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
effect(() => {
|
|
11
|
-
const execution = executionSignal.value;
|
|
12
|
-
const previousExecution = previousExecutionSignal.value;
|
|
13
|
-
if (execution) {
|
|
14
|
-
notifyExecutionResult(execution, previousExecution);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { signal } from "./signals.mjs";
|
|
2
|
-
export const executionTooltipOpenedSignal = signal(false);
|
|
3
|
-
export const executionSignal = signal({
|
|
4
|
-
status: "running"
|
|
5
|
-
});
|
|
6
|
-
export const previousExecutionSignal = signal(sessionStorage.hasOwnProperty(window.location.href) ? JSON.parse(sessionStorage.getItem(window.location.href)) : null);
|
|
7
|
-
window.parent.__supervisor__.getDocumentExecutionResult().then(({
|
|
8
|
-
status,
|
|
9
|
-
startTime,
|
|
10
|
-
endTime
|
|
11
|
-
}) => {
|
|
12
|
-
executionSignal.value = {
|
|
13
|
-
status,
|
|
14
|
-
startTime,
|
|
15
|
-
endTime
|
|
16
|
-
};
|
|
17
|
-
});
|