@jsenv/core 29.8.5 → 29.9.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/README.md +1 -1
- package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +21 -5
- package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +8 -6
- package/dist/js/autoreload.js +1 -1
- package/dist/js/s.js +22 -5
- package/dist/js/s.js.map +9 -7
- package/dist/main.js +50 -2085
- package/package.json +8 -8
- package/src/build/build.js +33 -33
- package/src/plugins/plugins.js +1 -1
- package/src/plugins/ribbon/jsenv_plugin_ribbon.js +6 -1
- package/src/plugins/url_resolution/jsenv_plugin_url_resolution.js +6 -2
- package/src/plugins/url_resolution/node_esm_resolver.js +6 -1
- package/dist/js/html_src_set.js +0 -20
- package/src/plugins/toolbar/client/animation/toolbar_animation.js +0 -39
- package/src/plugins/toolbar/client/eventsource/eventsource.css +0 -83
- package/src/plugins/toolbar/client/eventsource/toolbar_eventsource.js +0 -57
- package/src/plugins/toolbar/client/execution/execution.css +0 -79
- package/src/plugins/toolbar/client/execution/toolbar_execution.js +0 -88
- package/src/plugins/toolbar/client/focus/focus.css +0 -61
- package/src/plugins/toolbar/client/focus/toolbar_focus.js +0 -19
- package/src/plugins/toolbar/client/jsenv_logo.svg +0 -140
- package/src/plugins/toolbar/client/notification/toolbar_notification.js +0 -181
- package/src/plugins/toolbar/client/responsive/overflow_menu.css +0 -61
- package/src/plugins/toolbar/client/responsive/toolbar_responsive.js +0 -103
- package/src/plugins/toolbar/client/settings/settings.css +0 -201
- package/src/plugins/toolbar/client/settings/toolbar_settings.js +0 -47
- package/src/plugins/toolbar/client/theme/jsenv_theme.css +0 -77
- package/src/plugins/toolbar/client/theme/light_theme.css +0 -106
- package/src/plugins/toolbar/client/theme/toolbar_theme.js +0 -34
- package/src/plugins/toolbar/client/toolbar.html +0 -457
- package/src/plugins/toolbar/client/toolbar_injector.js +0 -218
- package/src/plugins/toolbar/client/toolbar_main.css +0 -172
- package/src/plugins/toolbar/client/toolbar_main.js +0 -197
- package/src/plugins/toolbar/client/tooltip/tooltip.css +0 -61
- package/src/plugins/toolbar/client/tooltip/tooltip.js +0 -39
- package/src/plugins/toolbar/client/util/animation.js +0 -305
- package/src/plugins/toolbar/client/util/dom.js +0 -108
- package/src/plugins/toolbar/client/util/fetch_using_xhr.js +0 -400
- package/src/plugins/toolbar/client/util/fetching.js +0 -14
- package/src/plugins/toolbar/client/util/iframe_to_parent_href.js +0 -10
- package/src/plugins/toolbar/client/util/jsenv_logger.js +0 -28
- package/src/plugins/toolbar/client/util/preferences.js +0 -10
- package/src/plugins/toolbar/client/util/responsive.js +0 -112
- package/src/plugins/toolbar/client/util/util.js +0 -19
- package/src/plugins/toolbar/client/variant/variant.js +0 -74
- package/src/plugins/toolbar/jsenv_plugin_toolbar.js +0 -62
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import { setStyles } from "./dom.js"
|
|
2
|
-
|
|
3
|
-
const animateFallback = () => {
|
|
4
|
-
return Promise.resolve()
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const animateNative = (node, keyframes, { signal, ...options } = {}) => {
|
|
8
|
-
const animation = node.animate(keyframes, options)
|
|
9
|
-
if (signal) {
|
|
10
|
-
signal.addEventListener("abort", () => {
|
|
11
|
-
animation.cancel()
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
return new Promise((resolve) => {
|
|
15
|
-
animation.onfinish = resolve
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const canUseAnimation = () =>
|
|
20
|
-
typeof HTMLElement.prototype.animate === "function"
|
|
21
|
-
|
|
22
|
-
export const animateElement = canUseAnimation()
|
|
23
|
-
? animateNative
|
|
24
|
-
: animateFallback
|
|
25
|
-
|
|
26
|
-
export const fadeIn = (node, options) =>
|
|
27
|
-
animateElement(
|
|
28
|
-
node,
|
|
29
|
-
[
|
|
30
|
-
{
|
|
31
|
-
opacity: 0,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
opacity: 1,
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
options,
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
export const fadeOut = (node, options) =>
|
|
41
|
-
animateElement(
|
|
42
|
-
node,
|
|
43
|
-
[
|
|
44
|
-
{
|
|
45
|
-
opacity: 1,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
opacity: 0,
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
options,
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
export const move = (fromNode, toNode, options) => {
|
|
55
|
-
const fromComputedStyle = window.getComputedStyle(fromNode)
|
|
56
|
-
const toComputedStyle = window.getComputedStyle(toNode)
|
|
57
|
-
// get positions of input in toolbar and aElement
|
|
58
|
-
const fromPosition = fromNode.getBoundingClientRect()
|
|
59
|
-
const toPosition = toNode.getBoundingClientRect()
|
|
60
|
-
|
|
61
|
-
// we'll do the animation in a div preventing overflow and pointer events
|
|
62
|
-
const div = document.createElement("div")
|
|
63
|
-
div.style.position = "absolute"
|
|
64
|
-
div.style.left = 0
|
|
65
|
-
div.style.top = 0
|
|
66
|
-
div.style.width = `${document.documentElement.scrollWidth}px`
|
|
67
|
-
div.style.height = `${document.documentElement.scrollHeight}px`
|
|
68
|
-
div.style.overflow = "hidden"
|
|
69
|
-
div.style.pointerEvents = "none"
|
|
70
|
-
|
|
71
|
-
const documentScroll = {
|
|
72
|
-
left: window.pageXOffset || document.documentElement.scrollLeft,
|
|
73
|
-
top: window.pageYOffset || document.documentElement.scrollTop,
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// clone node and style it
|
|
77
|
-
const copy = fromNode.cloneNode(true)
|
|
78
|
-
copy.style.position = "absolute"
|
|
79
|
-
copy.style.left = `${documentScroll.left + fromPosition.left}px`
|
|
80
|
-
copy.style.top = `${documentScroll.top + fromPosition.top}px`
|
|
81
|
-
copy.style.maxWidth = `${fromPosition.right - fromPosition.left}px`
|
|
82
|
-
copy.style.overflow = toComputedStyle.overflow
|
|
83
|
-
copy.style.textOverflow = toComputedStyle.textOverflow
|
|
84
|
-
div.appendChild(copy)
|
|
85
|
-
document.body.appendChild(div)
|
|
86
|
-
|
|
87
|
-
const left =
|
|
88
|
-
toPosition.left -
|
|
89
|
-
fromPosition.left -
|
|
90
|
-
(parseInt(fromComputedStyle.paddingLeft) || 0)
|
|
91
|
-
const top =
|
|
92
|
-
toPosition.top -
|
|
93
|
-
fromPosition.top -
|
|
94
|
-
(parseInt(fromComputedStyle.paddingTop) || 0)
|
|
95
|
-
// define final position of new element and the duration
|
|
96
|
-
const translate = `translate(${left}px, ${top}px)`
|
|
97
|
-
|
|
98
|
-
// animate new element
|
|
99
|
-
return animateElement(
|
|
100
|
-
copy,
|
|
101
|
-
[
|
|
102
|
-
{
|
|
103
|
-
transform: "translate(0px, 0px)",
|
|
104
|
-
backgroundColor: fromComputedStyle.backgroundColor,
|
|
105
|
-
color: fromComputedStyle.color,
|
|
106
|
-
fontSize: fromComputedStyle.fontSize,
|
|
107
|
-
height: `${fromPosition.bottom - fromPosition.top}px`,
|
|
108
|
-
width: "100%",
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
offset: 0.9,
|
|
112
|
-
backgroundColor: fromComputedStyle.backgroundColor,
|
|
113
|
-
color: fromComputedStyle.color,
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
transform: translate,
|
|
117
|
-
backgroundColor: toComputedStyle.backgroundColor,
|
|
118
|
-
color: toComputedStyle.color,
|
|
119
|
-
fontSize: toComputedStyle.fontSize,
|
|
120
|
-
height: `${toPosition.bottom - toPosition.top}px`,
|
|
121
|
-
width: toComputedStyle.width,
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
options,
|
|
125
|
-
).then(() => {
|
|
126
|
-
div.parentNode.removeChild(div)
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// the whole point of this toolbar animation wass to flight a visual imperfection when it's done by css transition.
|
|
131
|
-
// This imperfection is a white line sometimes flickering at the bottom of the page.
|
|
132
|
-
// It got fixed by removing the usage of calc(100vh - 40px)
|
|
133
|
-
// It was hapenning in chrome, safari but not inside Firefox
|
|
134
|
-
// I assume it's because Firefox does not read parent element min-height while
|
|
135
|
-
// chrome use it to compute min-height: 100%
|
|
136
|
-
export const createToolbarAnimation = () => {
|
|
137
|
-
const collapsedState = {
|
|
138
|
-
"#page": { paddingBottom: 0 },
|
|
139
|
-
"footer": { height: 0 },
|
|
140
|
-
"#toolbar": { visibility: "hidden" },
|
|
141
|
-
}
|
|
142
|
-
const expandedState = {
|
|
143
|
-
"#page": { paddingBottom: "40px" },
|
|
144
|
-
"footer": { height: "40px" },
|
|
145
|
-
"#toolbar": { visibility: "visible" },
|
|
146
|
-
}
|
|
147
|
-
const expandTransition = transit(collapsedState, expandedState, {
|
|
148
|
-
duration: 300,
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
const expand = () => {
|
|
152
|
-
expandTransition.play()
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const collapse = () => {
|
|
156
|
-
expandTransition.reverse()
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return { expand, collapse }
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export const transit = (
|
|
163
|
-
fromState,
|
|
164
|
-
toState,
|
|
165
|
-
{ commitStyles = true, fill = "both", duration = 300 } = {},
|
|
166
|
-
) => {
|
|
167
|
-
const steps = []
|
|
168
|
-
Object.keys(fromState).forEach((selector) => {
|
|
169
|
-
const fromStyles = {}
|
|
170
|
-
const toStyles = {}
|
|
171
|
-
const element = document.querySelector(selector)
|
|
172
|
-
|
|
173
|
-
const keyframes = []
|
|
174
|
-
const fromProperties = fromState[selector]
|
|
175
|
-
const toProperties = toState[selector]
|
|
176
|
-
Object.keys(fromProperties).forEach((propertyName) => {
|
|
177
|
-
const from = fromProperties[propertyName]
|
|
178
|
-
const to = toProperties[propertyName]
|
|
179
|
-
fromStyles[propertyName] = from
|
|
180
|
-
toStyles[propertyName] = to
|
|
181
|
-
})
|
|
182
|
-
keyframes.push(fromStyles, toStyles)
|
|
183
|
-
|
|
184
|
-
let animation
|
|
185
|
-
if (canUseAnimation()) {
|
|
186
|
-
const effect = new KeyframeEffect(element, keyframes, { fill, duration })
|
|
187
|
-
animation = new Animation(effect)
|
|
188
|
-
} else {
|
|
189
|
-
animation = {
|
|
190
|
-
playbackRate: 1,
|
|
191
|
-
play: () => {
|
|
192
|
-
animation.onfinish()
|
|
193
|
-
},
|
|
194
|
-
reverse: () => {
|
|
195
|
-
animation.playbackRate = -1
|
|
196
|
-
animation.onfinish()
|
|
197
|
-
},
|
|
198
|
-
finish: () => {},
|
|
199
|
-
onfinish: () => {},
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
steps.push({
|
|
204
|
-
element,
|
|
205
|
-
animation,
|
|
206
|
-
fromStyles,
|
|
207
|
-
toStyles,
|
|
208
|
-
})
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
const play = async () => {
|
|
212
|
-
await Promise.all(
|
|
213
|
-
steps.map(({ animation, element, toStyles }) => {
|
|
214
|
-
return new Promise((resolve) => {
|
|
215
|
-
animation.onfinish = () => {
|
|
216
|
-
if (commitStyles) {
|
|
217
|
-
setStyles(element, toStyles)
|
|
218
|
-
}
|
|
219
|
-
resolve()
|
|
220
|
-
}
|
|
221
|
-
if (animation.playbackRate === -1) {
|
|
222
|
-
animation.reverse()
|
|
223
|
-
} else {
|
|
224
|
-
animation.play()
|
|
225
|
-
}
|
|
226
|
-
})
|
|
227
|
-
}),
|
|
228
|
-
)
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const reverse = async () => {
|
|
232
|
-
await Promise.all(
|
|
233
|
-
steps.map(({ animation, element, fromStyles }) => {
|
|
234
|
-
return new Promise((resolve) => {
|
|
235
|
-
animation.onfinish = () => {
|
|
236
|
-
if (commitStyles) {
|
|
237
|
-
setStyles(element, fromStyles)
|
|
238
|
-
}
|
|
239
|
-
resolve()
|
|
240
|
-
}
|
|
241
|
-
animation.reverse()
|
|
242
|
-
})
|
|
243
|
-
}),
|
|
244
|
-
)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const finish = async () => {
|
|
248
|
-
steps.forEach(({ animation }) => {
|
|
249
|
-
animation.finish()
|
|
250
|
-
})
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return { play, reverse, finish }
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export const startJavaScriptAnimation = ({
|
|
257
|
-
duration = 300,
|
|
258
|
-
timingFunction = (t) => t,
|
|
259
|
-
onProgress = () => {},
|
|
260
|
-
onCancel = () => {},
|
|
261
|
-
onComplete = () => {},
|
|
262
|
-
}) => {
|
|
263
|
-
if (isNaN(duration)) {
|
|
264
|
-
// console.warn(`duration must be a number, received ${duration}`)
|
|
265
|
-
return () => {}
|
|
266
|
-
}
|
|
267
|
-
duration = parseInt(duration, 10)
|
|
268
|
-
const startMs = performance.now()
|
|
269
|
-
let currentRequestAnimationFrameId
|
|
270
|
-
let done = false
|
|
271
|
-
let rawProgress = 0
|
|
272
|
-
let progress = 0
|
|
273
|
-
const handler = () => {
|
|
274
|
-
currentRequestAnimationFrameId = null
|
|
275
|
-
const nowMs = performance.now()
|
|
276
|
-
rawProgress = Math.min((nowMs - startMs) / duration, 1)
|
|
277
|
-
progress = timingFunction(rawProgress)
|
|
278
|
-
done = rawProgress === 1
|
|
279
|
-
onProgress({
|
|
280
|
-
done,
|
|
281
|
-
rawProgress,
|
|
282
|
-
progress,
|
|
283
|
-
})
|
|
284
|
-
if (done) {
|
|
285
|
-
onComplete()
|
|
286
|
-
} else {
|
|
287
|
-
currentRequestAnimationFrameId = window.requestAnimationFrame(handler)
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
handler()
|
|
291
|
-
const stop = () => {
|
|
292
|
-
if (currentRequestAnimationFrameId) {
|
|
293
|
-
window.cancelAnimationFrame(currentRequestAnimationFrameId)
|
|
294
|
-
currentRequestAnimationFrameId = null
|
|
295
|
-
}
|
|
296
|
-
if (!done) {
|
|
297
|
-
done = true
|
|
298
|
-
onCancel({
|
|
299
|
-
rawProgress,
|
|
300
|
-
progress,
|
|
301
|
-
})
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return stop
|
|
305
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
export const updateIframeOverflowOnParentWindow = () => {
|
|
2
|
-
if (!window.parent) {
|
|
3
|
-
// can happen while parent iframe reloads
|
|
4
|
-
return
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const aTooltipIsOpened =
|
|
8
|
-
document.querySelector("[data-tooltip-visible]") ||
|
|
9
|
-
document.querySelector("[data-tooltip-auto-visible]")
|
|
10
|
-
const settingsAreOpened = document.querySelector("#settings[data-active]")
|
|
11
|
-
|
|
12
|
-
if (aTooltipIsOpened || settingsAreOpened) {
|
|
13
|
-
enableIframeOverflowOnParentWindow()
|
|
14
|
-
} else {
|
|
15
|
-
disableIframeOverflowOnParentWindow()
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let iframeOverflowEnabled = false
|
|
20
|
-
const enableIframeOverflowOnParentWindow = () => {
|
|
21
|
-
if (iframeOverflowEnabled) return
|
|
22
|
-
iframeOverflowEnabled = true
|
|
23
|
-
|
|
24
|
-
const iframe = getToolbarIframe()
|
|
25
|
-
const transitionDuration = iframe.style.transitionDuration
|
|
26
|
-
setStyles(iframe, { "height": "100%", "transition-duration": "0ms" })
|
|
27
|
-
if (transitionDuration) {
|
|
28
|
-
setTimeout(() => {
|
|
29
|
-
setStyles(iframe, { "transition-duration": transitionDuration })
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const disableIframeOverflowOnParentWindow = () => {
|
|
35
|
-
if (!iframeOverflowEnabled) return
|
|
36
|
-
iframeOverflowEnabled = false
|
|
37
|
-
|
|
38
|
-
const iframe = getToolbarIframe()
|
|
39
|
-
const transitionDuration = iframe.style.transitionDuration
|
|
40
|
-
setStyles(iframe, { "height": "40px", "transition-duration": "0ms" })
|
|
41
|
-
if (transitionDuration) {
|
|
42
|
-
setTimeout(() => {
|
|
43
|
-
setStyles(iframe, { "transition-duration": transitionDuration })
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const getToolbarIframe = () => {
|
|
49
|
-
const iframes = Array.from(window.parent.document.querySelectorAll("iframe"))
|
|
50
|
-
return iframes.find((iframe) => iframe.contentWindow === window)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const forceHideElement = (element) => {
|
|
54
|
-
element.setAttribute("data-force-hide", "")
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export const removeForceHideElement = (element) => {
|
|
58
|
-
element.removeAttribute("data-force-hide")
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const setStyles = (element, styles) => {
|
|
62
|
-
const elementStyle = element.style
|
|
63
|
-
const restoreStyles = Object.keys(styles).map((styleName) => {
|
|
64
|
-
let restore
|
|
65
|
-
if (styleName in elementStyle) {
|
|
66
|
-
const currentStyle = elementStyle[styleName]
|
|
67
|
-
restore = () => {
|
|
68
|
-
elementStyle[styleName] = currentStyle
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
restore = () => {
|
|
72
|
-
delete elementStyle[styleName]
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
elementStyle[styleName] = styles[styleName]
|
|
77
|
-
|
|
78
|
-
return restore
|
|
79
|
-
})
|
|
80
|
-
return () => {
|
|
81
|
-
restoreStyles.forEach((restore) => restore())
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const setAttributes = (element, attributes) => {
|
|
86
|
-
Object.keys(attributes).forEach((name) => {
|
|
87
|
-
element.setAttribute(name, attributes[name])
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export const getDocumentScroll = () => {
|
|
92
|
-
return {
|
|
93
|
-
x: document.documentElement.scrollLeft,
|
|
94
|
-
y: document.documentElement.scrollTop,
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export const toolbarSectionIsActive = (element) => {
|
|
99
|
-
return element.hasAttribute("data-active")
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export const activateToolbarSection = (element) => {
|
|
103
|
-
element.setAttribute("data-active", "")
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export const deactivateToolbarSection = (element) => {
|
|
107
|
-
element.removeAttribute("data-active")
|
|
108
|
-
}
|