@jsenv/core 24.2.2 → 24.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser_runtime/browser_runtime-fbd309a1.js +5137 -0
- package/dist/browser_runtime/browser_runtime-fbd309a1.js.map +1064 -0
- package/dist/{jsenv_browser_system.js → browser_system/browser_system-29eda202.js} +12 -12
- package/dist/{jsenv_browser_system.js.map → browser_system/browser_system-29eda202.js.map} +64 -64
- package/dist/build_manifest.js +12 -0
- package/dist/compile_proxy/assets/s.js-749702e8.map +242 -0
- package/dist/compile_proxy/compile_proxy-405777e6.html +2074 -0
- package/dist/compile_proxy/compile_proxy.html__inline__20-39c0801c.js.map +385 -0
- package/dist/{jsenv_event_source_client.js → event_source_client/event_source_client-9f14c8b9.js} +39 -21
- package/dist/event_source_client/event_source_client-9f14c8b9.js.map +127 -0
- package/dist/redirector/assets/s.js-749702e8.map +242 -0
- package/dist/redirector/redirector-237cd168.html +2118 -0
- package/dist/redirector/redirector.html__inline__15-33acb0b9.js.map +390 -0
- package/dist/toolbar/assets/compilation.css-209d68b4.map +12 -0
- package/dist/toolbar/assets/eventsource.css-38cd0a36.map +12 -0
- package/dist/toolbar/assets/execution.css-0ebe522f.map +12 -0
- package/dist/toolbar/assets/focus.css-3f9c156d.map +12 -0
- package/dist/toolbar/assets/light-theme.css-78b19a80.map +12 -0
- package/dist/toolbar/assets/overflow-menu.css-d9688a1c.map +12 -0
- package/dist/toolbar/assets/s.js-749702e8.map +242 -0
- package/dist/toolbar/assets/settings.css-2b81b245.map +12 -0
- package/dist/toolbar/assets/toolbar.main.css-846920e9.map +28 -0
- package/dist/toolbar/assets/tooltip.css-03395ee6.map +12 -0
- package/dist/toolbar/toolbar-29e91dcd.html +4779 -0
- package/dist/toolbar/toolbar.main-53e1ab2b.js.map +795 -0
- package/dist/toolbar_injector/assets/jsenv-logo-188b9ca6.svg +95 -0
- package/dist/{jsenv_toolbar_injector.js → toolbar_injector/toolbar_injector-0af91b43.js} +87 -65
- package/dist/toolbar_injector/toolbar_injector-0af91b43.js.map +294 -0
- package/main.js +0 -1
- package/package.json +2 -1
- package/readme.md +10 -7
- package/src/buildProject.js +6 -2
- package/src/dev_server.js +22 -130
- package/src/execute.js +7 -10
- package/src/executeTestPlan.js +7 -1
- package/src/importUsingChildProcess.js +1 -1
- package/src/internal/{runtime/detectBrowser/detectBrowser.js → browser_detection/browser_detection.js} +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectAndroid.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectChrome.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectEdge.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectElectron.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectFirefox.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectIOS.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectInternetExplorer.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectOpera.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectSafari.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/util.js +0 -0
- package/src/internal/{runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js → browser_feature_detection/browser_feature_detection.js} +116 -81
- package/src/internal/browser_feature_detection/compile_proxy.html +27 -0
- package/src/internal/browser_launcher/browser_runtime_report.js +75 -0
- package/src/internal/{browser-launcher → browser_launcher}/executeHtmlFile.js +13 -16
- package/src/internal/browser_launcher/from_playwright.js +314 -0
- package/src/internal/{browser-launcher → browser_launcher}/trackPageToNotify.js +0 -0
- package/src/internal/{browser-launcher/jsenv-browser-system.js → browser_runtime/browser_runtime.js} +4 -4
- package/src/internal/{runtime/createBrowserRuntime/createBrowserSystem.js → browser_runtime/browser_system.js} +3 -2
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/createBrowserRuntime.js +7 -5
- package/src/internal/{browser-launcher → browser_runtime}/displayErrorInDocument.js +0 -0
- package/src/internal/{browser-launcher → browser_runtime}/displayErrorNotification.js +2 -4
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/evalSource.js +2 -0
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/makeNamespaceTransferable.js +0 -0
- package/src/internal/{browser-utils → browser_utils}/fetch-browser.js +2 -0
- package/src/internal/{browser-utils → browser_utils}/fetchAndEvalUsingFetch.js +3 -0
- package/src/internal/{browser-utils → browser_utils}/fetchAndEvalUsingScript.js +2 -0
- package/src/internal/{browser-utils → browser_utils}/fetchJson.js +0 -0
- package/src/internal/{browser-utils → browser_utils}/fetchUsingXHR.js +4 -4
- package/src/internal/building/buildUsingRollup.js +4 -0
- package/src/internal/building/createJsenvRollupPlugin.js +19 -9
- package/src/internal/building/css/applyPostCss.js +19 -8
- package/src/internal/building/css/moveCssUrls.js +44 -0
- package/src/internal/building/css/parseCssRessource.js +67 -17
- package/src/internal/building/css/parseCssUrls.js +29 -23
- package/src/internal/building/css/postcss_plugin_url_visitor.js +11 -20
- package/src/internal/building/css/replaceCssUrls.js +38 -19
- package/src/internal/building/css_module.js +6 -10
- package/src/internal/building/html/parseHtmlRessource.js +37 -11
- package/src/internal/building/parseRessource.js +3 -0
- package/src/internal/building/ressource_builder.js +12 -3
- package/src/internal/compiling/babel_plugin_import_assertions.js +1 -2
- package/src/internal/compiling/html_source_file_service.js +23 -21
- package/src/internal/compiling/jsenvCompilerForHtml.js +15 -22
- package/src/internal/compiling/startCompileServer.js +37 -32
- package/src/internal/dev_server/event_source_client/event_source_connection.js +28 -19
- package/src/internal/dev_server/exploring/exploring.html +7 -2
- package/src/internal/dev_server/exploring/fetchExploringJson.js +4 -9
- package/src/internal/dev_server/redirector/redirector.html +37 -2
- package/src/internal/dev_server/toolbar/compilation/toolbar.compilation.js +4 -7
- package/src/internal/dev_server/toolbar/eventsource/toolbar.eventsource.js +2 -2
- package/src/internal/dev_server/toolbar/notification/toolbar.notification.js +75 -44
- package/src/internal/dev_server/toolbar/toolbar.html +31 -5
- package/src/internal/dev_server/toolbar/toolbar.injector.js +55 -36
- package/src/internal/dev_server/toolbar/toolbar.main.js +45 -31
- package/src/internal/dev_server/toolbar/util/fetching.js +1 -1
- package/src/internal/executing/executeConcurrently.js +15 -11
- package/src/internal/executing/executePlan.js +3 -2
- package/src/internal/generateGroupMap/one_runtime_compat.js +1 -1
- package/src/internal/generateGroupMap/runtime_compat_composition.js +1 -1
- package/src/internal/generateGroupMap/runtime_support.js +1 -1
- package/src/internal/jsenvInternalFiles.js +0 -26
- package/src/internal/jsenv_builds.js +19 -0
- package/src/internal/{runtime/node-feature-detect/feature-detect-dynamic-import.mjs → node_feature_detection/feature_detect_dynamic_import.mjs} +0 -0
- package/src/internal/{runtime/node-feature-detect/feature-detect-top-level-await.mjs → node_feature_detection/feature_detect_top_level_await.mjs} +0 -0
- package/src/internal/{runtime/node-feature-detect → node_feature_detection}/nodeSupportsDynamicImport.js +0 -0
- package/src/internal/node_feature_detection/nodeSupportsTopLevelAwait.js +16 -0
- package/src/internal/{runtime/createNodeRuntime/scanNodeRuntimeFeatures.js → node_feature_detection/node_feature_detection.js} +12 -13
- package/src/internal/{node-launcher → node_launcher}/createChildProcessOptions.js +0 -0
- package/src/internal/{node-launcher → node_launcher}/createControllableNodeProcess.js +9 -14
- package/src/internal/{node-launcher → node_launcher}/kill_process_tree.js +0 -0
- package/src/internal/node_launcher/node_runtime_report.js +71 -0
- package/src/internal/{node-launcher → node_launcher}/processOptions.js +0 -0
- package/src/internal/{runtime/detectNode → node_runtime}/detectNode.js +0 -0
- package/src/internal/{runtime/createNodeRuntime → node_runtime}/evalSource.js +1 -1
- package/src/internal/{runtime/createNodeRuntime → node_runtime}/fetchSource.js +1 -1
- package/src/internal/{node-launcher → node_runtime}/nodeControllableFile.mjs +14 -11
- package/src/internal/{runtime/createNodeRuntime/createNodeExecutionWithDynamicImport.js → node_runtime/node_execution_dynamic_import.js} +34 -6
- package/src/internal/node_runtime/node_execution_performance.js +67 -0
- package/src/internal/{runtime/createNodeRuntime/createNodeExecutionWithSystemJs.js → node_runtime/node_execution_systemjs.js} +38 -24
- package/src/internal/{runtime/createNodeRuntime/createNodeSystem.js → node_runtime/node_system.js} +4 -4
- package/src/internal/runtime/computeCompileIdFromGroupId.js +1 -0
- package/src/internal/runtime/resolveGroup.js +1 -1
- package/src/internal/runtime/resolveRuntimeGroup.js +2 -2
- package/src/internal/{semantic-versioning → semantic_versioning}/findHighestVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/findLowestVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/index.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/valueToVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionCompare.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsAbove.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsBelow.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsEqual.js +0 -0
- package/src/launchBrowser.js +33 -492
- package/src/launchNode.js +36 -7
- package/src/requireUsingChildProcess.js +1 -1
- package/dist/jsenv_compile_proxy.js +0 -1339
- package/dist/jsenv_compile_proxy.js.map +0 -378
- package/dist/jsenv_event_source_client.js.map +0 -126
- package/dist/jsenv_exploring_index.js +0 -1092
- package/dist/jsenv_exploring_index.js.map +0 -353
- package/dist/jsenv_exploring_redirector.js +0 -1386
- package/dist/jsenv_exploring_redirector.js.map +0 -384
- package/dist/jsenv_redirector.js +0 -1388
- package/dist/jsenv_redirector.js.map +0 -384
- package/dist/jsenv_toolbar.js +0 -2880
- package/dist/jsenv_toolbar.js.map +0 -771
- package/dist/jsenv_toolbar_injector.js.map +0 -301
- package/src/internal/browser-launcher/createSharing.js +0 -70
- package/src/internal/browser-launcher/jsenv_compile_proxy.html +0 -13
- package/src/internal/browser-launcher/jsenv_compile_proxy.js +0 -5
- package/src/internal/dev_server/event_source_client/event_source_client_file_info.js +0 -17
- package/src/internal/dev_server/exploring/exploring_file_info.js +0 -21
- package/src/internal/dev_server/redirector/redirector.js +0 -30
- package/src/internal/dev_server/redirector/redirector_file_info.js +0 -24
- package/src/internal/dev_server/toolbar/backtolist/toolbar.backtolist.js +0 -33
- package/src/internal/dev_server/toolbar/toolbar_file_info.js +0 -37
- package/src/internal/node-launcher/node-js-file.js +0 -110
- package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +0 -32
- package/src/internal/runtime/node-feature-detect/nodeSupportsTopLevelAwait.js +0 -18
- package/src/nodeRuntime.js +0 -5
package/dist/jsenv_toolbar.js
DELETED
|
@@ -1,2880 +0,0 @@
|
|
|
1
|
-
(function () {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var urlIsInsideOf = function urlIsInsideOf(url, otherUrl) {
|
|
5
|
-
var urlObject = new URL(url);
|
|
6
|
-
var otherUrlObject = new URL(otherUrl);
|
|
7
|
-
|
|
8
|
-
if (urlObject.origin !== otherUrlObject.origin) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
var urlPathname = urlObject.pathname;
|
|
13
|
-
var otherUrlPathname = otherUrlObject.pathname;
|
|
14
|
-
|
|
15
|
-
if (urlPathname === otherUrlPathname) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var isInside = urlPathname.startsWith(otherUrlPathname);
|
|
20
|
-
return isInside;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
var getCommonPathname = function getCommonPathname(pathname, otherPathname) {
|
|
24
|
-
var firstDifferentCharacterIndex = findFirstDifferentCharacterIndex(pathname, otherPathname); // pathname and otherpathname are exactly the same
|
|
25
|
-
|
|
26
|
-
if (firstDifferentCharacterIndex === -1) {
|
|
27
|
-
return pathname;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var commonString = pathname.slice(0, firstDifferentCharacterIndex + 1); // the first different char is at firstDifferentCharacterIndex
|
|
31
|
-
|
|
32
|
-
if (pathname.charAt(firstDifferentCharacterIndex) === "/") {
|
|
33
|
-
return commonString;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (otherPathname.charAt(firstDifferentCharacterIndex) === "/") {
|
|
37
|
-
return commonString;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var firstDifferentSlashIndex = commonString.lastIndexOf("/");
|
|
41
|
-
return pathname.slice(0, firstDifferentSlashIndex + 1);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
var findFirstDifferentCharacterIndex = function findFirstDifferentCharacterIndex(string, otherString) {
|
|
45
|
-
var maxCommonLength = Math.min(string.length, otherString.length);
|
|
46
|
-
var i = 0;
|
|
47
|
-
|
|
48
|
-
while (i < maxCommonLength) {
|
|
49
|
-
var char = string.charAt(i);
|
|
50
|
-
var otherChar = otherString.charAt(i);
|
|
51
|
-
|
|
52
|
-
if (char !== otherChar) {
|
|
53
|
-
return i;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
i++;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (string.length === otherString.length) {
|
|
60
|
-
return -1;
|
|
61
|
-
} // they differ at maxCommonLength
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return maxCommonLength;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
var pathnameToParentPathname = function pathnameToParentPathname(pathname) {
|
|
68
|
-
var slashLastIndex = pathname.lastIndexOf("/");
|
|
69
|
-
|
|
70
|
-
if (slashLastIndex === -1) {
|
|
71
|
-
return "/";
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return pathname.slice(0, slashLastIndex + 1);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
var urlToRelativeUrl = function urlToRelativeUrl(url, baseUrl) {
|
|
78
|
-
var urlObject = new URL(url);
|
|
79
|
-
var baseUrlObject = new URL(baseUrl);
|
|
80
|
-
|
|
81
|
-
if (urlObject.protocol !== baseUrlObject.protocol) {
|
|
82
|
-
var urlAsString = String(url);
|
|
83
|
-
return urlAsString;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (urlObject.username !== baseUrlObject.username || urlObject.password !== baseUrlObject.password || urlObject.host !== baseUrlObject.host) {
|
|
87
|
-
var afterUrlScheme = String(url).slice(urlObject.protocol.length);
|
|
88
|
-
return afterUrlScheme;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
var pathname = urlObject.pathname,
|
|
92
|
-
hash = urlObject.hash,
|
|
93
|
-
search = urlObject.search;
|
|
94
|
-
|
|
95
|
-
if (pathname === "/") {
|
|
96
|
-
var baseUrlRessourceWithoutLeadingSlash = baseUrlObject.pathname.slice(1);
|
|
97
|
-
return baseUrlRessourceWithoutLeadingSlash;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var basePathname = baseUrlObject.pathname;
|
|
101
|
-
var commonPathname = getCommonPathname(pathname, basePathname);
|
|
102
|
-
|
|
103
|
-
if (!commonPathname) {
|
|
104
|
-
var _urlAsString = String(url);
|
|
105
|
-
|
|
106
|
-
return _urlAsString;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
var specificPathname = pathname.slice(commonPathname.length);
|
|
110
|
-
var baseSpecificPathname = basePathname.slice(commonPathname.length);
|
|
111
|
-
|
|
112
|
-
if (baseSpecificPathname.includes("/")) {
|
|
113
|
-
var baseSpecificParentPathname = pathnameToParentPathname(baseSpecificPathname);
|
|
114
|
-
var relativeDirectoriesNotation = baseSpecificParentPathname.replace(/.*?\//g, "../");
|
|
115
|
-
|
|
116
|
-
var _relativeUrl = "".concat(relativeDirectoriesNotation).concat(specificPathname).concat(search).concat(hash);
|
|
117
|
-
|
|
118
|
-
return _relativeUrl;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
var relativeUrl = "".concat(specificPathname).concat(search).concat(hash);
|
|
122
|
-
return relativeUrl;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
var _defineProperty = (function (obj, key, value) {
|
|
126
|
-
// Shortcircuit the slow defineProperty path when possible.
|
|
127
|
-
// We are trying to avoid issues where setters defined on the
|
|
128
|
-
// prototype cause side effects under the fast path of simple
|
|
129
|
-
// assignment. By checking for existence of the property with
|
|
130
|
-
// the in operator, we can optimize most of this overhead away.
|
|
131
|
-
if (key in obj) {
|
|
132
|
-
Object.defineProperty(obj, key, {
|
|
133
|
-
value: value,
|
|
134
|
-
enumerable: true,
|
|
135
|
-
configurable: true,
|
|
136
|
-
writable: true
|
|
137
|
-
});
|
|
138
|
-
} else {
|
|
139
|
-
obj[key] = value;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return obj;
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
var createDetailedMessage = function createDetailedMessage(message) {
|
|
146
|
-
var details = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
147
|
-
var string = "".concat(message);
|
|
148
|
-
Object.keys(details).forEach(function (key) {
|
|
149
|
-
var value = details[key];
|
|
150
|
-
string += "\n--- ".concat(key, " ---\n").concat(Array.isArray(value) ? value.join("\n") : value);
|
|
151
|
-
});
|
|
152
|
-
return string;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
function ownKeys(object, enumerableOnly) {
|
|
156
|
-
var keys = Object.keys(object);
|
|
157
|
-
|
|
158
|
-
if (Object.getOwnPropertySymbols) {
|
|
159
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
160
|
-
|
|
161
|
-
if (enumerableOnly) {
|
|
162
|
-
symbols = symbols.filter(function (sym) {
|
|
163
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
keys.push.apply(keys, symbols);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return keys;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function _objectSpread2(target) {
|
|
174
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
175
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
176
|
-
|
|
177
|
-
if (i % 2) {
|
|
178
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
179
|
-
_defineProperty(target, key, source[key]);
|
|
180
|
-
});
|
|
181
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
182
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
183
|
-
} else {
|
|
184
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
185
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return target;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
var objectWithoutPropertiesLoose = (function (source, excluded) {
|
|
194
|
-
if (source === null) return {};
|
|
195
|
-
var target = {};
|
|
196
|
-
var sourceKeys = Object.keys(source);
|
|
197
|
-
var key;
|
|
198
|
-
var i;
|
|
199
|
-
|
|
200
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
201
|
-
key = sourceKeys[i];
|
|
202
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
203
|
-
target[key] = source[key];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return target;
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
var _objectWithoutProperties = (function (source, excluded) {
|
|
210
|
-
if (source === null) return {};
|
|
211
|
-
var target = objectWithoutPropertiesLoose(source, excluded);
|
|
212
|
-
var key;
|
|
213
|
-
var i;
|
|
214
|
-
|
|
215
|
-
if (Object.getOwnPropertySymbols) {
|
|
216
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
217
|
-
|
|
218
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
219
|
-
key = sourceSymbolKeys[i];
|
|
220
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
221
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
222
|
-
target[key] = source[key];
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return target;
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
var nativeTypeOf = function nativeTypeOf(obj) {
|
|
230
|
-
return typeof obj;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
var customTypeOf = function customTypeOf(obj) {
|
|
234
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? nativeTypeOf : customTypeOf;
|
|
238
|
-
|
|
239
|
-
function _await$5(value, then, direct) {
|
|
240
|
-
if (direct) {
|
|
241
|
-
return then ? then(value) : value;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (!value || !value.then) {
|
|
245
|
-
value = Promise.resolve(value);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return then ? value.then(then) : value;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function _async$6(f) {
|
|
252
|
-
return function () {
|
|
253
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
254
|
-
args[i] = arguments[i];
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
try {
|
|
258
|
-
return Promise.resolve(f.apply(this, args));
|
|
259
|
-
} catch (e) {
|
|
260
|
-
return Promise.reject(e);
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function _call$3(body, then, direct) {
|
|
266
|
-
if (direct) {
|
|
267
|
-
return then ? then(body()) : body();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
try {
|
|
271
|
-
var result = Promise.resolve(body());
|
|
272
|
-
return then ? result.then(then) : result;
|
|
273
|
-
} catch (e) {
|
|
274
|
-
return Promise.reject(e);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
var fetchUsingXHR = _async$6(function (url) {
|
|
279
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
280
|
-
signal = _ref.signal,
|
|
281
|
-
_ref$method = _ref.method,
|
|
282
|
-
method = _ref$method === void 0 ? "GET" : _ref$method,
|
|
283
|
-
_ref$credentials = _ref.credentials,
|
|
284
|
-
credentials = _ref$credentials === void 0 ? "same-origin" : _ref$credentials,
|
|
285
|
-
_ref$headers = _ref.headers,
|
|
286
|
-
headers = _ref$headers === void 0 ? {} : _ref$headers,
|
|
287
|
-
_ref$body = _ref.body,
|
|
288
|
-
body = _ref$body === void 0 ? null : _ref$body;
|
|
289
|
-
|
|
290
|
-
var headersPromise = createPromiseAndHooks();
|
|
291
|
-
var bodyPromise = createPromiseAndHooks();
|
|
292
|
-
var xhr = new XMLHttpRequest();
|
|
293
|
-
|
|
294
|
-
var failure = function failure(error) {
|
|
295
|
-
// if it was already resolved, we must reject the body promise
|
|
296
|
-
if (headersPromise.settled) {
|
|
297
|
-
bodyPromise.reject(error);
|
|
298
|
-
} else {
|
|
299
|
-
headersPromise.reject(error);
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
var cleanup = function cleanup() {
|
|
304
|
-
xhr.ontimeout = null;
|
|
305
|
-
xhr.onerror = null;
|
|
306
|
-
xhr.onload = null;
|
|
307
|
-
xhr.onreadystatechange = null;
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
xhr.ontimeout = function () {
|
|
311
|
-
cleanup();
|
|
312
|
-
failure(new Error("xhr request timeout on ".concat(url, ".")));
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
xhr.onerror = function (error) {
|
|
316
|
-
cleanup(); // unfortunately with have no clue why it fails
|
|
317
|
-
// might be cors for instance
|
|
318
|
-
|
|
319
|
-
failure(createRequestError(error, {
|
|
320
|
-
url: url
|
|
321
|
-
}));
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
xhr.onload = function () {
|
|
325
|
-
cleanup();
|
|
326
|
-
bodyPromise.resolve();
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
signal.addEventListener("abort", function () {
|
|
330
|
-
xhr.abort();
|
|
331
|
-
var abortError = new Error("aborted");
|
|
332
|
-
abortError.name = "AbortError";
|
|
333
|
-
failure(abortError);
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
xhr.onreadystatechange = function () {
|
|
337
|
-
// https://developer.mozilla.org/fr/docs/Web/API/XMLHttpRequest/readyState
|
|
338
|
-
var readyState = xhr.readyState;
|
|
339
|
-
|
|
340
|
-
if (readyState === 2) {
|
|
341
|
-
headersPromise.resolve();
|
|
342
|
-
} else if (readyState === 4) {
|
|
343
|
-
cleanup();
|
|
344
|
-
bodyPromise.resolve();
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
xhr.open(method, url, true);
|
|
349
|
-
Object.keys(headers).forEach(function (key) {
|
|
350
|
-
xhr.setRequestHeader(key, headers[key]);
|
|
351
|
-
});
|
|
352
|
-
xhr.withCredentials = computeWithCredentials({
|
|
353
|
-
credentials: credentials,
|
|
354
|
-
url: url
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
if ("responseType" in xhr && hasBlob) {
|
|
358
|
-
xhr.responseType = "blob";
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
xhr.send(body);
|
|
362
|
-
return _await$5(headersPromise, function () {
|
|
363
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseURL
|
|
364
|
-
var responseUrl = "responseURL" in xhr ? xhr.responseURL : headers["x-request-url"];
|
|
365
|
-
var responseStatus = xhr.status;
|
|
366
|
-
var responseStatusText = xhr.statusText;
|
|
367
|
-
var responseHeaders = getHeadersFromXHR(xhr);
|
|
368
|
-
|
|
369
|
-
var readBody = function readBody() {
|
|
370
|
-
return _await$5(bodyPromise, function () {
|
|
371
|
-
var status = xhr.status; // in Chrome on file:/// URLs, status is 0
|
|
372
|
-
|
|
373
|
-
if (status === 0) {
|
|
374
|
-
responseStatus = 200;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
var body = "response" in xhr ? xhr.response : xhr.responseText;
|
|
378
|
-
return {
|
|
379
|
-
responseBody: body,
|
|
380
|
-
responseBodyType: detectBodyType(body)
|
|
381
|
-
};
|
|
382
|
-
});
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
var text = function text() {
|
|
386
|
-
return _call$3(readBody, function (_ref2) {
|
|
387
|
-
var responseBody = _ref2.responseBody,
|
|
388
|
-
responseBodyType = _ref2.responseBodyType;
|
|
389
|
-
|
|
390
|
-
if (responseBodyType === "blob") {
|
|
391
|
-
return blobToText(responseBody);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (responseBodyType === "formData") {
|
|
395
|
-
throw new Error("could not read FormData body as text");
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return responseBodyType === "dataView" ? arrayBufferToText(responseBody.buffer) : responseBodyType === "arrayBuffer" ? arrayBufferToText(responseBody) : String(responseBody);
|
|
399
|
-
});
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
var json = function json() {
|
|
403
|
-
return _call$3(text, JSON.parse);
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
var blob = _async$6(function () {
|
|
407
|
-
if (!hasBlob) {
|
|
408
|
-
throw new Error("blob not supported");
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
return _call$3(readBody, function (_ref3) {
|
|
412
|
-
var responseBody = _ref3.responseBody,
|
|
413
|
-
responseBodyType = _ref3.responseBodyType;
|
|
414
|
-
|
|
415
|
-
if (responseBodyType === "blob") {
|
|
416
|
-
return responseBody;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
if (responseBodyType === "dataView") {
|
|
420
|
-
return new Blob([cloneBuffer(responseBody.buffer)]);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
if (responseBodyType === "arrayBuffer") {
|
|
424
|
-
return new Blob([cloneBuffer(responseBody)]);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
if (responseBodyType === "formData") {
|
|
428
|
-
throw new Error("could not read FormData body as blob");
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return new Blob([String(responseBody)]);
|
|
432
|
-
});
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
var arrayBuffer = function arrayBuffer() {
|
|
436
|
-
return _call$3(readBody, function (_ref4) {
|
|
437
|
-
var responseBody = _ref4.responseBody,
|
|
438
|
-
responseBodyType = _ref4.responseBodyType;
|
|
439
|
-
return responseBodyType === "arrayBuffer" ? cloneBuffer(responseBody) : _call$3(blob, blobToArrayBuffer);
|
|
440
|
-
});
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
var formData = _async$6(function () {
|
|
444
|
-
if (!hasFormData) {
|
|
445
|
-
throw new Error("formData not supported");
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
return _call$3(text, textToFormData);
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
return {
|
|
452
|
-
url: responseUrl,
|
|
453
|
-
status: responseStatus,
|
|
454
|
-
statusText: responseStatusText,
|
|
455
|
-
headers: responseHeaders,
|
|
456
|
-
text: text,
|
|
457
|
-
json: json,
|
|
458
|
-
blob: blob,
|
|
459
|
-
arrayBuffer: arrayBuffer,
|
|
460
|
-
formData: formData
|
|
461
|
-
};
|
|
462
|
-
});
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
var canUseBlob = function canUseBlob() {
|
|
466
|
-
if (typeof window.FileReader !== "function") return false;
|
|
467
|
-
if (typeof window.Blob !== "function") return false;
|
|
468
|
-
|
|
469
|
-
try {
|
|
470
|
-
// eslint-disable-next-line no-new
|
|
471
|
-
new Blob();
|
|
472
|
-
return true;
|
|
473
|
-
} catch (e) {
|
|
474
|
-
return false;
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
var hasBlob = canUseBlob();
|
|
479
|
-
var hasFormData = typeof window.FormData === "function";
|
|
480
|
-
var hasArrayBuffer = typeof window.ArrayBuffer === "function";
|
|
481
|
-
var hasSearchParams = typeof window.URLSearchParams === "function";
|
|
482
|
-
|
|
483
|
-
var createRequestError = function createRequestError(error, _ref5) {
|
|
484
|
-
var url = _ref5.url;
|
|
485
|
-
return new Error(createDetailedMessage("error during xhr request on ".concat(url, "."), _defineProperty({}, "error stack", error.stack)));
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
var createPromiseAndHooks = function createPromiseAndHooks() {
|
|
489
|
-
var resolve;
|
|
490
|
-
var reject;
|
|
491
|
-
var promise = new Promise(function (res, rej) {
|
|
492
|
-
resolve = function resolve(value) {
|
|
493
|
-
promise.settled = true;
|
|
494
|
-
res(value);
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
reject = function reject(value) {
|
|
498
|
-
promise.settled = true;
|
|
499
|
-
rej(value);
|
|
500
|
-
};
|
|
501
|
-
});
|
|
502
|
-
promise.resolve = resolve;
|
|
503
|
-
promise.reject = reject;
|
|
504
|
-
return promise;
|
|
505
|
-
}; // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
var computeWithCredentials = function computeWithCredentials(_ref6) {
|
|
509
|
-
var credentials = _ref6.credentials,
|
|
510
|
-
url = _ref6.url;
|
|
511
|
-
|
|
512
|
-
if (credentials === "same-origin") {
|
|
513
|
-
return originSameAsGlobalOrigin(url);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
return credentials === "include";
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
var originSameAsGlobalOrigin = function originSameAsGlobalOrigin(url) {
|
|
520
|
-
// if we cannot read globalOrigin from window.location.origin, let's consider it's ok
|
|
521
|
-
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== "object") return true;
|
|
522
|
-
if (_typeof(window.location) !== "object") return true;
|
|
523
|
-
var globalOrigin = window.location.origin;
|
|
524
|
-
if (globalOrigin === "null") return true;
|
|
525
|
-
return hrefToOrigin(url) === globalOrigin;
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
var detectBodyType = function detectBodyType(body) {
|
|
529
|
-
if (!body) {
|
|
530
|
-
return "";
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
if (typeof body === "string") {
|
|
534
|
-
return "text";
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
if (hasBlob && Blob.prototype.isPrototypeOf(body)) {
|
|
538
|
-
return "blob";
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
if (hasFormData && FormData.prototype.isPrototypeOf(body)) {
|
|
542
|
-
return "formData";
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
if (hasArrayBuffer) {
|
|
546
|
-
if (hasBlob && isDataView(body)) {
|
|
547
|
-
return "dataView";
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
if (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body)) {
|
|
551
|
-
return "arrayBuffer";
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
if (hasSearchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
556
|
-
return "searchParams";
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
return "";
|
|
560
|
-
}; // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#Example
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
var getHeadersFromXHR = function getHeadersFromXHR(xhr) {
|
|
564
|
-
var headerMap = {};
|
|
565
|
-
var headersString = xhr.getAllResponseHeaders();
|
|
566
|
-
if (headersString === "") return headerMap;
|
|
567
|
-
var lines = headersString.trim().split(/[\r\n]+/);
|
|
568
|
-
lines.forEach(function (line) {
|
|
569
|
-
var parts = line.split(": ");
|
|
570
|
-
var name = parts.shift();
|
|
571
|
-
var value = parts.join(": ");
|
|
572
|
-
headerMap[name.toLowerCase()] = value;
|
|
573
|
-
});
|
|
574
|
-
return headerMap;
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
var hrefToOrigin = function hrefToOrigin(href) {
|
|
578
|
-
var scheme = hrefToScheme(href);
|
|
579
|
-
|
|
580
|
-
if (scheme === "file") {
|
|
581
|
-
return "file://";
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
if (scheme === "http" || scheme === "https") {
|
|
585
|
-
var secondProtocolSlashIndex = scheme.length + "://".length;
|
|
586
|
-
var pathnameSlashIndex = href.indexOf("/", secondProtocolSlashIndex);
|
|
587
|
-
if (pathnameSlashIndex === -1) return href;
|
|
588
|
-
return href.slice(0, pathnameSlashIndex);
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
return href.slice(0, scheme.length + 1);
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
var hrefToScheme = function hrefToScheme(href) {
|
|
595
|
-
var colonIndex = href.indexOf(":");
|
|
596
|
-
if (colonIndex === -1) return "";
|
|
597
|
-
return href.slice(0, colonIndex);
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
var isDataView = function isDataView(obj) {
|
|
601
|
-
return obj && DataView.prototype.isPrototypeOf(obj);
|
|
602
|
-
};
|
|
603
|
-
|
|
604
|
-
var isArrayBufferView = ArrayBuffer.isView || function () {
|
|
605
|
-
var viewClasses = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"];
|
|
606
|
-
return function (value) {
|
|
607
|
-
return value && viewClasses.includes(Object.prototype.toString.call(value));
|
|
608
|
-
};
|
|
609
|
-
}();
|
|
610
|
-
|
|
611
|
-
var textToFormData = function textToFormData(text) {
|
|
612
|
-
var form = new FormData();
|
|
613
|
-
text.trim().split("&").forEach(function (bytes) {
|
|
614
|
-
if (bytes) {
|
|
615
|
-
var split = bytes.split("=");
|
|
616
|
-
var name = split.shift().replace(/\+/g, " ");
|
|
617
|
-
var value = split.join("=").replace(/\+/g, " ");
|
|
618
|
-
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
return form;
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
var blobToArrayBuffer = _async$6(function (blob) {
|
|
625
|
-
var reader = new FileReader();
|
|
626
|
-
var promise = fileReaderReady(reader);
|
|
627
|
-
reader.readAsArrayBuffer(blob);
|
|
628
|
-
return promise;
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
var blobToText = function blobToText(blob) {
|
|
632
|
-
var reader = new FileReader();
|
|
633
|
-
var promise = fileReaderReady(reader);
|
|
634
|
-
reader.readAsText(blob);
|
|
635
|
-
return promise;
|
|
636
|
-
};
|
|
637
|
-
|
|
638
|
-
var arrayBufferToText = function arrayBufferToText(arrayBuffer) {
|
|
639
|
-
var view = new Uint8Array(arrayBuffer);
|
|
640
|
-
var chars = new Array(view.length);
|
|
641
|
-
var i = 0;
|
|
642
|
-
|
|
643
|
-
while (i < view.length) {
|
|
644
|
-
chars[i] = String.fromCharCode(view[i]);
|
|
645
|
-
i++;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
return chars.join("");
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
var fileReaderReady = function fileReaderReady(reader) {
|
|
652
|
-
return new Promise(function (resolve, reject) {
|
|
653
|
-
reader.onload = function () {
|
|
654
|
-
resolve(reader.result);
|
|
655
|
-
};
|
|
656
|
-
|
|
657
|
-
reader.onerror = function () {
|
|
658
|
-
reject(reader.error);
|
|
659
|
-
};
|
|
660
|
-
});
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
var cloneBuffer = function cloneBuffer(buffer) {
|
|
664
|
-
if (buffer.slice) {
|
|
665
|
-
return buffer.slice(0);
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
var view = new Uint8Array(buffer.byteLength);
|
|
669
|
-
view.set(new Uint8Array(buffer));
|
|
670
|
-
return view.buffer;
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
var _excluded$1 = ["mode"];
|
|
674
|
-
|
|
675
|
-
function _await$4(value, then, direct) {
|
|
676
|
-
if (direct) {
|
|
677
|
-
return then ? then(value) : value;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
if (!value || !value.then) {
|
|
681
|
-
value = Promise.resolve(value);
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
return then ? value.then(then) : value;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
var fetchNative = _async$5(function (url) {
|
|
688
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
689
|
-
|
|
690
|
-
var _ref$mode = _ref.mode,
|
|
691
|
-
mode = _ref$mode === void 0 ? "cors" : _ref$mode,
|
|
692
|
-
options = _objectWithoutProperties(_ref, _excluded$1);
|
|
693
|
-
|
|
694
|
-
return _await$4(window.fetch(url, _objectSpread2({
|
|
695
|
-
mode: mode
|
|
696
|
-
}, options)), function (response) {
|
|
697
|
-
return {
|
|
698
|
-
url: response.url,
|
|
699
|
-
status: response.status,
|
|
700
|
-
statusText: "",
|
|
701
|
-
headers: responseToHeaders(response),
|
|
702
|
-
text: function text() {
|
|
703
|
-
return response.text();
|
|
704
|
-
},
|
|
705
|
-
json: function json() {
|
|
706
|
-
return response.json();
|
|
707
|
-
},
|
|
708
|
-
blob: function blob() {
|
|
709
|
-
return response.blob();
|
|
710
|
-
},
|
|
711
|
-
arrayBuffer: function arrayBuffer() {
|
|
712
|
-
return response.arrayBuffer();
|
|
713
|
-
},
|
|
714
|
-
formData: function formData() {
|
|
715
|
-
return response.formData();
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
});
|
|
719
|
-
});
|
|
720
|
-
|
|
721
|
-
function _async$5(f) {
|
|
722
|
-
return function () {
|
|
723
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
724
|
-
args[i] = arguments[i];
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
try {
|
|
728
|
-
return Promise.resolve(f.apply(this, args));
|
|
729
|
-
} catch (e) {
|
|
730
|
-
return Promise.reject(e);
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
var responseToHeaders = function responseToHeaders(response) {
|
|
736
|
-
var headers = {};
|
|
737
|
-
response.headers.forEach(function (value, name) {
|
|
738
|
-
headers[name] = value;
|
|
739
|
-
});
|
|
740
|
-
return headers;
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
var fetchUrl = typeof window.fetch === "function" && typeof window.AbortController === "function" ? fetchNative : fetchUsingXHR;
|
|
744
|
-
|
|
745
|
-
function _await$3(value, then, direct) {
|
|
746
|
-
if (direct) {
|
|
747
|
-
return then ? then(value) : value;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
if (!value || !value.then) {
|
|
751
|
-
value = Promise.resolve(value);
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
return then ? value.then(then) : value;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
function _async$4(f) {
|
|
758
|
-
return function () {
|
|
759
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
760
|
-
args[i] = arguments[i];
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
try {
|
|
764
|
-
return Promise.resolve(f.apply(this, args));
|
|
765
|
-
} catch (e) {
|
|
766
|
-
return Promise.reject(e);
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
var fetchJson = _async$4(function (url) {
|
|
772
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
773
|
-
return _await$3(fetchUrl(url, options), function (response) {
|
|
774
|
-
return _await$3(response.json());
|
|
775
|
-
});
|
|
776
|
-
});
|
|
777
|
-
|
|
778
|
-
function _await$2(value, then, direct) {
|
|
779
|
-
if (direct) {
|
|
780
|
-
return then ? then(value) : value;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
if (!value || !value.then) {
|
|
784
|
-
value = Promise.resolve(value);
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
return then ? value.then(then) : value;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
function _catch$1(body, recover) {
|
|
791
|
-
try {
|
|
792
|
-
var result = body();
|
|
793
|
-
} catch (e) {
|
|
794
|
-
return recover(e);
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
if (result && result.then) {
|
|
798
|
-
return result.then(void 0, recover);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
return result;
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
function _async$3(f) {
|
|
805
|
-
return function () {
|
|
806
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
807
|
-
args[i] = arguments[i];
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
try {
|
|
811
|
-
return Promise.resolve(f.apply(this, args));
|
|
812
|
-
} catch (e) {
|
|
813
|
-
return Promise.reject(e);
|
|
814
|
-
}
|
|
815
|
-
};
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
var fetchExploringJson = _async$3(function () {
|
|
819
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
820
|
-
signal = _ref.signal;
|
|
821
|
-
|
|
822
|
-
return _catch$1(function () {
|
|
823
|
-
return _await$2(fetchJson("/.jsenv/exploring.json", {
|
|
824
|
-
signal: signal
|
|
825
|
-
}));
|
|
826
|
-
}, function (e) {
|
|
827
|
-
if (signal && signal.aborted && e.name === "AbortError") {
|
|
828
|
-
throw e;
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
throw new Error(createDetailedMessage("Cannot communicate with exploring server due to a network error", _defineProperty({}, "error stack", e.stack)));
|
|
832
|
-
});
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
var updateIframeOverflowOnParentWindow = function updateIframeOverflowOnParentWindow() {
|
|
836
|
-
var aTooltipIsOpened = document.querySelector("[data-tooltip-visible]") || document.querySelector("[data-tooltip-auto-visible]");
|
|
837
|
-
var settingsAreOpened = document.querySelector("#settings[data-active]");
|
|
838
|
-
|
|
839
|
-
if (aTooltipIsOpened || settingsAreOpened) {
|
|
840
|
-
enableIframeOverflowOnParentWindow();
|
|
841
|
-
} else {
|
|
842
|
-
disableIframeOverflowOnParentWindow();
|
|
843
|
-
}
|
|
844
|
-
};
|
|
845
|
-
var iframeOverflowEnabled = false;
|
|
846
|
-
|
|
847
|
-
var enableIframeOverflowOnParentWindow = function enableIframeOverflowOnParentWindow() {
|
|
848
|
-
if (iframeOverflowEnabled) return;
|
|
849
|
-
iframeOverflowEnabled = true;
|
|
850
|
-
var iframe = getToolbarIframe();
|
|
851
|
-
var transitionDuration = iframe.style.transitionDuration;
|
|
852
|
-
setStyles(iframe, {
|
|
853
|
-
"height": "100%",
|
|
854
|
-
"transition-duration": "0ms"
|
|
855
|
-
});
|
|
856
|
-
|
|
857
|
-
if (transitionDuration) {
|
|
858
|
-
setTimeout(function () {
|
|
859
|
-
setStyles(iframe, {
|
|
860
|
-
"transition-duration": transitionDuration
|
|
861
|
-
});
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
};
|
|
865
|
-
|
|
866
|
-
var disableIframeOverflowOnParentWindow = function disableIframeOverflowOnParentWindow() {
|
|
867
|
-
if (!iframeOverflowEnabled) return;
|
|
868
|
-
iframeOverflowEnabled = false;
|
|
869
|
-
var iframe = getToolbarIframe();
|
|
870
|
-
var transitionDuration = iframe.style.transitionDuration;
|
|
871
|
-
setStyles(iframe, {
|
|
872
|
-
"height": "40px",
|
|
873
|
-
"transition-duration": "0ms"
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
if (transitionDuration) {
|
|
877
|
-
setTimeout(function () {
|
|
878
|
-
setStyles(iframe, {
|
|
879
|
-
"transition-duration": transitionDuration
|
|
880
|
-
});
|
|
881
|
-
});
|
|
882
|
-
}
|
|
883
|
-
};
|
|
884
|
-
|
|
885
|
-
var getToolbarIframe = function getToolbarIframe() {
|
|
886
|
-
var iframes = Array.from(window.parent.document.querySelectorAll("iframe"));
|
|
887
|
-
return iframes.find(function (iframe) {
|
|
888
|
-
return iframe.contentWindow === window;
|
|
889
|
-
});
|
|
890
|
-
};
|
|
891
|
-
var forceHideElement = function forceHideElement(element) {
|
|
892
|
-
element.setAttribute("data-force-hide", "");
|
|
893
|
-
};
|
|
894
|
-
var removeForceHideElement = function removeForceHideElement(element) {
|
|
895
|
-
element.removeAttribute("data-force-hide");
|
|
896
|
-
};
|
|
897
|
-
var setStyles = function setStyles(element, styles) {
|
|
898
|
-
var elementStyle = element.style;
|
|
899
|
-
var restoreStyles = Object.keys(styles).map(function (styleName) {
|
|
900
|
-
var restore;
|
|
901
|
-
|
|
902
|
-
if (styleName in elementStyle) {
|
|
903
|
-
var currentStyle = elementStyle[styleName];
|
|
904
|
-
|
|
905
|
-
restore = function restore() {
|
|
906
|
-
elementStyle[styleName] = currentStyle;
|
|
907
|
-
};
|
|
908
|
-
} else {
|
|
909
|
-
restore = function restore() {
|
|
910
|
-
delete elementStyle[styleName];
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
elementStyle[styleName] = styles[styleName];
|
|
915
|
-
return restore;
|
|
916
|
-
});
|
|
917
|
-
return function () {
|
|
918
|
-
restoreStyles.forEach(function (restore) {
|
|
919
|
-
return restore();
|
|
920
|
-
});
|
|
921
|
-
};
|
|
922
|
-
};
|
|
923
|
-
var toolbarSectionIsActive = function toolbarSectionIsActive(element) {
|
|
924
|
-
return element.hasAttribute("data-active");
|
|
925
|
-
};
|
|
926
|
-
var activateToolbarSection = function activateToolbarSection(element) {
|
|
927
|
-
element.setAttribute("data-active", "");
|
|
928
|
-
};
|
|
929
|
-
var deactivateToolbarSection = function deactivateToolbarSection(element) {
|
|
930
|
-
element.removeAttribute("data-active");
|
|
931
|
-
};
|
|
932
|
-
|
|
933
|
-
var startJavaScriptAnimation = function startJavaScriptAnimation(_ref6) {
|
|
934
|
-
var _ref6$duration = _ref6.duration,
|
|
935
|
-
duration = _ref6$duration === void 0 ? 300 : _ref6$duration,
|
|
936
|
-
_ref6$timingFunction = _ref6.timingFunction,
|
|
937
|
-
timingFunction = _ref6$timingFunction === void 0 ? function (t) {
|
|
938
|
-
return t;
|
|
939
|
-
} : _ref6$timingFunction,
|
|
940
|
-
_ref6$onProgress = _ref6.onProgress,
|
|
941
|
-
onProgress = _ref6$onProgress === void 0 ? function () {} : _ref6$onProgress,
|
|
942
|
-
_ref6$onCancel = _ref6.onCancel,
|
|
943
|
-
onCancel = _ref6$onCancel === void 0 ? function () {} : _ref6$onCancel,
|
|
944
|
-
_ref6$onComplete = _ref6.onComplete,
|
|
945
|
-
onComplete = _ref6$onComplete === void 0 ? function () {} : _ref6$onComplete;
|
|
946
|
-
|
|
947
|
-
if (isNaN(duration)) {
|
|
948
|
-
// console.warn(`duration must be a number, received ${duration}`)
|
|
949
|
-
return function () {};
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
duration = parseInt(duration, 10);
|
|
953
|
-
var startMs = performance.now();
|
|
954
|
-
var currentRequestAnimationFrameId;
|
|
955
|
-
var done = false;
|
|
956
|
-
var rawProgress = 0;
|
|
957
|
-
var progress = 0;
|
|
958
|
-
|
|
959
|
-
var handler = function handler() {
|
|
960
|
-
currentRequestAnimationFrameId = null;
|
|
961
|
-
var nowMs = performance.now();
|
|
962
|
-
rawProgress = Math.min((nowMs - startMs) / duration, 1);
|
|
963
|
-
progress = timingFunction(rawProgress);
|
|
964
|
-
done = rawProgress === 1;
|
|
965
|
-
onProgress({
|
|
966
|
-
done: done,
|
|
967
|
-
rawProgress: rawProgress,
|
|
968
|
-
progress: progress
|
|
969
|
-
});
|
|
970
|
-
|
|
971
|
-
if (done) {
|
|
972
|
-
onComplete();
|
|
973
|
-
} else {
|
|
974
|
-
currentRequestAnimationFrameId = window.requestAnimationFrame(handler);
|
|
975
|
-
}
|
|
976
|
-
};
|
|
977
|
-
|
|
978
|
-
handler();
|
|
979
|
-
|
|
980
|
-
var stop = function stop() {
|
|
981
|
-
if (currentRequestAnimationFrameId) {
|
|
982
|
-
window.cancelAnimationFrame(currentRequestAnimationFrameId);
|
|
983
|
-
currentRequestAnimationFrameId = null;
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
if (!done) {
|
|
987
|
-
done = true;
|
|
988
|
-
onCancel({
|
|
989
|
-
rawProgress: rawProgress,
|
|
990
|
-
progress: progress
|
|
991
|
-
});
|
|
992
|
-
}
|
|
993
|
-
};
|
|
994
|
-
|
|
995
|
-
return stop;
|
|
996
|
-
};
|
|
997
|
-
|
|
998
|
-
// handle data-last-interaction attr on html (focusring)
|
|
999
|
-
window.addEventListener("mousedown", function (mousedownEvent) {
|
|
1000
|
-
if (mousedownEvent.defaultPrevented) {
|
|
1001
|
-
return;
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
document.documentElement.setAttribute("data-last-interaction", "mouse");
|
|
1005
|
-
});
|
|
1006
|
-
window.addEventListener("touchstart", function (touchstartEvent) {
|
|
1007
|
-
if (touchstartEvent.defaultPrevented) {
|
|
1008
|
-
return;
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
document.documentElement.setAttribute("data-last-interaction", "mouse");
|
|
1012
|
-
});
|
|
1013
|
-
window.addEventListener("keydown", function (keydownEvent) {
|
|
1014
|
-
if (keydownEvent.defaultPrevented) {
|
|
1015
|
-
return;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
document.documentElement.setAttribute("data-last-interaction", "keyboard");
|
|
1019
|
-
});
|
|
1020
|
-
|
|
1021
|
-
var renderBackToListInToolbar = function renderBackToListInToolbar(_ref) {
|
|
1022
|
-
var outDirectoryRelativeUrl = _ref.outDirectoryRelativeUrl,
|
|
1023
|
-
exploringHtmlFileRelativeUrl = _ref.exploringHtmlFileRelativeUrl;
|
|
1024
|
-
var exploringHtmlFileUrl = "/".concat(outDirectoryRelativeUrl, "otherwise/").concat(exploringHtmlFileRelativeUrl);
|
|
1025
|
-
document.querySelector("#file-list-link a").href = exploringHtmlFileUrl;
|
|
1026
|
-
|
|
1027
|
-
document.querySelector("#file-list-link a").onclick = function (clickEvent) {
|
|
1028
|
-
if (clickEvent.defaultPrevented) {
|
|
1029
|
-
return;
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
if (isClickToOpenTab(clickEvent)) {
|
|
1033
|
-
return;
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
window.parent.location.href = exploringHtmlFileUrl;
|
|
1037
|
-
};
|
|
1038
|
-
};
|
|
1039
|
-
|
|
1040
|
-
var isClickToOpenTab = function isClickToOpenTab(clickEvent) {
|
|
1041
|
-
if (clickEvent.button !== 0) {
|
|
1042
|
-
// Chrome < 55 fires a click event when the middle mouse button is pressed
|
|
1043
|
-
return true;
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
if (clickEvent.metaKey) {
|
|
1047
|
-
return true;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
if (clickEvent.ctrlKey) {
|
|
1051
|
-
return true;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
return false;
|
|
1055
|
-
};
|
|
1056
|
-
|
|
1057
|
-
var createPreference = function createPreference(name) {
|
|
1058
|
-
return {
|
|
1059
|
-
has: function has() {
|
|
1060
|
-
return localStorage.hasOwnProperty(name);
|
|
1061
|
-
},
|
|
1062
|
-
get: function get() {
|
|
1063
|
-
return localStorage.hasOwnProperty(name) ? JSON.parse(localStorage.getItem(name)) : undefined;
|
|
1064
|
-
},
|
|
1065
|
-
set: function set(value) {
|
|
1066
|
-
return localStorage.setItem(name, JSON.stringify(value));
|
|
1067
|
-
}
|
|
1068
|
-
};
|
|
1069
|
-
};
|
|
1070
|
-
|
|
1071
|
-
var toggleTooltip = function toggleTooltip(element) {
|
|
1072
|
-
if (element.hasAttribute("data-tooltip-visible")) {
|
|
1073
|
-
hideTooltip(element);
|
|
1074
|
-
} else {
|
|
1075
|
-
showTooltip(element);
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
var hideTooltip = function hideTooltip(element) {
|
|
1079
|
-
element.removeAttribute("data-tooltip-visible");
|
|
1080
|
-
element.removeAttribute("data-tooltip-auto-visible");
|
|
1081
|
-
updateIframeOverflowOnParentWindow();
|
|
1082
|
-
};
|
|
1083
|
-
var showTooltip = function showTooltip(element) {
|
|
1084
|
-
element.setAttribute("data-tooltip-visible", "");
|
|
1085
|
-
updateIframeOverflowOnParentWindow();
|
|
1086
|
-
};
|
|
1087
|
-
var autoShowTooltip = function autoShowTooltip(element) {
|
|
1088
|
-
element.setAttribute("data-tooltip-auto-visible", "");
|
|
1089
|
-
updateIframeOverflowOnParentWindow();
|
|
1090
|
-
};
|
|
1091
|
-
var removeAutoShowTooltip = function removeAutoShowTooltip(element) {
|
|
1092
|
-
element.removeAttribute("data-tooltip-auto-visible");
|
|
1093
|
-
updateIframeOverflowOnParentWindow();
|
|
1094
|
-
};
|
|
1095
|
-
var hideAllTooltip = function hideAllTooltip() {
|
|
1096
|
-
var elementsWithTooltip = Array.from(document.querySelectorAll("[data-tooltip-visible]"));
|
|
1097
|
-
elementsWithTooltip.forEach(function (elementWithTooltip) {
|
|
1098
|
-
hideTooltip(elementWithTooltip);
|
|
1099
|
-
});
|
|
1100
|
-
};
|
|
1101
|
-
|
|
1102
|
-
var renderToolbarSettings = function renderToolbarSettings() {
|
|
1103
|
-
document.querySelector("#settings-button").onclick = toggleSettings;
|
|
1104
|
-
document.querySelector("#button-close-settings").onclick = toggleSettings;
|
|
1105
|
-
};
|
|
1106
|
-
|
|
1107
|
-
var toggleSettings = function toggleSettings() {
|
|
1108
|
-
if (settingsAreVisible()) {
|
|
1109
|
-
hideSettings();
|
|
1110
|
-
} else {
|
|
1111
|
-
showSettings();
|
|
1112
|
-
}
|
|
1113
|
-
};
|
|
1114
|
-
|
|
1115
|
-
var settingsAreVisible = function settingsAreVisible() {
|
|
1116
|
-
return toolbarSectionIsActive(document.querySelector("#settings"));
|
|
1117
|
-
};
|
|
1118
|
-
var hideSettings = function hideSettings() {
|
|
1119
|
-
deactivateToolbarSection(document.querySelector("#settings"));
|
|
1120
|
-
updateIframeOverflowOnParentWindow();
|
|
1121
|
-
};
|
|
1122
|
-
var showSettings = function showSettings() {
|
|
1123
|
-
activateToolbarSection(document.querySelector("#settings"));
|
|
1124
|
-
updateIframeOverflowOnParentWindow();
|
|
1125
|
-
};
|
|
1126
|
-
|
|
1127
|
-
var _excluded = ["clickToFocus", "clickToClose"];
|
|
1128
|
-
|
|
1129
|
-
function _await$1(value, then, direct) {
|
|
1130
|
-
if (direct) {
|
|
1131
|
-
return then ? then(value) : value;
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
if (!value || !value.then) {
|
|
1135
|
-
value = Promise.resolve(value);
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
return then ? value.then(then) : value;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
function _call$2(body, then, direct) {
|
|
1142
|
-
if (direct) {
|
|
1143
|
-
return then ? then(body()) : body();
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
try {
|
|
1147
|
-
var result = Promise.resolve(body());
|
|
1148
|
-
return then ? result.then(then) : result;
|
|
1149
|
-
} catch (e) {
|
|
1150
|
-
return Promise.reject(e);
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
var notificationPreference = createPreference("notification");
|
|
1155
|
-
|
|
1156
|
-
function _async$2(f) {
|
|
1157
|
-
return function () {
|
|
1158
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
1159
|
-
args[i] = arguments[i];
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
try {
|
|
1163
|
-
return Promise.resolve(f.apply(this, args));
|
|
1164
|
-
} catch (e) {
|
|
1165
|
-
return Promise.reject(e);
|
|
1166
|
-
}
|
|
1167
|
-
};
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
var arrayOfOpenedNotifications = [];
|
|
1171
|
-
var renderToolbarNotification = function renderToolbarNotification() {
|
|
1172
|
-
var notifCheckbox = document.querySelector("#toggle-notifs");
|
|
1173
|
-
notifCheckbox.checked = getNotificationPreference();
|
|
1174
|
-
|
|
1175
|
-
notifCheckbox.onchange = function () {
|
|
1176
|
-
setNotificationPreference(notifCheckbox.checked);
|
|
1177
|
-
|
|
1178
|
-
if (notifCheckbox.checked) {
|
|
1179
|
-
// request permission early
|
|
1180
|
-
// especially useful on firefox where you can request permission
|
|
1181
|
-
// only inside a user generated event such as this onchange handler
|
|
1182
|
-
requestPermission();
|
|
1183
|
-
} else {
|
|
1184
|
-
// slice because arrayOfOpenedNotifications can be mutated while looping
|
|
1185
|
-
arrayOfOpenedNotifications.slice().forEach(function (notification) {
|
|
1186
|
-
notification.close();
|
|
1187
|
-
});
|
|
1188
|
-
}
|
|
1189
|
-
};
|
|
1190
|
-
};
|
|
1191
|
-
var notifyExecutionResult = function notifyExecutionResult(executedFileRelativeUrl, execution, previousExecution) {
|
|
1192
|
-
var notificationEnabled = getNotificationPreference();
|
|
1193
|
-
if (!notificationEnabled) return;
|
|
1194
|
-
var notificationOptions = {
|
|
1195
|
-
lang: "en",
|
|
1196
|
-
icon: getFaviconHref(),
|
|
1197
|
-
clickToFocus: true,
|
|
1198
|
-
clickToClose: true
|
|
1199
|
-
};
|
|
1200
|
-
|
|
1201
|
-
if (execution.status === "errored") {
|
|
1202
|
-
if (previousExecution) {
|
|
1203
|
-
if (previousExecution.status === "completed") {
|
|
1204
|
-
notify("Broken", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
|
|
1205
|
-
body: "".concat(executedFileRelativeUrl, " execution now failing.")
|
|
1206
|
-
}));
|
|
1207
|
-
} else {
|
|
1208
|
-
notify("Still failing", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
|
|
1209
|
-
body: "".concat(executedFileRelativeUrl, " execution still failing.")
|
|
1210
|
-
}));
|
|
1211
|
-
}
|
|
1212
|
-
} else {
|
|
1213
|
-
notify("Failing", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
|
|
1214
|
-
body: "".concat(executedFileRelativeUrl, " execution failed.")
|
|
1215
|
-
}));
|
|
1216
|
-
}
|
|
1217
|
-
} else if (previousExecution && previousExecution.status === "errored") {
|
|
1218
|
-
notify("Fixed", _objectSpread2(_objectSpread2({}, notificationOptions), {}, {
|
|
1219
|
-
body: "".concat(executedFileRelativeUrl, " execution fixed.")
|
|
1220
|
-
}));
|
|
1221
|
-
}
|
|
1222
|
-
};
|
|
1223
|
-
var notificationAvailable = typeof window.Notification === "function";
|
|
1224
|
-
|
|
1225
|
-
var getNotificationPreference = function getNotificationPreference() {
|
|
1226
|
-
return notificationPreference.has() ? notificationPreference.get() : true;
|
|
1227
|
-
};
|
|
1228
|
-
|
|
1229
|
-
var setNotificationPreference = function setNotificationPreference(value) {
|
|
1230
|
-
return notificationPreference.set(value);
|
|
1231
|
-
};
|
|
1232
|
-
|
|
1233
|
-
var getFaviconHref = function getFaviconHref() {
|
|
1234
|
-
var link = document.querySelector('link[rel="icon"]');
|
|
1235
|
-
return link ? link.href : undefined;
|
|
1236
|
-
};
|
|
1237
|
-
|
|
1238
|
-
var notify = notificationAvailable ? function (title) {
|
|
1239
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1240
|
-
|
|
1241
|
-
var _ref$clickToFocus = _ref.clickToFocus,
|
|
1242
|
-
clickToFocus = _ref$clickToFocus === void 0 ? false : _ref$clickToFocus,
|
|
1243
|
-
_ref$clickToClose = _ref.clickToClose,
|
|
1244
|
-
clickToClose = _ref$clickToClose === void 0 ? false : _ref$clickToClose,
|
|
1245
|
-
options = _objectWithoutProperties(_ref, _excluded);
|
|
1246
|
-
|
|
1247
|
-
return _call$2(requestPermission, function (permission) {
|
|
1248
|
-
if (permission === "granted") {
|
|
1249
|
-
var notification = new Notification(title, options);
|
|
1250
|
-
arrayOfOpenedNotifications.push(notification);
|
|
1251
|
-
|
|
1252
|
-
notification.onclick = function () {
|
|
1253
|
-
// but if the user navigated inbetween
|
|
1254
|
-
// focusing window will show something else
|
|
1255
|
-
// in that case it could be great to do something
|
|
1256
|
-
// maybe like showing a message saying this execution
|
|
1257
|
-
// is no longer visible
|
|
1258
|
-
// we could also navigauate to this file execution but
|
|
1259
|
-
// there is no guarantee re-executing the file would give same output
|
|
1260
|
-
// and it would also trigger an other notification
|
|
1261
|
-
if (clickToFocus) window.focus();
|
|
1262
|
-
if (clickToClose) notification.close();
|
|
1263
|
-
};
|
|
1264
|
-
|
|
1265
|
-
notification.onclose = function () {
|
|
1266
|
-
var index = arrayOfOpenedNotifications.indexOf(notification);
|
|
1267
|
-
|
|
1268
|
-
if (index > -1) {
|
|
1269
|
-
arrayOfOpenedNotifications.splice(index, 1);
|
|
1270
|
-
}
|
|
1271
|
-
};
|
|
1272
|
-
|
|
1273
|
-
return notification;
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
return null;
|
|
1277
|
-
});
|
|
1278
|
-
} : function () {};
|
|
1279
|
-
var permissionPromise;
|
|
1280
|
-
var requestPermission = notificationAvailable ? _async$2(function () {
|
|
1281
|
-
if (permissionPromise) return permissionPromise;
|
|
1282
|
-
permissionPromise = Notification.requestPermission();
|
|
1283
|
-
return _await$1(permissionPromise, function (permission) {
|
|
1284
|
-
permissionPromise = undefined;
|
|
1285
|
-
return permission;
|
|
1286
|
-
});
|
|
1287
|
-
}) : function () {
|
|
1288
|
-
return Promise.resolve("denied");
|
|
1289
|
-
};
|
|
1290
|
-
|
|
1291
|
-
var DARK_THEME = "dark";
|
|
1292
|
-
var LIGHT_THEME = "light";
|
|
1293
|
-
var themePreference = createPreference("theme");
|
|
1294
|
-
var renderToolbarTheme = function renderToolbarTheme() {
|
|
1295
|
-
var theme = getThemePreference();
|
|
1296
|
-
var checkbox = document.querySelector("#checkbox-dark-theme");
|
|
1297
|
-
checkbox.checked = theme === DARK_THEME;
|
|
1298
|
-
setTheme(theme);
|
|
1299
|
-
|
|
1300
|
-
checkbox.onchange = function () {
|
|
1301
|
-
if (checkbox.checked) {
|
|
1302
|
-
setThemePreference(DARK_THEME);
|
|
1303
|
-
setTheme(DARK_THEME);
|
|
1304
|
-
} else {
|
|
1305
|
-
setThemePreference(LIGHT_THEME);
|
|
1306
|
-
setTheme(LIGHT_THEME);
|
|
1307
|
-
}
|
|
1308
|
-
};
|
|
1309
|
-
};
|
|
1310
|
-
|
|
1311
|
-
var getThemePreference = function getThemePreference() {
|
|
1312
|
-
return themePreference.has() ? themePreference.get() : DARK_THEME;
|
|
1313
|
-
};
|
|
1314
|
-
|
|
1315
|
-
var setThemePreference = function setThemePreference(value) {
|
|
1316
|
-
themePreference.set(value);
|
|
1317
|
-
setTheme(value);
|
|
1318
|
-
};
|
|
1319
|
-
|
|
1320
|
-
var setTheme = function setTheme(theme) {
|
|
1321
|
-
document.querySelector("html").setAttribute("data-theme", theme);
|
|
1322
|
-
};
|
|
1323
|
-
|
|
1324
|
-
var animationPreference = createPreference("animation");
|
|
1325
|
-
var renderToolbarAnimation = function renderToolbarAnimation() {
|
|
1326
|
-
var animCheckbox = document.querySelector("#toggle-anims");
|
|
1327
|
-
animCheckbox.checked = getAnimationPreference();
|
|
1328
|
-
|
|
1329
|
-
animCheckbox.onchange = function () {
|
|
1330
|
-
setAnimationPreference(animCheckbox.checked);
|
|
1331
|
-
onPreferenceChange(animCheckbox.checked);
|
|
1332
|
-
};
|
|
1333
|
-
|
|
1334
|
-
onPreferenceChange(); // enable toolbar transition only after first render
|
|
1335
|
-
|
|
1336
|
-
setTimeout(function () {
|
|
1337
|
-
document.querySelector("#toolbar").setAttribute("data-animate", "");
|
|
1338
|
-
});
|
|
1339
|
-
};
|
|
1340
|
-
|
|
1341
|
-
var onPreferenceChange = function onPreferenceChange() {
|
|
1342
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getAnimationPreference();
|
|
1343
|
-
|
|
1344
|
-
if (value) {
|
|
1345
|
-
enableAnimation();
|
|
1346
|
-
} else {
|
|
1347
|
-
disableAnimation();
|
|
1348
|
-
}
|
|
1349
|
-
};
|
|
1350
|
-
|
|
1351
|
-
var getAnimationPreference = function getAnimationPreference() {
|
|
1352
|
-
return animationPreference.has() ? animationPreference.get() : true;
|
|
1353
|
-
};
|
|
1354
|
-
|
|
1355
|
-
var setAnimationPreference = function setAnimationPreference(value) {
|
|
1356
|
-
return animationPreference.set(value);
|
|
1357
|
-
};
|
|
1358
|
-
|
|
1359
|
-
var enableAnimation = function enableAnimation() {
|
|
1360
|
-
document.documentElement.removeAttribute("data-animation-disabled");
|
|
1361
|
-
};
|
|
1362
|
-
|
|
1363
|
-
var disableAnimation = function disableAnimation() {
|
|
1364
|
-
document.documentElement.setAttribute("data-animation-disabled", "");
|
|
1365
|
-
};
|
|
1366
|
-
|
|
1367
|
-
var enableVariant = function enableVariant(rootNode, variables) {
|
|
1368
|
-
var nodesNotMatching = Array.from(rootNode.querySelectorAll("[".concat(attributeIndicatingACondition, "]")));
|
|
1369
|
-
nodesNotMatching.forEach(function (nodeNotMatching) {
|
|
1370
|
-
var conditionAttributeValue = nodeNotMatching.getAttribute(attributeIndicatingACondition);
|
|
1371
|
-
var matches = testCondition(conditionAttributeValue, variables);
|
|
1372
|
-
|
|
1373
|
-
if (matches) {
|
|
1374
|
-
renameAttribute(nodeNotMatching, attributeIndicatingACondition, attributeIndicatingAMatch);
|
|
1375
|
-
}
|
|
1376
|
-
});
|
|
1377
|
-
var nodesMatching = Array.from(rootNode.querySelectorAll("[".concat(attributeIndicatingAMatch, "]")));
|
|
1378
|
-
nodesMatching.forEach(function (nodeMatching) {
|
|
1379
|
-
var conditionAttributeValue = nodeMatching.getAttribute(attributeIndicatingAMatch);
|
|
1380
|
-
var matches = testCondition(conditionAttributeValue, variables);
|
|
1381
|
-
|
|
1382
|
-
if (!matches) {
|
|
1383
|
-
renameAttribute(nodeMatching, attributeIndicatingAMatch, attributeIndicatingACondition);
|
|
1384
|
-
}
|
|
1385
|
-
});
|
|
1386
|
-
};
|
|
1387
|
-
|
|
1388
|
-
var testCondition = function testCondition(conditionAttributeValue, variables) {
|
|
1389
|
-
var condition = parseCondition(conditionAttributeValue);
|
|
1390
|
-
return Object.keys(variables).some(function (key) {
|
|
1391
|
-
if (condition.key !== key) {
|
|
1392
|
-
return false;
|
|
1393
|
-
} // the condition do not specify a value, any value is ok
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
if (condition.value === undefined) {
|
|
1397
|
-
return true;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
if (condition.value === variables[key]) {
|
|
1401
|
-
return true;
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
return false;
|
|
1405
|
-
});
|
|
1406
|
-
};
|
|
1407
|
-
|
|
1408
|
-
var parseCondition = function parseCondition(conditionAttributeValue) {
|
|
1409
|
-
var colonIndex = conditionAttributeValue.indexOf(":");
|
|
1410
|
-
|
|
1411
|
-
if (colonIndex === -1) {
|
|
1412
|
-
return {
|
|
1413
|
-
key: conditionAttributeValue,
|
|
1414
|
-
value: undefined
|
|
1415
|
-
};
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
return {
|
|
1419
|
-
key: conditionAttributeValue.slice(0, colonIndex),
|
|
1420
|
-
value: conditionAttributeValue.slice(colonIndex + 1)
|
|
1421
|
-
};
|
|
1422
|
-
};
|
|
1423
|
-
|
|
1424
|
-
var attributeIndicatingACondition = "data-when";
|
|
1425
|
-
var attributeIndicatingAMatch = "data-when-active";
|
|
1426
|
-
|
|
1427
|
-
var renameAttribute = function renameAttribute(node, name, newName) {
|
|
1428
|
-
node.setAttribute(newName, node.getAttribute(name));
|
|
1429
|
-
node.removeAttribute(name);
|
|
1430
|
-
};
|
|
1431
|
-
|
|
1432
|
-
var createHorizontalBreakpoint = function createHorizontalBreakpoint(breakpointValue) {
|
|
1433
|
-
return createBreakpoint(windowWidthMeasure, breakpointValue);
|
|
1434
|
-
};
|
|
1435
|
-
|
|
1436
|
-
var createMeasure = function createMeasure(_ref) {
|
|
1437
|
-
var compute = _ref.compute,
|
|
1438
|
-
register = _ref.register;
|
|
1439
|
-
var currentValue = compute();
|
|
1440
|
-
|
|
1441
|
-
var get = function get() {
|
|
1442
|
-
return compute();
|
|
1443
|
-
};
|
|
1444
|
-
|
|
1445
|
-
var changed = createSignal();
|
|
1446
|
-
|
|
1447
|
-
var unregister = function unregister() {};
|
|
1448
|
-
|
|
1449
|
-
if (register) {
|
|
1450
|
-
unregister = register(function () {
|
|
1451
|
-
var value = compute();
|
|
1452
|
-
|
|
1453
|
-
if (value !== currentValue) {
|
|
1454
|
-
var previousValue = value;
|
|
1455
|
-
currentValue = value;
|
|
1456
|
-
changed.notify(value, previousValue);
|
|
1457
|
-
}
|
|
1458
|
-
});
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
return {
|
|
1462
|
-
get: get,
|
|
1463
|
-
changed: changed,
|
|
1464
|
-
unregister: unregister
|
|
1465
|
-
};
|
|
1466
|
-
};
|
|
1467
|
-
|
|
1468
|
-
var createSignal = function createSignal() {
|
|
1469
|
-
var callbackArray = [];
|
|
1470
|
-
|
|
1471
|
-
var listen = function listen(callback) {
|
|
1472
|
-
callbackArray.push(callback);
|
|
1473
|
-
return function () {
|
|
1474
|
-
var index = callbackArray.indexOf(callback);
|
|
1475
|
-
|
|
1476
|
-
if (index > -1) {
|
|
1477
|
-
callbackArray.splice(index, 1);
|
|
1478
|
-
}
|
|
1479
|
-
};
|
|
1480
|
-
};
|
|
1481
|
-
|
|
1482
|
-
var notify = function notify() {
|
|
1483
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1484
|
-
args[_key] = arguments[_key];
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
callbackArray.slice().forEach(function (callback) {
|
|
1488
|
-
callback.apply(void 0, args);
|
|
1489
|
-
});
|
|
1490
|
-
};
|
|
1491
|
-
|
|
1492
|
-
return {
|
|
1493
|
-
listen: listen,
|
|
1494
|
-
notify: notify
|
|
1495
|
-
};
|
|
1496
|
-
};
|
|
1497
|
-
|
|
1498
|
-
var windowWidthMeasure = createMeasure({
|
|
1499
|
-
name: "window-width",
|
|
1500
|
-
compute: function compute() {
|
|
1501
|
-
return window.innerWidth;
|
|
1502
|
-
},
|
|
1503
|
-
register: function register(onchange) {
|
|
1504
|
-
window.addEventListener("resize", onchange);
|
|
1505
|
-
window.addEventListener("orientationchange", onchange);
|
|
1506
|
-
return function () {
|
|
1507
|
-
window.removeEventListener("resize", onchange);
|
|
1508
|
-
window.removeEventListener("orientationchange", onchange);
|
|
1509
|
-
};
|
|
1510
|
-
}
|
|
1511
|
-
});
|
|
1512
|
-
|
|
1513
|
-
var createBreakpoint = function createBreakpoint(measure, breakpointValue) {
|
|
1514
|
-
var getBreakpointState = function getBreakpointState() {
|
|
1515
|
-
var value = measure.get();
|
|
1516
|
-
|
|
1517
|
-
if (value < breakpointValue) {
|
|
1518
|
-
return "below";
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
if (value > breakpointValue) {
|
|
1522
|
-
return "above";
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
return "equals";
|
|
1526
|
-
};
|
|
1527
|
-
|
|
1528
|
-
var currentBreakpointState = getBreakpointState();
|
|
1529
|
-
|
|
1530
|
-
var isAbove = function isAbove() {
|
|
1531
|
-
return measure.get() > breakpointValue;
|
|
1532
|
-
};
|
|
1533
|
-
|
|
1534
|
-
var isBelow = function isBelow() {
|
|
1535
|
-
return measure.get() < breakpointValue;
|
|
1536
|
-
};
|
|
1537
|
-
|
|
1538
|
-
var breakpointChanged = createSignal();
|
|
1539
|
-
measure.changed.listen(function () {
|
|
1540
|
-
var breakpointState = getBreakpointState();
|
|
1541
|
-
|
|
1542
|
-
if (breakpointState !== currentBreakpointState) {
|
|
1543
|
-
var breakpointStatePrevious = currentBreakpointState;
|
|
1544
|
-
currentBreakpointState = breakpointState;
|
|
1545
|
-
breakpointChanged.notify(breakpointState, breakpointStatePrevious);
|
|
1546
|
-
}
|
|
1547
|
-
});
|
|
1548
|
-
return {
|
|
1549
|
-
isAbove: isAbove,
|
|
1550
|
-
isBelow: isBelow,
|
|
1551
|
-
changed: breakpointChanged
|
|
1552
|
-
};
|
|
1553
|
-
}; // const windowScrollTop = createMeasure({
|
|
1554
|
-
// name: "window-scroll-top",
|
|
1555
|
-
// compute: () => window.scrollTop,
|
|
1556
|
-
// register: (onchange) => {
|
|
1557
|
-
// window.addEventListener("scroll", onchange)
|
|
1558
|
-
// return () => {
|
|
1559
|
-
// window.removeEventListener("scroll", onchange)
|
|
1560
|
-
// }
|
|
1561
|
-
// },
|
|
1562
|
-
// })
|
|
1563
|
-
|
|
1564
|
-
var WINDOW_MEDIUM_WIDTH = 570;
|
|
1565
|
-
var renderExecutionInToolbar = function renderExecutionInToolbar(_ref) {
|
|
1566
|
-
var executedFileRelativeUrl = _ref.executedFileRelativeUrl;
|
|
1567
|
-
// reset file execution indicator ui
|
|
1568
|
-
applyExecutionIndicator();
|
|
1569
|
-
removeForceHideElement(document.querySelector("#execution-indicator")); // apply responsive design on fileInput if needed + add listener on resize screen
|
|
1570
|
-
|
|
1571
|
-
var input = document.querySelector("#file-input");
|
|
1572
|
-
var fileWidthBreakpoint = createHorizontalBreakpoint(WINDOW_MEDIUM_WIDTH);
|
|
1573
|
-
|
|
1574
|
-
var handleFileWidthBreakpoint = function handleFileWidthBreakpoint() {
|
|
1575
|
-
resizeInput(input, fileWidthBreakpoint);
|
|
1576
|
-
};
|
|
1577
|
-
|
|
1578
|
-
handleFileWidthBreakpoint();
|
|
1579
|
-
fileWidthBreakpoint.changed.listen(handleFileWidthBreakpoint);
|
|
1580
|
-
input.value = executedFileRelativeUrl;
|
|
1581
|
-
resizeInput(input, fileWidthBreakpoint);
|
|
1582
|
-
activateToolbarSection(document.querySelector("#file"));
|
|
1583
|
-
removeForceHideElement(document.querySelector("#file"));
|
|
1584
|
-
|
|
1585
|
-
window.parent.__jsenv__.executionResultPromise.then(function (_ref2) {
|
|
1586
|
-
var status = _ref2.status,
|
|
1587
|
-
startTime = _ref2.startTime,
|
|
1588
|
-
endTime = _ref2.endTime;
|
|
1589
|
-
var execution = {
|
|
1590
|
-
status: status,
|
|
1591
|
-
startTime: startTime,
|
|
1592
|
-
endTime: endTime
|
|
1593
|
-
};
|
|
1594
|
-
applyExecutionIndicator(execution);
|
|
1595
|
-
var executionStorageKey = executedFileRelativeUrl;
|
|
1596
|
-
var previousExecution = sessionStorage.hasOwnProperty(executionStorageKey) ? JSON.parse(sessionStorage.getItem(executionStorageKey)) : undefined;
|
|
1597
|
-
notifyExecutionResult(executedFileRelativeUrl, execution, previousExecution);
|
|
1598
|
-
sessionStorage.setItem(executedFileRelativeUrl, JSON.stringify(execution));
|
|
1599
|
-
});
|
|
1600
|
-
};
|
|
1601
|
-
|
|
1602
|
-
var applyExecutionIndicator = function applyExecutionIndicator() {
|
|
1603
|
-
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1604
|
-
_ref3$status = _ref3.status,
|
|
1605
|
-
status = _ref3$status === void 0 ? "running" : _ref3$status,
|
|
1606
|
-
startTime = _ref3.startTime,
|
|
1607
|
-
endTime = _ref3.endTime;
|
|
1608
|
-
|
|
1609
|
-
var executionIndicator = document.querySelector("#execution-indicator");
|
|
1610
|
-
enableVariant(executionIndicator, {
|
|
1611
|
-
execution: status
|
|
1612
|
-
});
|
|
1613
|
-
var variantNode = executionIndicator.querySelector("[data-when-active]");
|
|
1614
|
-
|
|
1615
|
-
variantNode.querySelector("button").onclick = function () {
|
|
1616
|
-
return toggleTooltip(executionIndicator);
|
|
1617
|
-
};
|
|
1618
|
-
|
|
1619
|
-
variantNode.querySelector(".tooltip").textContent = computeText({
|
|
1620
|
-
status: status,
|
|
1621
|
-
startTime: startTime,
|
|
1622
|
-
endTime: endTime
|
|
1623
|
-
});
|
|
1624
|
-
};
|
|
1625
|
-
|
|
1626
|
-
var computeText = function computeText(_ref4) {
|
|
1627
|
-
var status = _ref4.status,
|
|
1628
|
-
startTime = _ref4.startTime,
|
|
1629
|
-
endTime = _ref4.endTime;
|
|
1630
|
-
|
|
1631
|
-
if (status === "completed") {
|
|
1632
|
-
return "Execution completed in ".concat(endTime - startTime, "ms");
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
if (status === "errored") {
|
|
1636
|
-
return "Execution failed in ".concat(endTime - startTime, "ms");
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
if (status === "running") {
|
|
1640
|
-
return "Executing...";
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
return "";
|
|
1644
|
-
};
|
|
1645
|
-
|
|
1646
|
-
var resizeInput = function resizeInput(input, fileWidthBreakpoint) {
|
|
1647
|
-
var size = fileWidthBreakpoint.isBelow() ? 20 : 40;
|
|
1648
|
-
|
|
1649
|
-
if (input.value.length > size) {
|
|
1650
|
-
input.style.width = "".concat(size, "ch");
|
|
1651
|
-
} else {
|
|
1652
|
-
input.style.width = "".concat(input.value.length, "ch");
|
|
1653
|
-
}
|
|
1654
|
-
};
|
|
1655
|
-
|
|
1656
|
-
var COMPILE_ID_OTHERWISE = "otherwise";
|
|
1657
|
-
|
|
1658
|
-
var computeCompileIdFromGroupId = function computeCompileIdFromGroupId(_ref) {
|
|
1659
|
-
var groupId = _ref.groupId,
|
|
1660
|
-
groupMap = _ref.groupMap;
|
|
1661
|
-
|
|
1662
|
-
if (typeof groupId === "undefined") {
|
|
1663
|
-
if (COMPILE_ID_OTHERWISE in groupMap) {
|
|
1664
|
-
return COMPILE_ID_OTHERWISE;
|
|
1665
|
-
}
|
|
1666
|
-
|
|
1667
|
-
var keys = Object.keys(groupMap);
|
|
1668
|
-
|
|
1669
|
-
if (keys.length === 1) {
|
|
1670
|
-
return keys[0];
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
throw new Error(createUnexpectedGroupIdMessage({
|
|
1674
|
-
groupMap: groupMap
|
|
1675
|
-
}));
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
if (groupId in groupMap === false) {
|
|
1679
|
-
throw new Error(createUnexpectedGroupIdMessage({
|
|
1680
|
-
groupId: groupId,
|
|
1681
|
-
groupMap: groupMap
|
|
1682
|
-
}));
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
return groupId;
|
|
1686
|
-
};
|
|
1687
|
-
|
|
1688
|
-
var createUnexpectedGroupIdMessage = function createUnexpectedGroupIdMessage(_ref2) {
|
|
1689
|
-
var _createDetailedMessag;
|
|
1690
|
-
|
|
1691
|
-
var compileId = _ref2.compileId,
|
|
1692
|
-
groupMap = _ref2.groupMap;
|
|
1693
|
-
return createDetailedMessage("unexpected groupId.", (_createDetailedMessag = {}, _defineProperty(_createDetailedMessag, "expected compiled id", Object.keys(groupMap)), _defineProperty(_createDetailedMessag, "received compile id", compileId), _createDetailedMessag));
|
|
1694
|
-
};
|
|
1695
|
-
|
|
1696
|
-
var firstMatch = function firstMatch(regexp, string) {
|
|
1697
|
-
var match = string.match(regexp);
|
|
1698
|
-
return match && match.length > 0 ? match[1] || undefined : undefined;
|
|
1699
|
-
};
|
|
1700
|
-
var secondMatch = function secondMatch(regexp, string) {
|
|
1701
|
-
var match = string.match(regexp);
|
|
1702
|
-
return match && match.length > 1 ? match[2] || undefined : undefined;
|
|
1703
|
-
};
|
|
1704
|
-
var userAgentToVersion = function userAgentToVersion(userAgent) {
|
|
1705
|
-
return firstMatch(/version\/(\d+(\.?_?\d+)+)/i, userAgent) || undefined;
|
|
1706
|
-
};
|
|
1707
|
-
|
|
1708
|
-
var detectAndroid = function detectAndroid() {
|
|
1709
|
-
return navigatorToBrowser$1(window.navigator);
|
|
1710
|
-
};
|
|
1711
|
-
|
|
1712
|
-
var navigatorToBrowser$1 = function navigatorToBrowser(_ref) {
|
|
1713
|
-
var userAgent = _ref.userAgent,
|
|
1714
|
-
appVersion = _ref.appVersion;
|
|
1715
|
-
|
|
1716
|
-
if (/(android)/i.test(userAgent)) {
|
|
1717
|
-
return {
|
|
1718
|
-
name: "android",
|
|
1719
|
-
version: firstMatch(/Android (\d+(\.?_?\d+)+)/i, appVersion)
|
|
1720
|
-
};
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1723
|
-
return null;
|
|
1724
|
-
};
|
|
1725
|
-
|
|
1726
|
-
var detectInternetExplorer = function detectInternetExplorer() {
|
|
1727
|
-
return userAgentToBrowser$5(window.navigator.userAgent);
|
|
1728
|
-
};
|
|
1729
|
-
|
|
1730
|
-
var userAgentToBrowser$5 = function userAgentToBrowser(userAgent) {
|
|
1731
|
-
if (/msie|trident/i.test(userAgent)) {
|
|
1732
|
-
return {
|
|
1733
|
-
name: "ie",
|
|
1734
|
-
version: firstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i, userAgent)
|
|
1735
|
-
};
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
return null;
|
|
1739
|
-
};
|
|
1740
|
-
|
|
1741
|
-
var detectOpera = function detectOpera() {
|
|
1742
|
-
return userAgentToBrowser$4(window.navigator.userAgent);
|
|
1743
|
-
};
|
|
1744
|
-
|
|
1745
|
-
var userAgentToBrowser$4 = function userAgentToBrowser(userAgent) {
|
|
1746
|
-
// opera below 13
|
|
1747
|
-
if (/opera/i.test(userAgent)) {
|
|
1748
|
-
return {
|
|
1749
|
-
name: "opera",
|
|
1750
|
-
version: userAgentToVersion(userAgent) || firstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i, userAgent)
|
|
1751
|
-
};
|
|
1752
|
-
} // opera above 13
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
if (/opr\/|opios/i.test(userAgent)) {
|
|
1756
|
-
return {
|
|
1757
|
-
name: "opera",
|
|
1758
|
-
version: firstMatch(/(?:opr|opios)[\s/](\S+)/i, userAgent) || userAgentToVersion(userAgent)
|
|
1759
|
-
};
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
return null;
|
|
1763
|
-
};
|
|
1764
|
-
|
|
1765
|
-
var detectEdge = function detectEdge() {
|
|
1766
|
-
return userAgentToBrowser$3(window.navigator.userAgent);
|
|
1767
|
-
};
|
|
1768
|
-
|
|
1769
|
-
var userAgentToBrowser$3 = function userAgentToBrowser(userAgent) {
|
|
1770
|
-
if (/edg([ea]|ios)/i.test(userAgent)) {
|
|
1771
|
-
return {
|
|
1772
|
-
name: "edge",
|
|
1773
|
-
version: secondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i, userAgent)
|
|
1774
|
-
};
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
return null;
|
|
1778
|
-
};
|
|
1779
|
-
|
|
1780
|
-
var detectFirefox = function detectFirefox() {
|
|
1781
|
-
return userAgentToBrowser$2(window.navigator.userAgent);
|
|
1782
|
-
};
|
|
1783
|
-
|
|
1784
|
-
var userAgentToBrowser$2 = function userAgentToBrowser(userAgent) {
|
|
1785
|
-
if (/firefox|iceweasel|fxios/i.test(userAgent)) {
|
|
1786
|
-
return {
|
|
1787
|
-
name: "firefox",
|
|
1788
|
-
version: firstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, userAgent)
|
|
1789
|
-
};
|
|
1790
|
-
}
|
|
1791
|
-
|
|
1792
|
-
return null;
|
|
1793
|
-
};
|
|
1794
|
-
|
|
1795
|
-
var detectChrome = function detectChrome() {
|
|
1796
|
-
return userAgentToBrowser$1(window.navigator.userAgent);
|
|
1797
|
-
};
|
|
1798
|
-
|
|
1799
|
-
var userAgentToBrowser$1 = function userAgentToBrowser(userAgent) {
|
|
1800
|
-
if (/chromium/i.test(userAgent)) {
|
|
1801
|
-
return {
|
|
1802
|
-
name: "chrome",
|
|
1803
|
-
version: firstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i, userAgent) || userAgentToVersion(userAgent)
|
|
1804
|
-
};
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
if (/chrome|crios|crmo/i.test(userAgent)) {
|
|
1808
|
-
return {
|
|
1809
|
-
name: "chrome",
|
|
1810
|
-
version: firstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i, userAgent)
|
|
1811
|
-
};
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
return null;
|
|
1815
|
-
};
|
|
1816
|
-
|
|
1817
|
-
var detectSafari = function detectSafari() {
|
|
1818
|
-
return userAgentToBrowser(window.navigator.userAgent);
|
|
1819
|
-
};
|
|
1820
|
-
|
|
1821
|
-
var userAgentToBrowser = function userAgentToBrowser(userAgent) {
|
|
1822
|
-
if (/safari|applewebkit/i.test(userAgent)) {
|
|
1823
|
-
return {
|
|
1824
|
-
name: "safari",
|
|
1825
|
-
version: userAgentToVersion(userAgent)
|
|
1826
|
-
};
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
return null;
|
|
1830
|
-
};
|
|
1831
|
-
|
|
1832
|
-
var detectElectron = function detectElectron() {
|
|
1833
|
-
return null;
|
|
1834
|
-
}; // TODO
|
|
1835
|
-
|
|
1836
|
-
var detectIOS = function detectIOS() {
|
|
1837
|
-
return navigatorToBrowser(window.navigator);
|
|
1838
|
-
};
|
|
1839
|
-
|
|
1840
|
-
var navigatorToBrowser = function navigatorToBrowser(_ref) {
|
|
1841
|
-
var userAgent = _ref.userAgent,
|
|
1842
|
-
appVersion = _ref.appVersion;
|
|
1843
|
-
|
|
1844
|
-
if (/iPhone;/.test(userAgent)) {
|
|
1845
|
-
return {
|
|
1846
|
-
name: "ios",
|
|
1847
|
-
version: firstMatch(/OS (\d+(\.?_?\d+)+)/i, appVersion)
|
|
1848
|
-
};
|
|
1849
|
-
}
|
|
1850
|
-
|
|
1851
|
-
if (/iPad;/.test(userAgent)) {
|
|
1852
|
-
return {
|
|
1853
|
-
name: "ios",
|
|
1854
|
-
version: firstMatch(/OS (\d+(\.?_?\d+)+)/i, appVersion)
|
|
1855
|
-
};
|
|
1856
|
-
}
|
|
1857
|
-
|
|
1858
|
-
return null;
|
|
1859
|
-
};
|
|
1860
|
-
|
|
1861
|
-
// https://github.com/Ahmdrza/detect-browser/blob/26254f85cf92795655a983bfd759d85f3de850c6/detect-browser.js#L1
|
|
1862
|
-
|
|
1863
|
-
var detectorCompose = function detectorCompose(detectors) {
|
|
1864
|
-
return function () {
|
|
1865
|
-
var i = 0;
|
|
1866
|
-
|
|
1867
|
-
while (i < detectors.length) {
|
|
1868
|
-
var _detector = detectors[i];
|
|
1869
|
-
i++;
|
|
1870
|
-
|
|
1871
|
-
var result = _detector();
|
|
1872
|
-
|
|
1873
|
-
if (result) {
|
|
1874
|
-
return result;
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
|
|
1878
|
-
return null;
|
|
1879
|
-
};
|
|
1880
|
-
};
|
|
1881
|
-
|
|
1882
|
-
var detector = detectorCompose([detectOpera, detectInternetExplorer, detectEdge, detectFirefox, detectChrome, detectSafari, detectElectron, detectIOS, detectAndroid]);
|
|
1883
|
-
var detectBrowser = function detectBrowser() {
|
|
1884
|
-
var _ref = detector() || {},
|
|
1885
|
-
_ref$name = _ref.name,
|
|
1886
|
-
name = _ref$name === void 0 ? "other" : _ref$name,
|
|
1887
|
-
_ref$version = _ref.version,
|
|
1888
|
-
version = _ref$version === void 0 ? "unknown" : _ref$version;
|
|
1889
|
-
|
|
1890
|
-
return {
|
|
1891
|
-
name: normalizeName(name),
|
|
1892
|
-
version: normalizeVersion(version)
|
|
1893
|
-
};
|
|
1894
|
-
};
|
|
1895
|
-
|
|
1896
|
-
var normalizeName = function normalizeName(name) {
|
|
1897
|
-
return name.toLowerCase();
|
|
1898
|
-
};
|
|
1899
|
-
|
|
1900
|
-
var normalizeVersion = function normalizeVersion(version) {
|
|
1901
|
-
if (version.indexOf(".") > -1) {
|
|
1902
|
-
var parts = version.split("."); // remove extraneous .
|
|
1903
|
-
|
|
1904
|
-
return parts.slice(0, 3).join(".");
|
|
1905
|
-
}
|
|
1906
|
-
|
|
1907
|
-
if (version.indexOf("_") > -1) {
|
|
1908
|
-
var _parts = version.split("_"); // remove extraneous _
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
return _parts.slice(0, 3).join("_");
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
return version;
|
|
1915
|
-
};
|
|
1916
|
-
|
|
1917
|
-
var valueToVersion = function valueToVersion(value) {
|
|
1918
|
-
if (typeof value === "number") {
|
|
1919
|
-
return numberToVersion(value);
|
|
1920
|
-
}
|
|
1921
|
-
|
|
1922
|
-
if (typeof value === "string") {
|
|
1923
|
-
return stringToVersion(value);
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
throw new TypeError("version must be a number or a string, got ".concat(value));
|
|
1927
|
-
};
|
|
1928
|
-
|
|
1929
|
-
var numberToVersion = function numberToVersion(number) {
|
|
1930
|
-
return {
|
|
1931
|
-
major: number,
|
|
1932
|
-
minor: 0,
|
|
1933
|
-
patch: 0
|
|
1934
|
-
};
|
|
1935
|
-
};
|
|
1936
|
-
|
|
1937
|
-
var stringToVersion = function stringToVersion(string) {
|
|
1938
|
-
if (string.indexOf(".") > -1) {
|
|
1939
|
-
var parts = string.split(".");
|
|
1940
|
-
return {
|
|
1941
|
-
major: Number(parts[0]),
|
|
1942
|
-
minor: parts[1] ? Number(parts[1]) : 0,
|
|
1943
|
-
patch: parts[2] ? Number(parts[2]) : 0
|
|
1944
|
-
};
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
if (isNaN(string)) {
|
|
1948
|
-
return {
|
|
1949
|
-
major: 0,
|
|
1950
|
-
minor: 0,
|
|
1951
|
-
patch: 0
|
|
1952
|
-
};
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
return {
|
|
1956
|
-
major: Number(string),
|
|
1957
|
-
minor: 0,
|
|
1958
|
-
patch: 0
|
|
1959
|
-
};
|
|
1960
|
-
};
|
|
1961
|
-
|
|
1962
|
-
var versionCompare = function versionCompare(versionA, versionB) {
|
|
1963
|
-
var semanticVersionA = valueToVersion(versionA);
|
|
1964
|
-
var semanticVersionB = valueToVersion(versionB);
|
|
1965
|
-
var majorDiff = semanticVersionA.major - semanticVersionB.major;
|
|
1966
|
-
|
|
1967
|
-
if (majorDiff > 0) {
|
|
1968
|
-
return majorDiff;
|
|
1969
|
-
}
|
|
1970
|
-
|
|
1971
|
-
if (majorDiff < 0) {
|
|
1972
|
-
return majorDiff;
|
|
1973
|
-
}
|
|
1974
|
-
|
|
1975
|
-
var minorDiff = semanticVersionA.minor - semanticVersionB.minor;
|
|
1976
|
-
|
|
1977
|
-
if (minorDiff > 0) {
|
|
1978
|
-
return minorDiff;
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
if (minorDiff < 0) {
|
|
1982
|
-
return minorDiff;
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
var patchDiff = semanticVersionA.patch - semanticVersionB.patch;
|
|
1986
|
-
|
|
1987
|
-
if (patchDiff > 0) {
|
|
1988
|
-
return patchDiff;
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
if (patchDiff < 0) {
|
|
1992
|
-
return patchDiff;
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
return 0;
|
|
1996
|
-
};
|
|
1997
|
-
|
|
1998
|
-
var versionIsBelow = function versionIsBelow(versionSupposedBelow, versionSupposedAbove) {
|
|
1999
|
-
return versionCompare(versionSupposedBelow, versionSupposedAbove) < 0;
|
|
2000
|
-
};
|
|
2001
|
-
|
|
2002
|
-
var findHighestVersion = function findHighestVersion() {
|
|
2003
|
-
for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2004
|
-
values[_key] = arguments[_key];
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
|
-
if (values.length === 0) throw new Error("missing argument");
|
|
2008
|
-
return values.reduce(function (highestVersion, value) {
|
|
2009
|
-
if (versionIsBelow(highestVersion, value)) {
|
|
2010
|
-
return value;
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
return highestVersion;
|
|
2014
|
-
});
|
|
2015
|
-
};
|
|
2016
|
-
|
|
2017
|
-
var resolveGroup = function resolveGroup(_ref, groupMap) {
|
|
2018
|
-
var name = _ref.name,
|
|
2019
|
-
version = _ref.version;
|
|
2020
|
-
return Object.keys(groupMap).find(function (compileIdCandidate) {
|
|
2021
|
-
var minRuntimeVersions = groupMap[compileIdCandidate].minRuntimeVersions;
|
|
2022
|
-
var versionForGroup = minRuntimeVersions[name];
|
|
2023
|
-
|
|
2024
|
-
if (!versionForGroup) {
|
|
2025
|
-
return false;
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
|
-
var highestVersion = findHighestVersion(version, versionForGroup);
|
|
2029
|
-
return highestVersion === version;
|
|
2030
|
-
});
|
|
2031
|
-
};
|
|
2032
|
-
|
|
2033
|
-
function _await(value, then, direct) {
|
|
2034
|
-
if (direct) {
|
|
2035
|
-
return then ? then(value) : value;
|
|
2036
|
-
}
|
|
2037
|
-
|
|
2038
|
-
if (!value || !value.then) {
|
|
2039
|
-
value = Promise.resolve(value);
|
|
2040
|
-
}
|
|
2041
|
-
|
|
2042
|
-
return then ? value.then(then) : value;
|
|
2043
|
-
}
|
|
2044
|
-
|
|
2045
|
-
function _async$1(f) {
|
|
2046
|
-
return function () {
|
|
2047
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
2048
|
-
args[i] = arguments[i];
|
|
2049
|
-
}
|
|
2050
|
-
|
|
2051
|
-
try {
|
|
2052
|
-
return Promise.resolve(f.apply(this, args));
|
|
2053
|
-
} catch (e) {
|
|
2054
|
-
return Promise.reject(e);
|
|
2055
|
-
}
|
|
2056
|
-
};
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
function _call$1(body, then, direct) {
|
|
2060
|
-
if (direct) {
|
|
2061
|
-
return then ? then(body()) : body();
|
|
2062
|
-
}
|
|
2063
|
-
|
|
2064
|
-
try {
|
|
2065
|
-
var result = Promise.resolve(body());
|
|
2066
|
-
return then ? result.then(then) : result;
|
|
2067
|
-
} catch (e) {
|
|
2068
|
-
return Promise.reject(e);
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
|
|
2072
|
-
function _invoke(body, then) {
|
|
2073
|
-
var result = body();
|
|
2074
|
-
|
|
2075
|
-
if (result && result.then) {
|
|
2076
|
-
return result.then(then);
|
|
2077
|
-
}
|
|
2078
|
-
|
|
2079
|
-
return then(result);
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
|
-
function _catch(body, recover) {
|
|
2083
|
-
try {
|
|
2084
|
-
var result = body();
|
|
2085
|
-
} catch (e) {
|
|
2086
|
-
return recover(e);
|
|
2087
|
-
}
|
|
2088
|
-
|
|
2089
|
-
if (result && result.then) {
|
|
2090
|
-
return result.then(void 0, recover);
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
return result;
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
var scanBrowserRuntimeFeatures = _async$1(function () {
|
|
2097
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
2098
|
-
_ref$coverageHandledF = _ref.coverageHandledFromOutside,
|
|
2099
|
-
coverageHandledFromOutside = _ref$coverageHandledF === void 0 ? false : _ref$coverageHandledF,
|
|
2100
|
-
_ref$failFastOnFeatur = _ref.failFastOnFeatureDetection,
|
|
2101
|
-
failFastOnFeatureDetection = _ref$failFastOnFeatur === void 0 ? false : _ref$failFastOnFeatur;
|
|
2102
|
-
|
|
2103
|
-
return _await(fetchJson("/.jsenv/__compile_server_meta__.json"), function (_ref2) {
|
|
2104
|
-
var outDirectoryRelativeUrl = _ref2.outDirectoryRelativeUrl,
|
|
2105
|
-
inlineImportMapIntoHTML = _ref2.inlineImportMapIntoHTML,
|
|
2106
|
-
customCompilerPatterns = _ref2.customCompilerPatterns,
|
|
2107
|
-
compileServerGroupMap = _ref2.compileServerGroupMap;
|
|
2108
|
-
var browser = detectBrowser();
|
|
2109
|
-
var compileId = computeCompileIdFromGroupId({
|
|
2110
|
-
groupId: resolveGroup(browser, compileServerGroupMap),
|
|
2111
|
-
groupMap: compileServerGroupMap
|
|
2112
|
-
});
|
|
2113
|
-
var groupInfo = compileServerGroupMap[compileId];
|
|
2114
|
-
var featuresReport = {
|
|
2115
|
-
importmap: undefined,
|
|
2116
|
-
dynamicImport: undefined,
|
|
2117
|
-
topLevelAwait: undefined,
|
|
2118
|
-
jsonImportAssertions: undefined,
|
|
2119
|
-
cssImportAssertions: undefined,
|
|
2120
|
-
newStylesheet: undefined
|
|
2121
|
-
};
|
|
2122
|
-
return _await(detectSupportedFeatures({
|
|
2123
|
-
featuresReport: featuresReport,
|
|
2124
|
-
failFastOnFeatureDetection: failFastOnFeatureDetection,
|
|
2125
|
-
inlineImportMapIntoHTML: inlineImportMapIntoHTML
|
|
2126
|
-
}), function () {
|
|
2127
|
-
return _await(pluginRequiredNamesFromGroupInfo(groupInfo, {
|
|
2128
|
-
featuresReport: featuresReport,
|
|
2129
|
-
coverageHandledFromOutside: coverageHandledFromOutside
|
|
2130
|
-
}), function (pluginRequiredNameArray) {
|
|
2131
|
-
var canAvoidCompilation = customCompilerPatterns.length === 0 && pluginRequiredNameArray.length === 0 && featuresReport.importmap && featuresReport.dynamicImport && featuresReport.topLevelAwait;
|
|
2132
|
-
return {
|
|
2133
|
-
canAvoidCompilation: canAvoidCompilation,
|
|
2134
|
-
featuresReport: featuresReport,
|
|
2135
|
-
customCompilerPatterns: customCompilerPatterns,
|
|
2136
|
-
pluginRequiredNameArray: pluginRequiredNameArray,
|
|
2137
|
-
inlineImportMapIntoHTML: inlineImportMapIntoHTML,
|
|
2138
|
-
outDirectoryRelativeUrl: outDirectoryRelativeUrl,
|
|
2139
|
-
compileId: compileId,
|
|
2140
|
-
browser: browser
|
|
2141
|
-
};
|
|
2142
|
-
});
|
|
2143
|
-
});
|
|
2144
|
-
});
|
|
2145
|
-
});
|
|
2146
|
-
|
|
2147
|
-
var detectSupportedFeatures = _async$1(function (_ref3) {
|
|
2148
|
-
var featuresReport = _ref3.featuresReport,
|
|
2149
|
-
failFastOnFeatureDetection = _ref3.failFastOnFeatureDetection,
|
|
2150
|
-
inlineImportMapIntoHTML = _ref3.inlineImportMapIntoHTML;
|
|
2151
|
-
// start testing importmap support first and not in paralell
|
|
2152
|
-
// so that there is not module script loaded beore importmap is injected
|
|
2153
|
-
// it would log an error in chrome console and return undefined
|
|
2154
|
-
return _await(supportsImportmap({
|
|
2155
|
-
// chrome supports inline but not remote importmap
|
|
2156
|
-
// https://github.com/WICG/import-maps/issues/235
|
|
2157
|
-
// at this stage we won't know if the html file will use
|
|
2158
|
-
// an importmap or not and if that importmap is inline or specified with an src
|
|
2159
|
-
// so we should test if browser support local and remote importmap.
|
|
2160
|
-
// But there exploring server can inline importmap by transforming html
|
|
2161
|
-
// and in that case we can test only the local importmap support
|
|
2162
|
-
// so we test importmap support and the remote one
|
|
2163
|
-
remote: !inlineImportMapIntoHTML
|
|
2164
|
-
}), function (importmap) {
|
|
2165
|
-
featuresReport.importmap = importmap;
|
|
2166
|
-
|
|
2167
|
-
if (!importmap && failFastOnFeatureDetection) {
|
|
2168
|
-
return;
|
|
2169
|
-
}
|
|
2170
|
-
|
|
2171
|
-
return _call$1(supportsDynamicImport, function (dynamicImport) {
|
|
2172
|
-
featuresReport.dynamicImport = dynamicImport;
|
|
2173
|
-
|
|
2174
|
-
if (!dynamicImport && failFastOnFeatureDetection) {
|
|
2175
|
-
return;
|
|
2176
|
-
}
|
|
2177
|
-
|
|
2178
|
-
return _call$1(supportsTopLevelAwait, function (topLevelAwait) {
|
|
2179
|
-
featuresReport.topLevelAwait = topLevelAwait;
|
|
2180
|
-
});
|
|
2181
|
-
});
|
|
2182
|
-
});
|
|
2183
|
-
});
|
|
2184
|
-
|
|
2185
|
-
var pluginRequiredNamesFromGroupInfo = _async$1(function (groupInfo, _ref4) {
|
|
2186
|
-
var featuresReport = _ref4.featuresReport,
|
|
2187
|
-
coverageHandledFromOutside = _ref4.coverageHandledFromOutside;
|
|
2188
|
-
var pluginRequiredNameArray = groupInfo.pluginRequiredNameArray;
|
|
2189
|
-
var requiredPluginNames = pluginRequiredNameArray.slice();
|
|
2190
|
-
|
|
2191
|
-
var markPluginAsSupported = function markPluginAsSupported(name) {
|
|
2192
|
-
var index = requiredPluginNames.indexOf(name);
|
|
2193
|
-
|
|
2194
|
-
if (index > -1) {
|
|
2195
|
-
requiredPluginNames.splice(index, 1);
|
|
2196
|
-
}
|
|
2197
|
-
}; // When instrumentation CAN be handed by playwright
|
|
2198
|
-
// https://playwright.dev/docs/api/class-chromiumcoverage#chromiumcoveragestartjscoverageoptions
|
|
2199
|
-
// coverageHandledFromOutside is true and "transform-instrument" becomes non mandatory
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
if (coverageHandledFromOutside) {
|
|
2203
|
-
markPluginAsSupported("transform-instrument");
|
|
2204
|
-
}
|
|
2205
|
-
|
|
2206
|
-
return _invoke(function () {
|
|
2207
|
-
if (pluginRequiredNameArray.includes("transform-import-assertions")) {
|
|
2208
|
-
return _call$1(supportsJsonImportAssertions, function (jsonImportAssertions) {
|
|
2209
|
-
featuresReport.jsonImportAssertions = jsonImportAssertions;
|
|
2210
|
-
return _call$1(supportsCssImportAssertions, function (cssImportAssertions) {
|
|
2211
|
-
featuresReport.cssImportAssertions = cssImportAssertions;
|
|
2212
|
-
|
|
2213
|
-
if (jsonImportAssertions && cssImportAssertions) {
|
|
2214
|
-
markPluginAsSupported("transform-import-assertions");
|
|
2215
|
-
}
|
|
2216
|
-
});
|
|
2217
|
-
});
|
|
2218
|
-
}
|
|
2219
|
-
}, function () {
|
|
2220
|
-
if (pluginRequiredNameArray.includes("new-stylesheet-as-jsenv-import")) {
|
|
2221
|
-
var newStylesheet = supportsNewStylesheet();
|
|
2222
|
-
featuresReport.newStylesheet = newStylesheet;
|
|
2223
|
-
markPluginAsSupported("new-stylesheet-as-jsenv-import");
|
|
2224
|
-
}
|
|
2225
|
-
|
|
2226
|
-
return requiredPluginNames;
|
|
2227
|
-
});
|
|
2228
|
-
});
|
|
2229
|
-
|
|
2230
|
-
var supportsNewStylesheet = function supportsNewStylesheet() {
|
|
2231
|
-
try {
|
|
2232
|
-
// eslint-disable-next-line no-new
|
|
2233
|
-
new CSSStyleSheet();
|
|
2234
|
-
return true;
|
|
2235
|
-
} catch (e) {
|
|
2236
|
-
return false;
|
|
2237
|
-
}
|
|
2238
|
-
};
|
|
2239
|
-
|
|
2240
|
-
var supportsImportmap = _async$1(function () {
|
|
2241
|
-
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
2242
|
-
_ref5$remote = _ref5.remote,
|
|
2243
|
-
remote = _ref5$remote === void 0 ? true : _ref5$remote;
|
|
2244
|
-
|
|
2245
|
-
var specifier = asBase64Url("export default false");
|
|
2246
|
-
var importMap = {
|
|
2247
|
-
imports: _defineProperty({}, specifier, asBase64Url("export default true"))
|
|
2248
|
-
};
|
|
2249
|
-
var importmapScript = document.createElement("script");
|
|
2250
|
-
var importmapString = JSON.stringify(importMap, null, " ");
|
|
2251
|
-
importmapScript.type = "importmap";
|
|
2252
|
-
|
|
2253
|
-
if (remote) {
|
|
2254
|
-
importmapScript.src = "data:application/json;base64,".concat(window.btoa(importmapString));
|
|
2255
|
-
} else {
|
|
2256
|
-
importmapScript.textContent = importmapString;
|
|
2257
|
-
}
|
|
2258
|
-
|
|
2259
|
-
document.body.appendChild(importmapScript);
|
|
2260
|
-
var scriptModule = document.createElement("script");
|
|
2261
|
-
scriptModule.type = "module";
|
|
2262
|
-
scriptModule.src = asBase64Url("import supported from \"".concat(specifier, "\"; window.__importmap_supported = supported"));
|
|
2263
|
-
return new Promise(function (resolve, reject) {
|
|
2264
|
-
scriptModule.onload = function () {
|
|
2265
|
-
var supported = window.__importmap_supported;
|
|
2266
|
-
delete window.__importmap_supported;
|
|
2267
|
-
document.body.removeChild(scriptModule);
|
|
2268
|
-
document.body.removeChild(importmapScript);
|
|
2269
|
-
resolve(supported);
|
|
2270
|
-
};
|
|
2271
|
-
|
|
2272
|
-
scriptModule.onerror = function () {
|
|
2273
|
-
document.body.removeChild(scriptModule);
|
|
2274
|
-
document.body.removeChild(importmapScript);
|
|
2275
|
-
reject();
|
|
2276
|
-
};
|
|
2277
|
-
|
|
2278
|
-
document.body.appendChild(scriptModule);
|
|
2279
|
-
});
|
|
2280
|
-
});
|
|
2281
|
-
|
|
2282
|
-
var supportsDynamicImport = _async$1(function () {
|
|
2283
|
-
var moduleSource = asBase64Url("export default 42");
|
|
2284
|
-
return _catch(function () {
|
|
2285
|
-
return _await(import(moduleSource), function (namespace) {
|
|
2286
|
-
return namespace.default === 42;
|
|
2287
|
-
});
|
|
2288
|
-
}, function () {
|
|
2289
|
-
return false;
|
|
2290
|
-
});
|
|
2291
|
-
});
|
|
2292
|
-
|
|
2293
|
-
var supportsTopLevelAwait = _async$1(function () {
|
|
2294
|
-
var moduleSource = asBase64Url("export default await Promise.resolve(42)");
|
|
2295
|
-
return _catch(function () {
|
|
2296
|
-
return _await(import(moduleSource), function (namespace) {
|
|
2297
|
-
return namespace.default === 42;
|
|
2298
|
-
});
|
|
2299
|
-
}, function () {
|
|
2300
|
-
return false;
|
|
2301
|
-
});
|
|
2302
|
-
});
|
|
2303
|
-
|
|
2304
|
-
var supportsJsonImportAssertions = _async$1(function () {
|
|
2305
|
-
var jsonBase64Url = asBase64Url("42", "application/json");
|
|
2306
|
-
var moduleSource = asBase64Url("export { default } from \"".concat(jsonBase64Url, "\" assert { type: \"json\" }"));
|
|
2307
|
-
return _catch(function () {
|
|
2308
|
-
return _await(import(moduleSource), function (namespace) {
|
|
2309
|
-
return namespace.default === 42;
|
|
2310
|
-
});
|
|
2311
|
-
}, function () {
|
|
2312
|
-
return false;
|
|
2313
|
-
});
|
|
2314
|
-
});
|
|
2315
|
-
|
|
2316
|
-
var supportsCssImportAssertions = _async$1(function () {
|
|
2317
|
-
var cssBase64Url = asBase64Url("p { color: red; }", "text/css");
|
|
2318
|
-
var moduleSource = asBase64Url("export { default } from \"".concat(cssBase64Url, "\" assert { type: \"css\" }"));
|
|
2319
|
-
return _catch(function () {
|
|
2320
|
-
return _await(import(moduleSource), function (namespace) {
|
|
2321
|
-
return namespace.default instanceof CSSStyleSheet;
|
|
2322
|
-
});
|
|
2323
|
-
}, function () {
|
|
2324
|
-
return false;
|
|
2325
|
-
});
|
|
2326
|
-
});
|
|
2327
|
-
|
|
2328
|
-
var asBase64Url = function asBase64Url(text) {
|
|
2329
|
-
var mimeType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "application/javascript";
|
|
2330
|
-
return "data:".concat(mimeType, ";base64,").concat(window.btoa(text));
|
|
2331
|
-
};
|
|
2332
|
-
|
|
2333
|
-
var renderCompilationInToolbar = function renderCompilationInToolbar(_ref) {
|
|
2334
|
-
var compileGroup = _ref.compileGroup;
|
|
2335
|
-
var browserSupportRootNode = document.querySelector("#browser_support");
|
|
2336
|
-
var filesCompilationRootNode = document.querySelector("#files_compilation");
|
|
2337
|
-
removeForceHideElement(browserSupportRootNode);
|
|
2338
|
-
removeForceHideElement(filesCompilationRootNode);
|
|
2339
|
-
scanBrowserRuntimeFeatures().then(function (_ref2) {
|
|
2340
|
-
var canAvoidCompilation = _ref2.canAvoidCompilation,
|
|
2341
|
-
featuresReport = _ref2.featuresReport,
|
|
2342
|
-
customCompilerPatterns = _ref2.customCompilerPatterns,
|
|
2343
|
-
pluginRequiredNameArray = _ref2.pluginRequiredNameArray,
|
|
2344
|
-
inlineImportMapIntoHTML = _ref2.inlineImportMapIntoHTML,
|
|
2345
|
-
outDirectoryRelativeUrl = _ref2.outDirectoryRelativeUrl,
|
|
2346
|
-
compileId = _ref2.compileId;
|
|
2347
|
-
var browserSupport = canAvoidCompilation ? inlineImportMapIntoHTML ? "partial" : "full" : "no";
|
|
2348
|
-
enableVariant(browserSupportRootNode, {
|
|
2349
|
-
browserSupport: browserSupport
|
|
2350
|
-
});
|
|
2351
|
-
|
|
2352
|
-
if (browserSupport === "no") {
|
|
2353
|
-
browserSupportRootNode.querySelector("a.browser_support_read_more_link").onclick = function () {
|
|
2354
|
-
// eslint-disable-next-line no-alert
|
|
2355
|
-
window.alert("Source files needs to be compiled to be executable in this browser because: ".concat(getBrowserSupportMessage({
|
|
2356
|
-
missingOnly: true,
|
|
2357
|
-
featuresReport: featuresReport,
|
|
2358
|
-
customCompilerPatterns: customCompilerPatterns,
|
|
2359
|
-
pluginRequiredNameArray: pluginRequiredNameArray,
|
|
2360
|
-
inlineImportMapIntoHTML: inlineImportMapIntoHTML
|
|
2361
|
-
})));
|
|
2362
|
-
};
|
|
2363
|
-
} else if (browserSupport === "partial") {
|
|
2364
|
-
browserSupportRootNode.querySelector("a.browser_support_read_more_link").onclick = function () {
|
|
2365
|
-
// eslint-disable-next-line no-alert
|
|
2366
|
-
window.alert("Source files (except html) can be executed directly in this browser because: ".concat(getBrowserSupportMessage({
|
|
2367
|
-
featuresReport: featuresReport,
|
|
2368
|
-
customCompilerPatterns: customCompilerPatterns,
|
|
2369
|
-
pluginRequiredNameArray: pluginRequiredNameArray,
|
|
2370
|
-
inlineImportMapIntoHTML: inlineImportMapIntoHTML
|
|
2371
|
-
})));
|
|
2372
|
-
};
|
|
2373
|
-
} else if (browserSupport === "full") {
|
|
2374
|
-
browserSupportRootNode.querySelector("a.browser_support_read_more_link").onclick = function () {
|
|
2375
|
-
// eslint-disable-next-line no-alert
|
|
2376
|
-
window.alert("Source files can be executed directly in this browser because: ".concat(getBrowserSupportMessage({
|
|
2377
|
-
featuresReport: featuresReport,
|
|
2378
|
-
customCompilerPatterns: customCompilerPatterns,
|
|
2379
|
-
pluginRequiredNameArray: pluginRequiredNameArray,
|
|
2380
|
-
inlineImportMapIntoHTML: inlineImportMapIntoHTML
|
|
2381
|
-
})));
|
|
2382
|
-
};
|
|
2383
|
-
}
|
|
2384
|
-
|
|
2385
|
-
var filesCompilation = compileGroup.compileId ? "yes" : inlineImportMapIntoHTML ? "html_only" : "no";
|
|
2386
|
-
enableVariant(filesCompilationRootNode, {
|
|
2387
|
-
filesCompilation: filesCompilation,
|
|
2388
|
-
compiled: compileGroup.compileId ? "yes" : "no"
|
|
2389
|
-
});
|
|
2390
|
-
|
|
2391
|
-
filesCompilationRootNode.querySelector("a.go_to_source_link").onclick = function () {
|
|
2392
|
-
window.parent.location = "/".concat(compileGroup.fileRelativeUrl);
|
|
2393
|
-
};
|
|
2394
|
-
|
|
2395
|
-
filesCompilationRootNode.querySelector("a.go_to_compiled_link").onclick = function () {
|
|
2396
|
-
window.parent.location = "/".concat(outDirectoryRelativeUrl).concat(compileId, "/").concat(compileGroup.fileRelativeUrl);
|
|
2397
|
-
};
|
|
2398
|
-
|
|
2399
|
-
var shouldCompile = filesCompilation !== "yes" && browserSupport === "no";
|
|
2400
|
-
|
|
2401
|
-
if (shouldCompile) {
|
|
2402
|
-
document.querySelector(".files_compilation_text").setAttribute("data-warning", "");
|
|
2403
|
-
document.querySelector(".browser_support_text").setAttribute("data-warning", "");
|
|
2404
|
-
document.querySelector("#settings-button").setAttribute("data-warning", "");
|
|
2405
|
-
} else {
|
|
2406
|
-
document.querySelector(".files_compilation_text").removeAttribute("data-warning");
|
|
2407
|
-
document.querySelector(".browser_support_text").removeAttribute("data-warning");
|
|
2408
|
-
document.querySelector("#settings-button").removeAttribute("data-warning");
|
|
2409
|
-
}
|
|
2410
|
-
});
|
|
2411
|
-
};
|
|
2412
|
-
|
|
2413
|
-
var getBrowserSupportMessage = function getBrowserSupportMessage(_ref3) {
|
|
2414
|
-
var missingOnly = _ref3.missingOnly,
|
|
2415
|
-
featuresReport = _ref3.featuresReport,
|
|
2416
|
-
customCompilerPatterns = _ref3.customCompilerPatterns,
|
|
2417
|
-
pluginRequiredNameArray = _ref3.pluginRequiredNameArray,
|
|
2418
|
-
inlineImportMapIntoHTML = _ref3.inlineImportMapIntoHTML;
|
|
2419
|
-
var parts = [];
|
|
2420
|
-
var importmapSupported = featuresReport.importmapSupported;
|
|
2421
|
-
|
|
2422
|
-
if (importmapSupported) {
|
|
2423
|
-
if (!missingOnly) {
|
|
2424
|
-
if (inlineImportMapIntoHTML) {
|
|
2425
|
-
parts.push("importmaps are supported (only when inlined in html files)");
|
|
2426
|
-
} else {
|
|
2427
|
-
parts.push("importmaps are supported");
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
|
-
} else {
|
|
2431
|
-
parts.push("importmaps are not supported");
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
|
-
var dynamicImportSupported = featuresReport.dynamicImportSupported;
|
|
2435
|
-
|
|
2436
|
-
if (dynamicImportSupported) {
|
|
2437
|
-
if (!missingOnly) {
|
|
2438
|
-
parts.push("dynamic imports are supported");
|
|
2439
|
-
}
|
|
2440
|
-
} else {
|
|
2441
|
-
parts.push("dynamic imports are not supported");
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2444
|
-
var topLevelAwaitSupported = featuresReport.topLevelAwaitSupported;
|
|
2445
|
-
|
|
2446
|
-
if (topLevelAwaitSupported) {
|
|
2447
|
-
if (!missingOnly) {
|
|
2448
|
-
parts.push("top level await is supported");
|
|
2449
|
-
}
|
|
2450
|
-
} else {
|
|
2451
|
-
parts.push("top level await is not supported");
|
|
2452
|
-
}
|
|
2453
|
-
|
|
2454
|
-
var pluginRequiredCount = pluginRequiredNameArray.length;
|
|
2455
|
-
|
|
2456
|
-
if (pluginRequiredCount === 0) {
|
|
2457
|
-
if (!missingOnly) {
|
|
2458
|
-
parts.push("all plugins are natively supported");
|
|
2459
|
-
}
|
|
2460
|
-
} else {
|
|
2461
|
-
parts.push("".concat(pluginRequiredCount, " plugins are mandatory: ").concat(pluginRequiredNameArray));
|
|
2462
|
-
}
|
|
2463
|
-
|
|
2464
|
-
var customCompilerCount = customCompilerPatterns.length;
|
|
2465
|
-
|
|
2466
|
-
if (customCompilerCount === 0) ; else {
|
|
2467
|
-
parts.push("".concat(customCompilerCount, " custom compilers enabled: ").concat(customCompilerPatterns));
|
|
2468
|
-
}
|
|
2469
|
-
|
|
2470
|
-
return "\n- ".concat(parts.join("\n- "));
|
|
2471
|
-
};
|
|
2472
|
-
|
|
2473
|
-
var livereloadingAvailableOnServer = false;
|
|
2474
|
-
var parentEventSourceClient = window.parent.__jsenv_event_source_client__;
|
|
2475
|
-
var initToolbarEventSource = function initToolbarEventSource(_ref) {
|
|
2476
|
-
var livereloading = _ref.livereloading;
|
|
2477
|
-
removeForceHideElement(document.querySelector("#eventsource-indicator"));
|
|
2478
|
-
livereloadingAvailableOnServer = livereloading;
|
|
2479
|
-
|
|
2480
|
-
if (!livereloadingAvailableOnServer) {
|
|
2481
|
-
disableLivereloadSetting();
|
|
2482
|
-
}
|
|
2483
|
-
|
|
2484
|
-
parentEventSourceClient.setConnectionStatusChangeCallback = function () {
|
|
2485
|
-
updateEventSourceIndicator();
|
|
2486
|
-
};
|
|
2487
|
-
|
|
2488
|
-
var livereloadCheckbox = document.querySelector("#toggle-livereload");
|
|
2489
|
-
livereloadCheckbox.checked = parentEventSourceClient.isLivereloadEnabled();
|
|
2490
|
-
|
|
2491
|
-
livereloadCheckbox.onchange = function () {
|
|
2492
|
-
parentEventSourceClient.setLivereloadPreference(livereloadCheckbox.checked);
|
|
2493
|
-
updateEventSourceIndicator();
|
|
2494
|
-
};
|
|
2495
|
-
|
|
2496
|
-
updateEventSourceIndicator();
|
|
2497
|
-
};
|
|
2498
|
-
|
|
2499
|
-
var updateEventSourceIndicator = function updateEventSourceIndicator() {
|
|
2500
|
-
var eventSourceIndicator = document.querySelector("#eventsource-indicator");
|
|
2501
|
-
var fileChanges = parentEventSourceClient.getFileChanges();
|
|
2502
|
-
var changeCount = Object.keys(fileChanges).length;
|
|
2503
|
-
var eventSourceConnectionState = parentEventSourceClient.getConnectionStatus();
|
|
2504
|
-
enableVariant(eventSourceIndicator, {
|
|
2505
|
-
eventsource: eventSourceConnectionState,
|
|
2506
|
-
livereload: parentEventSourceClient.isLivereloadEnabled() ? "on" : "off",
|
|
2507
|
-
changes: changeCount > 0 ? "yes" : "no"
|
|
2508
|
-
});
|
|
2509
|
-
var variantNode = document.querySelector("#eventsource-indicator > [data-when-active]");
|
|
2510
|
-
|
|
2511
|
-
variantNode.querySelector("button").onclick = function () {
|
|
2512
|
-
toggleTooltip(eventSourceIndicator);
|
|
2513
|
-
};
|
|
2514
|
-
|
|
2515
|
-
if (eventSourceConnectionState === "connecting") {
|
|
2516
|
-
variantNode.querySelector("a").onclick = function () {
|
|
2517
|
-
parentEventSourceClient.disconnect();
|
|
2518
|
-
};
|
|
2519
|
-
} else if (eventSourceConnectionState === "connected") {
|
|
2520
|
-
removeAutoShowTooltip(eventSourceIndicator);
|
|
2521
|
-
|
|
2522
|
-
if (changeCount) {
|
|
2523
|
-
var changeLink = variantNode.querySelector(".eventsource-changes-link");
|
|
2524
|
-
changeLink.innerHTML = changeCount;
|
|
2525
|
-
|
|
2526
|
-
changeLink.onclick = function () {
|
|
2527
|
-
console.log(JSON.stringify(fileChanges, null, " "), fileChanges); // eslint-disable-next-line no-alert
|
|
2528
|
-
|
|
2529
|
-
window.parent.alert(JSON.stringify(fileChanges, null, " "));
|
|
2530
|
-
};
|
|
2531
|
-
|
|
2532
|
-
variantNode.querySelector(".eventsource-reload-link").onclick = function () {
|
|
2533
|
-
parentEventSourceClient.reloadIfNeeded();
|
|
2534
|
-
};
|
|
2535
|
-
}
|
|
2536
|
-
} else if (eventSourceConnectionState === "disconnected") {
|
|
2537
|
-
autoShowTooltip(eventSourceIndicator);
|
|
2538
|
-
|
|
2539
|
-
variantNode.querySelector("a").onclick = function () {
|
|
2540
|
-
parentEventSourceClient.connect();
|
|
2541
|
-
};
|
|
2542
|
-
}
|
|
2543
|
-
};
|
|
2544
|
-
|
|
2545
|
-
var disableLivereloadSetting = function disableLivereloadSetting() {
|
|
2546
|
-
document.querySelector(".settings-livereload").setAttribute("data-disabled", "true");
|
|
2547
|
-
document.querySelector(".settings-livereload").setAttribute("title", "Livereload not available: disabled by server");
|
|
2548
|
-
document.querySelector("#toggle-livereload").disabled = true;
|
|
2549
|
-
};
|
|
2550
|
-
|
|
2551
|
-
var WINDOW_SMALL_WIDTH = 420;
|
|
2552
|
-
var makeToolbarResponsive = function makeToolbarResponsive() {
|
|
2553
|
-
// apply responsive design on toolbar icons if needed + add listener on resize screen
|
|
2554
|
-
// ideally we should listen breakpoint once, for now restore toolbar
|
|
2555
|
-
var overflowMenuBreakpoint = createHorizontalBreakpoint(WINDOW_SMALL_WIDTH);
|
|
2556
|
-
|
|
2557
|
-
var handleOverflowMenuBreakpoint = function handleOverflowMenuBreakpoint() {
|
|
2558
|
-
responsiveToolbar(overflowMenuBreakpoint);
|
|
2559
|
-
};
|
|
2560
|
-
|
|
2561
|
-
handleOverflowMenuBreakpoint();
|
|
2562
|
-
overflowMenuBreakpoint.changed.listen(handleOverflowMenuBreakpoint); // overflow menu
|
|
2563
|
-
|
|
2564
|
-
document.querySelector("#overflow-menu-button").onclick = function () {
|
|
2565
|
-
return toggleOverflowMenu();
|
|
2566
|
-
};
|
|
2567
|
-
};
|
|
2568
|
-
|
|
2569
|
-
var responsiveToolbar = function responsiveToolbar(overflowMenuBreakpoint) {
|
|
2570
|
-
// close all tooltips in case opened
|
|
2571
|
-
hideTooltip(document.querySelector("#eventsource-indicator"));
|
|
2572
|
-
hideTooltip(document.querySelector("#execution-indicator")); // close settings box in case opened
|
|
2573
|
-
|
|
2574
|
-
deactivateToolbarSection(document.querySelector("#settings"));
|
|
2575
|
-
|
|
2576
|
-
if (overflowMenuBreakpoint.isBelow()) {
|
|
2577
|
-
enableOverflow();
|
|
2578
|
-
} else {
|
|
2579
|
-
disableOverflow();
|
|
2580
|
-
}
|
|
2581
|
-
};
|
|
2582
|
-
|
|
2583
|
-
var moves = [];
|
|
2584
|
-
|
|
2585
|
-
var enableOverflow = function enableOverflow() {
|
|
2586
|
-
// move elements from toolbar to overflow menu
|
|
2587
|
-
var responsiveToolbarElements = document.querySelectorAll("[data-responsive-toolbar-element]");
|
|
2588
|
-
var overflowMenu = document.querySelector("#overflow-menu"); // keep a placeholder element to know where to move them back
|
|
2589
|
-
|
|
2590
|
-
moves = Array.from(responsiveToolbarElements).map(function (element) {
|
|
2591
|
-
var placeholder = document.createElement("div");
|
|
2592
|
-
placeholder.style.display = "none";
|
|
2593
|
-
placeholder.setAttribute("data-placeholder", "");
|
|
2594
|
-
element.parentNode.replaceChild(placeholder, element);
|
|
2595
|
-
overflowMenu.appendChild(element);
|
|
2596
|
-
return {
|
|
2597
|
-
element: element,
|
|
2598
|
-
placeholder: placeholder
|
|
2599
|
-
};
|
|
2600
|
-
});
|
|
2601
|
-
document.querySelector("#toolbar").setAttribute("data-overflow-menu-enabled", "");
|
|
2602
|
-
removeForceHideElement(document.querySelector("#overflow-menu-button"));
|
|
2603
|
-
};
|
|
2604
|
-
|
|
2605
|
-
var disableOverflow = function disableOverflow() {
|
|
2606
|
-
// close overflow menu in case it's open & unselect toggleOverflowMenu button in case it's selected
|
|
2607
|
-
hideOverflowMenu();
|
|
2608
|
-
deactivateToolbarSection(document.querySelector("#overflow-menu"));
|
|
2609
|
-
moves.forEach(function (_ref) {
|
|
2610
|
-
var element = _ref.element,
|
|
2611
|
-
placeholder = _ref.placeholder;
|
|
2612
|
-
placeholder.parentNode.replaceChild(element, placeholder);
|
|
2613
|
-
});
|
|
2614
|
-
moves = [];
|
|
2615
|
-
document.querySelector("#toolbar").removeAttribute("data-overflow-menu-enabled");
|
|
2616
|
-
forceHideElement(document.querySelector("#overflow-menu-button"));
|
|
2617
|
-
};
|
|
2618
|
-
|
|
2619
|
-
var toggleOverflowMenu = function toggleOverflowMenu() {
|
|
2620
|
-
if (overflowMenuIsVisible()) {
|
|
2621
|
-
hideOverflowMenu();
|
|
2622
|
-
} else {
|
|
2623
|
-
showOverflowMenu();
|
|
2624
|
-
}
|
|
2625
|
-
};
|
|
2626
|
-
|
|
2627
|
-
var overflowMenuIsVisible = function overflowMenuIsVisible() {
|
|
2628
|
-
var toolbar = document.querySelector("#toolbar");
|
|
2629
|
-
return toolbar.hasAttribute("data-overflow-menu-visible");
|
|
2630
|
-
};
|
|
2631
|
-
|
|
2632
|
-
var showOverflowMenu = function showOverflowMenu() {
|
|
2633
|
-
var toolbar = document.querySelector("#toolbar");
|
|
2634
|
-
document.querySelector("#overflow-menu").setAttribute("data-animate", "");
|
|
2635
|
-
toolbar.setAttribute("data-overflow-menu-visible", "");
|
|
2636
|
-
};
|
|
2637
|
-
|
|
2638
|
-
var hideOverflowMenu = function hideOverflowMenu() {
|
|
2639
|
-
var toolbar = document.querySelector("#toolbar");
|
|
2640
|
-
toolbar.removeAttribute("data-overflow-menu-visible");
|
|
2641
|
-
document.querySelector("#overflow-menu").removeAttribute("data-animate");
|
|
2642
|
-
};
|
|
2643
|
-
|
|
2644
|
-
function _call(body, then, direct) {
|
|
2645
|
-
if (direct) {
|
|
2646
|
-
return then ? then(body()) : body();
|
|
2647
|
-
}
|
|
2648
|
-
|
|
2649
|
-
try {
|
|
2650
|
-
var result = Promise.resolve(body());
|
|
2651
|
-
return then ? result.then(then) : result;
|
|
2652
|
-
} catch (e) {
|
|
2653
|
-
return Promise.reject(e);
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2656
|
-
|
|
2657
|
-
var toolbarVisibilityPreference = createPreference("toolbar");
|
|
2658
|
-
|
|
2659
|
-
function _async(f) {
|
|
2660
|
-
return function () {
|
|
2661
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
2662
|
-
args[i] = arguments[i];
|
|
2663
|
-
}
|
|
2664
|
-
|
|
2665
|
-
try {
|
|
2666
|
-
return Promise.resolve(f.apply(this, args));
|
|
2667
|
-
} catch (e) {
|
|
2668
|
-
return Promise.reject(e);
|
|
2669
|
-
}
|
|
2670
|
-
};
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
|
-
var renderToolbar = _async(function () {
|
|
2674
|
-
var executedFileCompiledUrl = window.parent.location.href;
|
|
2675
|
-
var compileServerOrigin = window.parent.location.origin; // this should not block the whole toolbar rendering + interactivity
|
|
2676
|
-
|
|
2677
|
-
return _call(fetchExploringJson, function (exploringConfig) {
|
|
2678
|
-
var outDirectoryRelativeUrl = exploringConfig.outDirectoryRelativeUrl,
|
|
2679
|
-
livereloading = exploringConfig.livereloading;
|
|
2680
|
-
var compileGroup = getCompileGroup({
|
|
2681
|
-
executedFileCompiledUrl: executedFileCompiledUrl,
|
|
2682
|
-
outDirectoryRelativeUrl: outDirectoryRelativeUrl,
|
|
2683
|
-
compileServerOrigin: compileServerOrigin
|
|
2684
|
-
});
|
|
2685
|
-
var executedFileRelativeUrl = compileGroup.fileRelativeUrl;
|
|
2686
|
-
var toolbarOverlay = document.querySelector("#toolbar-overlay");
|
|
2687
|
-
|
|
2688
|
-
toolbarOverlay.onclick = function () {
|
|
2689
|
-
hideAllTooltip();
|
|
2690
|
-
hideSettings();
|
|
2691
|
-
};
|
|
2692
|
-
|
|
2693
|
-
var toolbarElement = document.querySelector("#toolbar");
|
|
2694
|
-
exposeOnParentWindow({
|
|
2695
|
-
toolbar: {
|
|
2696
|
-
element: toolbarElement,
|
|
2697
|
-
show: showToolbar,
|
|
2698
|
-
hide: function hide() {
|
|
2699
|
-
return hideToolbar();
|
|
2700
|
-
},
|
|
2701
|
-
toggle: toogleToolbar
|
|
2702
|
-
}
|
|
2703
|
-
});
|
|
2704
|
-
var toolbarVisible = toolbarVisibilityPreference.has() ? toolbarVisibilityPreference.get() : true;
|
|
2705
|
-
|
|
2706
|
-
if (toolbarVisible) {
|
|
2707
|
-
showToolbar({
|
|
2708
|
-
animate: false
|
|
2709
|
-
});
|
|
2710
|
-
} else {
|
|
2711
|
-
hideToolbar({
|
|
2712
|
-
animate: false
|
|
2713
|
-
});
|
|
2714
|
-
}
|
|
2715
|
-
|
|
2716
|
-
renderBackToListInToolbar({
|
|
2717
|
-
outDirectoryRelativeUrl: outDirectoryRelativeUrl,
|
|
2718
|
-
exploringHtmlFileRelativeUrl: exploringConfig.exploringHtmlFileRelativeUrl
|
|
2719
|
-
});
|
|
2720
|
-
renderToolbarNotification();
|
|
2721
|
-
makeToolbarResponsive();
|
|
2722
|
-
renderToolbarSettings();
|
|
2723
|
-
renderToolbarAnimation();
|
|
2724
|
-
renderToolbarTheme();
|
|
2725
|
-
renderExecutionInToolbar({
|
|
2726
|
-
executedFileRelativeUrl: executedFileRelativeUrl
|
|
2727
|
-
});
|
|
2728
|
-
renderCompilationInToolbar({
|
|
2729
|
-
compileGroup: compileGroup
|
|
2730
|
-
}); // this might become active but we need to detect this somehow
|
|
2731
|
-
|
|
2732
|
-
deactivateToolbarSection(document.querySelector("#file-list-link"));
|
|
2733
|
-
initToolbarEventSource({
|
|
2734
|
-
executedFileRelativeUrl: executedFileRelativeUrl,
|
|
2735
|
-
livereloading: livereloading
|
|
2736
|
-
}); // if user click enter or space quickly while closing toolbar
|
|
2737
|
-
// it will cancel the closing
|
|
2738
|
-
// that's why I used toggleToolbar and not hideToolbar
|
|
2739
|
-
|
|
2740
|
-
document.querySelector("#button-close-toolbar").onclick = function () {
|
|
2741
|
-
return toogleToolbar();
|
|
2742
|
-
};
|
|
2743
|
-
});
|
|
2744
|
-
});
|
|
2745
|
-
|
|
2746
|
-
var exposeOnParentWindow = function exposeOnParentWindow(object) {
|
|
2747
|
-
var __jsenv__ = window.parent.__jsenv__;
|
|
2748
|
-
|
|
2749
|
-
if (!__jsenv__) {
|
|
2750
|
-
__jsenv__ = {};
|
|
2751
|
-
window.parent.__jsenv__ = {};
|
|
2752
|
-
}
|
|
2753
|
-
|
|
2754
|
-
Object.assign(__jsenv__, object);
|
|
2755
|
-
};
|
|
2756
|
-
|
|
2757
|
-
var toogleToolbar = function toogleToolbar() {
|
|
2758
|
-
if (toolbarIsVisible()) {
|
|
2759
|
-
hideToolbar();
|
|
2760
|
-
} else {
|
|
2761
|
-
showToolbar();
|
|
2762
|
-
}
|
|
2763
|
-
};
|
|
2764
|
-
|
|
2765
|
-
var toolbarIsVisible = function toolbarIsVisible() {
|
|
2766
|
-
return document.documentElement.hasAttribute("data-toolbar-visible");
|
|
2767
|
-
};
|
|
2768
|
-
|
|
2769
|
-
var hideToolbar = function hideToolbar() {
|
|
2770
|
-
// toolbar hidden by default, nothing to do to hide it by default
|
|
2771
|
-
sendEventToParent("toolbar-visibility-change", false);
|
|
2772
|
-
}; // (by the way it might be cool to have the toolbar auto show when)
|
|
2773
|
-
// it has something to say (being disconnected from livereload server)
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
var showToolbar = function showToolbar() {
|
|
2777
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
2778
|
-
_ref$animate = _ref.animate,
|
|
2779
|
-
animate = _ref$animate === void 0 ? true : _ref$animate;
|
|
2780
|
-
|
|
2781
|
-
toolbarVisibilityPreference.set(true);
|
|
2782
|
-
|
|
2783
|
-
if (animate) {
|
|
2784
|
-
document.documentElement.setAttribute("data-toolbar-animation", "");
|
|
2785
|
-
} else {
|
|
2786
|
-
document.documentElement.removeAttribute("data-toolbar-animation");
|
|
2787
|
-
}
|
|
2788
|
-
|
|
2789
|
-
document.documentElement.setAttribute("data-toolbar-visible", "");
|
|
2790
|
-
sendEventToParent("toolbar-visibility-change", true);
|
|
2791
|
-
var toolbarIframe = getToolbarIframe();
|
|
2792
|
-
var toolbarIframeParent = toolbarIframe.parentNode;
|
|
2793
|
-
var parentWindow = window.parent;
|
|
2794
|
-
var parentDocumentElement = parentWindow.document.compatMode === "CSS1Compat" ? parentWindow.document.documentElement : parentWindow.document.body;
|
|
2795
|
-
var scrollYMax = parentDocumentElement.scrollHeight - parentWindow.innerHeight;
|
|
2796
|
-
var scrollY = parentDocumentElement.scrollTop;
|
|
2797
|
-
var scrollYRemaining = scrollYMax - scrollY;
|
|
2798
|
-
setStyles(toolbarIframeParent, {
|
|
2799
|
-
"transition-property": "padding-bottom",
|
|
2800
|
-
"transition-duration": "300ms"
|
|
2801
|
-
}); // maybe we should use js animation here because we would not conflict with css
|
|
2802
|
-
|
|
2803
|
-
var restoreToolbarIframeParentStyles = setStyles(toolbarIframeParent, {
|
|
2804
|
-
"scroll-padding-bottom": "40px",
|
|
2805
|
-
// same here we should add 40px
|
|
2806
|
-
"padding-bottom": "40px" // if there is already one we should add 40px
|
|
2807
|
-
|
|
2808
|
-
});
|
|
2809
|
-
var restoreToolbarIframeStyles = setStyles(toolbarIframe, {
|
|
2810
|
-
height: "40px",
|
|
2811
|
-
visibility: "visible"
|
|
2812
|
-
});
|
|
2813
|
-
|
|
2814
|
-
if (scrollYRemaining < 40 && scrollYMax > 0) {
|
|
2815
|
-
var scrollEnd = scrollY + 40;
|
|
2816
|
-
startJavaScriptAnimation({
|
|
2817
|
-
duration: 300,
|
|
2818
|
-
onProgress: function onProgress(_ref2) {
|
|
2819
|
-
var progress = _ref2.progress;
|
|
2820
|
-
var value = scrollY + (scrollEnd - scrollY) * progress;
|
|
2821
|
-
parentDocumentElement.scrollTop = value;
|
|
2822
|
-
}
|
|
2823
|
-
});
|
|
2824
|
-
}
|
|
2825
|
-
|
|
2826
|
-
hideToolbar = function hideToolbar() {
|
|
2827
|
-
restoreToolbarIframeParentStyles();
|
|
2828
|
-
restoreToolbarIframeStyles();
|
|
2829
|
-
hideTooltip(document.querySelector("#eventsource-indicator"));
|
|
2830
|
-
hideTooltip(document.querySelector("#execution-indicator"));
|
|
2831
|
-
toolbarVisibilityPreference.set(false);
|
|
2832
|
-
|
|
2833
|
-
if (animate) {
|
|
2834
|
-
document.documentElement.setAttribute("data-toolbar-animation", "");
|
|
2835
|
-
} else {
|
|
2836
|
-
document.documentElement.removeAttribute("data-toolbar-animation");
|
|
2837
|
-
}
|
|
2838
|
-
|
|
2839
|
-
document.documentElement.removeAttribute("data-toolbar-visible");
|
|
2840
|
-
sendEventToParent("toolbar-visibility-change", false);
|
|
2841
|
-
};
|
|
2842
|
-
};
|
|
2843
|
-
|
|
2844
|
-
var getCompileGroup = function getCompileGroup(_ref3) {
|
|
2845
|
-
var executedFileCompiledUrl = _ref3.executedFileCompiledUrl,
|
|
2846
|
-
outDirectoryRelativeUrl = _ref3.outDirectoryRelativeUrl,
|
|
2847
|
-
compileServerOrigin = _ref3.compileServerOrigin;
|
|
2848
|
-
var outDirectoryServerUrl = String(new URL(outDirectoryRelativeUrl, compileServerOrigin));
|
|
2849
|
-
|
|
2850
|
-
if (urlIsInsideOf(executedFileCompiledUrl, outDirectoryServerUrl)) {
|
|
2851
|
-
var afterCompileDirectory = urlToRelativeUrl(executedFileCompiledUrl, outDirectoryServerUrl);
|
|
2852
|
-
var slashIndex = afterCompileDirectory.indexOf("/");
|
|
2853
|
-
var fileRelativeUrl = afterCompileDirectory.slice(slashIndex + 1);
|
|
2854
|
-
return {
|
|
2855
|
-
fileRelativeUrl: fileRelativeUrl,
|
|
2856
|
-
outDirectoryRelativeUrl: outDirectoryRelativeUrl,
|
|
2857
|
-
compileId: afterCompileDirectory.slice(0, slashIndex)
|
|
2858
|
-
};
|
|
2859
|
-
}
|
|
2860
|
-
|
|
2861
|
-
return {
|
|
2862
|
-
fileRelativeUrl: new URL(executedFileCompiledUrl).pathname.slice(1),
|
|
2863
|
-
outDirectoryRelativeUrl: outDirectoryRelativeUrl,
|
|
2864
|
-
compileId: null
|
|
2865
|
-
};
|
|
2866
|
-
};
|
|
2867
|
-
|
|
2868
|
-
var sendEventToParent = function sendEventToParent(type, value) {
|
|
2869
|
-
window.parent.postMessage({
|
|
2870
|
-
jsenv: true,
|
|
2871
|
-
type: type,
|
|
2872
|
-
value: value
|
|
2873
|
-
}, "*");
|
|
2874
|
-
};
|
|
2875
|
-
|
|
2876
|
-
window.renderToolbar = renderToolbar;
|
|
2877
|
-
|
|
2878
|
-
})();
|
|
2879
|
-
|
|
2880
|
-
//# sourceMappingURL=jsenv_toolbar.js.map
|