@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/toolbar_core.js
CHANGED
|
@@ -1,8 +1,1792 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var l$2;
|
|
2
|
+
l$2 = {
|
|
3
|
+
__e: function (n, l, u, i) {
|
|
4
|
+
for (var t, o, r; l = l.__;) if ((t = l.__c) && !t.__) try {
|
|
5
|
+
if ((o = t.constructor) && null != o.getDerivedStateFromError && (t.setState(o.getDerivedStateFromError(n)), r = t.__d), null != t.componentDidCatch && (t.componentDidCatch(n, i || {}), r = t.__d), r) return t.__E = t;
|
|
6
|
+
} catch (l) {
|
|
7
|
+
n = l;
|
|
8
|
+
}
|
|
9
|
+
throw n;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var t$1,
|
|
14
|
+
r$1,
|
|
15
|
+
u$1,
|
|
16
|
+
i$1,
|
|
17
|
+
o$1 = 0,
|
|
18
|
+
f$1 = [],
|
|
19
|
+
c$2 = [],
|
|
20
|
+
e$1 = l$2.__b,
|
|
21
|
+
a$2 = l$2.__r,
|
|
22
|
+
v$1 = l$2.diffed,
|
|
23
|
+
l$1 = l$2.__c,
|
|
24
|
+
m = l$2.unmount;
|
|
25
|
+
function d$2(t, u) {
|
|
26
|
+
l$2.__h && l$2.__h(r$1, t, o$1 || u), o$1 = 0;
|
|
27
|
+
var i = r$1.__H || (r$1.__H = {
|
|
28
|
+
__: [],
|
|
29
|
+
__h: []
|
|
30
|
+
});
|
|
31
|
+
return t >= i.__.length && i.__.push({
|
|
32
|
+
__V: c$2
|
|
33
|
+
}), i.__[t];
|
|
34
|
+
}
|
|
35
|
+
function F(n, r) {
|
|
36
|
+
var u = d$2(t$1++, 7);
|
|
37
|
+
return z(u.__H, r) ? (u.__V = n(), u.i = r, u.__h = n, u.__V) : u.__;
|
|
38
|
+
}
|
|
39
|
+
function b$1() {
|
|
40
|
+
for (var t; t = f$1.shift();) if (t.__P && t.__H) try {
|
|
41
|
+
t.__H.__h.forEach(k), t.__H.__h.forEach(w$1), t.__H.__h = [];
|
|
42
|
+
} catch (r) {
|
|
43
|
+
t.__H.__h = [], l$2.__e(r, t.__v);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
l$2.__b = function (n) {
|
|
47
|
+
r$1 = null, e$1 && e$1(n);
|
|
48
|
+
}, l$2.__r = function (n) {
|
|
49
|
+
a$2 && a$2(n), t$1 = 0;
|
|
50
|
+
var i = (r$1 = n.__c).__H;
|
|
51
|
+
i && (u$1 === r$1 ? (i.__h = [], r$1.__h = [], i.__.forEach(function (n) {
|
|
52
|
+
n.__N && (n.__ = n.__N), n.__V = c$2, n.__N = n.i = void 0;
|
|
53
|
+
})) : (i.__h.forEach(k), i.__h.forEach(w$1), i.__h = [])), u$1 = r$1;
|
|
54
|
+
}, l$2.diffed = function (t) {
|
|
55
|
+
v$1 && v$1(t);
|
|
56
|
+
var o = t.__c;
|
|
57
|
+
o && o.__H && (o.__H.__h.length && (1 !== f$1.push(o) && i$1 === l$2.requestAnimationFrame || ((i$1 = l$2.requestAnimationFrame) || j)(b$1)), o.__H.__.forEach(function (n) {
|
|
58
|
+
n.i && (n.__H = n.i), n.__V !== c$2 && (n.__ = n.__V), n.i = void 0, n.__V = c$2;
|
|
59
|
+
})), u$1 = r$1 = null;
|
|
60
|
+
}, l$2.__c = function (t, r) {
|
|
61
|
+
r.some(function (t) {
|
|
62
|
+
try {
|
|
63
|
+
t.__h.forEach(k), t.__h = t.__h.filter(function (n) {
|
|
64
|
+
return !n.__ || w$1(n);
|
|
65
|
+
});
|
|
66
|
+
} catch (u) {
|
|
67
|
+
r.some(function (n) {
|
|
68
|
+
n.__h && (n.__h = []);
|
|
69
|
+
}), r = [], l$2.__e(u, t.__v);
|
|
70
|
+
}
|
|
71
|
+
}), l$1 && l$1(t, r);
|
|
72
|
+
}, l$2.unmount = function (t) {
|
|
73
|
+
m && m(t);
|
|
74
|
+
var r,
|
|
75
|
+
u = t.__c;
|
|
76
|
+
u && u.__H && (u.__H.__.forEach(function (n) {
|
|
77
|
+
try {
|
|
78
|
+
k(n);
|
|
79
|
+
} catch (n) {
|
|
80
|
+
r = n;
|
|
81
|
+
}
|
|
82
|
+
}), u.__H = void 0, r && l$2.__e(r, u.__v));
|
|
83
|
+
};
|
|
84
|
+
var g$1 = "function" == typeof requestAnimationFrame;
|
|
85
|
+
function j(n) {
|
|
86
|
+
var t,
|
|
87
|
+
r = function () {
|
|
88
|
+
clearTimeout(u), g$1 && cancelAnimationFrame(t), setTimeout(n);
|
|
89
|
+
},
|
|
90
|
+
u = setTimeout(r, 100);
|
|
91
|
+
g$1 && (t = requestAnimationFrame(r));
|
|
92
|
+
}
|
|
93
|
+
function k(n) {
|
|
94
|
+
var t = r$1,
|
|
95
|
+
u = n.__c;
|
|
96
|
+
"function" == typeof u && (n.__c = void 0, u()), r$1 = t;
|
|
97
|
+
}
|
|
98
|
+
function w$1(n) {
|
|
99
|
+
var t = r$1;
|
|
100
|
+
n.__c = n.__(), r$1 = t;
|
|
101
|
+
}
|
|
102
|
+
function z(n, t) {
|
|
103
|
+
return !n || n.length !== t.length || t.some(function (t, r) {
|
|
104
|
+
return t !== n[r];
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function i() {
|
|
109
|
+
throw new Error("Cycle detected");
|
|
110
|
+
}
|
|
111
|
+
function t() {
|
|
112
|
+
if (h$1 > 1) {
|
|
113
|
+
h$1--;
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
let i,
|
|
117
|
+
t = !1;
|
|
118
|
+
while (void 0 !== o) {
|
|
119
|
+
let s = o;
|
|
120
|
+
o = void 0;
|
|
121
|
+
f++;
|
|
122
|
+
while (void 0 !== s) {
|
|
123
|
+
const n = s.o;
|
|
124
|
+
s.o = void 0;
|
|
125
|
+
s.f &= -3;
|
|
126
|
+
if (!(8 & s.f) && v(s)) try {
|
|
127
|
+
s.c();
|
|
128
|
+
} catch (s) {
|
|
129
|
+
if (!t) {
|
|
130
|
+
i = s;
|
|
131
|
+
t = !0;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
s = n;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
f = 0;
|
|
138
|
+
h$1--;
|
|
139
|
+
if (t) throw i;
|
|
140
|
+
}
|
|
141
|
+
let n,
|
|
142
|
+
o,
|
|
143
|
+
h$1 = 0,
|
|
144
|
+
f = 0,
|
|
145
|
+
r = 0;
|
|
146
|
+
function e(i) {
|
|
147
|
+
if (void 0 === n) return;
|
|
148
|
+
let t = i.n;
|
|
149
|
+
if (void 0 === t || t.t !== n) {
|
|
150
|
+
t = {
|
|
151
|
+
i: 0,
|
|
152
|
+
S: i,
|
|
153
|
+
p: void 0,
|
|
154
|
+
n: n.s,
|
|
155
|
+
t: n,
|
|
156
|
+
e: void 0,
|
|
157
|
+
x: void 0,
|
|
158
|
+
r: t
|
|
159
|
+
};
|
|
160
|
+
n.s = t;
|
|
161
|
+
i.n = t;
|
|
162
|
+
if (32 & n.f) i.S(t);
|
|
163
|
+
return t;
|
|
164
|
+
} else if (-1 === t.i) {
|
|
165
|
+
t.i = 0;
|
|
166
|
+
if (void 0 !== t.p) {
|
|
167
|
+
t.p.n = t.n;
|
|
168
|
+
if (void 0 !== t.n) t.n.p = t.p;
|
|
169
|
+
t.p = void 0;
|
|
170
|
+
t.n = n.s;
|
|
171
|
+
n.s.p = t;
|
|
172
|
+
n.s = t;
|
|
173
|
+
}
|
|
174
|
+
return t;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function u(i) {
|
|
178
|
+
this.v = i;
|
|
179
|
+
this.i = 0;
|
|
180
|
+
this.n = void 0;
|
|
181
|
+
this.t = void 0;
|
|
182
|
+
}
|
|
183
|
+
u.prototype.h = function () {
|
|
184
|
+
return !0;
|
|
185
|
+
};
|
|
186
|
+
u.prototype.S = function (i) {
|
|
187
|
+
if (this.t !== i && void 0 === i.e) {
|
|
188
|
+
i.x = this.t;
|
|
189
|
+
if (void 0 !== this.t) this.t.e = i;
|
|
190
|
+
this.t = i;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
u.prototype.U = function (i) {
|
|
194
|
+
const t = i.e,
|
|
195
|
+
s = i.x;
|
|
196
|
+
if (void 0 !== t) {
|
|
197
|
+
t.x = s;
|
|
198
|
+
i.e = void 0;
|
|
199
|
+
}
|
|
200
|
+
if (void 0 !== s) {
|
|
201
|
+
s.e = t;
|
|
202
|
+
i.x = void 0;
|
|
203
|
+
}
|
|
204
|
+
if (i === this.t) this.t = s;
|
|
205
|
+
};
|
|
206
|
+
u.prototype.subscribe = function (i) {
|
|
207
|
+
const t = this;
|
|
208
|
+
return b(function () {
|
|
209
|
+
const s = t.value,
|
|
210
|
+
n = 32 & this.f;
|
|
211
|
+
this.f &= -33;
|
|
212
|
+
try {
|
|
213
|
+
i(s);
|
|
214
|
+
} finally {
|
|
215
|
+
this.f |= n;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
u.prototype.valueOf = function () {
|
|
220
|
+
return this.value;
|
|
221
|
+
};
|
|
222
|
+
u.prototype.toString = function () {
|
|
223
|
+
return this.value + "";
|
|
224
|
+
};
|
|
225
|
+
u.prototype.peek = function () {
|
|
226
|
+
return this.v;
|
|
227
|
+
};
|
|
228
|
+
Object.defineProperty(u.prototype, "value", {
|
|
229
|
+
get() {
|
|
230
|
+
const i = e(this);
|
|
231
|
+
if (void 0 !== i) i.i = this.i;
|
|
232
|
+
return this.v;
|
|
233
|
+
},
|
|
234
|
+
set(s) {
|
|
235
|
+
if (s !== this.v) {
|
|
236
|
+
if (f > 100) i();
|
|
237
|
+
this.v = s;
|
|
238
|
+
this.i++;
|
|
239
|
+
r++;
|
|
240
|
+
h$1++;
|
|
241
|
+
try {
|
|
242
|
+
for (let i = this.t; void 0 !== i; i = i.x) i.t.N();
|
|
243
|
+
} finally {
|
|
244
|
+
t();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
function c$1(i) {
|
|
250
|
+
return new u(i);
|
|
251
|
+
}
|
|
252
|
+
function v(i) {
|
|
253
|
+
for (let t = i.s; void 0 !== t; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return !0;
|
|
254
|
+
return !1;
|
|
255
|
+
}
|
|
256
|
+
function d$1(i) {
|
|
257
|
+
for (let t = i.s; void 0 !== t; t = t.n) {
|
|
258
|
+
const i = t.S.n;
|
|
259
|
+
if (void 0 !== i) t.r = i;
|
|
260
|
+
t.S.n = t;
|
|
261
|
+
t.i = -1;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function l(i) {
|
|
265
|
+
let t,
|
|
266
|
+
s = i.s;
|
|
267
|
+
while (void 0 !== s) {
|
|
268
|
+
const i = s.n;
|
|
269
|
+
if (-1 === s.i) {
|
|
270
|
+
s.S.U(s);
|
|
271
|
+
s.n = void 0;
|
|
272
|
+
} else {
|
|
273
|
+
if (void 0 !== t) t.p = s;
|
|
274
|
+
s.p = void 0;
|
|
275
|
+
s.n = t;
|
|
276
|
+
t = s;
|
|
277
|
+
}
|
|
278
|
+
s.S.n = s.r;
|
|
279
|
+
if (void 0 !== s.r) s.r = void 0;
|
|
280
|
+
s = i;
|
|
281
|
+
}
|
|
282
|
+
i.s = t;
|
|
283
|
+
}
|
|
284
|
+
function w(i) {
|
|
285
|
+
u.call(this, void 0);
|
|
286
|
+
this.x = i;
|
|
287
|
+
this.s = void 0;
|
|
288
|
+
this.g = r - 1;
|
|
289
|
+
this.f = 4;
|
|
290
|
+
}
|
|
291
|
+
(w.prototype = new u()).h = function () {
|
|
292
|
+
this.f &= -3;
|
|
293
|
+
if (1 & this.f) return !1;
|
|
294
|
+
if (32 == (36 & this.f)) return !0;
|
|
295
|
+
this.f &= -5;
|
|
296
|
+
if (this.g === r) return !0;
|
|
297
|
+
this.g = r;
|
|
298
|
+
this.f |= 1;
|
|
299
|
+
if (this.i > 0 && !v(this)) {
|
|
300
|
+
this.f &= -2;
|
|
301
|
+
return !0;
|
|
302
|
+
}
|
|
303
|
+
const i = n;
|
|
304
|
+
try {
|
|
305
|
+
d$1(this);
|
|
306
|
+
n = this;
|
|
307
|
+
const i = this.x();
|
|
308
|
+
if (16 & this.f || this.v !== i || 0 === this.i) {
|
|
309
|
+
this.v = i;
|
|
310
|
+
this.f &= -17;
|
|
311
|
+
this.i++;
|
|
312
|
+
}
|
|
313
|
+
} catch (i) {
|
|
314
|
+
this.v = i;
|
|
315
|
+
this.f |= 16;
|
|
316
|
+
this.i++;
|
|
317
|
+
}
|
|
318
|
+
n = i;
|
|
319
|
+
l(this);
|
|
320
|
+
this.f &= -2;
|
|
321
|
+
return !0;
|
|
322
|
+
};
|
|
323
|
+
w.prototype.S = function (i) {
|
|
324
|
+
if (void 0 === this.t) {
|
|
325
|
+
this.f |= 36;
|
|
326
|
+
for (let i = this.s; void 0 !== i; i = i.n) i.S.S(i);
|
|
327
|
+
}
|
|
328
|
+
u.prototype.S.call(this, i);
|
|
329
|
+
};
|
|
330
|
+
w.prototype.U = function (i) {
|
|
331
|
+
u.prototype.U.call(this, i);
|
|
332
|
+
if (void 0 === this.t) {
|
|
333
|
+
this.f &= -33;
|
|
334
|
+
for (let i = this.s; void 0 !== i; i = i.n) i.S.U(i);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
w.prototype.N = function () {
|
|
338
|
+
if (!(2 & this.f)) {
|
|
339
|
+
this.f |= 6;
|
|
340
|
+
for (let i = this.t; void 0 !== i; i = i.x) i.t.N();
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
w.prototype.peek = function () {
|
|
344
|
+
if (!this.h()) i();
|
|
345
|
+
if (16 & this.f) throw this.v;
|
|
346
|
+
return this.v;
|
|
347
|
+
};
|
|
348
|
+
Object.defineProperty(w.prototype, "value", {
|
|
349
|
+
get() {
|
|
350
|
+
if (1 & this.f) i();
|
|
351
|
+
const t = e(this);
|
|
352
|
+
this.h();
|
|
353
|
+
if (void 0 !== t) t.i = this.i;
|
|
354
|
+
if (16 & this.f) throw this.v;
|
|
355
|
+
return this.v;
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
function a$1(i) {
|
|
359
|
+
return new w(i);
|
|
360
|
+
}
|
|
361
|
+
function y(i) {
|
|
362
|
+
const s = i.u;
|
|
363
|
+
i.u = void 0;
|
|
364
|
+
if ("function" == typeof s) {
|
|
365
|
+
h$1++;
|
|
366
|
+
const o = n;
|
|
367
|
+
n = void 0;
|
|
368
|
+
try {
|
|
369
|
+
s();
|
|
370
|
+
} catch (t) {
|
|
371
|
+
i.f &= -2;
|
|
372
|
+
i.f |= 8;
|
|
373
|
+
_(i);
|
|
374
|
+
throw t;
|
|
375
|
+
} finally {
|
|
376
|
+
n = o;
|
|
377
|
+
t();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function _(i) {
|
|
382
|
+
for (let t = i.s; void 0 !== t; t = t.n) t.S.U(t);
|
|
383
|
+
i.x = void 0;
|
|
384
|
+
i.s = void 0;
|
|
385
|
+
y(i);
|
|
386
|
+
}
|
|
387
|
+
function g(i) {
|
|
388
|
+
if (n !== this) throw new Error("Out-of-order effect");
|
|
389
|
+
l(this);
|
|
390
|
+
n = i;
|
|
391
|
+
this.f &= -2;
|
|
392
|
+
if (8 & this.f) _(this);
|
|
393
|
+
t();
|
|
394
|
+
}
|
|
395
|
+
function p$1(i) {
|
|
396
|
+
this.x = i;
|
|
397
|
+
this.u = void 0;
|
|
398
|
+
this.s = void 0;
|
|
399
|
+
this.o = void 0;
|
|
400
|
+
this.f = 32;
|
|
401
|
+
}
|
|
402
|
+
p$1.prototype.c = function () {
|
|
403
|
+
const i = this.S();
|
|
404
|
+
try {
|
|
405
|
+
if (!(8 & this.f) && void 0 !== this.x) this.u = this.x();
|
|
406
|
+
} finally {
|
|
407
|
+
i();
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
p$1.prototype.S = function () {
|
|
411
|
+
if (1 & this.f) i();
|
|
412
|
+
this.f |= 1;
|
|
413
|
+
this.f &= -9;
|
|
414
|
+
y(this);
|
|
415
|
+
d$1(this);
|
|
416
|
+
h$1++;
|
|
417
|
+
const t = n;
|
|
418
|
+
n = this;
|
|
419
|
+
return g.bind(this, t);
|
|
420
|
+
};
|
|
421
|
+
p$1.prototype.N = function () {
|
|
422
|
+
if (!(2 & this.f)) {
|
|
423
|
+
this.f |= 2;
|
|
424
|
+
this.o = o;
|
|
425
|
+
o = this;
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
p$1.prototype.d = function () {
|
|
429
|
+
this.f |= 8;
|
|
430
|
+
if (!(1 & this.f)) _(this);
|
|
431
|
+
};
|
|
432
|
+
function b(i) {
|
|
433
|
+
const t = new p$1(i);
|
|
434
|
+
t.c();
|
|
435
|
+
return t.d.bind(t);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function c(t, e) {
|
|
439
|
+
l$2[t] = e.bind(null, l$2[t] || (() => {}));
|
|
440
|
+
}
|
|
441
|
+
let a;
|
|
442
|
+
function d(t) {
|
|
443
|
+
if (a) a();
|
|
444
|
+
a = t && t.S();
|
|
445
|
+
}
|
|
446
|
+
function p({
|
|
447
|
+
data: t
|
|
448
|
+
}) {
|
|
449
|
+
const i = useSignal(t);
|
|
450
|
+
i.value = t;
|
|
451
|
+
const n = F(() => {
|
|
452
|
+
let t = this.__v;
|
|
453
|
+
while (t = t.__) if (t.__c) {
|
|
454
|
+
t.__c.__$f |= 4;
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
this.__$u.c = () => {
|
|
458
|
+
this.base.data = n.peek();
|
|
459
|
+
};
|
|
460
|
+
return a$1(() => {
|
|
461
|
+
let t = i.value.value;
|
|
462
|
+
return 0 === t ? 0 : !0 === t ? "" : t || "";
|
|
463
|
+
});
|
|
464
|
+
}, []);
|
|
465
|
+
return n.value;
|
|
466
|
+
}
|
|
467
|
+
p.displayName = "_st";
|
|
468
|
+
Object.defineProperties(u.prototype, {
|
|
469
|
+
constructor: {
|
|
470
|
+
configurable: !0
|
|
471
|
+
},
|
|
472
|
+
type: {
|
|
473
|
+
configurable: !0,
|
|
474
|
+
value: p
|
|
475
|
+
},
|
|
476
|
+
props: {
|
|
477
|
+
configurable: !0,
|
|
478
|
+
get() {
|
|
479
|
+
return {
|
|
480
|
+
data: this
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
__b: {
|
|
485
|
+
configurable: !0,
|
|
486
|
+
value: 1
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
c("__b", (t, i) => {
|
|
490
|
+
if ("string" == typeof i.type) {
|
|
491
|
+
let t,
|
|
492
|
+
e = i.props;
|
|
493
|
+
for (let n in e) {
|
|
494
|
+
if ("children" === n) continue;
|
|
495
|
+
let o = e[n];
|
|
496
|
+
if (o instanceof u) {
|
|
497
|
+
if (!t) i.__np = t = {};
|
|
498
|
+
t[n] = o;
|
|
499
|
+
e[n] = o.peek();
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
t(i);
|
|
504
|
+
});
|
|
505
|
+
c("__r", (t, i) => {
|
|
506
|
+
d();
|
|
507
|
+
let e,
|
|
508
|
+
n = i.__c;
|
|
509
|
+
if (n) {
|
|
510
|
+
n.__$f &= -2;
|
|
511
|
+
e = n.__$u;
|
|
512
|
+
if (void 0 === e) n.__$u = e = function (t) {
|
|
513
|
+
let i;
|
|
514
|
+
b(function () {
|
|
515
|
+
i = this;
|
|
516
|
+
});
|
|
517
|
+
i.c = () => {
|
|
518
|
+
n.__$f |= 1;
|
|
519
|
+
n.setState({});
|
|
520
|
+
};
|
|
521
|
+
return i;
|
|
522
|
+
}();
|
|
523
|
+
}
|
|
524
|
+
d(e);
|
|
525
|
+
t(i);
|
|
526
|
+
});
|
|
527
|
+
c("__e", (t, i, e, n) => {
|
|
528
|
+
d();
|
|
529
|
+
t(i, e, n);
|
|
530
|
+
});
|
|
531
|
+
c("diffed", (t, i) => {
|
|
532
|
+
d();
|
|
533
|
+
let e;
|
|
534
|
+
if ("string" == typeof i.type && (e = i.__e)) {
|
|
535
|
+
let t = i.__np,
|
|
536
|
+
n = i.props;
|
|
537
|
+
if (t) {
|
|
538
|
+
let i = e.U;
|
|
539
|
+
if (i) for (let e in i) {
|
|
540
|
+
let n = i[e];
|
|
541
|
+
if (void 0 !== n && !(e in t)) {
|
|
542
|
+
n.d();
|
|
543
|
+
i[e] = void 0;
|
|
544
|
+
}
|
|
545
|
+
} else {
|
|
546
|
+
i = {};
|
|
547
|
+
e.U = i;
|
|
548
|
+
}
|
|
549
|
+
for (let o in t) {
|
|
550
|
+
let r = i[o],
|
|
551
|
+
f = t[o];
|
|
552
|
+
if (void 0 === r) {
|
|
553
|
+
r = h(e, o, f, n);
|
|
554
|
+
i[o] = r;
|
|
555
|
+
} else r.o(f, n);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
t(i);
|
|
560
|
+
});
|
|
561
|
+
function h(t, i, e, n) {
|
|
562
|
+
const o = i in t && void 0 === t.ownerSVGElement,
|
|
563
|
+
r = c$1(e);
|
|
564
|
+
return {
|
|
565
|
+
o: (t, i) => {
|
|
566
|
+
r.value = t;
|
|
567
|
+
n = i;
|
|
568
|
+
},
|
|
569
|
+
d: b(() => {
|
|
570
|
+
const e = r.value.value;
|
|
571
|
+
if (n[i] !== e) {
|
|
572
|
+
n[i] = e;
|
|
573
|
+
if (o) t[i] = e;else if (e) t.setAttribute(i, e);else t.removeAttribute(i);
|
|
574
|
+
}
|
|
575
|
+
})
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
c("unmount", (t, i) => {
|
|
579
|
+
if ("string" == typeof i.type) {
|
|
580
|
+
let t = i.__e;
|
|
581
|
+
if (t) {
|
|
582
|
+
const i = t.U;
|
|
583
|
+
if (i) {
|
|
584
|
+
t.U = void 0;
|
|
585
|
+
for (let t in i) {
|
|
586
|
+
let e = i[t];
|
|
587
|
+
if (e) e.d();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
} else {
|
|
592
|
+
let t = i.__c;
|
|
593
|
+
if (t) {
|
|
594
|
+
const i = t.__$u;
|
|
595
|
+
if (i) {
|
|
596
|
+
t.__$u = void 0;
|
|
597
|
+
i.d();
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
t(i);
|
|
602
|
+
});
|
|
603
|
+
c("__h", (t, i, e, n) => {
|
|
604
|
+
if (n < 3) i.__$f |= 2;
|
|
605
|
+
t(i, e, n);
|
|
606
|
+
});
|
|
607
|
+
function useSignal(t) {
|
|
608
|
+
return F(() => c$1(t), []);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
const paramsFromParentWindow = {};
|
|
612
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
613
|
+
searchParams.forEach((value, key) => {
|
|
614
|
+
paramsFromParentWindow[key] = value === "" ? true : value;
|
|
615
|
+
});
|
|
616
|
+
const parentWindowReloader = window.parent.__reloader__;
|
|
617
|
+
|
|
618
|
+
const stateFromLocalStorage = localStorage.hasOwnProperty("jsenv_toolbar") ? JSON.parse(localStorage.getItem("jsenv_toolbar")) : {};
|
|
619
|
+
|
|
620
|
+
const animationsEnabledSignal = c$1(typeof stateFromLocalStorage.animationsEnabled === "boolean" ? stateFromLocalStorage.animationsEnabled : typeof paramsFromParentWindow.animationsEnabled === "boolean" ? paramsFromParentWindow.animationsEnabled : false);
|
|
621
|
+
|
|
622
|
+
b(() => {
|
|
623
|
+
const animationsEnabled = animationsEnabledSignal.value;
|
|
624
|
+
if (animationsEnabled) {
|
|
625
|
+
document.documentElement.removeAttribute("data-animation-disabled");
|
|
626
|
+
} else {
|
|
627
|
+
document.documentElement.setAttribute("data-animation-disabled", "");
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
const executionTooltipOpenedSignal = c$1(false);
|
|
632
|
+
const executionSignal = c$1({
|
|
633
|
+
status: "running"
|
|
634
|
+
});
|
|
635
|
+
const previousExecutionSignal = c$1(sessionStorage.hasOwnProperty(window.location.href) ? JSON.parse(sessionStorage.getItem(window.location.href)) : null);
|
|
636
|
+
window.parent.__supervisor__.getDocumentExecutionResult().then(({
|
|
637
|
+
status,
|
|
638
|
+
startTime,
|
|
639
|
+
endTime
|
|
640
|
+
}) => {
|
|
641
|
+
executionSignal.value = {
|
|
642
|
+
status,
|
|
643
|
+
startTime,
|
|
644
|
+
endTime
|
|
645
|
+
};
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
const notificationAPIDetected = typeof window.Notification === "function";
|
|
649
|
+
|
|
650
|
+
const notificationsEnabledSignal = c$1(typeof stateFromLocalStorage.notificationsEnabled === "boolean" ? stateFromLocalStorage.notificationsEnabled : typeof paramsFromParentWindow.notificationsEnabled === "boolean" ? paramsFromParentWindow.notificationsEnabled : false);
|
|
651
|
+
const notificationPermissionSignal = c$1(Notification.permission);
|
|
652
|
+
|
|
653
|
+
const enableNotifications = () => {
|
|
654
|
+
notificationsEnabledSignal.value = true;
|
|
655
|
+
};
|
|
656
|
+
const disableNotifications = () => {
|
|
657
|
+
notificationsEnabledSignal.value = false;
|
|
658
|
+
};
|
|
659
|
+
const arrayOfOpenedNotifications = [];
|
|
660
|
+
const notify = notificationAPIDetected ? async (title, {
|
|
661
|
+
clickToFocus = false,
|
|
662
|
+
clickToClose = false,
|
|
663
|
+
...options
|
|
664
|
+
} = {}) => {
|
|
665
|
+
const notificationsEnabled = notificationsEnabledSignal.value;
|
|
666
|
+
if (!notificationsEnabled) {
|
|
667
|
+
return null;
|
|
668
|
+
}
|
|
669
|
+
if (Notification.permission !== "granted") {
|
|
670
|
+
return null;
|
|
671
|
+
}
|
|
672
|
+
const notification = new Notification(title, options);
|
|
673
|
+
arrayOfOpenedNotifications.push(notification);
|
|
674
|
+
notification.onclick = () => {
|
|
675
|
+
// but if the user navigated inbetween
|
|
676
|
+
// focusing window will show something else
|
|
677
|
+
// in that case it could be great to do something
|
|
678
|
+
// maybe like showing a message saying this execution
|
|
679
|
+
// is no longer visible
|
|
680
|
+
// we could also navigauate to this file execution but
|
|
681
|
+
// there is no guarantee re-executing the file would give same output
|
|
682
|
+
// and it would also trigger an other notification
|
|
683
|
+
if (clickToFocus) window.focus();
|
|
684
|
+
if (clickToClose) notification.close();
|
|
685
|
+
};
|
|
686
|
+
notification.onclose = () => {
|
|
687
|
+
const index = arrayOfOpenedNotifications.indexOf(notification);
|
|
688
|
+
if (index > -1) {
|
|
689
|
+
arrayOfOpenedNotifications.splice(index, 1);
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
return notification;
|
|
693
|
+
} : () => {};
|
|
694
|
+
const closeAllNotifications = () => {
|
|
695
|
+
// slice because arrayOfOpenedNotifications can be mutated while looping
|
|
696
|
+
arrayOfOpenedNotifications.slice().forEach(notification => {
|
|
697
|
+
notification.close();
|
|
698
|
+
});
|
|
699
|
+
};
|
|
700
|
+
let requestPromise;
|
|
701
|
+
const requestPermission = notificationAPIDetected ? async () => {
|
|
702
|
+
if (requestPromise) {
|
|
703
|
+
await requestPromise;
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
requestPromise = Notification.requestPermission();
|
|
707
|
+
await requestPromise;
|
|
708
|
+
requestPromise = undefined;
|
|
709
|
+
notificationPermissionSignal.value = Notification.permission;
|
|
710
|
+
} : () => Promise.resolve();
|
|
711
|
+
|
|
712
|
+
const openExecutionTooltip = () => {
|
|
713
|
+
executionTooltipOpenedSignal.value = true;
|
|
714
|
+
};
|
|
715
|
+
const closeExecutionTooltip = () => {
|
|
716
|
+
executionTooltipOpenedSignal.value = false;
|
|
717
|
+
};
|
|
718
|
+
const notifyExecutionResult = (execution, previousExecution) => {
|
|
719
|
+
const executedFileRelativeUrl = window.location.href;
|
|
720
|
+
const notificationOptions = {
|
|
721
|
+
lang: "en",
|
|
722
|
+
icon: getFaviconHref(),
|
|
723
|
+
clickToFocus: true,
|
|
724
|
+
clickToClose: true
|
|
725
|
+
};
|
|
726
|
+
if (execution.status === "errored") {
|
|
727
|
+
if (previousExecution) {
|
|
728
|
+
if (previousExecution.status === "completed") {
|
|
729
|
+
notify("Broken", {
|
|
730
|
+
...notificationOptions,
|
|
731
|
+
body: `${executedFileRelativeUrl} execution now failing.`
|
|
732
|
+
});
|
|
733
|
+
} else {
|
|
734
|
+
notify("Still failing", {
|
|
735
|
+
...notificationOptions,
|
|
736
|
+
body: `${executedFileRelativeUrl} execution still failing.`
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
} else {
|
|
740
|
+
notify("Failing", {
|
|
741
|
+
...notificationOptions,
|
|
742
|
+
body: `${executedFileRelativeUrl} execution failed.`
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
} else if (previousExecution && previousExecution.status === "errored") {
|
|
746
|
+
notify("Fixed", {
|
|
747
|
+
...notificationOptions,
|
|
748
|
+
body: `${executedFileRelativeUrl} execution fixed.`
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
const getFaviconHref = () => {
|
|
753
|
+
const link = document.querySelector('link[rel="icon"]');
|
|
754
|
+
return link ? link.href : undefined;
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
b(() => {
|
|
758
|
+
const execution = executionSignal.value;
|
|
759
|
+
if (execution) {
|
|
760
|
+
sessionStorage.setItem(window.location.href, JSON.stringify(execution));
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
b(() => {
|
|
764
|
+
const execution = executionSignal.value;
|
|
765
|
+
const previousExecution = previousExecutionSignal.value;
|
|
766
|
+
if (execution) {
|
|
767
|
+
notifyExecutionResult(execution, previousExecution);
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
b(() => {
|
|
772
|
+
const notificationsEnabled = notificationsEnabledSignal.value;
|
|
773
|
+
if (!notificationsEnabled) {
|
|
774
|
+
closeAllNotifications();
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
const sendEventToParent = (name, data) => {
|
|
779
|
+
window.parent.postMessage({
|
|
780
|
+
__jsenv__: {
|
|
781
|
+
event: name,
|
|
782
|
+
data
|
|
783
|
+
}
|
|
784
|
+
}, "*");
|
|
785
|
+
};
|
|
786
|
+
const addExternalCommandCallback = (command, callback) => {
|
|
787
|
+
const messageEventCallback = messageEvent => {
|
|
788
|
+
const {
|
|
789
|
+
data
|
|
790
|
+
} = messageEvent;
|
|
791
|
+
if (typeof data !== "object") {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
const {
|
|
795
|
+
__jsenv__
|
|
796
|
+
} = data;
|
|
797
|
+
if (!__jsenv__) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
if (__jsenv__.command !== command) {
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
callback(...__jsenv__.args);
|
|
804
|
+
};
|
|
805
|
+
window.addEventListener("message", messageEventCallback);
|
|
806
|
+
return () => {
|
|
807
|
+
window.removeEventListener("message", messageEventCallback);
|
|
808
|
+
};
|
|
809
|
+
};
|
|
810
|
+
const enableAutoreload = () => {
|
|
811
|
+
parentWindowReloader.autoreload.enable();
|
|
812
|
+
};
|
|
813
|
+
const disableAutoreload = () => {
|
|
814
|
+
parentWindowReloader.autoreload.disable();
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
const serverTooltipOpenedSignal = c$1(false);
|
|
818
|
+
const serverConnectionSignal = c$1("default");
|
|
819
|
+
const serverEvents$1 = window.__server_events__;
|
|
820
|
+
if (serverEvents$1) {
|
|
821
|
+
serverEvents$1.readyState.onchange = () => {
|
|
822
|
+
serverConnectionSignal.value = serverEvents$1.readyState.value;
|
|
823
|
+
};
|
|
824
|
+
serverConnectionSignal.value = serverEvents$1.readyState.value;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
const openServerTooltip = () => {
|
|
828
|
+
serverTooltipOpenedSignal.value = true;
|
|
829
|
+
};
|
|
830
|
+
const closeServerTooltip = () => {
|
|
831
|
+
serverTooltipOpenedSignal.value = false;
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
const closeAllTooltips = () => {
|
|
835
|
+
closeExecutionTooltip();
|
|
836
|
+
closeServerTooltip();
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
const openedSignal = c$1(typeof stateFromLocalStorage.opened === "boolean" ? stateFromLocalStorage.opened : typeof paramsFromParentWindow.opened === "boolean" ? paramsFromParentWindow.opened : false);
|
|
840
|
+
|
|
841
|
+
const getToolbarIframe = () => {
|
|
842
|
+
const iframes = Array.from(window.parent.document.querySelectorAll("iframe"));
|
|
843
|
+
return iframes.find(iframe => iframe.contentWindow === window);
|
|
844
|
+
};
|
|
845
|
+
const forceHideElement = element => {
|
|
846
|
+
element.setAttribute("data-force-hide", "");
|
|
847
|
+
};
|
|
848
|
+
const removeForceHideElement = element => {
|
|
849
|
+
element.removeAttribute("data-force-hide");
|
|
850
|
+
};
|
|
851
|
+
const setStyles = (element, styles) => {
|
|
852
|
+
const elementStyle = element.style;
|
|
853
|
+
const restoreStyles = Object.keys(styles).map(styleName => {
|
|
854
|
+
let restore;
|
|
855
|
+
if (styleName in elementStyle) {
|
|
856
|
+
const currentStyle = elementStyle[styleName];
|
|
857
|
+
restore = () => {
|
|
858
|
+
elementStyle[styleName] = currentStyle;
|
|
859
|
+
};
|
|
860
|
+
} else {
|
|
861
|
+
restore = () => {
|
|
862
|
+
delete elementStyle[styleName];
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
elementStyle[styleName] = styles[styleName];
|
|
866
|
+
return restore;
|
|
867
|
+
});
|
|
868
|
+
return () => {
|
|
869
|
+
restoreStyles.forEach(restore => restore());
|
|
870
|
+
};
|
|
871
|
+
};
|
|
872
|
+
const activateToolbarSection = element => {
|
|
873
|
+
element.setAttribute("data-active", "");
|
|
874
|
+
};
|
|
875
|
+
const deactivateToolbarSection = element => {
|
|
876
|
+
element.removeAttribute("data-active");
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
const startJavaScriptAnimation = ({
|
|
880
|
+
duration = 300,
|
|
881
|
+
timingFunction = t => t,
|
|
882
|
+
onProgress = () => {},
|
|
883
|
+
onCancel = () => {},
|
|
884
|
+
onComplete = () => {}
|
|
885
|
+
}) => {
|
|
886
|
+
if (isNaN(duration)) {
|
|
887
|
+
// console.warn(`duration must be a number, received ${duration}`)
|
|
888
|
+
return () => {};
|
|
889
|
+
}
|
|
890
|
+
duration = parseInt(duration, 10);
|
|
891
|
+
const startMs = performance.now();
|
|
892
|
+
let currentRequestAnimationFrameId;
|
|
893
|
+
let done = false;
|
|
894
|
+
let rawProgress = 0;
|
|
895
|
+
let progress = 0;
|
|
896
|
+
const handler = () => {
|
|
897
|
+
currentRequestAnimationFrameId = null;
|
|
898
|
+
const nowMs = performance.now();
|
|
899
|
+
rawProgress = Math.min((nowMs - startMs) / duration, 1);
|
|
900
|
+
progress = timingFunction(rawProgress);
|
|
901
|
+
done = rawProgress === 1;
|
|
902
|
+
onProgress({
|
|
903
|
+
done,
|
|
904
|
+
rawProgress,
|
|
905
|
+
progress
|
|
906
|
+
});
|
|
907
|
+
if (done) {
|
|
908
|
+
onComplete();
|
|
909
|
+
} else {
|
|
910
|
+
currentRequestAnimationFrameId = window.requestAnimationFrame(handler);
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
handler();
|
|
914
|
+
const stop = () => {
|
|
915
|
+
if (currentRequestAnimationFrameId) {
|
|
916
|
+
window.cancelAnimationFrame(currentRequestAnimationFrameId);
|
|
917
|
+
currentRequestAnimationFrameId = null;
|
|
918
|
+
}
|
|
919
|
+
if (!done) {
|
|
920
|
+
done = true;
|
|
921
|
+
onCancel({
|
|
922
|
+
rawProgress,
|
|
923
|
+
progress
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
return stop;
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
const initToolbarOpening = () => {
|
|
931
|
+
b(() => {
|
|
932
|
+
const opened = openedSignal.value;
|
|
933
|
+
if (opened) {
|
|
934
|
+
showToolbar();
|
|
935
|
+
} else {
|
|
936
|
+
hideToolbar();
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
};
|
|
940
|
+
let restoreToolbarIframeParentStyles = () => {};
|
|
941
|
+
let restoreToolbarIframeStyles = () => {};
|
|
942
|
+
const hideToolbar = () => {
|
|
943
|
+
closeAllTooltips();
|
|
944
|
+
restoreToolbarIframeParentStyles();
|
|
945
|
+
restoreToolbarIframeStyles();
|
|
946
|
+
document.documentElement.removeAttribute("data-toolbar-visible");
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
// (by the way it might be cool to have the toolbar auto show when)
|
|
950
|
+
// it has something to say (being disconnected from server)
|
|
951
|
+
const showToolbar = () => {
|
|
952
|
+
const animationsEnabled = animationsEnabledSignal.peek();
|
|
953
|
+
document.documentElement.setAttribute("data-toolbar-visible", "");
|
|
954
|
+
const toolbarIframe = getToolbarIframe();
|
|
955
|
+
const toolbarIframeParent = toolbarIframe.parentNode;
|
|
956
|
+
const parentWindow = window.parent;
|
|
957
|
+
const parentDocumentElement = parentWindow.document.compatMode === "CSS1Compat" ? parentWindow.document.documentElement : parentWindow.document.body;
|
|
958
|
+
const scrollYMax = parentDocumentElement.scrollHeight - parentWindow.innerHeight;
|
|
959
|
+
const scrollY = parentDocumentElement.scrollTop;
|
|
960
|
+
const scrollYRemaining = scrollYMax - scrollY;
|
|
961
|
+
setStyles(toolbarIframeParent, {
|
|
962
|
+
"transition-property": "padding-bottom",
|
|
963
|
+
"transition-duration": animationsEnabled ? "300ms" : "0s"
|
|
964
|
+
});
|
|
965
|
+
// maybe we should use js animation here because we would not conflict with css
|
|
966
|
+
restoreToolbarIframeParentStyles = setStyles(toolbarIframeParent, {
|
|
967
|
+
"scroll-padding-bottom": "40px",
|
|
968
|
+
// same here we should add 40px
|
|
969
|
+
"padding-bottom": "40px" // if there is already one we should add 40px
|
|
970
|
+
});
|
|
971
|
+
|
|
972
|
+
restoreToolbarIframeStyles = setStyles(toolbarIframe, {
|
|
973
|
+
height: "40px",
|
|
974
|
+
visibility: "visible"
|
|
975
|
+
});
|
|
976
|
+
if (scrollYRemaining < 40 && scrollYMax > 0) {
|
|
977
|
+
const scrollEnd = scrollY + 40;
|
|
978
|
+
startJavaScriptAnimation({
|
|
979
|
+
duration: 300,
|
|
980
|
+
onProgress: ({
|
|
981
|
+
progress
|
|
982
|
+
}) => {
|
|
983
|
+
const value = scrollY + (scrollEnd - scrollY) * progress;
|
|
984
|
+
parentDocumentElement.scrollTop = value;
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
const createHorizontalBreakpoint = breakpointValue => {
|
|
991
|
+
return createBreakpoint(windowWidthMeasure, breakpointValue);
|
|
992
|
+
};
|
|
993
|
+
const createMeasure = ({
|
|
994
|
+
compute,
|
|
995
|
+
register
|
|
996
|
+
}) => {
|
|
997
|
+
let currentValue = compute();
|
|
998
|
+
const get = () => compute();
|
|
999
|
+
const changed = createSignal();
|
|
1000
|
+
let unregister = () => {};
|
|
1001
|
+
if (register) {
|
|
1002
|
+
unregister = register(() => {
|
|
1003
|
+
const value = compute();
|
|
1004
|
+
if (value !== currentValue) {
|
|
1005
|
+
const previousValue = value;
|
|
1006
|
+
currentValue = value;
|
|
1007
|
+
changed.notify(value, previousValue);
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
return {
|
|
1012
|
+
get,
|
|
1013
|
+
changed,
|
|
1014
|
+
unregister
|
|
1015
|
+
};
|
|
1016
|
+
};
|
|
1017
|
+
const createSignal = () => {
|
|
1018
|
+
const callbackArray = [];
|
|
1019
|
+
const listen = callback => {
|
|
1020
|
+
callbackArray.push(callback);
|
|
1021
|
+
return () => {
|
|
1022
|
+
const index = callbackArray.indexOf(callback);
|
|
1023
|
+
if (index > -1) {
|
|
1024
|
+
callbackArray.splice(index, 1);
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
};
|
|
1028
|
+
const notify = (...args) => {
|
|
1029
|
+
callbackArray.slice().forEach(callback => {
|
|
1030
|
+
callback(...args);
|
|
1031
|
+
});
|
|
1032
|
+
};
|
|
1033
|
+
return {
|
|
1034
|
+
listen,
|
|
1035
|
+
notify
|
|
1036
|
+
};
|
|
1037
|
+
};
|
|
1038
|
+
const windowWidthMeasure = createMeasure({
|
|
1039
|
+
name: "window-width",
|
|
1040
|
+
compute: () => window.innerWidth,
|
|
1041
|
+
register: onchange => {
|
|
1042
|
+
window.addEventListener("resize", onchange);
|
|
1043
|
+
window.addEventListener("orientationchange", onchange);
|
|
1044
|
+
return () => {
|
|
1045
|
+
window.removeEventListener("resize", onchange);
|
|
1046
|
+
window.removeEventListener("orientationchange", onchange);
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
const createBreakpoint = (measure, breakpointValue) => {
|
|
1051
|
+
const getBreakpointState = () => {
|
|
1052
|
+
const value = measure.get();
|
|
1053
|
+
if (value < breakpointValue) {
|
|
1054
|
+
return "below";
|
|
1055
|
+
}
|
|
1056
|
+
if (value > breakpointValue) {
|
|
1057
|
+
return "above";
|
|
1058
|
+
}
|
|
1059
|
+
return "equals";
|
|
1060
|
+
};
|
|
1061
|
+
let currentBreakpointState = getBreakpointState();
|
|
1062
|
+
const isAbove = () => {
|
|
1063
|
+
return measure.get() > breakpointValue;
|
|
1064
|
+
};
|
|
1065
|
+
const isBelow = () => {
|
|
1066
|
+
return measure.get() < breakpointValue;
|
|
1067
|
+
};
|
|
1068
|
+
const breakpointChanged = createSignal();
|
|
1069
|
+
measure.changed.listen(() => {
|
|
1070
|
+
const breakpointState = getBreakpointState();
|
|
1071
|
+
if (breakpointState !== currentBreakpointState) {
|
|
1072
|
+
const breakpointStatePrevious = currentBreakpointState;
|
|
1073
|
+
currentBreakpointState = breakpointState;
|
|
1074
|
+
breakpointChanged.notify(breakpointState, breakpointStatePrevious);
|
|
1075
|
+
}
|
|
1076
|
+
});
|
|
1077
|
+
return {
|
|
1078
|
+
isAbove,
|
|
1079
|
+
isBelow,
|
|
1080
|
+
changed: breakpointChanged
|
|
1081
|
+
};
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
// const windowScrollTop = createMeasure({
|
|
1085
|
+
// name: "window-scroll-top",
|
|
1086
|
+
// compute: () => window.scrollTop,
|
|
1087
|
+
// register: (onchange) => {
|
|
1088
|
+
// window.addEventListener("scroll", onchange)
|
|
1089
|
+
// return () => {
|
|
1090
|
+
// window.removeEventListener("scroll", onchange)
|
|
1091
|
+
// }
|
|
1092
|
+
// },
|
|
1093
|
+
// })
|
|
1094
|
+
|
|
1095
|
+
const WINDOW_SMALL_WIDTH = 420;
|
|
1096
|
+
const initToolbarMenuOverflow = () => {
|
|
1097
|
+
// apply responsive design on toolbar icons if needed + add listener on resize screen
|
|
1098
|
+
// ideally we should listen breakpoint once, for now restore toolbar
|
|
1099
|
+
const overflowMenuBreakpoint = createHorizontalBreakpoint(WINDOW_SMALL_WIDTH);
|
|
1100
|
+
const handleOverflowMenuBreakpoint = () => {
|
|
1101
|
+
responsiveToolbar(overflowMenuBreakpoint);
|
|
1102
|
+
};
|
|
1103
|
+
handleOverflowMenuBreakpoint();
|
|
1104
|
+
overflowMenuBreakpoint.changed.listen(handleOverflowMenuBreakpoint);
|
|
1105
|
+
document.querySelector("#menu_overflow_button").onclick = () => {
|
|
1106
|
+
if (overflowMenuIsOpened()) {
|
|
1107
|
+
closeOverflowMenu();
|
|
1108
|
+
} else {
|
|
1109
|
+
openOverflowMenu();
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
};
|
|
1113
|
+
const responsiveToolbar = overflowMenuBreakpoint => {
|
|
1114
|
+
// close all tooltips in case opened
|
|
1115
|
+
closeAllTooltips();
|
|
1116
|
+
// close settings box in case opened
|
|
1117
|
+
deactivateToolbarSection(document.querySelector("#settings"));
|
|
1118
|
+
if (overflowMenuBreakpoint.isBelow()) {
|
|
1119
|
+
enableOverflow();
|
|
1120
|
+
} else {
|
|
1121
|
+
disableOverflow();
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
let moves = [];
|
|
1125
|
+
const enableOverflow = () => {
|
|
1126
|
+
// move elements from toolbar to overflow menu
|
|
1127
|
+
const responsiveToolbarElements = document.querySelectorAll("[data-responsive-toolbar-element]");
|
|
1128
|
+
const overflowMenu = document.querySelector("#menu_overflow");
|
|
1129
|
+
|
|
1130
|
+
// keep a placeholder element to know where to move them back
|
|
1131
|
+
moves = Array.from(responsiveToolbarElements).map(element => {
|
|
1132
|
+
const placeholder = document.createElement("div");
|
|
1133
|
+
placeholder.style.display = "none";
|
|
1134
|
+
placeholder.setAttribute("data-placeholder", "");
|
|
1135
|
+
element.parentNode.replaceChild(placeholder, element);
|
|
1136
|
+
overflowMenu.appendChild(element);
|
|
1137
|
+
return {
|
|
1138
|
+
element,
|
|
1139
|
+
placeholder
|
|
1140
|
+
};
|
|
1141
|
+
});
|
|
1142
|
+
document.querySelector("#toolbar").setAttribute("data-menu-overflow-enabled", "");
|
|
1143
|
+
removeForceHideElement(document.querySelector("#menu_overflow_button"));
|
|
1144
|
+
};
|
|
1145
|
+
const disableOverflow = () => {
|
|
1146
|
+
// close overflow menu in case it's open & unselect toggleOverflowMenu button in case it's selected
|
|
1147
|
+
closeOverflowMenu();
|
|
1148
|
+
deactivateToolbarSection(document.querySelector("#menu_overflow"));
|
|
1149
|
+
moves.forEach(({
|
|
1150
|
+
element,
|
|
1151
|
+
placeholder
|
|
1152
|
+
}) => {
|
|
1153
|
+
placeholder.parentNode.replaceChild(element, placeholder);
|
|
1154
|
+
});
|
|
1155
|
+
moves = [];
|
|
1156
|
+
document.querySelector("#toolbar").removeAttribute("data-menu-overflow-enabled");
|
|
1157
|
+
forceHideElement(document.querySelector("#menu_overflow_button"));
|
|
1158
|
+
};
|
|
1159
|
+
const overflowMenuIsOpened = () => {
|
|
1160
|
+
const toolbar = document.querySelector("#toolbar");
|
|
1161
|
+
return toolbar.hasAttribute("data-menu-overflow-opened");
|
|
1162
|
+
};
|
|
1163
|
+
const openOverflowMenu = () => {
|
|
1164
|
+
const toolbar = document.querySelector("#toolbar");
|
|
1165
|
+
document.querySelector("#menu_overflow").setAttribute("data-animate", "");
|
|
1166
|
+
toolbar.setAttribute("data-menu-overflow-opened", "");
|
|
1167
|
+
};
|
|
1168
|
+
const closeOverflowMenu = () => {
|
|
1169
|
+
const toolbar = document.querySelector("#toolbar");
|
|
1170
|
+
toolbar.removeAttribute("data-menu-overflow-opened");
|
|
1171
|
+
document.querySelector("#menu_overflow").removeAttribute("data-animate");
|
|
1172
|
+
};
|
|
1173
|
+
|
|
1174
|
+
const settingsOpenedSignal = c$1(false);
|
|
1175
|
+
|
|
1176
|
+
const openSettings = () => {
|
|
1177
|
+
settingsOpenedSignal.value = true;
|
|
1178
|
+
};
|
|
1179
|
+
const closeSettings = () => {
|
|
1180
|
+
settingsOpenedSignal.value = false;
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
const changesTooltipOpenedSignal = c$1(false);
|
|
1184
|
+
|
|
1185
|
+
const renderToolbarOverlay = () => {
|
|
1186
|
+
const toolbarOverlay = document.querySelector("#toolbar_overlay");
|
|
1187
|
+
toolbarOverlay.onclick = () => {
|
|
1188
|
+
closeAllTooltips();
|
|
1189
|
+
closeSettings();
|
|
1190
|
+
};
|
|
1191
|
+
b(() => {
|
|
1192
|
+
if (!window.parent) {
|
|
1193
|
+
// can happen while parent iframe reloads
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
const opened = openedSignal.value;
|
|
1197
|
+
const settingsOpened = settingsOpenedSignal.value;
|
|
1198
|
+
const executionTooltipOpened = executionTooltipOpenedSignal.value;
|
|
1199
|
+
const changesTooltipOpened = changesTooltipOpenedSignal.value;
|
|
1200
|
+
const serverTooltipOpened = serverTooltipOpenedSignal.value;
|
|
1201
|
+
if (!opened) {
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
if (settingsOpened || executionTooltipOpened || changesTooltipOpened || serverTooltipOpened) {
|
|
1205
|
+
enableIframeOverflowOnParentWindow();
|
|
1206
|
+
} else {
|
|
1207
|
+
disableIframeOverflowOnParentWindow();
|
|
1208
|
+
}
|
|
1209
|
+
});
|
|
1210
|
+
};
|
|
1211
|
+
const enableIframeOverflowOnParentWindow = () => {
|
|
1212
|
+
const iframe = getToolbarIframe();
|
|
1213
|
+
const transitionDuration = iframe.style.transitionDuration;
|
|
1214
|
+
setStyles(iframe, {
|
|
1215
|
+
"height": "100%",
|
|
1216
|
+
// we don't want to animate height transition
|
|
1217
|
+
// but if it was enabled, we'll restore it afterwards
|
|
1218
|
+
"transition-duration": "0ms"
|
|
1219
|
+
});
|
|
1220
|
+
if (transitionDuration) {
|
|
1221
|
+
setTimeout(() => {
|
|
1222
|
+
setStyles(iframe, {
|
|
1223
|
+
"transition-duration": transitionDuration
|
|
1224
|
+
});
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
const disableIframeOverflowOnParentWindow = () => {
|
|
1229
|
+
const iframe = getToolbarIframe();
|
|
1230
|
+
const transitionDuration = iframe.style.transitionDuration;
|
|
1231
|
+
setStyles(iframe, {
|
|
1232
|
+
"height": "40px",
|
|
1233
|
+
// we don't want to animate height transition
|
|
1234
|
+
// but if it was enabled, we'll restore it afterwards
|
|
1235
|
+
"transition-duration": "0ms"
|
|
1236
|
+
});
|
|
1237
|
+
if (transitionDuration) {
|
|
1238
|
+
setTimeout(() => {
|
|
1239
|
+
setStyles(iframe, {
|
|
1240
|
+
"transition-duration": transitionDuration
|
|
1241
|
+
});
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
const setLinkHrefForParentWindow = (a, href) => {
|
|
1247
|
+
a.href = href;
|
|
1248
|
+
a.onclick = e => {
|
|
1249
|
+
if (e.ctrlKey || e.metaKey) {
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
e.preventDefault();
|
|
1253
|
+
window.parent.location.href = href;
|
|
1254
|
+
};
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
const renderDocumentIndexLink = () => {
|
|
1258
|
+
setLinkHrefForParentWindow(document.querySelector("#document_index_link"), "/");
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
const enableVariant = (rootNode, variables) => {
|
|
1262
|
+
const nodesNotMatching = Array.from(rootNode.querySelectorAll(`[${attributeIndicatingACondition}]`));
|
|
1263
|
+
nodesNotMatching.forEach(nodeNotMatching => {
|
|
1264
|
+
const conditionAttributeValue = nodeNotMatching.getAttribute(attributeIndicatingACondition);
|
|
1265
|
+
const matches = testCondition(conditionAttributeValue, variables);
|
|
1266
|
+
if (matches) {
|
|
1267
|
+
renameAttribute(nodeNotMatching, attributeIndicatingACondition, attributeIndicatingAMatch);
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
const nodesMatching = Array.from(rootNode.querySelectorAll(`[${attributeIndicatingAMatch}]`));
|
|
1271
|
+
nodesMatching.forEach(nodeMatching => {
|
|
1272
|
+
const conditionAttributeValue = nodeMatching.getAttribute(attributeIndicatingAMatch);
|
|
1273
|
+
const matches = testCondition(conditionAttributeValue, variables);
|
|
1274
|
+
if (!matches) {
|
|
1275
|
+
renameAttribute(nodeMatching, attributeIndicatingAMatch, attributeIndicatingACondition);
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
};
|
|
1279
|
+
const testCondition = (conditionAttributeValue, variables) => {
|
|
1280
|
+
const condition = parseCondition(conditionAttributeValue);
|
|
1281
|
+
return Object.keys(variables).some(key => {
|
|
1282
|
+
if (condition.key !== key) {
|
|
1283
|
+
return false;
|
|
1284
|
+
}
|
|
1285
|
+
// the condition do not specify a value, any value is ok
|
|
1286
|
+
if (condition.value === undefined) {
|
|
1287
|
+
return true;
|
|
1288
|
+
}
|
|
1289
|
+
if (condition.value === variables[key]) {
|
|
1290
|
+
return true;
|
|
1291
|
+
}
|
|
1292
|
+
return false;
|
|
1293
|
+
});
|
|
1294
|
+
};
|
|
1295
|
+
const parseCondition = conditionAttributeValue => {
|
|
1296
|
+
const colonIndex = conditionAttributeValue.indexOf(":");
|
|
1297
|
+
if (colonIndex === -1) {
|
|
1298
|
+
return {
|
|
1299
|
+
key: conditionAttributeValue,
|
|
1300
|
+
value: undefined
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
return {
|
|
1304
|
+
key: conditionAttributeValue.slice(0, colonIndex),
|
|
1305
|
+
value: conditionAttributeValue.slice(colonIndex + 1)
|
|
1306
|
+
};
|
|
1307
|
+
};
|
|
1308
|
+
const attributeIndicatingACondition = `data-when`;
|
|
1309
|
+
const attributeIndicatingAMatch = `data-when-active`;
|
|
1310
|
+
const renameAttribute = (node, name, newName) => {
|
|
1311
|
+
node.setAttribute(newName, node.getAttribute(name));
|
|
1312
|
+
node.removeAttribute(name);
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
const executionIndicator = document.querySelector("#document_execution_indicator");
|
|
1316
|
+
const renderDocumentExecutionIndicator = async () => {
|
|
1317
|
+
removeForceHideElement(document.querySelector("#document_execution_indicator"));
|
|
1318
|
+
b(() => {
|
|
1319
|
+
const execution = executionSignal.value;
|
|
1320
|
+
updateExecutionIndicator(execution);
|
|
1321
|
+
});
|
|
1322
|
+
b(() => {
|
|
1323
|
+
const executionTooltipOpened = executionTooltipOpenedSignal.value;
|
|
1324
|
+
if (executionTooltipOpened) {
|
|
1325
|
+
executionIndicator.setAttribute("data-tooltip-visible", "");
|
|
1326
|
+
} else {
|
|
1327
|
+
executionIndicator.removeAttribute("data-tooltip-visible");
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
};
|
|
1331
|
+
const updateExecutionIndicator = ({
|
|
1332
|
+
status,
|
|
1333
|
+
startTime,
|
|
1334
|
+
endTime
|
|
1335
|
+
} = {}) => {
|
|
1336
|
+
enableVariant(executionIndicator, {
|
|
1337
|
+
execution: status
|
|
1338
|
+
});
|
|
1339
|
+
const variantNode = executionIndicator.querySelector("[data-when-active]");
|
|
1340
|
+
variantNode.querySelector("button").onclick = () => {
|
|
1341
|
+
const executionTooltipOpened = executionTooltipOpenedSignal.value;
|
|
1342
|
+
if (executionTooltipOpened) {
|
|
1343
|
+
closeExecutionTooltip();
|
|
1344
|
+
} else {
|
|
1345
|
+
openExecutionTooltip();
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
variantNode.querySelector(".tooltip").textContent = computeText({
|
|
1349
|
+
status,
|
|
1350
|
+
startTime,
|
|
1351
|
+
endTime
|
|
1352
|
+
});
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1355
|
+
// relative time: https://github.com/tc39/proposal-intl-relative-time/issues/118
|
|
1356
|
+
const computeText = ({
|
|
1357
|
+
status,
|
|
1358
|
+
startTime,
|
|
1359
|
+
endTime
|
|
1360
|
+
}) => {
|
|
1361
|
+
if (status === "completed") {
|
|
1362
|
+
return `Execution completed in ${endTime - startTime}ms`;
|
|
1363
|
+
}
|
|
1364
|
+
if (status === "errored") {
|
|
1365
|
+
return `Execution failed in ${endTime - startTime}ms`;
|
|
1366
|
+
}
|
|
1367
|
+
if (status === "running") {
|
|
1368
|
+
return "Executing...";
|
|
1369
|
+
}
|
|
1370
|
+
return "";
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
const autoreloadEnabledSignal = c$1(false);
|
|
1374
|
+
const reloaderStatusSignal = c$1("idle");
|
|
1375
|
+
const changesSignal = c$1(0);
|
|
1376
|
+
if (parentWindowReloader) {
|
|
1377
|
+
if (!parentWindowReloader.autoreload.enabled && paramsFromParentWindow.autoreload) {
|
|
1378
|
+
autoreloadEnabledSignal.value = true;
|
|
1379
|
+
} else {
|
|
1380
|
+
autoreloadEnabledSignal.value = parentWindowReloader.autoreload.enabled;
|
|
1381
|
+
}
|
|
1382
|
+
parentWindowReloader.autoreload.onchange = () => {
|
|
1383
|
+
autoreloadEnabledSignal.value = parentWindowReloader.autoreload.enabled;
|
|
1384
|
+
};
|
|
1385
|
+
reloaderStatusSignal.value = parentWindowReloader.status.value;
|
|
1386
|
+
const onchange = parentWindowReloader.status.onchange;
|
|
1387
|
+
parentWindowReloader.status.onchange = () => {
|
|
1388
|
+
onchange();
|
|
1389
|
+
reloaderStatusSignal.value = parentWindowReloader.status.value;
|
|
1390
|
+
};
|
|
1391
|
+
changesSignal.value = parentWindowReloader.changes.value;
|
|
1392
|
+
parentWindowReloader.changes.onchange = () => {
|
|
1393
|
+
changesSignal.value = [...parentWindowReloader.changes.value];
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
const openChangesToolip = () => {
|
|
1398
|
+
changesTooltipOpenedSignal.value = true;
|
|
1399
|
+
};
|
|
1400
|
+
const closeChangesToolip = () => {
|
|
1401
|
+
changesTooltipOpenedSignal.value = false;
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1404
|
+
const changesIndicator = document.querySelector("#changes_indicator");
|
|
1405
|
+
const renderChangesIndicator = () => {
|
|
1406
|
+
b(() => {
|
|
1407
|
+
const autoreloadEnabled = autoreloadEnabledSignal.value;
|
|
1408
|
+
const changes = changesSignal.value;
|
|
1409
|
+
const changeCount = changes.length;
|
|
1410
|
+
enableVariant(changesIndicator, {
|
|
1411
|
+
changes: !autoreloadEnabled && changeCount ? "yes" : "no"
|
|
1412
|
+
});
|
|
1413
|
+
if (changeCount) {
|
|
1414
|
+
changesIndicator.querySelector(".tooltip_text").innerHTML = computeTooltipText({
|
|
1415
|
+
changes
|
|
1416
|
+
});
|
|
1417
|
+
changesIndicator.querySelector(".tooltip_text a").onclick = () => {
|
|
1418
|
+
// eslint-disable-next-line no-alert
|
|
1419
|
+
window.alert(JSON.stringify(changes, null, " "));
|
|
1420
|
+
console.log(changes);
|
|
1421
|
+
};
|
|
1422
|
+
changesIndicator.querySelector(".changes_text").innerHTML = changeCount;
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
changesIndicator.querySelector(".tooltip_action").onclick = () => {
|
|
1426
|
+
parentWindowReloader.reload();
|
|
1427
|
+
};
|
|
1428
|
+
b(() => {
|
|
1429
|
+
const changesTooltipOpened = changesTooltipOpenedSignal.value;
|
|
1430
|
+
if (changesTooltipOpened) {
|
|
1431
|
+
changesIndicator.setAttribute("data-tooltip-visible", "");
|
|
1432
|
+
} else {
|
|
1433
|
+
changesIndicator.removeAttribute("data-tooltip-visible");
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
const button = changesIndicator.querySelector("button");
|
|
1437
|
+
button.onclick = () => {
|
|
1438
|
+
const changesTooltipOpened = changesTooltipOpenedSignal.value;
|
|
1439
|
+
if (changesTooltipOpened) {
|
|
1440
|
+
closeChangesToolip();
|
|
1441
|
+
} else {
|
|
1442
|
+
openChangesToolip();
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
};
|
|
1446
|
+
const computeTooltipText = ({
|
|
1447
|
+
changes
|
|
1448
|
+
}) => {
|
|
1449
|
+
const changesCount = changes.length;
|
|
1450
|
+
if (changesCount === 1) {
|
|
1451
|
+
return `There is <a href="javascript:void(0)">1</a> change to apply`;
|
|
1452
|
+
}
|
|
1453
|
+
return `There is <a href="javascript:void(0)">${changesCount}<a> changes to apply`;
|
|
1454
|
+
};
|
|
1455
|
+
|
|
1456
|
+
const parentServerEvents = window.parent.__server_events__;
|
|
1457
|
+
const serverEvents = window.__server_events__;
|
|
1458
|
+
const serverIndicator = document.querySelector("#server_indicator");
|
|
1459
|
+
const renderServerIndicator = () => {
|
|
1460
|
+
removeForceHideElement(document.querySelector("#server_indicator"));
|
|
1461
|
+
b(() => {
|
|
1462
|
+
const serverConnection = serverConnectionSignal.value;
|
|
1463
|
+
updateServerIndicator(serverConnection);
|
|
1464
|
+
});
|
|
1465
|
+
b(() => {
|
|
1466
|
+
const serverTooltipOpened = serverTooltipOpenedSignal.value;
|
|
1467
|
+
if (serverTooltipOpened) {
|
|
1468
|
+
serverIndicator.setAttribute("data-tooltip-visible", "");
|
|
1469
|
+
} else {
|
|
1470
|
+
serverIndicator.removeAttribute("data-tooltip-visible");
|
|
1471
|
+
}
|
|
1472
|
+
});
|
|
1473
|
+
};
|
|
1474
|
+
const updateServerIndicator = connectionState => {
|
|
1475
|
+
enableVariant(serverIndicator, {
|
|
1476
|
+
connectionState
|
|
1477
|
+
});
|
|
1478
|
+
const variantNode = document.querySelector("#server_indicator > [data-when-active]");
|
|
1479
|
+
variantNode.querySelector("button").onclick = () => {
|
|
1480
|
+
const serverTooltipOpened = serverTooltipOpenedSignal.value;
|
|
1481
|
+
if (serverTooltipOpened) {
|
|
1482
|
+
closeServerTooltip();
|
|
1483
|
+
} else {
|
|
1484
|
+
openServerTooltip();
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
if (connectionState === "connecting") {
|
|
1488
|
+
variantNode.querySelector("a").onclick = () => {
|
|
1489
|
+
if (parentServerEvents) {
|
|
1490
|
+
parentServerEvents.disconnect();
|
|
1491
|
+
}
|
|
1492
|
+
serverEvents.disconnect();
|
|
1493
|
+
};
|
|
1494
|
+
} else if (connectionState === "closed") {
|
|
1495
|
+
variantNode.querySelector("a").onclick = () => {
|
|
1496
|
+
if (parentServerEvents) {
|
|
1497
|
+
parentServerEvents.connect();
|
|
1498
|
+
}
|
|
1499
|
+
serverEvents.connect();
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
|
|
1504
|
+
const renderToolbarAutoreloadSetting = () => {
|
|
1505
|
+
const parentWindowReloader = window.parent.__reloader__;
|
|
1506
|
+
if (!parentWindowReloader) {
|
|
1507
|
+
disableAutoreloadSetting();
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
const autoreloadCheckbox = document.querySelector("#toggle_autoreload");
|
|
1511
|
+
b(() => {
|
|
1512
|
+
const autoreloadEnabled = autoreloadEnabledSignal.value;
|
|
1513
|
+
if (autoreloadEnabled) {
|
|
1514
|
+
autoreloadCheckbox.checked = true;
|
|
1515
|
+
} else {
|
|
1516
|
+
autoreloadCheckbox.checked = false;
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
autoreloadCheckbox.onchange = () => {
|
|
1520
|
+
if (autoreloadCheckbox.checked) {
|
|
1521
|
+
enableAutoreload();
|
|
1522
|
+
} else {
|
|
1523
|
+
disableAutoreload();
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1526
|
+
};
|
|
1527
|
+
const disableAutoreloadSetting = () => {
|
|
1528
|
+
document.querySelector(".settings_autoreload").setAttribute("data-disabled", "true");
|
|
1529
|
+
document.querySelector(".settings_autoreload").setAttribute("title", `Autoreload not enabled on server`);
|
|
1530
|
+
document.querySelector("#toggle_autoreload").disabled = true;
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
// const changeLink = variantNode.querySelector(".eventsource-changes-link")
|
|
1534
|
+
// changeLink.innerHTML = reloadMessageCount
|
|
1535
|
+
// changeLink.onclick = () => {
|
|
1536
|
+
// console.log(reloadMessages)
|
|
1537
|
+
// // eslint-disable-next-line no-alert
|
|
1538
|
+
// window.parent.alert(JSON.stringify(reloadMessages, null, " "))
|
|
1539
|
+
// }
|
|
1540
|
+
|
|
1541
|
+
// const someFailed = reloadMessages.some((m) => m.status === "failed")
|
|
1542
|
+
// const somePending = reloadMessages.some((m) => m.status === "pending")
|
|
1543
|
+
// const applyLink = variantNode.querySelector(".eventsource-reload-link")
|
|
1544
|
+
// applyLink.innerHTML = someFailed
|
|
1545
|
+
// ? "failed"
|
|
1546
|
+
// : somePending
|
|
1547
|
+
// ? "applying..."
|
|
1548
|
+
// : "apply changes"
|
|
1549
|
+
// applyLink.onclick = someFailed
|
|
1550
|
+
// ? () => {
|
|
1551
|
+
// parentEventSourceClient.applyReloadMessageEffects()
|
|
1552
|
+
// }
|
|
1553
|
+
// : somePending
|
|
1554
|
+
// ? () => {}
|
|
1555
|
+
// : () => {
|
|
1556
|
+
// parentEventSourceClient.applyReloadMessageEffects()
|
|
1557
|
+
// }
|
|
1558
|
+
|
|
1559
|
+
// parentEventSourceClient.reloadMessagesSignal.onchange = () => {
|
|
1560
|
+
// updateEventSourceIndicator()
|
|
1561
|
+
// }
|
|
1562
|
+
// const autoreloadCheckbox = document.querySelector("#toggle-autoreload")
|
|
1563
|
+
// autoreloadCheckbox.checked = parentEventSourceClient.isAutoreloadEnabled()
|
|
1564
|
+
// autoreloadCheckbox.onchange = () => {
|
|
1565
|
+
// parentEventSourceClient.setAutoreloadPreference(autoreloadCheckbox.checked)
|
|
1566
|
+
// updateEventSourceIndicator()
|
|
1567
|
+
// }
|
|
1568
|
+
|
|
1569
|
+
const enableAnimations = () => {
|
|
1570
|
+
animationsEnabledSignal.value = true;
|
|
1571
|
+
};
|
|
1572
|
+
const disableAnimations = () => {
|
|
1573
|
+
animationsEnabledSignal.value = false;
|
|
1574
|
+
};
|
|
1575
|
+
|
|
1576
|
+
const renderToolbarAnimationSetting = () => {
|
|
1577
|
+
const animCheckbox = document.querySelector("#toggle_anims");
|
|
1578
|
+
b(() => {
|
|
1579
|
+
const animationsEnabled = animationsEnabledSignal.value;
|
|
1580
|
+
animCheckbox.checked = animationsEnabled;
|
|
1581
|
+
});
|
|
1582
|
+
animCheckbox.onchange = () => {
|
|
1583
|
+
if (animCheckbox.checked) {
|
|
1584
|
+
enableAnimations();
|
|
1585
|
+
} else {
|
|
1586
|
+
disableAnimations();
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
// enable toolbar transition only after first render
|
|
1590
|
+
setTimeout(() => {
|
|
1591
|
+
document.querySelector("#toolbar").setAttribute("data-animate", "");
|
|
1592
|
+
});
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
const notifCheckbox = document.querySelector("#toggle_notifs");
|
|
1596
|
+
const renderToolbarNotificationSetting = () => {
|
|
1597
|
+
b(() => {
|
|
1598
|
+
const notificationsEnabled = notificationsEnabledSignal.value;
|
|
1599
|
+
notifCheckbox.checked = notificationsEnabled;
|
|
1600
|
+
});
|
|
1601
|
+
b(() => {
|
|
1602
|
+
const notificationPermission = notificationPermissionSignal.value;
|
|
1603
|
+
if (!notificationAPIDetected) {
|
|
1604
|
+
applyNotificationNotAvailableEffects();
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
if (notificationPermission === "default") {
|
|
1608
|
+
applyNotificationDefaultEffects();
|
|
1609
|
+
return;
|
|
1610
|
+
}
|
|
1611
|
+
if (notificationPermission === "denied") {
|
|
1612
|
+
applyNotificationDeniedEffects();
|
|
1613
|
+
return;
|
|
1614
|
+
}
|
|
1615
|
+
if (notificationPermission === "granted") {
|
|
1616
|
+
applyNotificationGrantedEffects();
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
};
|
|
1621
|
+
const applyNotificationNotAvailableEffects = () => {
|
|
1622
|
+
const notifSetting = document.querySelector(".settings_notification");
|
|
1623
|
+
notifSetting.setAttribute("data-disabled", "true");
|
|
1624
|
+
notifSetting.setAttribute("title", `Notification not available in the browser`);
|
|
1625
|
+
notifCheckbox.disabled = true;
|
|
1626
|
+
};
|
|
1627
|
+
const applyNotificationDefaultEffects = () => {
|
|
1628
|
+
applyNotificationNOTGrantedEffects();
|
|
1629
|
+
const notifSetting = document.querySelector(".settings_notification");
|
|
1630
|
+
notifSetting.removeAttribute("data-disabled");
|
|
1631
|
+
notifSetting.removeAttribute("title");
|
|
1632
|
+
};
|
|
1633
|
+
const applyNotificationDeniedEffects = () => {
|
|
1634
|
+
applyNotificationNOTGrantedEffects();
|
|
1635
|
+
const notifSetting = document.querySelector(".settings_notification");
|
|
1636
|
+
notifSetting.setAttribute("data-disabled", "true");
|
|
1637
|
+
notifSetting.setAttribute("title", `Notification denied`);
|
|
1638
|
+
};
|
|
1639
|
+
const applyNotificationGrantedEffects = () => {
|
|
1640
|
+
enableVariant(document.querySelector(".notification_text"), {
|
|
1641
|
+
notif_granted: "yes"
|
|
1642
|
+
});
|
|
1643
|
+
notifCheckbox.disabled = false;
|
|
1644
|
+
notifCheckbox.onchange = () => {
|
|
1645
|
+
if (notifCheckbox.checked) {
|
|
1646
|
+
enableNotifications();
|
|
1647
|
+
} else {
|
|
1648
|
+
disableNotifications();
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
};
|
|
1652
|
+
const applyNotificationNOTGrantedEffects = () => {
|
|
1653
|
+
enableVariant(document.querySelector(".notification_text"), {
|
|
1654
|
+
notif_granted: "no"
|
|
1655
|
+
});
|
|
1656
|
+
notifCheckbox.disabled = true;
|
|
1657
|
+
notifCheckbox.checked = false;
|
|
1658
|
+
document.querySelector("a.request_notification_permission").onclick = () => {
|
|
1659
|
+
requestPermission();
|
|
1660
|
+
};
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
const themeSignal = c$1(typeof stateFromLocalStorage.theme === "string" ? stateFromLocalStorage.theme : typeof paramsFromParentWindow.theme === "string" ? paramsFromParentWindow.theme : "dark");
|
|
1664
|
+
|
|
1665
|
+
const switchToLightTheme = () => {
|
|
1666
|
+
themeSignal.value = "light";
|
|
1667
|
+
};
|
|
1668
|
+
const switchToDefaultTheme = () => {
|
|
1669
|
+
themeSignal.value = "dark";
|
|
1670
|
+
};
|
|
1671
|
+
|
|
1672
|
+
const renderToolbarThemeSetting = () => {
|
|
1673
|
+
const checkbox = document.querySelector("#checkbox_dark_theme");
|
|
1674
|
+
checkbox.checked = themeSignal.value === "dark";
|
|
1675
|
+
checkbox.onchange = () => {
|
|
1676
|
+
if (checkbox.checked) {
|
|
1677
|
+
switchToDefaultTheme();
|
|
1678
|
+
} else {
|
|
1679
|
+
switchToLightTheme();
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
};
|
|
1683
|
+
|
|
1684
|
+
const renderToolbarSettings = () => {
|
|
1685
|
+
document.querySelector("#settings_open_button").onclick = toggleSettings;
|
|
1686
|
+
document.querySelector("#settings_close_button").onclick = toggleSettings;
|
|
1687
|
+
disableWarningStyle();
|
|
1688
|
+
renderToolbarAutoreloadSetting();
|
|
1689
|
+
renderToolbarAnimationSetting();
|
|
1690
|
+
renderToolbarNotificationSetting();
|
|
1691
|
+
renderToolbarThemeSetting();
|
|
1692
|
+
b(() => {
|
|
1693
|
+
const settingsOpened = settingsOpenedSignal.value;
|
|
1694
|
+
if (settingsOpened) {
|
|
1695
|
+
activateToolbarSection(document.querySelector("#settings"));
|
|
1696
|
+
} else {
|
|
1697
|
+
deactivateToolbarSection(document.querySelector("#settings"));
|
|
1698
|
+
}
|
|
1699
|
+
});
|
|
1700
|
+
};
|
|
1701
|
+
const toggleSettings = () => {
|
|
1702
|
+
const settingsOpened = settingsOpenedSignal.value;
|
|
1703
|
+
if (settingsOpened) {
|
|
1704
|
+
closeSettings();
|
|
1705
|
+
} else {
|
|
1706
|
+
openSettings();
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
const disableWarningStyle = () => {
|
|
1710
|
+
enableVariant(document.querySelector("#settings_open_button"), {
|
|
1711
|
+
has_warning: "no"
|
|
1712
|
+
});
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
const openToolbar = () => {
|
|
1716
|
+
openedSignal.value = true;
|
|
1717
|
+
};
|
|
1718
|
+
const closeToolbar = () => {
|
|
1719
|
+
openedSignal.value = false;
|
|
1720
|
+
};
|
|
1721
|
+
|
|
1722
|
+
const renderToolbarCloseButton = () => {
|
|
1723
|
+
// if user click enter or space quickly while closing toolbar
|
|
1724
|
+
// it will cancel the closing
|
|
1725
|
+
// that's why I used toggleToolbar and not hideToolbar
|
|
1726
|
+
document.querySelector("#toolbar_close_button").onclick = () => {
|
|
1727
|
+
if (openedSignal.value) {
|
|
1728
|
+
closeToolbar();
|
|
1729
|
+
} else {
|
|
1730
|
+
openToolbar();
|
|
1731
|
+
}
|
|
1732
|
+
};
|
|
1733
|
+
};
|
|
1734
|
+
|
|
1735
|
+
const initToolbarUI = () => {
|
|
1736
|
+
initToolbarOpening();
|
|
1737
|
+
initToolbarMenuOverflow();
|
|
1738
|
+
renderToolbarOverlay();
|
|
1739
|
+
renderDocumentIndexLink();
|
|
1740
|
+
renderDocumentExecutionIndicator();
|
|
1741
|
+
renderChangesIndicator();
|
|
1742
|
+
renderServerIndicator();
|
|
1743
|
+
renderToolbarSettings();
|
|
1744
|
+
renderToolbarCloseButton();
|
|
1745
|
+
};
|
|
1746
|
+
|
|
1747
|
+
addExternalCommandCallback("initToolbar", () => {
|
|
1748
|
+
// for the first render, force disable animations
|
|
1749
|
+
const animationsEnabled = animationsEnabledSignal.value;
|
|
1750
|
+
if (animationsEnabled) {
|
|
1751
|
+
animationsEnabledSignal.value = false;
|
|
1752
|
+
}
|
|
1753
|
+
initToolbarUI();
|
|
1754
|
+
if (animationsEnabled) {
|
|
1755
|
+
animationsEnabledSignal.value = true;
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
sendEventToParent("toolbar_ready");
|
|
1759
|
+
|
|
1760
|
+
b(() => {
|
|
1761
|
+
const serverConnection = serverConnectionSignal.value;
|
|
1762
|
+
if (serverConnection === "connecting" || serverConnection === "closed") {
|
|
1763
|
+
openServerTooltip();
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
|
|
1767
|
+
b(() => {
|
|
1768
|
+
const theme = themeSignal.value;
|
|
1769
|
+
document.querySelector("html").setAttribute("data-theme", theme);
|
|
1770
|
+
});
|
|
1771
|
+
|
|
1772
|
+
addExternalCommandCallback("openToolbar", openToolbar);
|
|
1773
|
+
addExternalCommandCallback("closeToolbar", closeToolbar);
|
|
1774
|
+
|
|
1775
|
+
const toolbarStateSignal = a$1(() => {
|
|
1776
|
+
const opened = openedSignal.value;
|
|
1777
|
+
const theme = themeSignal.value;
|
|
1778
|
+
const animationsEnabled = animationsEnabledSignal.value;
|
|
1779
|
+
const notificationsEnabled = notificationsEnabledSignal.value;
|
|
1780
|
+
return {
|
|
1781
|
+
opened,
|
|
1782
|
+
theme,
|
|
1783
|
+
animationsEnabled,
|
|
1784
|
+
notificationsEnabled
|
|
1785
|
+
};
|
|
1786
|
+
});
|
|
1787
|
+
|
|
1788
|
+
b(() => {
|
|
1789
|
+
const toolbarState = toolbarStateSignal.value;
|
|
1790
|
+
localStorage.setItem("jsenv_toolbar", JSON.stringify(toolbarState));
|
|
1791
|
+
sendEventToParent("toolbar_state_change", toolbarState);
|
|
1792
|
+
});
|