@jsenv/core 25.4.0 → 25.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/build_manifest.js +4 -4
  2. package/dist/compile_proxy/asset-manifest.json +2 -2
  3. package/dist/compile_proxy/{compile_proxy.html__inline__20_2334a374.js.map → compile_proxy.html__inline__20_f4285042.js.map} +3 -2
  4. package/dist/compile_proxy/{compile_proxy_9f737eaf.html → compile_proxy_ab528227.html} +6 -4
  5. package/dist/redirector/asset-manifest.json +2 -2
  6. package/dist/redirector/{redirector.html__inline__12_009c47c7.js.map → redirector.html__inline__12_404b8295.js.map} +6 -5
  7. package/dist/redirector/{redirector_96f74871.html → redirector_6df2620a.html} +57 -52
  8. package/dist/toolbar/asset-manifest.json +2 -2
  9. package/dist/toolbar/{toolbar.main_86335f90.js.map → toolbar.main_279b3a68.js.map} +175 -180
  10. package/dist/toolbar/{toolbar_d3a918a4.html → toolbar_0a91ca3b.html} +1232 -1285
  11. package/dist/toolbar_injector/asset-manifest.json +2 -2
  12. package/dist/toolbar_injector/toolbar_injector_34f6ad8e.js +976 -0
  13. package/dist/toolbar_injector/toolbar_injector_34f6ad8e.js.map +294 -0
  14. package/package.json +3 -4
  15. package/src/dev_server.js +36 -6
  16. package/src/internal/compiling/startCompileServer.js +1 -0
  17. package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +9 -2
  18. package/src/internal/dev_server/toolbar/toolbar.html +6 -0
  19. package/src/internal/dev_server/toolbar/toolbar.injector.js +11 -3
  20. package/src/internal/dev_server/toolbar/toolbar.main.js +10 -14
  21. package/src/internal/features/browser_feature_detection/browser_feature_detection.js +7 -3
  22. package/src/internal/redirector/redirector.html +6 -4
  23. package/dist/toolbar_injector/toolbar_injector_978bbd14.js +0 -267
  24. package/dist/toolbar_injector/toolbar_injector_978bbd14.js.map +0 -119
@@ -1921,6 +1921,7 @@ html[data-toolbar-visible] #toolbar-trigger {
1921
1921
  <a data-when="compilation_link:source" class="link_to_source_files" href="javascript:void(0);">Switch to source files</a>
1922
1922
  <a data-when="compilation_link:mismatch" class="link_to_appropriate_files" href="javascript:void(0);">Switch to appropriate files</a>
1923
1923
  <a data-when="compilation_link:compiled" class="link_to_compiled_files" href="javascript:void(0);">Switch to compiled files</a>
1924
+ <a data-when="compilation_link:force" class="link_to_compilation_forced_files" href="javascript:void(0);">Force compilation</a>
1924
1925
  </div>
1925
1926
  </div>
1926
1927
  </div>
@@ -2191,64 +2192,6 @@ html[data-toolbar-visible] #toolbar-trigger {
2191
2192
  return relativeUrl;
2192
2193
  };
2193
2194
 
2194
- var _defineProperty = function (obj, key, value) {
2195
- // Shortcircuit the slow defineProperty path when possible.
2196
- // We are trying to avoid issues where setters defined on the
2197
- // prototype cause side effects under the fast path of simple
2198
- // assignment. By checking for existence of the property with
2199
- // the in operator, we can optimize most of this overhead away.
2200
- if (key in obj) {
2201
- Object.defineProperty(obj, key, {
2202
- value: value,
2203
- enumerable: true,
2204
- configurable: true,
2205
- writable: true
2206
- });
2207
- } else {
2208
- obj[key] = value;
2209
- }
2210
-
2211
- return obj;
2212
- };
2213
-
2214
- function ownKeys(object, enumerableOnly) {
2215
- var keys = Object.keys(object);
2216
-
2217
- if (Object.getOwnPropertySymbols) {
2218
- var symbols = Object.getOwnPropertySymbols(object);
2219
-
2220
- if (enumerableOnly) {
2221
- symbols = symbols.filter(function (sym) {
2222
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2223
- });
2224
- }
2225
-
2226
- keys.push.apply(keys, symbols);
2227
- }
2228
-
2229
- return keys;
2230
- }
2231
-
2232
- function _objectSpread2(target) {
2233
- for (var i = 1; i < arguments.length; i++) {
2234
- var source = arguments[i] != null ? arguments[i] : {};
2235
-
2236
- if (i % 2) {
2237
- ownKeys(Object(source), true).forEach(function (key) {
2238
- _defineProperty(target, key, source[key]);
2239
- });
2240
- } else if (Object.getOwnPropertyDescriptors) {
2241
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2242
- } else {
2243
- ownKeys(Object(source)).forEach(function (key) {
2244
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2245
- });
2246
- }
2247
- }
2248
-
2249
- return target;
2250
- }
2251
-
2252
2195
  var objectWithoutPropertiesLoose = function (source, excluded) {
2253
2196
  if (source === null) return {};
2254
2197
  var target = {};
@@ -2284,457 +2227,419 @@ html[data-toolbar-visible] #toolbar-trigger {
2284
2227
 
2285
2228
  return target;
2286
2229
  };
2287
- /* eslint-env browser */
2288
-
2289
2230
 
2290
- function _await$a(value, then, direct) {
2291
- if (direct) {
2292
- return then ? then(value) : value;
2231
+ var updateIframeOverflowOnParentWindow = function updateIframeOverflowOnParentWindow() {
2232
+ if (!window.parent) {
2233
+ // can happen while parent iframe reloads
2234
+ return;
2293
2235
  }
2294
2236
 
2295
- if (!value || !value.then) {
2296
- value = Promise.resolve(value);
2297
- }
2237
+ var aTooltipIsOpened = document.querySelector("[data-tooltip-visible]") || document.querySelector("[data-tooltip-auto-visible]");
2238
+ var settingsAreOpened = document.querySelector("#settings[data-active]");
2298
2239
 
2299
- return then ? value.then(then) : value;
2300
- }
2240
+ if (aTooltipIsOpened || settingsAreOpened) {
2241
+ enableIframeOverflowOnParentWindow();
2242
+ } else {
2243
+ disableIframeOverflowOnParentWindow();
2244
+ }
2245
+ };
2301
2246
 
2302
- function _async$a(f) {
2303
- return function () {
2304
- for (var args = [], i = 0; i < arguments.length; i++) {
2305
- args[i] = arguments[i];
2306
- }
2247
+ var iframeOverflowEnabled = false;
2307
2248
 
2308
- try {
2309
- return Promise.resolve(f.apply(this, args));
2310
- } catch (e) {
2311
- return Promise.reject(e);
2312
- }
2313
- };
2314
- }
2249
+ var enableIframeOverflowOnParentWindow = function enableIframeOverflowOnParentWindow() {
2250
+ if (iframeOverflowEnabled) return;
2251
+ iframeOverflowEnabled = true;
2252
+ var iframe = getToolbarIframe();
2253
+ var transitionDuration = iframe.style.transitionDuration;
2254
+ setStyles(iframe, {
2255
+ "height": "100%",
2256
+ "transition-duration": "0ms"
2257
+ });
2315
2258
 
2316
- function _call$2(body, then, direct) {
2317
- if (direct) {
2318
- return then ? then(body()) : body();
2259
+ if (transitionDuration) {
2260
+ setTimeout(function () {
2261
+ setStyles(iframe, {
2262
+ "transition-duration": transitionDuration
2263
+ });
2264
+ });
2319
2265
  }
2266
+ };
2320
2267
 
2321
- try {
2322
- var result = Promise.resolve(body());
2323
- return then ? result.then(then) : result;
2324
- } catch (e) {
2325
- return Promise.reject(e);
2268
+ var disableIframeOverflowOnParentWindow = function disableIframeOverflowOnParentWindow() {
2269
+ if (!iframeOverflowEnabled) return;
2270
+ iframeOverflowEnabled = false;
2271
+ var iframe = getToolbarIframe();
2272
+ var transitionDuration = iframe.style.transitionDuration;
2273
+ setStyles(iframe, {
2274
+ "height": "40px",
2275
+ "transition-duration": "0ms"
2276
+ });
2277
+
2278
+ if (transitionDuration) {
2279
+ setTimeout(function () {
2280
+ setStyles(iframe, {
2281
+ "transition-duration": transitionDuration
2282
+ });
2283
+ });
2326
2284
  }
2327
- }
2285
+ };
2328
2286
 
2329
- var fetchUsingXHR = _async$a(function (url) {
2330
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
2331
- signal = _ref.signal,
2332
- _ref$method = _ref.method,
2333
- method = _ref$method === void 0 ? "GET" : _ref$method,
2334
- _ref$credentials = _ref.credentials,
2335
- credentials = _ref$credentials === void 0 ? "same-origin" : _ref$credentials,
2336
- _ref$headers = _ref.headers,
2337
- headers = _ref$headers === void 0 ? {} : _ref$headers,
2338
- _ref$body = _ref.body,
2339
- body = _ref$body === void 0 ? null : _ref$body;
2287
+ var getToolbarIframe = function getToolbarIframe() {
2288
+ var iframes = Array.from(window.parent.document.querySelectorAll("iframe"));
2289
+ return iframes.find(function (iframe) {
2290
+ return iframe.contentWindow === window;
2291
+ });
2292
+ };
2340
2293
 
2341
- var headersPromise = createPromiseAndHooks();
2342
- var bodyPromise = createPromiseAndHooks();
2343
- var xhr = new XMLHttpRequest();
2294
+ var forceHideElement = function forceHideElement(element) {
2295
+ element.setAttribute("data-force-hide", "");
2296
+ };
2344
2297
 
2345
- var failure = function failure(error) {
2346
- // if it was already resolved, we must reject the body promise
2347
- if (headersPromise.settled) {
2348
- bodyPromise.reject(error);
2298
+ var removeForceHideElement = function removeForceHideElement(element) {
2299
+ element.removeAttribute("data-force-hide");
2300
+ };
2301
+
2302
+ var setStyles = function setStyles(element, styles) {
2303
+ var elementStyle = element.style;
2304
+ var restoreStyles = Object.keys(styles).map(function (styleName) {
2305
+ var restore;
2306
+
2307
+ if (styleName in elementStyle) {
2308
+ var currentStyle = elementStyle[styleName];
2309
+
2310
+ restore = function restore() {
2311
+ elementStyle[styleName] = currentStyle;
2312
+ };
2349
2313
  } else {
2350
- headersPromise.reject(error);
2314
+ restore = function restore() {
2315
+ delete elementStyle[styleName];
2316
+ };
2351
2317
  }
2352
- };
2353
-
2354
- var cleanup = function cleanup() {
2355
- xhr.ontimeout = null;
2356
- xhr.onerror = null;
2357
- xhr.onload = null;
2358
- xhr.onreadystatechange = null;
2359
- };
2360
2318
 
2361
- xhr.ontimeout = function () {
2362
- cleanup();
2363
- failure(new Error("xhr request timeout on ".concat(url, ".")));
2319
+ elementStyle[styleName] = styles[styleName];
2320
+ return restore;
2321
+ });
2322
+ return function () {
2323
+ restoreStyles.forEach(function (restore) {
2324
+ return restore();
2325
+ });
2364
2326
  };
2327
+ };
2365
2328
 
2366
- xhr.onerror = function (error) {
2367
- cleanup(); // unfortunately with have no clue why it fails
2368
- // might be cors for instance
2329
+ var toolbarSectionIsActive = function toolbarSectionIsActive(element) {
2330
+ return element.hasAttribute("data-active");
2331
+ };
2369
2332
 
2370
- failure(createRequestError(error, {
2371
- url: url
2372
- }));
2373
- };
2333
+ var activateToolbarSection = function activateToolbarSection(element) {
2334
+ element.setAttribute("data-active", "");
2335
+ };
2374
2336
 
2375
- xhr.onload = function () {
2376
- cleanup();
2377
- bodyPromise.resolve();
2378
- };
2337
+ var deactivateToolbarSection = function deactivateToolbarSection(element) {
2338
+ element.removeAttribute("data-active");
2339
+ };
2379
2340
 
2380
- signal.addEventListener("abort", function () {
2381
- xhr.abort();
2382
- var abortError = new Error("aborted");
2383
- abortError.name = "AbortError";
2384
- failure(abortError);
2385
- });
2341
+ var startJavaScriptAnimation = function startJavaScriptAnimation(_ref6) {
2342
+ var _ref6$duration = _ref6.duration,
2343
+ duration = _ref6$duration === void 0 ? 300 : _ref6$duration,
2344
+ _ref6$timingFunction = _ref6.timingFunction,
2345
+ timingFunction = _ref6$timingFunction === void 0 ? function (t) {
2346
+ return t;
2347
+ } : _ref6$timingFunction,
2348
+ _ref6$onProgress = _ref6.onProgress,
2349
+ onProgress = _ref6$onProgress === void 0 ? function () {} : _ref6$onProgress,
2350
+ _ref6$onCancel = _ref6.onCancel,
2351
+ onCancel = _ref6$onCancel === void 0 ? function () {} : _ref6$onCancel,
2352
+ _ref6$onComplete = _ref6.onComplete,
2353
+ onComplete = _ref6$onComplete === void 0 ? function () {} : _ref6$onComplete;
2386
2354
 
2387
- xhr.onreadystatechange = function () {
2388
- // https://developer.mozilla.org/fr/docs/Web/API/XMLHttpRequest/readyState
2389
- var readyState = xhr.readyState;
2355
+ if (isNaN(duration)) {
2356
+ // console.warn(`duration must be a number, received ${duration}`)
2357
+ return function () {};
2358
+ }
2390
2359
 
2391
- if (readyState === 2) {
2392
- headersPromise.resolve();
2393
- } else if (readyState === 4) {
2394
- cleanup();
2395
- bodyPromise.resolve();
2396
- }
2397
- };
2360
+ duration = parseInt(duration, 10);
2361
+ var startMs = performance.now();
2362
+ var currentRequestAnimationFrameId;
2363
+ var done = false;
2364
+ var rawProgress = 0;
2365
+ var progress = 0;
2398
2366
 
2399
- xhr.open(method, url, true);
2400
- Object.keys(headers).forEach(function (key) {
2401
- xhr.setRequestHeader(key, headers[key]);
2402
- });
2403
- xhr.withCredentials = computeWithCredentials({
2404
- credentials: credentials,
2405
- url: url
2406
- });
2407
-
2408
- if ("responseType" in xhr && hasBlob) {
2409
- xhr.responseType = "blob";
2410
- }
2367
+ var handler = function handler() {
2368
+ currentRequestAnimationFrameId = null;
2369
+ var nowMs = performance.now();
2370
+ rawProgress = Math.min((nowMs - startMs) / duration, 1);
2371
+ progress = timingFunction(rawProgress);
2372
+ done = rawProgress === 1;
2373
+ onProgress({
2374
+ done: done,
2375
+ rawProgress: rawProgress,
2376
+ progress: progress
2377
+ });
2411
2378
 
2412
- xhr.send(body);
2413
- return _await$a(headersPromise, function () {
2414
- // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseURL
2415
- var responseUrl = "responseURL" in xhr ? xhr.responseURL : headers["x-request-url"];
2416
- var responseStatus = xhr.status;
2417
- var responseStatusText = xhr.statusText;
2418
- var responseHeaders = getHeadersFromXHR(xhr);
2379
+ if (done) {
2380
+ onComplete();
2381
+ } else {
2382
+ currentRequestAnimationFrameId = window.requestAnimationFrame(handler);
2383
+ }
2384
+ };
2419
2385
 
2420
- var readBody = function readBody() {
2421
- return _await$a(bodyPromise, function () {
2422
- var status = xhr.status; // in Chrome on file:/// URLs, status is 0
2386
+ handler();
2423
2387
 
2424
- if (status === 0) {
2425
- responseStatus = 200;
2426
- }
2388
+ var stop = function stop() {
2389
+ if (currentRequestAnimationFrameId) {
2390
+ window.cancelAnimationFrame(currentRequestAnimationFrameId);
2391
+ currentRequestAnimationFrameId = null;
2392
+ }
2427
2393
 
2428
- var body = "response" in xhr ? xhr.response : xhr.responseText;
2429
- return {
2430
- responseBody: body,
2431
- responseBodyType: detectBodyType(body)
2432
- };
2394
+ if (!done) {
2395
+ done = true;
2396
+ onCancel({
2397
+ rawProgress: rawProgress,
2398
+ progress: progress
2433
2399
  });
2434
- };
2400
+ }
2401
+ };
2435
2402
 
2436
- var text = function text() {
2437
- return _call$2(readBody, function (_ref2) {
2438
- var responseBody = _ref2.responseBody,
2439
- responseBodyType = _ref2.responseBodyType;
2403
+ return stop;
2404
+ }; // handle data-last-interaction attr on html (focusring)
2440
2405
 
2441
- if (responseBodyType === "blob") {
2442
- return blobToText(responseBody);
2443
- }
2444
2406
 
2445
- if (responseBodyType === "formData") {
2446
- throw new Error("could not read FormData body as text");
2447
- }
2407
+ window.addEventListener("mousedown", function (mousedownEvent) {
2408
+ if (mousedownEvent.defaultPrevented) {
2409
+ return;
2410
+ }
2448
2411
 
2449
- return responseBodyType === "dataView" ? arrayBufferToText(responseBody.buffer) : responseBodyType === "arrayBuffer" ? arrayBufferToText(responseBody) : String(responseBody);
2450
- });
2451
- };
2412
+ document.documentElement.setAttribute("data-last-interaction", "mouse");
2413
+ });
2414
+ window.addEventListener("touchstart", function (touchstartEvent) {
2415
+ if (touchstartEvent.defaultPrevented) {
2416
+ return;
2417
+ }
2452
2418
 
2453
- var json = function json() {
2454
- return _call$2(text, JSON.parse);
2455
- };
2419
+ document.documentElement.setAttribute("data-last-interaction", "mouse");
2420
+ });
2421
+ window.addEventListener("keydown", function (keydownEvent) {
2422
+ if (keydownEvent.defaultPrevented) {
2423
+ return;
2424
+ }
2456
2425
 
2457
- var blob = _async$a(function () {
2458
- if (!hasBlob) {
2459
- throw new Error("blob not supported");
2460
- }
2426
+ document.documentElement.setAttribute("data-last-interaction", "keyboard");
2427
+ });
2461
2428
 
2462
- return _call$2(readBody, function (_ref3) {
2463
- var responseBody = _ref3.responseBody,
2464
- responseBodyType = _ref3.responseBodyType;
2429
+ var createPreference = function createPreference(name) {
2430
+ return {
2431
+ has: function has() {
2432
+ return localStorage.hasOwnProperty(name);
2433
+ },
2434
+ get: function get() {
2435
+ return localStorage.hasOwnProperty(name) ? JSON.parse(localStorage.getItem(name)) : undefined;
2436
+ },
2437
+ set: function set(value) {
2438
+ return localStorage.setItem(name, JSON.stringify(value));
2439
+ }
2440
+ };
2441
+ };
2465
2442
 
2466
- if (responseBodyType === "blob") {
2467
- return responseBody;
2468
- }
2443
+ var toggleTooltip = function toggleTooltip(element) {
2444
+ if (element.hasAttribute("data-tooltip-visible")) {
2445
+ hideTooltip(element);
2446
+ } else {
2447
+ showTooltip(element);
2448
+ }
2449
+ };
2469
2450
 
2470
- if (responseBodyType === "dataView") {
2471
- return new Blob([cloneBuffer(responseBody.buffer)]);
2472
- }
2451
+ var hideTooltip = function hideTooltip(element) {
2452
+ element.removeAttribute("data-tooltip-visible");
2453
+ element.removeAttribute("data-tooltip-auto-visible");
2454
+ updateIframeOverflowOnParentWindow();
2455
+ };
2473
2456
 
2474
- if (responseBodyType === "arrayBuffer") {
2475
- return new Blob([cloneBuffer(responseBody)]);
2476
- }
2457
+ var showTooltip = function showTooltip(element) {
2458
+ element.setAttribute("data-tooltip-visible", "");
2459
+ updateIframeOverflowOnParentWindow();
2460
+ };
2477
2461
 
2478
- if (responseBodyType === "formData") {
2479
- throw new Error("could not read FormData body as blob");
2480
- }
2462
+ var autoShowTooltip = function autoShowTooltip(element) {
2463
+ element.setAttribute("data-tooltip-auto-visible", "");
2464
+ updateIframeOverflowOnParentWindow();
2465
+ };
2481
2466
 
2482
- return new Blob([String(responseBody)]);
2483
- });
2484
- });
2467
+ var removeAutoShowTooltip = function removeAutoShowTooltip(element) {
2468
+ element.removeAttribute("data-tooltip-auto-visible");
2469
+ updateIframeOverflowOnParentWindow();
2470
+ };
2485
2471
 
2486
- var arrayBuffer = function arrayBuffer() {
2487
- return _call$2(readBody, function (_ref4) {
2488
- var responseBody = _ref4.responseBody,
2489
- responseBodyType = _ref4.responseBodyType;
2490
- return responseBodyType === "arrayBuffer" ? cloneBuffer(responseBody) : _call$2(blob, blobToArrayBuffer);
2491
- });
2492
- };
2472
+ var hideAllTooltip = function hideAllTooltip() {
2473
+ var elementsWithTooltip = Array.from(document.querySelectorAll("[data-tooltip-visible]"));
2474
+ elementsWithTooltip.forEach(function (elementWithTooltip) {
2475
+ hideTooltip(elementWithTooltip);
2476
+ });
2477
+ };
2493
2478
 
2494
- var formData = _async$a(function () {
2495
- if (!hasFormData) {
2496
- throw new Error("formData not supported");
2497
- }
2479
+ var enableVariant = function enableVariant(rootNode, variables) {
2480
+ var nodesNotMatching = Array.from(rootNode.querySelectorAll("[".concat(attributeIndicatingACondition, "]")));
2481
+ nodesNotMatching.forEach(function (nodeNotMatching) {
2482
+ var conditionAttributeValue = nodeNotMatching.getAttribute(attributeIndicatingACondition);
2483
+ var matches = testCondition(conditionAttributeValue, variables);
2498
2484
 
2499
- return _call$2(text, textToFormData);
2500
- });
2485
+ if (matches) {
2486
+ renameAttribute(nodeNotMatching, attributeIndicatingACondition, attributeIndicatingAMatch);
2487
+ }
2488
+ });
2489
+ var nodesMatching = Array.from(rootNode.querySelectorAll("[".concat(attributeIndicatingAMatch, "]")));
2490
+ nodesMatching.forEach(function (nodeMatching) {
2491
+ var conditionAttributeValue = nodeMatching.getAttribute(attributeIndicatingAMatch);
2492
+ var matches = testCondition(conditionAttributeValue, variables);
2501
2493
 
2502
- return {
2503
- url: responseUrl,
2504
- status: responseStatus,
2505
- statusText: responseStatusText,
2506
- headers: responseHeaders,
2507
- text: text,
2508
- json: json,
2509
- blob: blob,
2510
- arrayBuffer: arrayBuffer,
2511
- formData: formData
2512
- };
2494
+ if (!matches) {
2495
+ renameAttribute(nodeMatching, attributeIndicatingAMatch, attributeIndicatingACondition);
2496
+ }
2513
2497
  });
2514
- });
2498
+ };
2515
2499
 
2516
- var canUseBlob = function canUseBlob() {
2517
- if (typeof window.FileReader !== "function") return false;
2518
- if (typeof window.Blob !== "function") return false;
2500
+ var testCondition = function testCondition(conditionAttributeValue, variables) {
2501
+ var condition = parseCondition(conditionAttributeValue);
2502
+ return Object.keys(variables).some(function (key) {
2503
+ if (condition.key !== key) {
2504
+ return false;
2505
+ } // the condition do not specify a value, any value is ok
2519
2506
 
2520
- try {
2521
- // eslint-disable-next-line no-new
2522
- new Blob();
2523
- return true;
2524
- } catch (e) {
2525
- return false;
2526
- }
2527
- };
2528
2507
 
2529
- var hasBlob = canUseBlob();
2530
- var hasFormData = typeof window.FormData === "function";
2531
- var hasArrayBuffer = typeof window.ArrayBuffer === "function";
2532
- var hasSearchParams = typeof window.URLSearchParams === "function";
2508
+ if (condition.value === undefined) {
2509
+ return true;
2510
+ }
2533
2511
 
2534
- var createRequestError = function createRequestError(error, _ref5) {
2535
- var url = _ref5.url;
2536
- return new Error("error during xhr request on ".concat(url, ".\n--- error stack ---\n").concat(error.stack));
2512
+ if (condition.value === variables[key]) {
2513
+ return true;
2514
+ }
2515
+
2516
+ return false;
2517
+ });
2537
2518
  };
2538
2519
 
2539
- var createPromiseAndHooks = function createPromiseAndHooks() {
2540
- var resolve;
2541
- var reject;
2542
- var promise = new Promise(function (res, rej) {
2543
- resolve = function resolve(value) {
2544
- promise.settled = true;
2545
- res(value);
2546
- };
2520
+ var parseCondition = function parseCondition(conditionAttributeValue) {
2521
+ var colonIndex = conditionAttributeValue.indexOf(":");
2547
2522
 
2548
- reject = function reject(value) {
2549
- promise.settled = true;
2550
- rej(value);
2523
+ if (colonIndex === -1) {
2524
+ return {
2525
+ key: conditionAttributeValue,
2526
+ value: undefined
2551
2527
  };
2552
- });
2553
- promise.resolve = resolve;
2554
- promise.reject = reject;
2555
- return promise;
2556
- }; // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
2528
+ }
2557
2529
 
2530
+ return {
2531
+ key: conditionAttributeValue.slice(0, colonIndex),
2532
+ value: conditionAttributeValue.slice(colonIndex + 1)
2533
+ };
2534
+ };
2558
2535
 
2559
- var computeWithCredentials = function computeWithCredentials(_ref6) {
2560
- var credentials = _ref6.credentials,
2561
- url = _ref6.url;
2562
-
2563
- if (credentials === "same-origin") {
2564
- return originSameAsGlobalOrigin(url);
2565
- }
2536
+ var attributeIndicatingACondition = "data-when";
2537
+ var attributeIndicatingAMatch = "data-when-active";
2566
2538
 
2567
- return credentials === "include";
2539
+ var renameAttribute = function renameAttribute(node, name, newName) {
2540
+ node.setAttribute(newName, node.getAttribute(name));
2541
+ node.removeAttribute(name);
2568
2542
  };
2569
2543
 
2570
- var originSameAsGlobalOrigin = function originSameAsGlobalOrigin(url) {
2571
- // if we cannot read globalOrigin from window.location.origin, let's consider it's ok
2572
- if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== "object") return true;
2573
- if (_typeof(window.location) !== "object") return true;
2574
- var globalOrigin = window.location.origin;
2575
- if (globalOrigin === "null") return true;
2576
- return hrefToOrigin(url) === globalOrigin;
2544
+ var renderToolbarSettings = function renderToolbarSettings() {
2545
+ document.querySelector("#settings-button").onclick = toggleSettings;
2546
+ document.querySelector("#button-close-settings").onclick = toggleSettings;
2577
2547
  };
2578
2548
 
2579
- var detectBodyType = function detectBodyType(body) {
2580
- if (!body) {
2581
- return "";
2582
- }
2583
-
2584
- if (typeof body === "string") {
2585
- return "text";
2586
- }
2587
-
2588
- if (hasBlob && Blob.prototype.isPrototypeOf(body)) {
2589
- return "blob";
2590
- }
2591
-
2592
- if (hasFormData && FormData.prototype.isPrototypeOf(body)) {
2593
- return "formData";
2594
- }
2595
-
2596
- if (hasArrayBuffer) {
2597
- if (hasBlob && isDataView(body)) {
2598
- return "dataView";
2599
- }
2600
-
2601
- if (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body)) {
2602
- return "arrayBuffer";
2603
- }
2604
- }
2605
-
2606
- if (hasSearchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
2607
- return "searchParams";
2549
+ var toggleSettings = function toggleSettings() {
2550
+ if (settingsAreVisible()) {
2551
+ hideSettings();
2552
+ } else {
2553
+ showSettings();
2608
2554
  }
2609
-
2610
- return "";
2611
- }; // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#Example
2612
-
2613
-
2614
- var getHeadersFromXHR = function getHeadersFromXHR(xhr) {
2615
- var headerMap = {};
2616
- var headersString = xhr.getAllResponseHeaders();
2617
- if (headersString === "") return headerMap;
2618
- var lines = headersString.trim().split(/[\r\n]+/);
2619
- lines.forEach(function (line) {
2620
- var parts = line.split(": ");
2621
- var name = parts.shift();
2622
- var value = parts.join(": ");
2623
- headerMap[name.toLowerCase()] = value;
2624
- });
2625
- return headerMap;
2626
2555
  };
2627
2556
 
2628
- var hrefToOrigin = function hrefToOrigin(href) {
2629
- var scheme = hrefToScheme(href);
2630
-
2631
- if (scheme === "file") {
2632
- return "file://";
2633
- }
2634
-
2635
- if (scheme === "http" || scheme === "https") {
2636
- var secondProtocolSlashIndex = scheme.length + "://".length;
2637
- var pathnameSlashIndex = href.indexOf("/", secondProtocolSlashIndex);
2638
- if (pathnameSlashIndex === -1) return href;
2639
- return href.slice(0, pathnameSlashIndex);
2640
- }
2641
-
2642
- return href.slice(0, scheme.length + 1);
2557
+ var enableWarningStyle = function enableWarningStyle() {
2558
+ enableVariant(document.querySelector("#settings-button"), {
2559
+ has_warning: "yes"
2560
+ });
2643
2561
  };
2644
2562
 
2645
- var hrefToScheme = function hrefToScheme(href) {
2646
- var colonIndex = href.indexOf(":");
2647
- if (colonIndex === -1) return "";
2648
- return href.slice(0, colonIndex);
2563
+ var disableWarningStyle = function disableWarningStyle() {
2564
+ enableVariant(document.querySelector("#settings-button"), {
2565
+ has_warning: "no"
2566
+ });
2649
2567
  };
2650
2568
 
2651
- var isDataView = function isDataView(obj) {
2652
- return obj && DataView.prototype.isPrototypeOf(obj);
2569
+ var settingsAreVisible = function settingsAreVisible() {
2570
+ return toolbarSectionIsActive(document.querySelector("#settings"));
2653
2571
  };
2654
2572
 
2655
- var isArrayBufferView = ArrayBuffer.isView || function () {
2656
- var viewClasses = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"];
2657
- return function (value) {
2658
- return value && viewClasses.includes(Object.prototype.toString.call(value));
2659
- };
2660
- }();
2661
-
2662
- var textToFormData = function textToFormData(text) {
2663
- var form = new FormData();
2664
- text.trim().split("&").forEach(function (bytes) {
2665
- if (bytes) {
2666
- var split = bytes.split("=");
2667
- var name = split.shift().replace(/\+/g, " ");
2668
- var value = split.join("=").replace(/\+/g, " ");
2669
- form.append(decodeURIComponent(name), decodeURIComponent(value));
2670
- }
2671
- });
2672
- return form;
2573
+ var hideSettings = function hideSettings() {
2574
+ deactivateToolbarSection(document.querySelector("#settings"));
2575
+ updateIframeOverflowOnParentWindow();
2673
2576
  };
2674
2577
 
2675
- var blobToArrayBuffer = _async$a(function (blob) {
2676
- var reader = new FileReader();
2677
- var promise = fileReaderReady(reader);
2678
- reader.readAsArrayBuffer(blob);
2679
- return promise;
2680
- });
2681
-
2682
- var blobToText = function blobToText(blob) {
2683
- var reader = new FileReader();
2684
- var promise = fileReaderReady(reader);
2685
- reader.readAsText(blob);
2686
- return promise;
2578
+ var showSettings = function showSettings() {
2579
+ activateToolbarSection(document.querySelector("#settings"));
2580
+ updateIframeOverflowOnParentWindow();
2687
2581
  };
2688
2582
 
2689
- var arrayBufferToText = function arrayBufferToText(arrayBuffer) {
2690
- var view = new Uint8Array(arrayBuffer);
2691
- var chars = new Array(view.length);
2692
- var i = 0;
2693
-
2694
- while (i < view.length) {
2695
- chars[i] = String.fromCharCode(view[i]);
2696
- i++;
2583
+ var _defineProperty = function (obj, key, value) {
2584
+ // Shortcircuit the slow defineProperty path when possible.
2585
+ // We are trying to avoid issues where setters defined on the
2586
+ // prototype cause side effects under the fast path of simple
2587
+ // assignment. By checking for existence of the property with
2588
+ // the in operator, we can optimize most of this overhead away.
2589
+ if (key in obj) {
2590
+ Object.defineProperty(obj, key, {
2591
+ value: value,
2592
+ enumerable: true,
2593
+ configurable: true,
2594
+ writable: true
2595
+ });
2596
+ } else {
2597
+ obj[key] = value;
2697
2598
  }
2698
2599
 
2699
- return chars.join("");
2600
+ return obj;
2700
2601
  };
2701
2602
 
2702
- var fileReaderReady = function fileReaderReady(reader) {
2703
- return new Promise(function (resolve, reject) {
2704
- reader.onload = function () {
2705
- resolve(reader.result);
2706
- };
2603
+ function ownKeys(object, enumerableOnly) {
2604
+ var keys = Object.keys(object);
2707
2605
 
2708
- reader.onerror = function () {
2709
- reject(reader.error);
2710
- };
2711
- });
2712
- };
2606
+ if (Object.getOwnPropertySymbols) {
2607
+ var symbols = Object.getOwnPropertySymbols(object);
2713
2608
 
2714
- var cloneBuffer = function cloneBuffer(buffer) {
2715
- if (buffer.slice) {
2716
- return buffer.slice(0);
2717
- }
2609
+ if (enumerableOnly) {
2610
+ symbols = symbols.filter(function (sym) {
2611
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2612
+ });
2613
+ }
2718
2614
 
2719
- var view = new Uint8Array(buffer.byteLength);
2720
- view.set(new Uint8Array(buffer));
2721
- return view.buffer;
2722
- };
2615
+ keys.push.apply(keys, symbols);
2616
+ }
2723
2617
 
2724
- var _excluded$1 = ["mode"];
2618
+ return keys;
2619
+ }
2725
2620
 
2726
- function _await$9(value, then, direct) {
2727
- if (direct) {
2728
- return then ? then(value) : value;
2729
- }
2621
+ function _objectSpread2(target) {
2622
+ for (var i = 1; i < arguments.length; i++) {
2623
+ var source = arguments[i] != null ? arguments[i] : {};
2730
2624
 
2731
- if (!value || !value.then) {
2732
- value = Promise.resolve(value);
2625
+ if (i % 2) {
2626
+ ownKeys(Object(source), true).forEach(function (key) {
2627
+ _defineProperty(target, key, source[key]);
2628
+ });
2629
+ } else if (Object.getOwnPropertyDescriptors) {
2630
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2631
+ } else {
2632
+ ownKeys(Object(source)).forEach(function (key) {
2633
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2634
+ });
2635
+ }
2733
2636
  }
2734
2637
 
2735
- return then ? value.then(then) : value;
2638
+ return target;
2736
2639
  }
2737
2640
 
2641
+ var _excluded$1 = ["clickToFocus", "clickToClose"];
2642
+
2738
2643
  function _async$9(f) {
2739
2644
  return function () {
2740
2645
  for (var args = [], i = 0; i < arguments.length; i++) {
@@ -2749,495 +2654,492 @@ html[data-toolbar-visible] #toolbar-trigger {
2749
2654
  };
2750
2655
  }
2751
2656
 
2752
- var fetchNative = _async$9(function (url) {
2753
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2657
+ function _await$a(value, then, direct) {
2658
+ if (direct) {
2659
+ return then ? then(value) : value;
2660
+ }
2754
2661
 
2755
- var _ref$mode = _ref.mode,
2756
- mode = _ref$mode === void 0 ? "cors" : _ref$mode,
2757
- options = _objectWithoutProperties(_ref, _excluded$1);
2662
+ if (!value || !value.then) {
2663
+ value = Promise.resolve(value);
2664
+ }
2758
2665
 
2759
- return _await$9(window.fetch(url, _objectSpread2({
2760
- mode: mode
2761
- }, options)), function (response) {
2762
- return {
2763
- url: response.url,
2764
- status: response.status,
2765
- statusText: "",
2766
- headers: responseToHeaders(response),
2767
- text: function text() {
2768
- return response.text();
2769
- },
2770
- json: function json() {
2771
- return response.json();
2772
- },
2773
- blob: function blob() {
2774
- return response.blob();
2775
- },
2776
- arrayBuffer: function arrayBuffer() {
2777
- return response.arrayBuffer();
2778
- },
2779
- formData: function formData() {
2780
- return response.formData();
2781
- }
2782
- };
2783
- });
2784
- });
2666
+ return then ? value.then(then) : value;
2667
+ }
2785
2668
 
2786
- var responseToHeaders = function responseToHeaders(response) {
2787
- var headers = {};
2788
- response.headers.forEach(function (value, name) {
2789
- headers[name] = value;
2790
- });
2791
- return headers;
2792
- };
2669
+ var notificationAvailable = typeof window.Notification === "function";
2670
+ var notificationPreference = createPreference("notification");
2671
+ var arrayOfOpenedNotifications = [];
2793
2672
 
2794
- var fetchUrl = typeof window.fetch === "function" && typeof window.AbortController === "function" ? fetchNative : fetchUsingXHR;
2673
+ var renderToolbarNotification = function renderToolbarNotification() {
2674
+ var notifCheckbox = document.querySelector("#toggle-notifs");
2795
2675
 
2796
- function _await$8(value, then, direct) {
2797
- if (direct) {
2798
- return then ? then(value) : value;
2676
+ if (!notificationAvailable) {
2677
+ var notifSetting = document.querySelector(".settings-notification");
2678
+ notifSetting.setAttribute("data-disabled", "true");
2679
+ notifSetting.setAttribute("title", "Notification not available in the browser");
2680
+ notifCheckbox.disabled = true;
2681
+ return;
2799
2682
  }
2800
2683
 
2801
- if (!value || !value.then) {
2802
- value = Promise.resolve(value);
2803
- }
2684
+ var updatePermission = function updatePermission() {
2685
+ if (Notification.permission === "denied") {
2686
+ var _notifSetting = document.querySelector(".settings-notification");
2804
2687
 
2805
- return then ? value.then(then) : value;
2806
- }
2688
+ _notifSetting.setAttribute("data-disabled", "true");
2807
2689
 
2808
- function _async$8(f) {
2809
- return function () {
2810
- for (var args = [], i = 0; i < arguments.length; i++) {
2811
- args[i] = arguments[i];
2812
- }
2690
+ _notifSetting.setAttribute("title", "Notification denied");
2813
2691
 
2814
- try {
2815
- return Promise.resolve(f.apply(this, args));
2816
- } catch (e) {
2817
- return Promise.reject(e);
2692
+ notifCheckbox.disabled = true;
2693
+ return;
2818
2694
  }
2819
- };
2820
- }
2821
-
2822
- var fetchJson = _async$8(function (url) {
2823
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2824
- return _await$8(fetchUrl(url, options), function (response) {
2825
- return _await$8(response.json());
2826
- });
2827
- });
2828
-
2829
- function _await$7(value, then, direct) {
2830
- if (direct) {
2831
- return then ? then(value) : value;
2832
- }
2833
-
2834
- if (!value || !value.then) {
2835
- value = Promise.resolve(value);
2836
- }
2837
-
2838
- return then ? value.then(then) : value;
2839
- }
2840
2695
 
2841
- function _catch$5(body, recover) {
2842
- try {
2843
- var result = body();
2844
- } catch (e) {
2845
- return recover(e);
2846
- }
2696
+ notifCheckbox.checked = getNotificationPreference();
2847
2697
 
2848
- if (result && result.then) {
2849
- return result.then(void 0, recover);
2850
- }
2698
+ notifCheckbox.onchange = function () {
2699
+ setNotificationPreference(notifCheckbox.checked);
2851
2700
 
2852
- return result;
2853
- }
2701
+ if (!notifCheckbox.checked) {
2702
+ // slice because arrayOfOpenedNotifications can be mutated while looping
2703
+ arrayOfOpenedNotifications.slice().forEach(function (notification) {
2704
+ notification.close();
2705
+ });
2706
+ }
2707
+ };
2854
2708
 
2855
- function _async$7(f) {
2856
- return function () {
2857
- for (var args = [], i = 0; i < arguments.length; i++) {
2858
- args[i] = arguments[i];
2859
- }
2709
+ var notifPermission = Notification.permission;
2710
+ enableVariant(document.querySelector(".notification-text"), {
2711
+ notif_permission: notifPermission === "granted" ? "yes" : "no"
2712
+ });
2860
2713
 
2861
- try {
2862
- return Promise.resolve(f.apply(this, args));
2863
- } catch (e) {
2864
- return Promise.reject(e);
2714
+ if (notifPermission === "default") {
2715
+ document.querySelector("a.request_notification_permission").onclick = function () {
2716
+ requestPermission().then(function () {
2717
+ updatePermission();
2718
+ });
2719
+ };
2865
2720
  }
2866
2721
  };
2867
- }
2868
-
2869
- var fetchExploringJson = _async$7(function () {
2870
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
2871
- signal = _ref.signal;
2872
-
2873
- return _catch$5(function () {
2874
- return _await$7(fetchJson("/.jsenv/exploring.json", {
2875
- signal: signal
2876
- }));
2877
- }, function (e) {
2878
- if (signal && signal.aborted && e.name === "AbortError") {
2879
- throw e;
2880
- }
2881
-
2882
- throw new Error("Cannot communicate with exploring server due to a network error\n--- error stack ---\n".concat(e.stack));
2883
- });
2884
- });
2885
-
2886
- var updateIframeOverflowOnParentWindow = function updateIframeOverflowOnParentWindow() {
2887
- if (!window.parent) {
2888
- // can happen while parent iframe reloads
2889
- return;
2890
- }
2891
-
2892
- var aTooltipIsOpened = document.querySelector("[data-tooltip-visible]") || document.querySelector("[data-tooltip-auto-visible]");
2893
- var settingsAreOpened = document.querySelector("#settings[data-active]");
2894
2722
 
2895
- if (aTooltipIsOpened || settingsAreOpened) {
2896
- enableIframeOverflowOnParentWindow();
2897
- } else {
2898
- disableIframeOverflowOnParentWindow();
2899
- }
2723
+ updatePermission();
2900
2724
  };
2901
2725
 
2902
- var iframeOverflowEnabled = false;
2903
-
2904
- var enableIframeOverflowOnParentWindow = function enableIframeOverflowOnParentWindow() {
2905
- if (iframeOverflowEnabled) return;
2906
- iframeOverflowEnabled = true;
2907
- var iframe = getToolbarIframe();
2908
- var transitionDuration = iframe.style.transitionDuration;
2909
- setStyles(iframe, {
2910
- "height": "100%",
2911
- "transition-duration": "0ms"
2912
- });
2726
+ var notifyExecutionResult = function notifyExecutionResult(executedFileRelativeUrl, execution, previousExecution) {
2727
+ var notificationEnabled = getNotificationPreference();
2728
+ if (!notificationEnabled) return;
2729
+ var notificationOptions = {
2730
+ lang: "en",
2731
+ icon: getFaviconHref(),
2732
+ clickToFocus: true,
2733
+ clickToClose: true
2734
+ };
2913
2735
 
2914
- if (transitionDuration) {
2915
- setTimeout(function () {
2916
- setStyles(iframe, {
2917
- "transition-duration": transitionDuration
2918
- });
2919
- });
2736
+ if (execution.status === "errored") {
2737
+ if (previousExecution) {
2738
+ if (previousExecution.status === "completed") {
2739
+ notify("Broken", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
2740
+ body: "".concat(executedFileRelativeUrl, " execution now failing.")
2741
+ }));
2742
+ } else {
2743
+ notify("Still failing", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
2744
+ body: "".concat(executedFileRelativeUrl, " execution still failing.")
2745
+ }));
2746
+ }
2747
+ } else {
2748
+ notify("Failing", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
2749
+ body: "".concat(executedFileRelativeUrl, " execution failed.")
2750
+ }));
2751
+ }
2752
+ } else if (previousExecution && previousExecution.status === "errored") {
2753
+ notify("Fixed", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
2754
+ body: "".concat(executedFileRelativeUrl, " execution fixed.")
2755
+ }));
2920
2756
  }
2921
2757
  };
2922
2758
 
2923
- var disableIframeOverflowOnParentWindow = function disableIframeOverflowOnParentWindow() {
2924
- if (!iframeOverflowEnabled) return;
2925
- iframeOverflowEnabled = false;
2926
- var iframe = getToolbarIframe();
2927
- var transitionDuration = iframe.style.transitionDuration;
2928
- setStyles(iframe, {
2929
- "height": "40px",
2930
- "transition-duration": "0ms"
2931
- });
2932
-
2933
- if (transitionDuration) {
2934
- setTimeout(function () {
2935
- setStyles(iframe, {
2936
- "transition-duration": transitionDuration
2937
- });
2938
- });
2939
- }
2759
+ var getNotificationPreference = function getNotificationPreference() {
2760
+ return notificationPreference.has() ? notificationPreference.get() : true;
2940
2761
  };
2941
2762
 
2942
- var getToolbarIframe = function getToolbarIframe() {
2943
- var iframes = Array.from(window.parent.document.querySelectorAll("iframe"));
2944
- return iframes.find(function (iframe) {
2945
- return iframe.contentWindow === window;
2946
- });
2763
+ var setNotificationPreference = function setNotificationPreference(value) {
2764
+ return notificationPreference.set(value);
2947
2765
  };
2948
2766
 
2949
- var forceHideElement = function forceHideElement(element) {
2950
- element.setAttribute("data-force-hide", "");
2767
+ var getFaviconHref = function getFaviconHref() {
2768
+ var link = document.querySelector('link[rel="icon"]');
2769
+ return link ? link.href : undefined;
2951
2770
  };
2952
2771
 
2953
- var removeForceHideElement = function removeForceHideElement(element) {
2954
- element.removeAttribute("data-force-hide");
2955
- };
2772
+ var permission = "default";
2773
+ var notify = notificationAvailable ? _async$9(function (title) {
2774
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2956
2775
 
2957
- var setStyles = function setStyles(element, styles) {
2958
- var elementStyle = element.style;
2959
- var restoreStyles = Object.keys(styles).map(function (styleName) {
2960
- var restore;
2776
+ var _ref$clickToFocus = _ref.clickToFocus,
2777
+ clickToFocus = _ref$clickToFocus === void 0 ? false : _ref$clickToFocus,
2778
+ _ref$clickToClose = _ref.clickToClose,
2779
+ clickToClose = _ref$clickToClose === void 0 ? false : _ref$clickToClose,
2780
+ options = _objectWithoutProperties(_ref, _excluded$1);
2961
2781
 
2962
- if (styleName in elementStyle) {
2963
- var currentStyle = elementStyle[styleName];
2782
+ if (permission !== "granted") {
2783
+ return null;
2784
+ }
2964
2785
 
2965
- restore = function restore() {
2966
- elementStyle[styleName] = currentStyle;
2967
- };
2968
- } else {
2969
- restore = function restore() {
2970
- delete elementStyle[styleName];
2971
- };
2972
- }
2786
+ var notification = new Notification(title, options);
2787
+ arrayOfOpenedNotifications.push(notification);
2973
2788
 
2974
- elementStyle[styleName] = styles[styleName];
2975
- return restore;
2976
- });
2977
- return function () {
2978
- restoreStyles.forEach(function (restore) {
2979
- return restore();
2980
- });
2789
+ notification.onclick = function () {
2790
+ // but if the user navigated inbetween
2791
+ // focusing window will show something else
2792
+ // in that case it could be great to do something
2793
+ // maybe like showing a message saying this execution
2794
+ // is no longer visible
2795
+ // we could also navigauate to this file execution but
2796
+ // there is no guarantee re-executing the file would give same output
2797
+ // and it would also trigger an other notification
2798
+ if (clickToFocus) window.focus();
2799
+ if (clickToClose) notification.close();
2981
2800
  };
2982
- };
2983
2801
 
2984
- var toolbarSectionIsActive = function toolbarSectionIsActive(element) {
2985
- return element.hasAttribute("data-active");
2986
- };
2802
+ notification.onclose = function () {
2803
+ var index = arrayOfOpenedNotifications.indexOf(notification);
2987
2804
 
2988
- var activateToolbarSection = function activateToolbarSection(element) {
2989
- element.setAttribute("data-active", "");
2990
- };
2805
+ if (index > -1) {
2806
+ arrayOfOpenedNotifications.splice(index, 1);
2807
+ }
2808
+ };
2991
2809
 
2992
- var deactivateToolbarSection = function deactivateToolbarSection(element) {
2993
- element.removeAttribute("data-active");
2810
+ return notification;
2811
+ }) : function () {};
2812
+ var requestPromise;
2813
+ var requestPermission = notificationAvailable ? _async$9(function () {
2814
+ if (requestPromise) return requestPromise;
2815
+ requestPromise = Notification.requestPermission();
2816
+ return _await$a(requestPromise, function (_requestPromise) {
2817
+ permission = _requestPromise;
2818
+ requestPromise = undefined;
2819
+ return permission;
2820
+ });
2821
+ }) : function () {
2822
+ return Promise.resolve("default");
2994
2823
  };
2824
+ var DARK_THEME = "dark";
2825
+ var LIGHT_THEME = "light";
2826
+ var themePreference = createPreference("theme");
2995
2827
 
2996
- var startJavaScriptAnimation = function startJavaScriptAnimation(_ref6) {
2997
- var _ref6$duration = _ref6.duration,
2998
- duration = _ref6$duration === void 0 ? 300 : _ref6$duration,
2999
- _ref6$timingFunction = _ref6.timingFunction,
3000
- timingFunction = _ref6$timingFunction === void 0 ? function (t) {
3001
- return t;
3002
- } : _ref6$timingFunction,
3003
- _ref6$onProgress = _ref6.onProgress,
3004
- onProgress = _ref6$onProgress === void 0 ? function () {} : _ref6$onProgress,
3005
- _ref6$onCancel = _ref6.onCancel,
3006
- onCancel = _ref6$onCancel === void 0 ? function () {} : _ref6$onCancel,
3007
- _ref6$onComplete = _ref6.onComplete,
3008
- onComplete = _ref6$onComplete === void 0 ? function () {} : _ref6$onComplete;
3009
-
3010
- if (isNaN(duration)) {
3011
- // console.warn(`duration must be a number, received ${duration}`)
3012
- return function () {};
3013
- }
3014
-
3015
- duration = parseInt(duration, 10);
3016
- var startMs = performance.now();
3017
- var currentRequestAnimationFrameId;
3018
- var done = false;
3019
- var rawProgress = 0;
3020
- var progress = 0;
3021
-
3022
- var handler = function handler() {
3023
- currentRequestAnimationFrameId = null;
3024
- var nowMs = performance.now();
3025
- rawProgress = Math.min((nowMs - startMs) / duration, 1);
3026
- progress = timingFunction(rawProgress);
3027
- done = rawProgress === 1;
3028
- onProgress({
3029
- done: done,
3030
- rawProgress: rawProgress,
3031
- progress: progress
3032
- });
2828
+ var renderToolbarTheme = function renderToolbarTheme() {
2829
+ var theme = getThemePreference();
2830
+ var checkbox = document.querySelector("#checkbox-dark-theme");
2831
+ checkbox.checked = theme === DARK_THEME;
2832
+ setTheme(theme);
3033
2833
 
3034
- if (done) {
3035
- onComplete();
2834
+ checkbox.onchange = function () {
2835
+ if (checkbox.checked) {
2836
+ setThemePreference(DARK_THEME);
2837
+ setTheme(DARK_THEME);
3036
2838
  } else {
3037
- currentRequestAnimationFrameId = window.requestAnimationFrame(handler);
2839
+ setThemePreference(LIGHT_THEME);
2840
+ setTheme(LIGHT_THEME);
3038
2841
  }
3039
2842
  };
2843
+ };
3040
2844
 
3041
- handler();
3042
-
3043
- var stop = function stop() {
3044
- if (currentRequestAnimationFrameId) {
3045
- window.cancelAnimationFrame(currentRequestAnimationFrameId);
3046
- currentRequestAnimationFrameId = null;
3047
- }
3048
-
3049
- if (!done) {
3050
- done = true;
3051
- onCancel({
3052
- rawProgress: rawProgress,
3053
- progress: progress
3054
- });
3055
- }
3056
- };
2845
+ var getThemePreference = function getThemePreference() {
2846
+ return themePreference.has() ? themePreference.get() : DARK_THEME;
2847
+ };
3057
2848
 
3058
- return stop;
3059
- }; // handle data-last-interaction attr on html (focusring)
2849
+ var setThemePreference = function setThemePreference(value) {
2850
+ themePreference.set(value);
2851
+ setTheme(value);
2852
+ };
3060
2853
 
2854
+ var setTheme = function setTheme(theme) {
2855
+ document.querySelector("html").setAttribute("data-theme", theme);
2856
+ };
3061
2857
 
3062
- window.addEventListener("mousedown", function (mousedownEvent) {
3063
- if (mousedownEvent.defaultPrevented) {
3064
- return;
3065
- }
2858
+ var animationPreference = createPreference("animation");
3066
2859
 
3067
- document.documentElement.setAttribute("data-last-interaction", "mouse");
3068
- });
3069
- window.addEventListener("touchstart", function (touchstartEvent) {
3070
- if (touchstartEvent.defaultPrevented) {
3071
- return;
3072
- }
2860
+ var renderToolbarAnimation = function renderToolbarAnimation() {
2861
+ var animCheckbox = document.querySelector("#toggle-anims");
2862
+ animCheckbox.checked = getAnimationPreference();
3073
2863
 
3074
- document.documentElement.setAttribute("data-last-interaction", "mouse");
3075
- });
3076
- window.addEventListener("keydown", function (keydownEvent) {
3077
- if (keydownEvent.defaultPrevented) {
3078
- return;
3079
- }
2864
+ animCheckbox.onchange = function () {
2865
+ setAnimationPreference(animCheckbox.checked);
2866
+ onPreferenceChange(animCheckbox.checked);
2867
+ };
3080
2868
 
3081
- document.documentElement.setAttribute("data-last-interaction", "keyboard");
3082
- });
2869
+ onPreferenceChange(); // enable toolbar transition only after first render
3083
2870
 
3084
- var createPreference = function createPreference(name) {
3085
- return {
3086
- has: function has() {
3087
- return localStorage.hasOwnProperty(name);
3088
- },
3089
- get: function get() {
3090
- return localStorage.hasOwnProperty(name) ? JSON.parse(localStorage.getItem(name)) : undefined;
3091
- },
3092
- set: function set(value) {
3093
- return localStorage.setItem(name, JSON.stringify(value));
3094
- }
3095
- };
2871
+ setTimeout(function () {
2872
+ document.querySelector("#toolbar").setAttribute("data-animate", "");
2873
+ });
3096
2874
  };
3097
2875
 
3098
- var toggleTooltip = function toggleTooltip(element) {
3099
- if (element.hasAttribute("data-tooltip-visible")) {
3100
- hideTooltip(element);
2876
+ var onPreferenceChange = function onPreferenceChange() {
2877
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getAnimationPreference();
2878
+
2879
+ if (value) {
2880
+ enableAnimation();
3101
2881
  } else {
3102
- showTooltip(element);
2882
+ disableAnimation();
3103
2883
  }
3104
2884
  };
3105
2885
 
3106
- var hideTooltip = function hideTooltip(element) {
3107
- element.removeAttribute("data-tooltip-visible");
3108
- element.removeAttribute("data-tooltip-auto-visible");
3109
- updateIframeOverflowOnParentWindow();
3110
- };
3111
-
3112
- var showTooltip = function showTooltip(element) {
3113
- element.setAttribute("data-tooltip-visible", "");
3114
- updateIframeOverflowOnParentWindow();
2886
+ var getAnimationPreference = function getAnimationPreference() {
2887
+ return animationPreference.has() ? animationPreference.get() : true;
3115
2888
  };
3116
2889
 
3117
- var autoShowTooltip = function autoShowTooltip(element) {
3118
- element.setAttribute("data-tooltip-auto-visible", "");
3119
- updateIframeOverflowOnParentWindow();
2890
+ var setAnimationPreference = function setAnimationPreference(value) {
2891
+ return animationPreference.set(value);
3120
2892
  };
3121
2893
 
3122
- var removeAutoShowTooltip = function removeAutoShowTooltip(element) {
3123
- element.removeAttribute("data-tooltip-auto-visible");
3124
- updateIframeOverflowOnParentWindow();
2894
+ var enableAnimation = function enableAnimation() {
2895
+ document.documentElement.removeAttribute("data-animation-disabled");
3125
2896
  };
3126
2897
 
3127
- var hideAllTooltip = function hideAllTooltip() {
3128
- var elementsWithTooltip = Array.from(document.querySelectorAll("[data-tooltip-visible]"));
3129
- elementsWithTooltip.forEach(function (elementWithTooltip) {
3130
- hideTooltip(elementWithTooltip);
3131
- });
2898
+ var disableAnimation = function disableAnimation() {
2899
+ document.documentElement.setAttribute("data-animation-disabled", "");
3132
2900
  };
3133
2901
 
3134
- var enableVariant = function enableVariant(rootNode, variables) {
3135
- var nodesNotMatching = Array.from(rootNode.querySelectorAll("[".concat(attributeIndicatingACondition, "]")));
3136
- nodesNotMatching.forEach(function (nodeNotMatching) {
3137
- var conditionAttributeValue = nodeNotMatching.getAttribute(attributeIndicatingACondition);
3138
- var matches = testCondition(conditionAttributeValue, variables);
3139
-
3140
- if (matches) {
3141
- renameAttribute(nodeNotMatching, attributeIndicatingACondition, attributeIndicatingAMatch);
3142
- }
3143
- });
3144
- var nodesMatching = Array.from(rootNode.querySelectorAll("[".concat(attributeIndicatingAMatch, "]")));
3145
- nodesMatching.forEach(function (nodeMatching) {
3146
- var conditionAttributeValue = nodeMatching.getAttribute(attributeIndicatingAMatch);
3147
- var matches = testCondition(conditionAttributeValue, variables);
3148
-
3149
- if (!matches) {
3150
- renameAttribute(nodeMatching, attributeIndicatingAMatch, attributeIndicatingACondition);
3151
- }
3152
- });
2902
+ var createHorizontalBreakpoint = function createHorizontalBreakpoint(breakpointValue) {
2903
+ return createBreakpoint(windowWidthMeasure, breakpointValue);
3153
2904
  };
3154
2905
 
3155
- var testCondition = function testCondition(conditionAttributeValue, variables) {
3156
- var condition = parseCondition(conditionAttributeValue);
3157
- return Object.keys(variables).some(function (key) {
3158
- if (condition.key !== key) {
3159
- return false;
3160
- } // the condition do not specify a value, any value is ok
3161
-
2906
+ var createMeasure = function createMeasure(_ref) {
2907
+ var compute = _ref.compute,
2908
+ register = _ref.register;
2909
+ var currentValue = compute();
3162
2910
 
3163
- if (condition.value === undefined) {
3164
- return true;
3165
- }
2911
+ var get = function get() {
2912
+ return compute();
2913
+ };
3166
2914
 
3167
- if (condition.value === variables[key]) {
3168
- return true;
3169
- }
2915
+ var changed = createSignal();
3170
2916
 
3171
- return false;
3172
- });
3173
- };
2917
+ var unregister = function unregister() {};
3174
2918
 
3175
- var parseCondition = function parseCondition(conditionAttributeValue) {
3176
- var colonIndex = conditionAttributeValue.indexOf(":");
2919
+ if (register) {
2920
+ unregister = register(function () {
2921
+ var value = compute();
3177
2922
 
3178
- if (colonIndex === -1) {
3179
- return {
3180
- key: conditionAttributeValue,
3181
- value: undefined
3182
- };
2923
+ if (value !== currentValue) {
2924
+ var previousValue = value;
2925
+ currentValue = value;
2926
+ changed.notify(value, previousValue);
2927
+ }
2928
+ });
3183
2929
  }
3184
2930
 
3185
2931
  return {
3186
- key: conditionAttributeValue.slice(0, colonIndex),
3187
- value: conditionAttributeValue.slice(colonIndex + 1)
2932
+ get: get,
2933
+ changed: changed,
2934
+ unregister: unregister
3188
2935
  };
3189
2936
  };
3190
2937
 
3191
- var attributeIndicatingACondition = "data-when";
3192
- var attributeIndicatingAMatch = "data-when-active";
2938
+ var createSignal = function createSignal() {
2939
+ var callbackArray = [];
3193
2940
 
3194
- var renameAttribute = function renameAttribute(node, name, newName) {
3195
- node.setAttribute(newName, node.getAttribute(name));
3196
- node.removeAttribute(name);
3197
- };
2941
+ var listen = function listen(callback) {
2942
+ callbackArray.push(callback);
2943
+ return function () {
2944
+ var index = callbackArray.indexOf(callback);
3198
2945
 
3199
- var renderToolbarSettings = function renderToolbarSettings() {
3200
- document.querySelector("#settings-button").onclick = toggleSettings;
3201
- document.querySelector("#button-close-settings").onclick = toggleSettings;
2946
+ if (index > -1) {
2947
+ callbackArray.splice(index, 1);
2948
+ }
2949
+ };
2950
+ };
2951
+
2952
+ var notify = function notify() {
2953
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2954
+ args[_key] = arguments[_key];
2955
+ }
2956
+
2957
+ callbackArray.slice().forEach(function (callback) {
2958
+ callback.apply(void 0, args);
2959
+ });
2960
+ };
2961
+
2962
+ return {
2963
+ listen: listen,
2964
+ notify: notify
2965
+ };
3202
2966
  };
3203
2967
 
3204
- var toggleSettings = function toggleSettings() {
3205
- if (settingsAreVisible()) {
3206
- hideSettings();
3207
- } else {
3208
- showSettings();
2968
+ var windowWidthMeasure = createMeasure({
2969
+ name: "window-width",
2970
+ compute: function compute() {
2971
+ return window.innerWidth;
2972
+ },
2973
+ register: function register(onchange) {
2974
+ window.addEventListener("resize", onchange);
2975
+ window.addEventListener("orientationchange", onchange);
2976
+ return function () {
2977
+ window.removeEventListener("resize", onchange);
2978
+ window.removeEventListener("orientationchange", onchange);
2979
+ };
3209
2980
  }
3210
- };
2981
+ });
3211
2982
 
3212
- var enableWarningStyle = function enableWarningStyle() {
3213
- enableVariant(document.querySelector("#settings-button"), {
3214
- has_warning: "yes"
2983
+ var createBreakpoint = function createBreakpoint(measure, breakpointValue) {
2984
+ var getBreakpointState = function getBreakpointState() {
2985
+ var value = measure.get();
2986
+
2987
+ if (value < breakpointValue) {
2988
+ return "below";
2989
+ }
2990
+
2991
+ if (value > breakpointValue) {
2992
+ return "above";
2993
+ }
2994
+
2995
+ return "equals";
2996
+ };
2997
+
2998
+ var currentBreakpointState = getBreakpointState();
2999
+
3000
+ var isAbove = function isAbove() {
3001
+ return measure.get() > breakpointValue;
3002
+ };
3003
+
3004
+ var isBelow = function isBelow() {
3005
+ return measure.get() < breakpointValue;
3006
+ };
3007
+
3008
+ var breakpointChanged = createSignal();
3009
+ measure.changed.listen(function () {
3010
+ var breakpointState = getBreakpointState();
3011
+
3012
+ if (breakpointState !== currentBreakpointState) {
3013
+ var breakpointStatePrevious = currentBreakpointState;
3014
+ currentBreakpointState = breakpointState;
3015
+ breakpointChanged.notify(breakpointState, breakpointStatePrevious);
3016
+ }
3215
3017
  });
3216
- };
3018
+ return {
3019
+ isAbove: isAbove,
3020
+ isBelow: isBelow,
3021
+ changed: breakpointChanged
3022
+ };
3023
+ }; // const windowScrollTop = createMeasure({
3024
+ // name: "window-scroll-top",
3025
+ // compute: () => window.scrollTop,
3026
+ // register: (onchange) => {
3027
+ // window.addEventListener("scroll", onchange)
3028
+ // return () => {
3029
+ // window.removeEventListener("scroll", onchange)
3030
+ // }
3031
+ // },
3032
+ // })
3217
3033
 
3218
- var disableWarningStyle = function disableWarningStyle() {
3219
- enableVariant(document.querySelector("#settings-button"), {
3220
- has_warning: "no"
3034
+
3035
+ var WINDOW_MEDIUM_WIDTH = 570;
3036
+
3037
+ var renderExecutionInToolbar = function renderExecutionInToolbar(_ref) {
3038
+ var executedFileRelativeUrl = _ref.executedFileRelativeUrl; // reset file execution indicator ui
3039
+
3040
+ applyExecutionIndicator();
3041
+ removeForceHideElement(document.querySelector("#execution-indicator")); // apply responsive design on fileInput if needed + add listener on resize screen
3042
+
3043
+ var input = document.querySelector("#file-input");
3044
+ var fileWidthBreakpoint = createHorizontalBreakpoint(WINDOW_MEDIUM_WIDTH);
3045
+
3046
+ var handleFileWidthBreakpoint = function handleFileWidthBreakpoint() {
3047
+ resizeInput(input, fileWidthBreakpoint);
3048
+ };
3049
+
3050
+ handleFileWidthBreakpoint();
3051
+ fileWidthBreakpoint.changed.listen(handleFileWidthBreakpoint);
3052
+ input.value = executedFileRelativeUrl;
3053
+ resizeInput(input, fileWidthBreakpoint);
3054
+ activateToolbarSection(document.querySelector("#file"));
3055
+ removeForceHideElement(document.querySelector("#file"));
3056
+
3057
+ window.parent.__jsenv__.executionResultPromise.then(function (_ref2) {
3058
+ var status = _ref2.status,
3059
+ startTime = _ref2.startTime,
3060
+ endTime = _ref2.endTime;
3061
+ var execution = {
3062
+ status: status,
3063
+ startTime: startTime,
3064
+ endTime: endTime
3065
+ };
3066
+ applyExecutionIndicator(execution);
3067
+ var executionStorageKey = executedFileRelativeUrl;
3068
+ var previousExecution = sessionStorage.hasOwnProperty(executionStorageKey) ? JSON.parse(sessionStorage.getItem(executionStorageKey)) : undefined;
3069
+ notifyExecutionResult(executedFileRelativeUrl, execution, previousExecution);
3070
+ sessionStorage.setItem(executedFileRelativeUrl, JSON.stringify(execution));
3221
3071
  });
3222
3072
  };
3223
3073
 
3224
- var settingsAreVisible = function settingsAreVisible() {
3225
- return toolbarSectionIsActive(document.querySelector("#settings"));
3074
+ var applyExecutionIndicator = function applyExecutionIndicator() {
3075
+ var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3076
+ _ref3$status = _ref3.status,
3077
+ status = _ref3$status === void 0 ? "running" : _ref3$status,
3078
+ startTime = _ref3.startTime,
3079
+ endTime = _ref3.endTime;
3080
+
3081
+ var executionIndicator = document.querySelector("#execution-indicator");
3082
+ enableVariant(executionIndicator, {
3083
+ execution: status
3084
+ });
3085
+ var variantNode = executionIndicator.querySelector("[data-when-active]");
3086
+
3087
+ variantNode.querySelector("button").onclick = function () {
3088
+ return toggleTooltip(executionIndicator);
3089
+ };
3090
+
3091
+ variantNode.querySelector(".tooltip").textContent = computeText({
3092
+ status: status,
3093
+ startTime: startTime,
3094
+ endTime: endTime
3095
+ });
3226
3096
  };
3227
3097
 
3228
- var hideSettings = function hideSettings() {
3229
- deactivateToolbarSection(document.querySelector("#settings"));
3230
- updateIframeOverflowOnParentWindow();
3098
+ var computeText = function computeText(_ref4) {
3099
+ var status = _ref4.status,
3100
+ startTime = _ref4.startTime,
3101
+ endTime = _ref4.endTime;
3102
+
3103
+ if (status === "completed") {
3104
+ return "Execution completed in ".concat(endTime - startTime, "ms");
3105
+ }
3106
+
3107
+ if (status === "errored") {
3108
+ return "Execution failed in ".concat(endTime - startTime, "ms");
3109
+ }
3110
+
3111
+ if (status === "running") {
3112
+ return "Executing...";
3113
+ }
3114
+
3115
+ return "";
3231
3116
  };
3232
3117
 
3233
- var showSettings = function showSettings() {
3234
- activateToolbarSection(document.querySelector("#settings"));
3235
- updateIframeOverflowOnParentWindow();
3118
+ var resizeInput = function resizeInput(input, fileWidthBreakpoint) {
3119
+ var size = fileWidthBreakpoint.isBelow() ? 20 : 40;
3120
+
3121
+ if (input.value.length > size) {
3122
+ input.style.width = "".concat(size, "ch");
3123
+ } else {
3124
+ input.style.width = "".concat(input.value.length, "ch");
3125
+ }
3236
3126
  };
3127
+ /* eslint-env browser */
3237
3128
 
3238
- var _excluded = ["clickToFocus", "clickToClose"];
3239
3129
 
3240
- function _async$6(f) {
3130
+ function _await$9(value, then, direct) {
3131
+ if (direct) {
3132
+ return then ? then(value) : value;
3133
+ }
3134
+
3135
+ if (!value || !value.then) {
3136
+ value = Promise.resolve(value);
3137
+ }
3138
+
3139
+ return then ? value.then(then) : value;
3140
+ }
3141
+
3142
+ function _async$8(f) {
3241
3143
  return function () {
3242
3144
  for (var args = [], i = 0; i < arguments.length; i++) {
3243
3145
  args[i] = arguments[i];
@@ -3251,476 +3153,518 @@ html[data-toolbar-visible] #toolbar-trigger {
3251
3153
  };
3252
3154
  }
3253
3155
 
3254
- function _await$6(value, then, direct) {
3156
+ function _call$1(body, then, direct) {
3255
3157
  if (direct) {
3256
- return then ? then(value) : value;
3158
+ return then ? then(body()) : body();
3257
3159
  }
3258
3160
 
3259
- if (!value || !value.then) {
3260
- value = Promise.resolve(value);
3161
+ try {
3162
+ var result = Promise.resolve(body());
3163
+ return then ? result.then(then) : result;
3164
+ } catch (e) {
3165
+ return Promise.reject(e);
3261
3166
  }
3262
-
3263
- return then ? value.then(then) : value;
3264
3167
  }
3265
3168
 
3266
- var notificationAvailable = typeof window.Notification === "function";
3267
- var notificationPreference = createPreference("notification");
3268
- var arrayOfOpenedNotifications = [];
3269
-
3270
- var renderToolbarNotification = function renderToolbarNotification() {
3271
- var notifCheckbox = document.querySelector("#toggle-notifs");
3169
+ var fetchUsingXHR = _async$8(function (url) {
3170
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
3171
+ signal = _ref.signal,
3172
+ _ref$method = _ref.method,
3173
+ method = _ref$method === void 0 ? "GET" : _ref$method,
3174
+ _ref$credentials = _ref.credentials,
3175
+ credentials = _ref$credentials === void 0 ? "same-origin" : _ref$credentials,
3176
+ _ref$headers = _ref.headers,
3177
+ headers = _ref$headers === void 0 ? {} : _ref$headers,
3178
+ _ref$body = _ref.body,
3179
+ body = _ref$body === void 0 ? null : _ref$body;
3272
3180
 
3273
- if (!notificationAvailable) {
3274
- var notifSetting = document.querySelector(".settings-notification");
3275
- notifSetting.setAttribute("data-disabled", "true");
3276
- notifSetting.setAttribute("title", "Notification not available in the browser");
3277
- notifCheckbox.disabled = true;
3278
- return;
3279
- }
3181
+ var headersPromise = createPromiseAndHooks();
3182
+ var bodyPromise = createPromiseAndHooks();
3183
+ var xhr = new XMLHttpRequest();
3280
3184
 
3281
- var updatePermission = function updatePermission() {
3282
- if (Notification.permission === "denied") {
3283
- var _notifSetting = document.querySelector(".settings-notification");
3185
+ var failure = function failure(error) {
3186
+ // if it was already resolved, we must reject the body promise
3187
+ if (headersPromise.settled) {
3188
+ bodyPromise.reject(error);
3189
+ } else {
3190
+ headersPromise.reject(error);
3191
+ }
3192
+ };
3284
3193
 
3285
- _notifSetting.setAttribute("data-disabled", "true");
3194
+ var cleanup = function cleanup() {
3195
+ xhr.ontimeout = null;
3196
+ xhr.onerror = null;
3197
+ xhr.onload = null;
3198
+ xhr.onreadystatechange = null;
3199
+ };
3286
3200
 
3287
- _notifSetting.setAttribute("title", "Notification denied");
3201
+ xhr.ontimeout = function () {
3202
+ cleanup();
3203
+ failure(new Error("xhr request timeout on ".concat(url, ".")));
3204
+ };
3288
3205
 
3289
- notifCheckbox.disabled = true;
3290
- return;
3291
- }
3206
+ xhr.onerror = function (error) {
3207
+ cleanup(); // unfortunately with have no clue why it fails
3208
+ // might be cors for instance
3292
3209
 
3293
- notifCheckbox.checked = getNotificationPreference();
3210
+ failure(createRequestError(error, {
3211
+ url: url
3212
+ }));
3213
+ };
3294
3214
 
3295
- notifCheckbox.onchange = function () {
3296
- setNotificationPreference(notifCheckbox.checked);
3215
+ xhr.onload = function () {
3216
+ cleanup();
3217
+ bodyPromise.resolve();
3218
+ };
3297
3219
 
3298
- if (!notifCheckbox.checked) {
3299
- // slice because arrayOfOpenedNotifications can be mutated while looping
3300
- arrayOfOpenedNotifications.slice().forEach(function (notification) {
3301
- notification.close();
3302
- });
3303
- }
3304
- };
3220
+ signal.addEventListener("abort", function () {
3221
+ xhr.abort();
3222
+ var abortError = new Error("aborted");
3223
+ abortError.name = "AbortError";
3224
+ failure(abortError);
3225
+ });
3305
3226
 
3306
- var notifPermission = Notification.permission;
3307
- enableVariant(document.querySelector(".notification-text"), {
3308
- notif_permission: notifPermission === "granted" ? "yes" : "no"
3309
- });
3227
+ xhr.onreadystatechange = function () {
3228
+ // https://developer.mozilla.org/fr/docs/Web/API/XMLHttpRequest/readyState
3229
+ var readyState = xhr.readyState;
3310
3230
 
3311
- if (notifPermission === "default") {
3312
- document.querySelector("a.request_notification_permission").onclick = function () {
3313
- requestPermission().then(function () {
3314
- updatePermission();
3315
- });
3316
- };
3231
+ if (readyState === 2) {
3232
+ headersPromise.resolve();
3233
+ } else if (readyState === 4) {
3234
+ cleanup();
3235
+ bodyPromise.resolve();
3317
3236
  }
3318
3237
  };
3319
3238
 
3320
- updatePermission();
3321
- };
3322
-
3323
- var notifyExecutionResult = function notifyExecutionResult(executedFileRelativeUrl, execution, previousExecution) {
3324
- var notificationEnabled = getNotificationPreference();
3325
- if (!notificationEnabled) return;
3326
- var notificationOptions = {
3327
- lang: "en",
3328
- icon: getFaviconHref(),
3329
- clickToFocus: true,
3330
- clickToClose: true
3331
- };
3239
+ xhr.open(method, url, true);
3240
+ Object.keys(headers).forEach(function (key) {
3241
+ xhr.setRequestHeader(key, headers[key]);
3242
+ });
3243
+ xhr.withCredentials = computeWithCredentials({
3244
+ credentials: credentials,
3245
+ url: url
3246
+ });
3332
3247
 
3333
- if (execution.status === "errored") {
3334
- if (previousExecution) {
3335
- if (previousExecution.status === "completed") {
3336
- notify("Broken", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
3337
- body: "".concat(executedFileRelativeUrl, " execution now failing.")
3338
- }));
3339
- } else {
3340
- notify("Still failing", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
3341
- body: "".concat(executedFileRelativeUrl, " execution still failing.")
3342
- }));
3343
- }
3344
- } else {
3345
- notify("Failing", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
3346
- body: "".concat(executedFileRelativeUrl, " execution failed.")
3347
- }));
3348
- }
3349
- } else if (previousExecution && previousExecution.status === "errored") {
3350
- notify("Fixed", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
3351
- body: "".concat(executedFileRelativeUrl, " execution fixed.")
3352
- }));
3248
+ if ("responseType" in xhr && hasBlob) {
3249
+ xhr.responseType = "blob";
3353
3250
  }
3354
- };
3355
3251
 
3356
- var getNotificationPreference = function getNotificationPreference() {
3357
- return notificationPreference.has() ? notificationPreference.get() : true;
3358
- };
3252
+ xhr.send(body);
3253
+ return _await$9(headersPromise, function () {
3254
+ // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseURL
3255
+ var responseUrl = "responseURL" in xhr ? xhr.responseURL : headers["x-request-url"];
3256
+ var responseStatus = xhr.status;
3257
+ var responseStatusText = xhr.statusText;
3258
+ var responseHeaders = getHeadersFromXHR(xhr);
3359
3259
 
3360
- var setNotificationPreference = function setNotificationPreference(value) {
3361
- return notificationPreference.set(value);
3362
- };
3260
+ var readBody = function readBody() {
3261
+ return _await$9(bodyPromise, function () {
3262
+ var status = xhr.status; // in Chrome on file:/// URLs, status is 0
3363
3263
 
3364
- var getFaviconHref = function getFaviconHref() {
3365
- var link = document.querySelector('link[rel="icon"]');
3366
- return link ? link.href : undefined;
3367
- };
3264
+ if (status === 0) {
3265
+ responseStatus = 200;
3266
+ }
3368
3267
 
3369
- var permission = "default";
3370
- var notify = notificationAvailable ? _async$6(function (title) {
3371
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3268
+ var body = "response" in xhr ? xhr.response : xhr.responseText;
3269
+ return {
3270
+ responseBody: body,
3271
+ responseBodyType: detectBodyType(body)
3272
+ };
3273
+ });
3274
+ };
3372
3275
 
3373
- var _ref$clickToFocus = _ref.clickToFocus,
3374
- clickToFocus = _ref$clickToFocus === void 0 ? false : _ref$clickToFocus,
3375
- _ref$clickToClose = _ref.clickToClose,
3376
- clickToClose = _ref$clickToClose === void 0 ? false : _ref$clickToClose,
3377
- options = _objectWithoutProperties(_ref, _excluded);
3276
+ var text = function text() {
3277
+ return _call$1(readBody, function (_ref2) {
3278
+ var responseBody = _ref2.responseBody,
3279
+ responseBodyType = _ref2.responseBodyType;
3378
3280
 
3379
- if (permission !== "granted") {
3380
- return null;
3381
- }
3281
+ if (responseBodyType === "blob") {
3282
+ return blobToText(responseBody);
3283
+ }
3382
3284
 
3383
- var notification = new Notification(title, options);
3384
- arrayOfOpenedNotifications.push(notification);
3285
+ if (responseBodyType === "formData") {
3286
+ throw new Error("could not read FormData body as text");
3287
+ }
3385
3288
 
3386
- notification.onclick = function () {
3387
- // but if the user navigated inbetween
3388
- // focusing window will show something else
3389
- // in that case it could be great to do something
3390
- // maybe like showing a message saying this execution
3391
- // is no longer visible
3392
- // we could also navigauate to this file execution but
3393
- // there is no guarantee re-executing the file would give same output
3394
- // and it would also trigger an other notification
3395
- if (clickToFocus) window.focus();
3396
- if (clickToClose) notification.close();
3397
- };
3289
+ return responseBodyType === "dataView" ? arrayBufferToText(responseBody.buffer) : responseBodyType === "arrayBuffer" ? arrayBufferToText(responseBody) : String(responseBody);
3290
+ });
3291
+ };
3398
3292
 
3399
- notification.onclose = function () {
3400
- var index = arrayOfOpenedNotifications.indexOf(notification);
3293
+ var json = function json() {
3294
+ return _call$1(text, JSON.parse);
3295
+ };
3401
3296
 
3402
- if (index > -1) {
3403
- arrayOfOpenedNotifications.splice(index, 1);
3404
- }
3405
- };
3297
+ var blob = _async$8(function () {
3298
+ if (!hasBlob) {
3299
+ throw new Error("blob not supported");
3300
+ }
3406
3301
 
3407
- return notification;
3408
- }) : function () {};
3409
- var requestPromise;
3410
- var requestPermission = notificationAvailable ? _async$6(function () {
3411
- if (requestPromise) return requestPromise;
3412
- requestPromise = Notification.requestPermission();
3413
- return _await$6(requestPromise, function (_requestPromise) {
3414
- permission = _requestPromise;
3415
- requestPromise = undefined;
3416
- return permission;
3417
- });
3418
- }) : function () {
3419
- return Promise.resolve("default");
3420
- };
3421
- var DARK_THEME = "dark";
3422
- var LIGHT_THEME = "light";
3423
- var themePreference = createPreference("theme");
3302
+ return _call$1(readBody, function (_ref3) {
3303
+ var responseBody = _ref3.responseBody,
3304
+ responseBodyType = _ref3.responseBodyType;
3424
3305
 
3425
- var renderToolbarTheme = function renderToolbarTheme() {
3426
- var theme = getThemePreference();
3427
- var checkbox = document.querySelector("#checkbox-dark-theme");
3428
- checkbox.checked = theme === DARK_THEME;
3429
- setTheme(theme);
3306
+ if (responseBodyType === "blob") {
3307
+ return responseBody;
3308
+ }
3430
3309
 
3431
- checkbox.onchange = function () {
3432
- if (checkbox.checked) {
3433
- setThemePreference(DARK_THEME);
3434
- setTheme(DARK_THEME);
3435
- } else {
3436
- setThemePreference(LIGHT_THEME);
3437
- setTheme(LIGHT_THEME);
3438
- }
3439
- };
3440
- };
3310
+ if (responseBodyType === "dataView") {
3311
+ return new Blob([cloneBuffer(responseBody.buffer)]);
3312
+ }
3441
3313
 
3442
- var getThemePreference = function getThemePreference() {
3443
- return themePreference.has() ? themePreference.get() : DARK_THEME;
3444
- };
3314
+ if (responseBodyType === "arrayBuffer") {
3315
+ return new Blob([cloneBuffer(responseBody)]);
3316
+ }
3317
+
3318
+ if (responseBodyType === "formData") {
3319
+ throw new Error("could not read FormData body as blob");
3320
+ }
3321
+
3322
+ return new Blob([String(responseBody)]);
3323
+ });
3324
+ });
3325
+
3326
+ var arrayBuffer = function arrayBuffer() {
3327
+ return _call$1(readBody, function (_ref4) {
3328
+ var responseBody = _ref4.responseBody,
3329
+ responseBodyType = _ref4.responseBodyType;
3330
+ return responseBodyType === "arrayBuffer" ? cloneBuffer(responseBody) : _call$1(blob, blobToArrayBuffer);
3331
+ });
3332
+ };
3333
+
3334
+ var formData = _async$8(function () {
3335
+ if (!hasFormData) {
3336
+ throw new Error("formData not supported");
3337
+ }
3338
+
3339
+ return _call$1(text, textToFormData);
3340
+ });
3341
+
3342
+ return {
3343
+ url: responseUrl,
3344
+ status: responseStatus,
3345
+ statusText: responseStatusText,
3346
+ headers: responseHeaders,
3347
+ text: text,
3348
+ json: json,
3349
+ blob: blob,
3350
+ arrayBuffer: arrayBuffer,
3351
+ formData: formData
3352
+ };
3353
+ });
3354
+ });
3445
3355
 
3446
- var setThemePreference = function setThemePreference(value) {
3447
- themePreference.set(value);
3448
- setTheme(value);
3449
- };
3356
+ var canUseBlob = function canUseBlob() {
3357
+ if (typeof window.FileReader !== "function") return false;
3358
+ if (typeof window.Blob !== "function") return false;
3450
3359
 
3451
- var setTheme = function setTheme(theme) {
3452
- document.querySelector("html").setAttribute("data-theme", theme);
3360
+ try {
3361
+ // eslint-disable-next-line no-new
3362
+ new Blob();
3363
+ return true;
3364
+ } catch (e) {
3365
+ return false;
3366
+ }
3453
3367
  };
3454
3368
 
3455
- var animationPreference = createPreference("animation");
3456
-
3457
- var renderToolbarAnimation = function renderToolbarAnimation() {
3458
- var animCheckbox = document.querySelector("#toggle-anims");
3459
- animCheckbox.checked = getAnimationPreference();
3369
+ var hasBlob = canUseBlob();
3370
+ var hasFormData = typeof window.FormData === "function";
3371
+ var hasArrayBuffer = typeof window.ArrayBuffer === "function";
3372
+ var hasSearchParams = typeof window.URLSearchParams === "function";
3460
3373
 
3461
- animCheckbox.onchange = function () {
3462
- setAnimationPreference(animCheckbox.checked);
3463
- onPreferenceChange(animCheckbox.checked);
3464
- };
3374
+ var createRequestError = function createRequestError(error, _ref5) {
3375
+ var url = _ref5.url;
3376
+ return new Error("error during xhr request on ".concat(url, ".\n--- error stack ---\n").concat(error.stack));
3377
+ };
3465
3378
 
3466
- onPreferenceChange(); // enable toolbar transition only after first render
3379
+ var createPromiseAndHooks = function createPromiseAndHooks() {
3380
+ var resolve;
3381
+ var reject;
3382
+ var promise = new Promise(function (res, rej) {
3383
+ resolve = function resolve(value) {
3384
+ promise.settled = true;
3385
+ res(value);
3386
+ };
3467
3387
 
3468
- setTimeout(function () {
3469
- document.querySelector("#toolbar").setAttribute("data-animate", "");
3388
+ reject = function reject(value) {
3389
+ promise.settled = true;
3390
+ rej(value);
3391
+ };
3470
3392
  });
3471
- };
3393
+ promise.resolve = resolve;
3394
+ promise.reject = reject;
3395
+ return promise;
3396
+ }; // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
3472
3397
 
3473
- var onPreferenceChange = function onPreferenceChange() {
3474
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getAnimationPreference();
3475
3398
 
3476
- if (value) {
3477
- enableAnimation();
3478
- } else {
3479
- disableAnimation();
3399
+ var computeWithCredentials = function computeWithCredentials(_ref6) {
3400
+ var credentials = _ref6.credentials,
3401
+ url = _ref6.url;
3402
+
3403
+ if (credentials === "same-origin") {
3404
+ return originSameAsGlobalOrigin(url);
3480
3405
  }
3481
- };
3482
3406
 
3483
- var getAnimationPreference = function getAnimationPreference() {
3484
- return animationPreference.has() ? animationPreference.get() : true;
3407
+ return credentials === "include";
3485
3408
  };
3486
3409
 
3487
- var setAnimationPreference = function setAnimationPreference(value) {
3488
- return animationPreference.set(value);
3410
+ var originSameAsGlobalOrigin = function originSameAsGlobalOrigin(url) {
3411
+ // if we cannot read globalOrigin from window.location.origin, let's consider it's ok
3412
+ if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== "object") return true;
3413
+ if (_typeof(window.location) !== "object") return true;
3414
+ var globalOrigin = window.location.origin;
3415
+ if (globalOrigin === "null") return true;
3416
+ return hrefToOrigin(url) === globalOrigin;
3489
3417
  };
3490
3418
 
3491
- var enableAnimation = function enableAnimation() {
3492
- document.documentElement.removeAttribute("data-animation-disabled");
3493
- };
3419
+ var detectBodyType = function detectBodyType(body) {
3420
+ if (!body) {
3421
+ return "";
3422
+ }
3494
3423
 
3495
- var disableAnimation = function disableAnimation() {
3496
- document.documentElement.setAttribute("data-animation-disabled", "");
3497
- };
3424
+ if (typeof body === "string") {
3425
+ return "text";
3426
+ }
3498
3427
 
3499
- var createHorizontalBreakpoint = function createHorizontalBreakpoint(breakpointValue) {
3500
- return createBreakpoint(windowWidthMeasure, breakpointValue);
3501
- };
3428
+ if (hasBlob && Blob.prototype.isPrototypeOf(body)) {
3429
+ return "blob";
3430
+ }
3502
3431
 
3503
- var createMeasure = function createMeasure(_ref) {
3504
- var compute = _ref.compute,
3505
- register = _ref.register;
3506
- var currentValue = compute();
3432
+ if (hasFormData && FormData.prototype.isPrototypeOf(body)) {
3433
+ return "formData";
3434
+ }
3507
3435
 
3508
- var get = function get() {
3509
- return compute();
3510
- };
3436
+ if (hasArrayBuffer) {
3437
+ if (hasBlob && isDataView(body)) {
3438
+ return "dataView";
3439
+ }
3511
3440
 
3512
- var changed = createSignal();
3441
+ if (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body)) {
3442
+ return "arrayBuffer";
3443
+ }
3444
+ }
3513
3445
 
3514
- var unregister = function unregister() {};
3446
+ if (hasSearchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
3447
+ return "searchParams";
3448
+ }
3515
3449
 
3516
- if (register) {
3517
- unregister = register(function () {
3518
- var value = compute();
3450
+ return "";
3451
+ }; // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#Example
3519
3452
 
3520
- if (value !== currentValue) {
3521
- var previousValue = value;
3522
- currentValue = value;
3523
- changed.notify(value, previousValue);
3524
- }
3525
- });
3526
- }
3527
3453
 
3528
- return {
3529
- get: get,
3530
- changed: changed,
3531
- unregister: unregister
3532
- };
3454
+ var getHeadersFromXHR = function getHeadersFromXHR(xhr) {
3455
+ var headerMap = {};
3456
+ var headersString = xhr.getAllResponseHeaders();
3457
+ if (headersString === "") return headerMap;
3458
+ var lines = headersString.trim().split(/[\r\n]+/);
3459
+ lines.forEach(function (line) {
3460
+ var parts = line.split(": ");
3461
+ var name = parts.shift();
3462
+ var value = parts.join(": ");
3463
+ headerMap[name.toLowerCase()] = value;
3464
+ });
3465
+ return headerMap;
3533
3466
  };
3534
3467
 
3535
- var createSignal = function createSignal() {
3536
- var callbackArray = [];
3537
-
3538
- var listen = function listen(callback) {
3539
- callbackArray.push(callback);
3540
- return function () {
3541
- var index = callbackArray.indexOf(callback);
3468
+ var hrefToOrigin = function hrefToOrigin(href) {
3469
+ var scheme = hrefToScheme(href);
3542
3470
 
3543
- if (index > -1) {
3544
- callbackArray.splice(index, 1);
3545
- }
3546
- };
3547
- };
3471
+ if (scheme === "file") {
3472
+ return "file://";
3473
+ }
3548
3474
 
3549
- var notify = function notify() {
3550
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3551
- args[_key] = arguments[_key];
3552
- }
3475
+ if (scheme === "http" || scheme === "https") {
3476
+ var secondProtocolSlashIndex = scheme.length + "://".length;
3477
+ var pathnameSlashIndex = href.indexOf("/", secondProtocolSlashIndex);
3478
+ if (pathnameSlashIndex === -1) return href;
3479
+ return href.slice(0, pathnameSlashIndex);
3480
+ }
3553
3481
 
3554
- callbackArray.slice().forEach(function (callback) {
3555
- callback.apply(void 0, args);
3556
- });
3557
- };
3482
+ return href.slice(0, scheme.length + 1);
3483
+ };
3558
3484
 
3559
- return {
3560
- listen: listen,
3561
- notify: notify
3562
- };
3485
+ var hrefToScheme = function hrefToScheme(href) {
3486
+ var colonIndex = href.indexOf(":");
3487
+ if (colonIndex === -1) return "";
3488
+ return href.slice(0, colonIndex);
3563
3489
  };
3564
3490
 
3565
- var windowWidthMeasure = createMeasure({
3566
- name: "window-width",
3567
- compute: function compute() {
3568
- return window.innerWidth;
3569
- },
3570
- register: function register(onchange) {
3571
- window.addEventListener("resize", onchange);
3572
- window.addEventListener("orientationchange", onchange);
3573
- return function () {
3574
- window.removeEventListener("resize", onchange);
3575
- window.removeEventListener("orientationchange", onchange);
3576
- };
3577
- }
3578
- });
3491
+ var isDataView = function isDataView(obj) {
3492
+ return obj && DataView.prototype.isPrototypeOf(obj);
3493
+ };
3579
3494
 
3580
- var createBreakpoint = function createBreakpoint(measure, breakpointValue) {
3581
- var getBreakpointState = function getBreakpointState() {
3582
- var value = measure.get();
3495
+ var isArrayBufferView = ArrayBuffer.isView || function () {
3496
+ var viewClasses = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"];
3497
+ return function (value) {
3498
+ return value && viewClasses.includes(Object.prototype.toString.call(value));
3499
+ };
3500
+ }();
3583
3501
 
3584
- if (value < breakpointValue) {
3585
- return "below";
3502
+ var textToFormData = function textToFormData(text) {
3503
+ var form = new FormData();
3504
+ text.trim().split("&").forEach(function (bytes) {
3505
+ if (bytes) {
3506
+ var split = bytes.split("=");
3507
+ var name = split.shift().replace(/\+/g, " ");
3508
+ var value = split.join("=").replace(/\+/g, " ");
3509
+ form.append(decodeURIComponent(name), decodeURIComponent(value));
3586
3510
  }
3511
+ });
3512
+ return form;
3513
+ };
3587
3514
 
3588
- if (value > breakpointValue) {
3589
- return "above";
3590
- }
3515
+ var blobToArrayBuffer = _async$8(function (blob) {
3516
+ var reader = new FileReader();
3517
+ var promise = fileReaderReady(reader);
3518
+ reader.readAsArrayBuffer(blob);
3519
+ return promise;
3520
+ });
3591
3521
 
3592
- return "equals";
3593
- };
3522
+ var blobToText = function blobToText(blob) {
3523
+ var reader = new FileReader();
3524
+ var promise = fileReaderReady(reader);
3525
+ reader.readAsText(blob);
3526
+ return promise;
3527
+ };
3594
3528
 
3595
- var currentBreakpointState = getBreakpointState();
3529
+ var arrayBufferToText = function arrayBufferToText(arrayBuffer) {
3530
+ var view = new Uint8Array(arrayBuffer);
3531
+ var chars = new Array(view.length);
3532
+ var i = 0;
3596
3533
 
3597
- var isAbove = function isAbove() {
3598
- return measure.get() > breakpointValue;
3599
- };
3534
+ while (i < view.length) {
3535
+ chars[i] = String.fromCharCode(view[i]);
3536
+ i++;
3537
+ }
3600
3538
 
3601
- var isBelow = function isBelow() {
3602
- return measure.get() < breakpointValue;
3603
- };
3539
+ return chars.join("");
3540
+ };
3604
3541
 
3605
- var breakpointChanged = createSignal();
3606
- measure.changed.listen(function () {
3607
- var breakpointState = getBreakpointState();
3542
+ var fileReaderReady = function fileReaderReady(reader) {
3543
+ return new Promise(function (resolve, reject) {
3544
+ reader.onload = function () {
3545
+ resolve(reader.result);
3546
+ };
3608
3547
 
3609
- if (breakpointState !== currentBreakpointState) {
3610
- var breakpointStatePrevious = currentBreakpointState;
3611
- currentBreakpointState = breakpointState;
3612
- breakpointChanged.notify(breakpointState, breakpointStatePrevious);
3613
- }
3548
+ reader.onerror = function () {
3549
+ reject(reader.error);
3550
+ };
3614
3551
  });
3615
- return {
3616
- isAbove: isAbove,
3617
- isBelow: isBelow,
3618
- changed: breakpointChanged
3619
- };
3620
- }; // const windowScrollTop = createMeasure({
3621
- // name: "window-scroll-top",
3622
- // compute: () => window.scrollTop,
3623
- // register: (onchange) => {
3624
- // window.addEventListener("scroll", onchange)
3625
- // return () => {
3626
- // window.removeEventListener("scroll", onchange)
3627
- // }
3628
- // },
3629
- // })
3552
+ };
3630
3553
 
3554
+ var cloneBuffer = function cloneBuffer(buffer) {
3555
+ if (buffer.slice) {
3556
+ return buffer.slice(0);
3557
+ }
3631
3558
 
3632
- var WINDOW_MEDIUM_WIDTH = 570;
3559
+ var view = new Uint8Array(buffer.byteLength);
3560
+ view.set(new Uint8Array(buffer));
3561
+ return view.buffer;
3562
+ };
3633
3563
 
3634
- var renderExecutionInToolbar = function renderExecutionInToolbar(_ref) {
3635
- var executedFileRelativeUrl = _ref.executedFileRelativeUrl; // reset file execution indicator ui
3564
+ var _excluded = ["mode"];
3636
3565
 
3637
- applyExecutionIndicator();
3638
- removeForceHideElement(document.querySelector("#execution-indicator")); // apply responsive design on fileInput if needed + add listener on resize screen
3566
+ function _await$8(value, then, direct) {
3567
+ if (direct) {
3568
+ return then ? then(value) : value;
3569
+ }
3639
3570
 
3640
- var input = document.querySelector("#file-input");
3641
- var fileWidthBreakpoint = createHorizontalBreakpoint(WINDOW_MEDIUM_WIDTH);
3571
+ if (!value || !value.then) {
3572
+ value = Promise.resolve(value);
3573
+ }
3642
3574
 
3643
- var handleFileWidthBreakpoint = function handleFileWidthBreakpoint() {
3644
- resizeInput(input, fileWidthBreakpoint);
3645
- };
3575
+ return then ? value.then(then) : value;
3576
+ }
3646
3577
 
3647
- handleFileWidthBreakpoint();
3648
- fileWidthBreakpoint.changed.listen(handleFileWidthBreakpoint);
3649
- input.value = executedFileRelativeUrl;
3650
- resizeInput(input, fileWidthBreakpoint);
3651
- activateToolbarSection(document.querySelector("#file"));
3652
- removeForceHideElement(document.querySelector("#file"));
3578
+ function _async$7(f) {
3579
+ return function () {
3580
+ for (var args = [], i = 0; i < arguments.length; i++) {
3581
+ args[i] = arguments[i];
3582
+ }
3653
3583
 
3654
- window.parent.__jsenv__.executionResultPromise.then(function (_ref2) {
3655
- var status = _ref2.status,
3656
- startTime = _ref2.startTime,
3657
- endTime = _ref2.endTime;
3658
- var execution = {
3659
- status: status,
3660
- startTime: startTime,
3661
- endTime: endTime
3662
- };
3663
- applyExecutionIndicator(execution);
3664
- var executionStorageKey = executedFileRelativeUrl;
3665
- var previousExecution = sessionStorage.hasOwnProperty(executionStorageKey) ? JSON.parse(sessionStorage.getItem(executionStorageKey)) : undefined;
3666
- notifyExecutionResult(executedFileRelativeUrl, execution, previousExecution);
3667
- sessionStorage.setItem(executedFileRelativeUrl, JSON.stringify(execution));
3668
- });
3669
- };
3584
+ try {
3585
+ return Promise.resolve(f.apply(this, args));
3586
+ } catch (e) {
3587
+ return Promise.reject(e);
3588
+ }
3589
+ };
3590
+ }
3670
3591
 
3671
- var applyExecutionIndicator = function applyExecutionIndicator() {
3672
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3673
- _ref3$status = _ref3.status,
3674
- status = _ref3$status === void 0 ? "running" : _ref3$status,
3675
- startTime = _ref3.startTime,
3676
- endTime = _ref3.endTime;
3592
+ var fetchNative = _async$7(function (url) {
3593
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3677
3594
 
3678
- var executionIndicator = document.querySelector("#execution-indicator");
3679
- enableVariant(executionIndicator, {
3680
- execution: status
3681
- });
3682
- var variantNode = executionIndicator.querySelector("[data-when-active]");
3595
+ var _ref$mode = _ref.mode,
3596
+ mode = _ref$mode === void 0 ? "cors" : _ref$mode,
3597
+ options = _objectWithoutProperties(_ref, _excluded);
3683
3598
 
3684
- variantNode.querySelector("button").onclick = function () {
3685
- return toggleTooltip(executionIndicator);
3686
- };
3599
+ return _await$8(window.fetch(url, _objectSpread2({
3600
+ mode: mode
3601
+ }, options)), function (response) {
3602
+ return {
3603
+ url: response.url,
3604
+ status: response.status,
3605
+ statusText: "",
3606
+ headers: responseToHeaders(response),
3607
+ text: function text() {
3608
+ return response.text();
3609
+ },
3610
+ json: function json() {
3611
+ return response.json();
3612
+ },
3613
+ blob: function blob() {
3614
+ return response.blob();
3615
+ },
3616
+ arrayBuffer: function arrayBuffer() {
3617
+ return response.arrayBuffer();
3618
+ },
3619
+ formData: function formData() {
3620
+ return response.formData();
3621
+ }
3622
+ };
3623
+ });
3624
+ });
3687
3625
 
3688
- variantNode.querySelector(".tooltip").textContent = computeText({
3689
- status: status,
3690
- startTime: startTime,
3691
- endTime: endTime
3626
+ var responseToHeaders = function responseToHeaders(response) {
3627
+ var headers = {};
3628
+ response.headers.forEach(function (value, name) {
3629
+ headers[name] = value;
3692
3630
  });
3631
+ return headers;
3693
3632
  };
3694
3633
 
3695
- var computeText = function computeText(_ref4) {
3696
- var status = _ref4.status,
3697
- startTime = _ref4.startTime,
3698
- endTime = _ref4.endTime;
3634
+ var fetchUrl = typeof window.fetch === "function" && typeof window.AbortController === "function" ? fetchNative : fetchUsingXHR;
3699
3635
 
3700
- if (status === "completed") {
3701
- return "Execution completed in ".concat(endTime - startTime, "ms");
3636
+ function _await$7(value, then, direct) {
3637
+ if (direct) {
3638
+ return then ? then(value) : value;
3702
3639
  }
3703
3640
 
3704
- if (status === "errored") {
3705
- return "Execution failed in ".concat(endTime - startTime, "ms");
3641
+ if (!value || !value.then) {
3642
+ value = Promise.resolve(value);
3706
3643
  }
3707
3644
 
3708
- if (status === "running") {
3709
- return "Executing...";
3710
- }
3645
+ return then ? value.then(then) : value;
3646
+ }
3711
3647
 
3712
- return "";
3713
- };
3648
+ function _async$6(f) {
3649
+ return function () {
3650
+ for (var args = [], i = 0; i < arguments.length; i++) {
3651
+ args[i] = arguments[i];
3652
+ }
3714
3653
 
3715
- var resizeInput = function resizeInput(input, fileWidthBreakpoint) {
3716
- var size = fileWidthBreakpoint.isBelow() ? 20 : 40;
3654
+ try {
3655
+ return Promise.resolve(f.apply(this, args));
3656
+ } catch (e) {
3657
+ return Promise.reject(e);
3658
+ }
3659
+ };
3660
+ }
3717
3661
 
3718
- if (input.value.length > size) {
3719
- input.style.width = "".concat(size, "ch");
3720
- } else {
3721
- input.style.width = "".concat(input.value.length, "ch");
3722
- }
3723
- };
3662
+ var fetchJson = _async$6(function (url) {
3663
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3664
+ return _await$7(fetchUrl(url, options), function (response) {
3665
+ return _await$7(response.json());
3666
+ });
3667
+ });
3724
3668
  /*
3725
3669
  * Prefer window.navigator.userAgentData before resorting to
3726
3670
  * window.navigator.userAgent because of
@@ -4005,7 +3949,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4005
3949
  return "data:".concat(mimeType, ";base64,").concat(window.btoa(text));
4006
3950
  };
4007
3951
 
4008
- function _await$5(value, then, direct) {
3952
+ function _await$6(value, then, direct) {
4009
3953
  if (direct) {
4010
3954
  return then ? then(value) : value;
4011
3955
  }
@@ -4066,7 +4010,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4066
4010
 
4067
4011
  document.body.appendChild(importmapScript);
4068
4012
  return _catch$4(function () {
4069
- return _await$5(executeWithScriptModuleInjection("import supported from \"".concat(specifier, "\"; window.__jsenv_runtime_test_importmap__ = supported")), function () {
4013
+ return _await$6(executeWithScriptModuleInjection("import supported from \"".concat(specifier, "\"; window.__jsenv_runtime_test_importmap__ = supported")), function () {
4070
4014
  document.body.removeChild(importmapScript);
4071
4015
  var supported = window.__jsenv_runtime_test_importmap__;
4072
4016
  delete window.__jsenv_runtime_test_importmap__;
@@ -4078,7 +4022,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4078
4022
  });
4079
4023
  });
4080
4024
 
4081
- function _await$4(value, then, direct) {
4025
+ function _await$5(value, then, direct) {
4082
4026
  if (direct) {
4083
4027
  return then ? then(value) : value;
4084
4028
  }
@@ -4121,8 +4065,8 @@ html[data-toolbar-visible] #toolbar-trigger {
4121
4065
  var supportsDynamicImport = _async$4(function () {
4122
4066
  var moduleSource = asBase64Url("export default 42");
4123
4067
  return _catch$3(function () {
4124
- return _await$4(executeWithScriptModuleInjection("window.__jsenv_runtime_test_dynamic_import__ = import(".concat(JSON.stringify(moduleSource), ")")), function () {
4125
- return _await$4(window.__jsenv_runtime_test_dynamic_import__, function (namespace) {
4068
+ return _await$5(executeWithScriptModuleInjection("window.__jsenv_runtime_test_dynamic_import__ = import(".concat(JSON.stringify(moduleSource), ")")), function () {
4069
+ return _await$5(window.__jsenv_runtime_test_dynamic_import__, function (namespace) {
4126
4070
  delete window.__jsenv_runtime_test_dynamic_import__;
4127
4071
  return namespace.default === 42;
4128
4072
  });
@@ -4132,7 +4076,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4132
4076
  });
4133
4077
  });
4134
4078
 
4135
- function _await$3(value, then, direct) {
4079
+ function _await$4(value, then, direct) {
4136
4080
  if (direct) {
4137
4081
  return then ? then(value) : value;
4138
4082
  }
@@ -4159,8 +4103,8 @@ html[data-toolbar-visible] #toolbar-trigger {
4159
4103
  }
4160
4104
 
4161
4105
  var supportsTopLevelAwait = function supportsTopLevelAwait() {
4162
- return _await$3(_catch$2(function () {
4163
- return _await$3(executeWithScriptModuleInjection("window.__jsenv_runtime_test_top_level_await__ = await Promise.resolve(42)"), function () {
4106
+ return _await$4(_catch$2(function () {
4107
+ return _await$4(executeWithScriptModuleInjection("window.__jsenv_runtime_test_top_level_await__ = await Promise.resolve(42)"), function () {
4164
4108
  var supported = window.__jsenv_runtime_test_top_level_await__ === 42;
4165
4109
  delete window.__jsenv_runtime_test_top_level_await__;
4166
4110
  return supported;
@@ -4170,7 +4114,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4170
4114
  }));
4171
4115
  };
4172
4116
 
4173
- function _await$2(value, then, direct) {
4117
+ function _await$3(value, then, direct) {
4174
4118
  if (direct) {
4175
4119
  return then ? then(value) : value;
4176
4120
  }
@@ -4214,8 +4158,8 @@ html[data-toolbar-visible] #toolbar-trigger {
4214
4158
  var jsonBase64Url = asBase64Url("42", "application/json");
4215
4159
  var moduleSource = asBase64Url("import data from \"".concat(jsonBase64Url, "\" assert { type: \"json\" }\n export default data"));
4216
4160
  return _catch$1(function () {
4217
- return _await$2(executeWithScriptModuleInjection("window.__jsenv_runtime_test_json_import_assertion__ = import(".concat(JSON.stringify(moduleSource), ")")), function () {
4218
- return _await$2(window.__jsenv_runtime_test_json_import_assertion__, function (namespace) {
4161
+ return _await$3(executeWithScriptModuleInjection("window.__jsenv_runtime_test_json_import_assertion__ = import(".concat(JSON.stringify(moduleSource), ")")), function () {
4162
+ return _await$3(window.__jsenv_runtime_test_json_import_assertion__, function (namespace) {
4219
4163
  var supported = namespace.default === 42;
4220
4164
  delete window.__jsenv_runtime_test_json_import_assertion__;
4221
4165
  return supported;
@@ -4226,7 +4170,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4226
4170
  });
4227
4171
  });
4228
4172
 
4229
- function _await$1(value, then, direct) {
4173
+ function _await$2(value, then, direct) {
4230
4174
  if (direct) {
4231
4175
  return then ? then(value) : value;
4232
4176
  }
@@ -4270,8 +4214,8 @@ html[data-toolbar-visible] #toolbar-trigger {
4270
4214
  var cssBase64Url = asBase64Url("p { color: red; }", "text/css");
4271
4215
  var moduleSource = asBase64Url("import css from \"".concat(cssBase64Url, "\" assert { type: \"css\" }\n export default css"));
4272
4216
  return _catch(function () {
4273
- return _await$1(executeWithScriptModuleInjection("window.__jsenv_runtime_test_css_import_assertion__ = import(".concat(JSON.stringify(moduleSource), ")")), function () {
4274
- return _await$1(window.__jsenv_runtime_test_css_import_assertion__, function (namespace) {
4217
+ return _await$2(executeWithScriptModuleInjection("window.__jsenv_runtime_test_css_import_assertion__ = import(".concat(JSON.stringify(moduleSource), ")")), function () {
4218
+ return _await$2(window.__jsenv_runtime_test_css_import_assertion__, function (namespace) {
4275
4219
  return namespace.default instanceof CSSStyleSheet;
4276
4220
  });
4277
4221
  });
@@ -4290,7 +4234,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4290
4234
  }
4291
4235
  };
4292
4236
 
4293
- function _await(value, then, direct) {
4237
+ function _await$1(value, then, direct) {
4294
4238
  if (direct) {
4295
4239
  return then ? then(value) : value;
4296
4240
  }
@@ -4316,7 +4260,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4316
4260
  };
4317
4261
  }
4318
4262
 
4319
- function _call$1(body, then, direct) {
4263
+ function _call(body, then, direct) {
4320
4264
  if (direct) {
4321
4265
  return then ? then(body()) : body();
4322
4266
  }
@@ -4339,15 +4283,16 @@ html[data-toolbar-visible] #toolbar-trigger {
4339
4283
  forceSource = _ref$forceSource === void 0 ? false : _ref$forceSource;
4340
4284
 
4341
4285
  var jsenvCompileProfileUrl = "/__jsenv_compile_profile__";
4342
- return _await(fetchJson(jsenvCompileProfileUrl), function (_ref2) {
4286
+ return _await$1(fetchJson(jsenvCompileProfileUrl), function (_ref2) {
4343
4287
  var jsenvDirectoryRelativeUrl = _ref2.jsenvDirectoryRelativeUrl,
4344
- inlineImportMapIntoHTML = _ref2.inlineImportMapIntoHTML;
4288
+ inlineImportMapIntoHTML = _ref2.inlineImportMapIntoHTML,
4289
+ availableCompileIds = _ref2.availableCompileIds;
4345
4290
 
4346
4291
  var _detectBrowser = detectBrowser(),
4347
4292
  name = _detectBrowser.name,
4348
4293
  version = _detectBrowser.version;
4349
4294
 
4350
- return _await(detectSupportedFeatures({
4295
+ return _await$1(detectSupportedFeatures({
4351
4296
  coverageHandledFromOutside: coverageHandledFromOutside,
4352
4297
  inlineImportMapIntoHTML: inlineImportMapIntoHTML
4353
4298
  }), function (featuresReport) {
@@ -4361,7 +4306,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4361
4306
  forceSource: forceSource,
4362
4307
  forceCompilation: forceCompilation
4363
4308
  };
4364
- return _await(fetchJson(jsenvCompileProfileUrl, {
4309
+ return _await$1(fetchJson(jsenvCompileProfileUrl, {
4365
4310
  method: "POST",
4366
4311
  headers: {
4367
4312
  "content-type": "application/json"
@@ -4373,9 +4318,10 @@ html[data-toolbar-visible] #toolbar-trigger {
4373
4318
  return {
4374
4319
  jsenvDirectoryRelativeUrl: jsenvDirectoryRelativeUrl,
4375
4320
  inlineImportMapIntoHTML: inlineImportMapIntoHTML,
4321
+ availableCompileIds: availableCompileIds,
4322
+ runtimeReport: runtimeReport,
4376
4323
  compileProfile: compileProfile,
4377
- compileId: compileId,
4378
- runtimeReport: runtimeReport
4324
+ compileId: compileId
4379
4325
  };
4380
4326
  });
4381
4327
  });
@@ -4394,7 +4340,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4394
4340
  // so that there is not module script loaded beore importmap is injected
4395
4341
  // it would log an error in chrome console and return undefined
4396
4342
 
4397
- return _await(supportsImportmap({
4343
+ return _await$1(supportsImportmap({
4398
4344
  // chrome supports inline but not remote importmap
4399
4345
  // https://github.com/WICG/import-maps/issues/235
4400
4346
  // at this stage we won't know if the html file will use
@@ -4407,15 +4353,15 @@ html[data-toolbar-visible] #toolbar-trigger {
4407
4353
  }), function (_supportsImportmap) {
4408
4354
  featuresReport.importmap = _supportsImportmap; // dynamic import
4409
4355
 
4410
- return _call$1(supportsDynamicImport, function (_supportsDynamicImpor) {
4356
+ return _call(supportsDynamicImport, function (_supportsDynamicImpor) {
4411
4357
  featuresReport["import_dynamic"] = _supportsDynamicImpor; // top level await
4412
4358
 
4413
- return _call$1(supportsTopLevelAwait, function (_supportsTopLevelAwai) {
4359
+ return _call(supportsTopLevelAwait, function (_supportsTopLevelAwai) {
4414
4360
  featuresReport["top_level_await"] = _supportsTopLevelAwai; // import assertions
4415
4361
 
4416
- return _call$1(supportsJsonImportAssertions, function (_supportsJsonImportAs) {
4362
+ return _call(supportsJsonImportAssertions, function (_supportsJsonImportAs) {
4417
4363
  featuresReport["import_assertion_type_json"] = _supportsJsonImportAs;
4418
- return _call$1(supportsCssImportAssertions, function (_supportsCssImportAss) {
4364
+ return _call(supportsCssImportAssertions, function (_supportsCssImportAss) {
4419
4365
  featuresReport["import_assertion_type_css"] = _supportsCssImportAss;
4420
4366
  return featuresReport;
4421
4367
  });
@@ -4473,7 +4419,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4473
4419
  var hasWarning = shouldCompile || shouldSwitchCompileId;
4474
4420
  enableVariant(filesCompilationRootNode, {
4475
4421
  filesCompilation: filesCompilation,
4476
- compilation_link: shouldSwitchCompileId ? "mismatch" : actualCompileId ? "source" : "compiled"
4422
+ compilation_link: shouldSwitchCompileId ? "mismatch" : actualCompileId ? "source" : expectedCompiledId ? "compiled" : "force"
4477
4423
  });
4478
4424
 
4479
4425
  if (filesCompilation === "yes") {
@@ -4485,7 +4431,11 @@ html[data-toolbar-visible] #toolbar-trigger {
4485
4431
  };
4486
4432
 
4487
4433
  filesCompilationRootNode.querySelector("a.link_to_compiled_files").onclick = function () {
4488
- window.parent.location.href = "/".concat(jsenvDirectoryRelativeUrl).concat(compileId, "/").concat(compileGroup.fileRelativeUrl);
4434
+ window.parent.location.href = "/".concat(jsenvDirectoryRelativeUrl).concat(expectedCompiledId, "/").concat(compileGroup.fileRelativeUrl);
4435
+ };
4436
+
4437
+ filesCompilationRootNode.querySelector("a.link_to_compilation_forced_files").onclick = function () {
4438
+ window.parent.location.href = "/".concat(jsenvDirectoryRelativeUrl, "force/").concat(compileGroup.fileRelativeUrl);
4489
4439
  };
4490
4440
 
4491
4441
  filesCompilationRootNode.querySelector("a.link_to_appropriate_files").onclick = function () {
@@ -4729,17 +4679,16 @@ html[data-toolbar-visible] #toolbar-trigger {
4729
4679
  document.querySelector("#overflow-menu").removeAttribute("data-animate");
4730
4680
  };
4731
4681
 
4732
- function _call(body, then, direct) {
4682
+ function _await(value, then, direct) {
4733
4683
  if (direct) {
4734
- return then ? then(body()) : body();
4684
+ return then ? then(value) : value;
4735
4685
  }
4736
4686
 
4737
- try {
4738
- var result = Promise.resolve(body());
4739
- return then ? result.then(then) : result;
4740
- } catch (e) {
4741
- return Promise.reject(e);
4687
+ if (!value || !value.then) {
4688
+ value = Promise.resolve(value);
4742
4689
  }
4690
+
4691
+ return then ? value.then(then) : value;
4743
4692
  }
4744
4693
 
4745
4694
  var toolbarVisibilityPreference = createPreference("toolbar");
@@ -4758,66 +4707,67 @@ html[data-toolbar-visible] #toolbar-trigger {
4758
4707
  };
4759
4708
  }
4760
4709
 
4761
- var renderToolbar = _async(function () {
4710
+ var renderToolbar = _async(function (_ref) {
4711
+ var exploringJSON = _ref.exploringJSON;
4762
4712
  var executedFileCompiledUrl = window.parent.location.href;
4763
4713
  var compileServerOrigin = window.parent.location.origin; // this should not block the whole toolbar rendering + interactivity
4764
4714
 
4765
- return _call(fetchExploringJson, function (exploringConfig) {
4766
- var jsenvDirectoryRelativeUrl = exploringConfig.jsenvDirectoryRelativeUrl,
4767
- livereloading = exploringConfig.livereloading;
4768
- var compileGroup = getCompileGroup({
4769
- executedFileCompiledUrl: executedFileCompiledUrl,
4770
- jsenvDirectoryRelativeUrl: jsenvDirectoryRelativeUrl,
4771
- compileServerOrigin: compileServerOrigin
4772
- });
4773
- var executedFileRelativeUrl = compileGroup.fileRelativeUrl;
4774
- var toolbarOverlay = document.querySelector("#toolbar-overlay");
4715
+ var jsenvDirectoryRelativeUrl = exploringJSON.jsenvDirectoryRelativeUrl,
4716
+ livereloading = exploringJSON.livereloading;
4717
+ var compileGroup = getCompileGroup({
4718
+ executedFileCompiledUrl: executedFileCompiledUrl,
4719
+ jsenvDirectoryRelativeUrl: jsenvDirectoryRelativeUrl,
4720
+ compileServerOrigin: compileServerOrigin
4721
+ });
4722
+ var executedFileRelativeUrl = compileGroup.fileRelativeUrl;
4723
+ var toolbarOverlay = document.querySelector("#toolbar-overlay");
4775
4724
 
4776
- toolbarOverlay.onclick = function () {
4777
- hideAllTooltip();
4778
- hideSettings();
4779
- };
4725
+ toolbarOverlay.onclick = function () {
4726
+ hideAllTooltip();
4727
+ hideSettings();
4728
+ };
4780
4729
 
4781
- var toolbarVisible = toolbarVisibilityPreference.has() ? toolbarVisibilityPreference.get() : true;
4730
+ var toolbarVisible = toolbarVisibilityPreference.has() ? toolbarVisibilityPreference.get() : true;
4782
4731
 
4783
- if (toolbarVisible) {
4784
- showToolbar({
4785
- animate: false
4786
- });
4787
- } else {
4788
- hideToolbar({
4789
- animate: false
4790
- });
4791
- }
4732
+ if (toolbarVisible) {
4733
+ showToolbar({
4734
+ animate: false
4735
+ });
4736
+ } else {
4737
+ hideToolbar({
4738
+ animate: false
4739
+ });
4740
+ }
4792
4741
 
4793
- document.querySelector(".toolbar-icon-wrapper").onclick = function () {
4794
- window.parent.location.href = "/";
4795
- };
4742
+ document.querySelector(".toolbar-icon-wrapper").onclick = function () {
4743
+ window.parent.location.href = "/";
4744
+ };
4796
4745
 
4797
- renderToolbarNotification();
4798
- makeToolbarResponsive();
4799
- renderToolbarSettings();
4800
- renderToolbarAnimation();
4801
- renderToolbarTheme();
4802
- renderExecutionInToolbar({
4803
- executedFileRelativeUrl: executedFileRelativeUrl
4804
- });
4805
- renderCompilationInToolbar({
4806
- compileGroup: compileGroup
4807
- }); // this might become active but we need to detect this somehow
4808
-
4809
- deactivateToolbarSection(document.querySelector("#file-list-link"));
4810
- initToolbarEventSource({
4811
- executedFileRelativeUrl: executedFileRelativeUrl,
4812
- livereloading: livereloading
4813
- }); // if user click enter or space quickly while closing toolbar
4814
- // it will cancel the closing
4815
- // that's why I used toggleToolbar and not hideToolbar
4816
-
4817
- document.querySelector("#button-close-toolbar").onclick = function () {
4818
- return toogleToolbar();
4819
- };
4746
+ renderToolbarNotification();
4747
+ makeToolbarResponsive();
4748
+ renderToolbarSettings();
4749
+ renderToolbarAnimation();
4750
+ renderToolbarTheme();
4751
+ renderExecutionInToolbar({
4752
+ executedFileRelativeUrl: executedFileRelativeUrl
4820
4753
  });
4754
+ renderCompilationInToolbar({
4755
+ compileGroup: compileGroup
4756
+ }); // this might become active but we need to detect this somehow
4757
+
4758
+ deactivateToolbarSection(document.querySelector("#file-list-link"));
4759
+ initToolbarEventSource({
4760
+ executedFileRelativeUrl: executedFileRelativeUrl,
4761
+ livereloading: livereloading
4762
+ }); // if user click enter or space quickly while closing toolbar
4763
+ // it will cancel the closing
4764
+ // that's why I used toggleToolbar and not hideToolbar
4765
+
4766
+ document.querySelector("#button-close-toolbar").onclick = function () {
4767
+ return toogleToolbar();
4768
+ };
4769
+
4770
+ return _await();
4821
4771
  });
4822
4772
 
4823
4773
  var toogleToolbar = function toogleToolbar() {
@@ -4840,9 +4790,9 @@ html[data-toolbar-visible] #toolbar-trigger {
4840
4790
 
4841
4791
 
4842
4792
  var showToolbar = function showToolbar() {
4843
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
4844
- _ref$animate = _ref.animate,
4845
- animate = _ref$animate === void 0 ? true : _ref$animate;
4793
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
4794
+ _ref2$animate = _ref2.animate,
4795
+ animate = _ref2$animate === void 0 ? true : _ref2$animate;
4846
4796
 
4847
4797
  toolbarVisibilityPreference.set(true);
4848
4798
 
@@ -4881,8 +4831,8 @@ html[data-toolbar-visible] #toolbar-trigger {
4881
4831
  var scrollEnd = scrollY + 40;
4882
4832
  startJavaScriptAnimation({
4883
4833
  duration: 300,
4884
- onProgress: function onProgress(_ref2) {
4885
- var progress = _ref2.progress;
4834
+ onProgress: function onProgress(_ref3) {
4835
+ var progress = _ref3.progress;
4886
4836
  var value = scrollY + (scrollEnd - scrollY) * progress;
4887
4837
  parentDocumentElement.scrollTop = value;
4888
4838
  }
@@ -4907,26 +4857,24 @@ html[data-toolbar-visible] #toolbar-trigger {
4907
4857
  };
4908
4858
  };
4909
4859
 
4910
- var getCompileGroup = function getCompileGroup(_ref3) {
4911
- var executedFileCompiledUrl = _ref3.executedFileCompiledUrl,
4912
- jsenvDirectoryRelativeUrl = _ref3.jsenvDirectoryRelativeUrl,
4913
- compileServerOrigin = _ref3.compileServerOrigin;
4914
- var outDirectoryServerUrl = String(new URL(jsenvDirectoryRelativeUrl, compileServerOrigin));
4860
+ var getCompileGroup = function getCompileGroup(_ref4) {
4861
+ var executedFileCompiledUrl = _ref4.executedFileCompiledUrl,
4862
+ jsenvDirectoryRelativeUrl = _ref4.jsenvDirectoryRelativeUrl,
4863
+ compileServerOrigin = _ref4.compileServerOrigin;
4864
+ var jsenvDirectoryServerUrl = new URL(jsenvDirectoryRelativeUrl, compileServerOrigin).href;
4915
4865
 
4916
- if (urlIsInsideOf(executedFileCompiledUrl, outDirectoryServerUrl)) {
4917
- var afterCompileDirectory = urlToRelativeUrl(executedFileCompiledUrl, outDirectoryServerUrl);
4866
+ if (urlIsInsideOf(executedFileCompiledUrl, jsenvDirectoryServerUrl)) {
4867
+ var afterCompileDirectory = urlToRelativeUrl(executedFileCompiledUrl, jsenvDirectoryServerUrl);
4918
4868
  var slashIndex = afterCompileDirectory.indexOf("/");
4919
4869
  var fileRelativeUrl = afterCompileDirectory.slice(slashIndex + 1);
4920
4870
  return {
4921
4871
  fileRelativeUrl: fileRelativeUrl,
4922
- jsenvDirectoryRelativeUrl: jsenvDirectoryRelativeUrl,
4923
4872
  compileId: afterCompileDirectory.slice(0, slashIndex)
4924
4873
  };
4925
4874
  }
4926
4875
 
4927
4876
  return {
4928
4877
  fileRelativeUrl: new URL(executedFileCompiledUrl).pathname.slice(1),
4929
- jsenvDirectoryRelativeUrl: jsenvDirectoryRelativeUrl,
4930
4878
  compileId: null
4931
4879
  };
4932
4880
  };
@@ -4968,14 +4916,13 @@ html[data-toolbar-visible] #toolbar-trigger {
4968
4916
  };
4969
4917
 
4970
4918
  window.toolbar = {
4971
- render: renderToolbar,
4972
4919
  show: showToolbar,
4973
4920
  hide: function hide() {
4974
4921
  return hideToolbar();
4975
4922
  }
4976
4923
  };
4977
- addExternalCommandCallback("renderToolbar", function () {
4978
- renderToolbar();
4924
+ addExternalCommandCallback("renderToolbar", function (data) {
4925
+ renderToolbar(data);
4979
4926
  });
4980
4927
  addExternalCommandCallback("showToolbar", function () {
4981
4928
  showToolbar();
@@ -4988,7 +4935,7 @@ html[data-toolbar-visible] #toolbar-trigger {
4988
4935
  };
4989
4936
  });
4990
4937
 
4991
- //# sourceMappingURL=toolbar.main_86335f90.js.map</script>
4938
+ //# sourceMappingURL=toolbar.main_279b3a68.js.map</script>
4992
4939
 
4993
4940
 
4994
4941
  </body></html>