@jsenv/core 23.6.1 → 23.8.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/{license → LICENSE} +21 -21
- package/dist/jsenv_browser_system.js +35 -35
- package/dist/jsenv_browser_system.js.map +14 -14
- package/dist/jsenv_compile_proxy.js +47 -128
- package/dist/jsenv_compile_proxy.js.map +25 -62
- package/dist/jsenv_exploring_index.js.map +5 -5
- package/dist/jsenv_exploring_redirector.js +47 -54
- package/dist/jsenv_exploring_redirector.js.map +17 -19
- package/dist/jsenv_toolbar.js +47 -130
- package/dist/jsenv_toolbar.js.map +13 -48
- package/dist/jsenv_toolbar_injector.js.map +5 -5
- package/helpers/babel/.eslintrc.cjs +24 -24
- package/helpers/babel/AsyncGenerator/AsyncGenerator.js +81 -81
- package/helpers/babel/AwaitValue/AwaitValue.js +3 -3
- package/helpers/babel/applyDecoratorDescriptor/applyDecoratorDescriptor.js +33 -33
- package/helpers/babel/arrayLikeToArray/arrayLikeToArray.js +7 -7
- package/helpers/babel/arrayWithHoles/arrayWithHoles.js +4 -4
- package/helpers/babel/arrayWithoutHoles/arrayWithoutHoles.js +6 -6
- package/helpers/babel/assertThisInitialized/assertThisInitialized.js +7 -7
- package/helpers/babel/asyncGeneratorDelegate/asyncGeneratorDelegate.js +40 -40
- package/helpers/babel/asyncIterator/asyncIterator.js +12 -12
- package/helpers/babel/asyncToGenerator/asyncToGenerator.js +34 -34
- package/helpers/babel/awaitAsyncGenerator/awaitAsyncGenerator.js +5 -5
- package/helpers/babel/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +20 -20
- package/helpers/babel/classApplyDescriptorGet/classApplyDescriptorGet.js +6 -6
- package/helpers/babel/classApplyDescriptorSet/classApplyDescriptorSet.js +13 -13
- package/helpers/babel/classCallCheck/classCallCheck.js +5 -5
- package/helpers/babel/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -5
- package/helpers/babel/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -6
- package/helpers/babel/classExtractFieldDescriptor/classExtractFieldDescriptor.js +7 -7
- package/helpers/babel/classNameTDZError/classNameTDZError.js +4 -4
- package/helpers/babel/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +7 -7
- package/helpers/babel/classPrivateFieldGet/classPrivateFieldGet.js +7 -7
- package/helpers/babel/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +6 -6
- package/helpers/babel/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -5
- package/helpers/babel/classPrivateFieldSet/classPrivateFieldSet.js +8 -8
- package/helpers/babel/classPrivateMethodGet/classPrivateMethodGet.js +6 -6
- package/helpers/babel/classPrivateMethodSet/classPrivateMethodSet.js +3 -3
- package/helpers/babel/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +9 -9
- package/helpers/babel/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +15 -15
- package/helpers/babel/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +6 -6
- package/helpers/babel/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -3
- package/helpers/babel/construct/construct.js +16 -16
- package/helpers/babel/createClass/createClass.js +15 -15
- package/helpers/babel/createForOfIteratorHelper/createForOfIteratorHelper.js +60 -60
- package/helpers/babel/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +23 -23
- package/helpers/babel/createRawReactElement/createRawReactElement.js +50 -50
- package/helpers/babel/createSuper/createSuper.js +22 -22
- package/helpers/babel/decorate/decorate.js +403 -403
- package/helpers/babel/defaults/defaults.js +11 -11
- package/helpers/babel/defineEnumerableProperties/defineEnumerableProperties.js +23 -23
- package/helpers/babel/defineProperty/defineProperty.js +18 -18
- package/helpers/babel/extends/extends.js +14 -14
- package/helpers/babel/get/get.js +13 -13
- package/helpers/babel/getPrototypeOf/getPrototypeOf.js +4 -4
- package/helpers/babel/inherits/inherits.js +15 -15
- package/helpers/babel/inheritsLoose/inheritsLoose.js +7 -7
- package/helpers/babel/initializerDefineProperty/initializerDefineProperty.js +10 -10
- package/helpers/babel/initializerWarningHelper/initializerWarningHelper.js +6 -6
- package/helpers/babel/instanceof/instanceof.js +6 -6
- package/helpers/babel/interopRequireDefault/interopRequireDefault.js +3 -3
- package/helpers/babel/interopRequireWildcard/interopRequireWildcard.js +37 -37
- package/helpers/babel/isNativeFunction/isNativeFunction.js +4 -4
- package/helpers/babel/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -21
- package/helpers/babel/iterableToArray/iterableToArray.js +7 -7
- package/helpers/babel/iterableToArrayLimit/iterableToArrayLimit.js +36 -36
- package/helpers/babel/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +10 -10
- package/helpers/babel/jsx/jsx.js +45 -45
- package/helpers/babel/maybeArrayLike/maybeArrayLike.js +10 -10
- package/helpers/babel/newArrowCheck/newArrowCheck.js +5 -5
- package/helpers/babel/nonIterableRest/nonIterableRest.js +5 -5
- package/helpers/babel/nonIterableSpread/nonIterableSpread.js +5 -5
- package/helpers/babel/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -3
- package/helpers/babel/objectSpread/objectSpread.js +23 -23
- package/helpers/babel/objectSpread2/objectSpread2.js +33 -33
- package/helpers/babel/objectWithoutProperties/objectWithoutProperties.js +19 -19
- package/helpers/babel/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +13 -13
- package/helpers/babel/possibleConstructorReturn/possibleConstructorReturn.js +10 -10
- package/helpers/babel/readOnlyError/readOnlyError.js +4 -4
- package/helpers/babel/readme.md +9 -9
- package/helpers/babel/set/set.js +44 -44
- package/helpers/babel/setPrototypeOf/setPrototypeOf.js +6 -6
- package/helpers/babel/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -8
- package/helpers/babel/slicedToArray/slicedToArray.js +10 -10
- package/helpers/babel/slicedToArrayLoose/slicedToArrayLoose.js +13 -13
- package/helpers/babel/superPropBase/superPropBase.js +10 -10
- package/helpers/babel/taggedTemplateLiteral/taggedTemplateLiteral.js +10 -10
- package/helpers/babel/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +7 -7
- package/helpers/babel/tdz/tdz.js +4 -4
- package/helpers/babel/temporalRef/temporalRef.js +6 -6
- package/helpers/babel/temporalUndefined/temporalUndefined.js +3 -3
- package/helpers/babel/toArray/toArray.js +10 -10
- package/helpers/babel/toConsumableArray/toConsumableArray.js +10 -10
- package/helpers/babel/toPrimitive/toPrimitive.js +10 -10
- package/helpers/babel/toPropertyKey/toPropertyKey.js +6 -6
- package/helpers/babel/typeof/typeof.js +14 -14
- package/helpers/babel/unsupportedIterableToArray/unsupportedIterableToArray.js +12 -12
- package/helpers/babel/wrapAsyncGenerator/wrapAsyncGenerator.js +8 -8
- package/helpers/babel/wrapNativeSuper/wrapNativeSuper.js +30 -30
- package/helpers/babel/wrapRegExp/wrapRegExp.js +63 -63
- package/helpers/babel/writeOnlyError/writeOnlyError.js +4 -4
- package/helpers/regenerator-runtime/regenerator-runtime.js +748 -748
- package/package.json +5 -3
- package/src/buildProject.js +300 -300
- package/src/execute.js +184 -184
- package/src/internal/browser-launcher/jsenv-browser-system.js +199 -199
- package/src/internal/compiling/babel_plugin_import_assertions.js +121 -100
- package/src/internal/compiling/babel_plugin_import_metadata.js +22 -0
- package/src/internal/compiling/babel_plugin_import_visitor.js +84 -0
- package/src/internal/compiling/compile-directory/getOrGenerateCompiledFile.js +268 -265
- package/src/internal/compiling/compile-directory/updateMeta.js +154 -150
- package/src/internal/compiling/compile-directory/validateCache.js +265 -265
- package/src/internal/compiling/compileFile.js +215 -200
- package/src/internal/compiling/compileHtml.js +550 -494
- package/src/internal/compiling/createCompiledFileService.js +291 -290
- package/src/internal/compiling/html_source_file_service.js +403 -379
- package/src/internal/compiling/js-compilation-service/jsenvTransform.js +270 -269
- package/src/internal/compiling/jsenvCompilerForHtml.js +300 -293
- package/src/internal/compiling/startCompileServer.js +1048 -1131
- package/src/internal/compiling/transformResultToCompilationResult.js +220 -217
- package/src/internal/executing/coverage/babel_plugin_instrument.js +90 -90
- package/src/internal/executing/coverage/reportToCoverage.js +187 -187
- package/src/internal/executing/executePlan.js +183 -183
- package/src/internal/executing/launchAndExecute.js +458 -450
- package/src/internal/runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js +246 -250
- package/src/internal/runtime/createNodeRuntime/scanNodeRuntimeFeatures.js +112 -115
- package/src/internal/runtime/s.js +727 -727
- package/src/internal/toolbar/jsenv-logo.svg +144 -144
- package/src/internal/toolbar/toolbar.main.css +196 -188
- package/src/internal/toolbar/toolbar.main.js +227 -228
- package/src/internal/url_conversion.js +317 -317
- package/src/startExploring.js +309 -309
- package/src/internal/compiling/babel_plugin_transform_import_specifier.js +0 -86
- package/src/internal/toolbar/animation/animation.css +0 -5
- package/src/internal/toolbar/variant/variant.css +0 -3
|
@@ -1,228 +1,227 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import "./
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "./util/
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from "./
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
__jsenv__ = {}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"transition-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
"
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
hideTooltip(document.querySelector("#
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
)
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
window.renderToolbar = renderToolbar
|
|
1
|
+
import { urlIsInsideOf } from "@jsenv/filesystem/src/urlIsInsideOf.js"
|
|
2
|
+
import { urlToRelativeUrl } from "@jsenv/filesystem/src/urlToRelativeUrl.js"
|
|
3
|
+
|
|
4
|
+
import { fetchExploringJson } from "../exploring/fetchExploringJson.js"
|
|
5
|
+
import { startJavaScriptAnimation } from "../toolbar/util/animation.js"
|
|
6
|
+
import "./focus/toolbar.focus.js"
|
|
7
|
+
import { renderBackToListInToolbar } from "./backtolist/toolbar.backtolist.js"
|
|
8
|
+
import {
|
|
9
|
+
getToolbarIframe,
|
|
10
|
+
deactivateToolbarSection,
|
|
11
|
+
setStyles,
|
|
12
|
+
} from "./util/dom.js"
|
|
13
|
+
import { createPreference } from "./util/preferences.js"
|
|
14
|
+
import { hideTooltip, hideAllTooltip } from "./tooltip/tooltip.js"
|
|
15
|
+
import {
|
|
16
|
+
renderToolbarSettings,
|
|
17
|
+
hideSettings,
|
|
18
|
+
} from "./settings/toolbar.settings.js"
|
|
19
|
+
import { renderToolbarNotification } from "./notification/toolbar.notification.js"
|
|
20
|
+
import { renderToolbarTheme } from "./theme/toolbar.theme.js"
|
|
21
|
+
import { renderToolbarAnimation } from "./animation/toolbar.animation.js"
|
|
22
|
+
import { renderExecutionInToolbar } from "./execution/toolbar.execution.js"
|
|
23
|
+
import { renderCompilationInToolbar } from "./compilation/toolbar.compilation.js"
|
|
24
|
+
import { initToolbarEventSource } from "./eventsource/toolbar.eventsource.js"
|
|
25
|
+
import { makeToolbarResponsive } from "./responsive/toolbar.responsive.js"
|
|
26
|
+
|
|
27
|
+
const toolbarVisibilityPreference = createPreference("toolbar")
|
|
28
|
+
|
|
29
|
+
const renderToolbar = async () => {
|
|
30
|
+
const executedFileCompiledUrl = window.parent.location.href
|
|
31
|
+
const compileServerOrigin = window.parent.location.origin
|
|
32
|
+
// this should not block the whole toolbar rendering + interactivity
|
|
33
|
+
const exploringConfig = await fetchExploringJson()
|
|
34
|
+
const { outDirectoryRelativeUrl, livereloading } = exploringConfig
|
|
35
|
+
const compileGroup = getCompileGroup({
|
|
36
|
+
executedFileCompiledUrl,
|
|
37
|
+
outDirectoryRelativeUrl,
|
|
38
|
+
compileServerOrigin,
|
|
39
|
+
})
|
|
40
|
+
const executedFileRelativeUrl = compileGroup.fileRelativeUrl
|
|
41
|
+
|
|
42
|
+
const toolbarOverlay = document.querySelector("#toolbar-overlay")
|
|
43
|
+
toolbarOverlay.onclick = () => {
|
|
44
|
+
hideAllTooltip()
|
|
45
|
+
hideSettings()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const toolbarElement = document.querySelector("#toolbar")
|
|
49
|
+
exposeOnParentWindow({
|
|
50
|
+
toolbar: {
|
|
51
|
+
element: toolbarElement,
|
|
52
|
+
show: showToolbar,
|
|
53
|
+
hide: () => hideToolbar(),
|
|
54
|
+
toggle: toogleToolbar,
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const toolbarVisible = toolbarVisibilityPreference.has()
|
|
59
|
+
? toolbarVisibilityPreference.get()
|
|
60
|
+
: true
|
|
61
|
+
|
|
62
|
+
if (toolbarVisible) {
|
|
63
|
+
showToolbar({ animate: false })
|
|
64
|
+
} else {
|
|
65
|
+
hideToolbar({ animate: false })
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
renderBackToListInToolbar({
|
|
69
|
+
outDirectoryRelativeUrl,
|
|
70
|
+
exploringHtmlFileRelativeUrl: exploringConfig.exploringHtmlFileRelativeUrl,
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
renderToolbarNotification()
|
|
74
|
+
makeToolbarResponsive()
|
|
75
|
+
renderToolbarSettings()
|
|
76
|
+
renderToolbarAnimation()
|
|
77
|
+
renderToolbarTheme()
|
|
78
|
+
renderExecutionInToolbar({ executedFileRelativeUrl })
|
|
79
|
+
renderCompilationInToolbar({ compileGroup })
|
|
80
|
+
// this might become active but we need to detect this somehow
|
|
81
|
+
deactivateToolbarSection(document.querySelector("#file-list-link"))
|
|
82
|
+
initToolbarEventSource({
|
|
83
|
+
executedFileRelativeUrl,
|
|
84
|
+
livereloading,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
// if user click enter or space quickly while closing toolbar
|
|
88
|
+
// it will cancel the closing
|
|
89
|
+
// that's why I used toggleToolbar and not hideToolbar
|
|
90
|
+
document.querySelector("#button-close-toolbar").onclick = () =>
|
|
91
|
+
toogleToolbar()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const exposeOnParentWindow = (object) => {
|
|
95
|
+
let { __jsenv__ } = window.parent
|
|
96
|
+
if (!__jsenv__) {
|
|
97
|
+
__jsenv__ = {}
|
|
98
|
+
window.parent.__jsenv__ = {}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
Object.assign(__jsenv__, object)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const toogleToolbar = () => {
|
|
105
|
+
if (toolbarIsVisible()) {
|
|
106
|
+
hideToolbar()
|
|
107
|
+
} else {
|
|
108
|
+
showToolbar()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const toolbarIsVisible = () =>
|
|
113
|
+
document.documentElement.hasAttribute("data-toolbar-visible")
|
|
114
|
+
|
|
115
|
+
let hideToolbar = () => {
|
|
116
|
+
// toolbar hidden by default, nothing to do to hide it by default
|
|
117
|
+
sendEventToParent("toolbar-visibility-change", false)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// (by the way it might be cool to have the toolbar auto show when)
|
|
121
|
+
// it has something to say (being disconnected from livereload server)
|
|
122
|
+
const showToolbar = ({ animate = true } = {}) => {
|
|
123
|
+
toolbarVisibilityPreference.set(true)
|
|
124
|
+
if (animate) {
|
|
125
|
+
document.documentElement.setAttribute("data-toolbar-animation", "")
|
|
126
|
+
} else {
|
|
127
|
+
document.documentElement.removeAttribute("data-toolbar-animation")
|
|
128
|
+
}
|
|
129
|
+
document.documentElement.setAttribute("data-toolbar-visible", "")
|
|
130
|
+
|
|
131
|
+
sendEventToParent("toolbar-visibility-change", true)
|
|
132
|
+
|
|
133
|
+
const toolbarIframe = getToolbarIframe()
|
|
134
|
+
const toolbarIframeParent = toolbarIframe.parentNode
|
|
135
|
+
const parentWindow = window.parent
|
|
136
|
+
const parentDocumentElement =
|
|
137
|
+
parentWindow.document.compatMode === "CSS1Compat"
|
|
138
|
+
? parentWindow.document.documentElement
|
|
139
|
+
: parentWindow.document.body
|
|
140
|
+
|
|
141
|
+
const scrollYMax =
|
|
142
|
+
parentDocumentElement.scrollHeight - parentWindow.innerHeight
|
|
143
|
+
const scrollY = parentDocumentElement.scrollTop
|
|
144
|
+
const scrollYRemaining = scrollYMax - scrollY
|
|
145
|
+
|
|
146
|
+
setStyles(toolbarIframeParent, {
|
|
147
|
+
"transition-property": "padding-bottom",
|
|
148
|
+
"transition-duration": "300ms",
|
|
149
|
+
})
|
|
150
|
+
// maybe we should use js animation here because we would not conflict with css
|
|
151
|
+
const restoreToolbarIframeParentStyles = setStyles(toolbarIframeParent, {
|
|
152
|
+
"scroll-padding-bottom": "40px", // same here we should add 40px
|
|
153
|
+
"padding-bottom": "40px", // if there is already one we should add 40px
|
|
154
|
+
})
|
|
155
|
+
const restoreToolbarIframeStyles = setStyles(toolbarIframe, {
|
|
156
|
+
height: "40px",
|
|
157
|
+
visibility: "visible",
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
if (scrollYRemaining < 40 && scrollYMax > 0) {
|
|
161
|
+
const scrollEnd = scrollY + 40
|
|
162
|
+
startJavaScriptAnimation({
|
|
163
|
+
duration: 300,
|
|
164
|
+
onProgress: ({ progress }) => {
|
|
165
|
+
const value = scrollY + (scrollEnd - scrollY) * progress
|
|
166
|
+
parentDocumentElement.scrollTop = value
|
|
167
|
+
},
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
hideToolbar = () => {
|
|
172
|
+
restoreToolbarIframeParentStyles()
|
|
173
|
+
restoreToolbarIframeStyles()
|
|
174
|
+
|
|
175
|
+
hideTooltip(document.querySelector("#eventsource-indicator"))
|
|
176
|
+
hideTooltip(document.querySelector("#execution-indicator"))
|
|
177
|
+
toolbarVisibilityPreference.set(false)
|
|
178
|
+
if (animate) {
|
|
179
|
+
document.documentElement.setAttribute("data-toolbar-animation", "")
|
|
180
|
+
} else {
|
|
181
|
+
document.documentElement.removeAttribute("data-toolbar-animation")
|
|
182
|
+
}
|
|
183
|
+
document.documentElement.removeAttribute("data-toolbar-visible")
|
|
184
|
+
sendEventToParent("toolbar-visibility-change", false)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const getCompileGroup = ({
|
|
189
|
+
executedFileCompiledUrl,
|
|
190
|
+
outDirectoryRelativeUrl,
|
|
191
|
+
compileServerOrigin,
|
|
192
|
+
}) => {
|
|
193
|
+
const outDirectoryServerUrl = String(
|
|
194
|
+
new URL(outDirectoryRelativeUrl, compileServerOrigin),
|
|
195
|
+
)
|
|
196
|
+
if (urlIsInsideOf(executedFileCompiledUrl, outDirectoryServerUrl)) {
|
|
197
|
+
const afterCompileDirectory = urlToRelativeUrl(
|
|
198
|
+
executedFileCompiledUrl,
|
|
199
|
+
outDirectoryServerUrl,
|
|
200
|
+
)
|
|
201
|
+
const slashIndex = afterCompileDirectory.indexOf("/")
|
|
202
|
+
const fileRelativeUrl = afterCompileDirectory.slice(slashIndex + 1)
|
|
203
|
+
return {
|
|
204
|
+
fileRelativeUrl,
|
|
205
|
+
outDirectoryRelativeUrl,
|
|
206
|
+
compileId: afterCompileDirectory.slice(0, slashIndex),
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
fileRelativeUrl: new URL(executedFileCompiledUrl).pathname.slice(1),
|
|
211
|
+
outDirectoryRelativeUrl,
|
|
212
|
+
compileId: null,
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const sendEventToParent = (type, value) => {
|
|
217
|
+
window.parent.postMessage(
|
|
218
|
+
{
|
|
219
|
+
jsenv: true,
|
|
220
|
+
type,
|
|
221
|
+
value,
|
|
222
|
+
},
|
|
223
|
+
"*",
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
window.renderToolbar = renderToolbar
|