Skip to content

Commit

Permalink
Merge remote-tracking branch 'original/main' into wat
Browse files Browse the repository at this point in the history
  • Loading branch information
disberd committed Aug 28, 2024
2 parents f18cb6a + aaa835b commit df24abb
Show file tree
Hide file tree
Showing 73 changed files with 3,696 additions and 3,396 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/IntegrationTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ on:
branches-ignore:
- release

env:
JULIA_PLUTO_IGNORE_CDN_BUNDLE_WARNING: true

jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Pluto"
uuid = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
license = "MIT"
authors = ["Fons van der Plas <[email protected]>"]
version = "0.19.45"
version = "0.19.46"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down Expand Up @@ -42,7 +42,7 @@ Dates = "0, 1"
Downloads = "1"
ExpressionExplorer = "0.5, 0.6, 1"
FileWatching = "1"
FuzzyCompletions = "=0.5.4"
FuzzyCompletions = "=0.5.5"
HTTP = "^1.5.2"
HypertextLiteral = "0.7, 0.8, 0.9"
InteractiveUtils = "1"
Expand Down
5 changes: 3 additions & 2 deletions frontend/common/PlutoConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const create_ws_connection = (address, { on_message, on_socket_close }, timeout_

const send_encoded = (message) => {
const encoded = pack(message)
if (socket.readyState === WebSocket.CLOSED || socket.readyState === WebSocket.CLOSING) throw new Error("Socket is closed")
socket.send(encoded)
}

Expand Down Expand Up @@ -266,7 +267,7 @@ const default_ws_address = () => ws_address_from_base(window.location.href)
*
* @param {{
* on_unrequested_update: (message: PlutoMessage, by_me: boolean) => void,
* on_reconnect: () => boolean,
* on_reconnect: () => Promise<boolean>,
* on_connection_status: (connection_status: boolean, hopeless: boolean) => void,
* connect_metadata?: Object,
* ws_address?: String,
Expand Down Expand Up @@ -377,7 +378,7 @@ export const create_pluto_connection = async ({
await connect() // reconnect!

console.log(`Starting state sync`, new Date().toLocaleTimeString())
const accept = on_reconnect()
const accept = await on_reconnect()
console.log(`State sync ${accept ? "" : "not "}successful`, new Date().toLocaleTimeString())
on_connection_status(accept, false)
if (!accept) {
Expand Down
19 changes: 15 additions & 4 deletions frontend/common/useEventListener.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import { useCallback, useEffect } from "../imports/Preact.js"

/**
* @typedef EventListenerAddable
* @type Document | HTMLElement | Window | EventSource | MediaQueryList | null
*/

export const useEventListener = (
/** @type {Document | HTMLElement | Window | EventSource | MediaQueryList | null} */ element,
/** @type {EventListenerAddable | import("../imports/Preact.js").Ref<EventListenerAddable>} */ element,
/** @type {string} */ event_name,
/** @type {EventListenerOrEventListenerObject} */ handler,
/** @type {any[] | undefined} */ deps
) => {
let handler_cached = useCallback(handler, deps)
useEffect(() => {
if (element == null) return
element.addEventListener(event_name, handler_cached)
return () => element.removeEventListener(event_name, handler_cached)
const e = element
const useme =
e == null || e instanceof Document || e instanceof HTMLElement || e instanceof Window || e instanceof EventSource || e instanceof MediaQueryList
? /** @type {EventListenerAddable} */ (e)
: e.current

if (useme == null) return
useme.addEventListener(event_name, handler_cached)
return () => useme.removeEventListener(event_name, handler_cached)
}, [element, event_name, handler_cached])
}
Loading

0 comments on commit df24abb

Please sign in to comment.