Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎁 Built-in Pkg management #844

Merged
merged 177 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
f190f27
asdf
fonsp Oct 8, 2020
680aeb2
Merge branch 'master' into experiment-pkg-ui-1
fonsp Oct 8, 2020
6ac357d
🐒
fonsp Oct 9, 2020
611bd7a
yay
fonsp Oct 9, 2020
9f0540a
Merge branch 'master' into experiment-pkg-ui-1
fonsp Nov 2, 2020
02eb166
Merge branch 'master' into experiment-pkg-ui-1
fonsp Nov 10, 2020
db98bf6
Pkg versions and names
fonsp Nov 10, 2020
d93ec69
a
fonsp Nov 11, 2020
5107572
Merge branch 'master' into experiment-pkg-ui-1
fonsp Nov 16, 2020
b4034d6
persist bubble state
fonsp Nov 16, 2020
746f004
installed not installed UI
fonsp Nov 16, 2020
1a5f276
asdf
fonsp Nov 17, 2020
7349f6e
serialization
fonsp Nov 17, 2020
6617549
a
fonsp Nov 19, 2020
638ca1e
Merge branch 'master' into experiment-pkg-ui-1
fonsp Dec 12, 2020
a8f519d
Simple ranges, recommendations
fonsp Dec 12, 2020
9aef1d4
prompts
fonsp Dec 13, 2020
5b61052
asdf
fonsp Dec 13, 2020
0d87c3f
asdf
fonsp Dec 13, 2020
400f92a
Update PkgBubble.js
fonsp Dec 13, 2020
de2836c
serialization 1
fonsp Jan 14, 2021
ea5c7fd
serialization 2
fonsp Jan 14, 2021
0f86669
compat julia 1.0
fonsp Jan 14, 2021
1fda096
Update Notebook.jl
fonsp Jan 15, 2021
a8e2e22
Extract module imports from code
fonsp Jan 15, 2021
c807ca2
tests
fonsp Jan 15, 2021
2687e92
rename
fonsp Jan 15, 2021
43837a7
Add and remove packages to match using/import in code
fonsp Jan 15, 2021
1efd31d
helloooo it works!
fonsp Jan 15, 2021
59e0fac
Merge branch 'master' into experiment-pkg-ui-2
fonsp Jan 17, 2021
a28431e
Check for package existance
fonsp Jan 17, 2021
d3dda3d
rename
fonsp Jan 17, 2021
ca6ff15
make available to frontend
fonsp Jan 17, 2021
0122613
asdf
fonsp Jan 17, 2021
3771b6f
Merge inline GUI branch
fonsp Jan 17, 2021
eb97f43
rename
fonsp Jan 17, 2021
6566dfa
rename
fonsp Jan 17, 2021
da339a9
rename
fonsp Jan 17, 2021
6233792
Inline GUI and tooltip for status
fonsp Jan 18, 2021
d959492
Info popup
fonsp Jan 18, 2021
7d924aa
fix
fonsp Jan 20, 2021
9fd8763
Merge branch 'master' into experiment-pkg-ui-2
fonsp Feb 20, 2021
363aff7
Update editor.css
fonsp Feb 20, 2021
a37fcec
Merge branch 'master' into experiment-pkg-ui-2
fonsp Feb 20, 2021
873d758
only test julia 1.5 and 1.6
fonsp Feb 20, 2021
80210ff
Update Test.yml
fonsp Feb 20, 2021
a881608
fix merge from master
fonsp Feb 20, 2021
187920d
Backwards-forwards-compatible file format
fonsp Feb 20, 2021
fbe5f5d
Merge branch 'master' into experiment-pkg-ui-2
fonsp Feb 20, 2021
e543416
Write semver compat entries to Project.toml
fonsp Feb 20, 2021
ce2fc65
Disable PlutoPkg when you Pkg.activate
fonsp Feb 20, 2021
035ef59
delete some old code
fonsp Feb 20, 2021
40bcd9c
css cleanup
fonsp Feb 24, 2021
82823d8
Merge branch 'master' into experiment-pkg-ui-2
fonsp Feb 24, 2021
db4d084
Merge branch 'master' into experiment-pkg-ui-2
fonsp Mar 5, 2021
e6d165e
More flexible loading of old notebooks
fonsp Mar 5, 2021
7bef59b
asdf
fonsp Mar 5, 2021
f35b456
Merge branch 'master' into experiment-pkg-ui-2
fonsp Mar 5, 2021
a31a628
Create old_notebook_with_using.jl
fonsp Mar 5, 2021
a6dd0c6
Update Run.jl
fonsp Mar 5, 2021
b6b3e9f
Merge branch 'master' into experiment-pkg-ui-2
fonsp Mar 5, 2021
8173555
Merge branch 'master' into experiment-pkg-ui-2
fonsp Mar 5, 2021
13d9b09
avoid recommending unnecessary reboot
fonsp Mar 6, 2021
7f8ff63
Update Packages.jl
fonsp Mar 6, 2021
ed64257
comments
fonsp Mar 6, 2021
8766116
Update sample notebooks
fonsp Mar 6, 2021
c6fe6a6
Merge branch 'master' into experiment-pkg-ui-2
fonsp Mar 10, 2021
e8827c4
Update Packages.jl
fonsp Mar 10, 2021
47c7115
Merge branch 'master' into experiment-pkg-ui-2
fonsp Mar 10, 2021
8ff84da
Button to restart notebook when Pkg needs it
fonsp Mar 10, 2021
f0fa8b1
Pkg.add also disabled PlutoPkg
fonsp Mar 10, 2021
45373cf
renamings
fonsp Mar 10, 2021
8dced6b
Update PkgTools.jl
fonsp Mar 11, 2021
1022697
Fix require problem by adding stdlib to LOAD_PATH
fonsp Mar 11, 2021
4f34da7
Run PlutoPkg async while prerendering the notebook
fonsp Mar 11, 2021
0317d86
Pkg.instantiate loaded notebook
fonsp Mar 11, 2021
24c8a83
Merge branch 'master' into experiment-pkg-ui-2
fonsp Mar 11, 2021
829cd5d
Merge branch 'main' into experiment-pkg-ui-2
fonsp Mar 16, 2021
6f7b97b
Merge branch 'main' into experiment-pkg-ui-2
fonsp Mar 17, 2021
340d7c4
Merge branch 'main' into experiment-pkg-ui-2
fonsp Mar 17, 2021
daa1770
Fix frontend race condition
fonsp Mar 17, 2021
d77635e
Merge branch 'main' into experiment-pkg-ui-2
fonsp Mar 17, 2021
1f2c240
add PkgUtils
fonsp Mar 17, 2021
7ec2939
Merge branch 'main' into experiment-pkg-ui-2
fonsp Mar 18, 2021
dd92bf3
merge part 2
fonsp Mar 18, 2021
099ce31
Merge branch 'main' into experiment-pkg-ui-2
fonsp Mar 18, 2021
6de5763
Merge branch 'main' into experiment-pkg-ui-2
fonsp Mar 18, 2021
980192a
Merge branch 'main' into experiment-pkg-ui-2
fonsp Mar 25, 2021
4c37932
Merge branch 'main' into experiment-pkg-ui-2
fonsp Mar 25, 2021
1a3441d
Merge branch 'main' into experiment-pkg-ui-2
Mar 30, 2021
0811a5c
Fix import
Mar 30, 2021
87472f1
format
fonsp Mar 31, 2021
3878a5a
Merge branch 'main' into experiment-pkg-ui-2
fonsp Mar 31, 2021
fae4eb0
Merge branch 'main' into experiment-pkg-ui-2
fonsp Apr 1, 2021
13a17f5
Merge branch 'main' into experiment-pkg-ui-2
fonsp Apr 2, 2021
98f40e4
Merge branch 'main' into experiment-pkg-ui-2
fonsp May 2, 2021
b029f4c
document.title fix
fonsp May 4, 2021
e69db39
Merge branch 'main' into experiment-pkg-ui-2
fonsp Jun 1, 2021
258c9fc
Fix failed precompilation issues
fonsp Jun 1, 2021
1b6ccb1
debug pkg lock
fonsp Jun 1, 2021
0b9382c
autocomplete all registered packages
fonsp Jun 1, 2021
d14fdf1
Merge branch 'main' into experiment-pkg-ui-2
fonsp Jun 1, 2021
4e9c733
show installed version in static export
fonsp Jun 1, 2021
55845fd
Merge branch 'main' into experiment-pkg-ui-2
fonsp Jun 1, 2021
14f1f34
fix tests?
fonsp Jun 1, 2021
5819338
fewer registry updates
fonsp Jun 1, 2021
5eb81bf
disable failing test on windows
fonsp Jun 1, 2021
810188e
Revert "disable failing test on windows"
fonsp Jun 1, 2021
76d5fa9
disable failing tests on windows again
fonsp Jun 1, 2021
a91bdf0
ughh
fonsp Jun 1, 2021
4a24b83
Merge branch 'main' into experiment-pkg-ui-2
fonsp Jun 1, 2021
9dd6dae
Built-in Pkg: relay io to frontend terminal (#1210)
fonsp Jun 1, 2021
fc26006
oops
fonsp Jun 1, 2021
7d925a1
show busy packages
fonsp Jun 1, 2021
b177f3f
toggle terminal
fonsp Jun 1, 2021
6fe02d9
css tweaks
fonsp Jun 1, 2021
cfb8e33
cleanup
fonsp Jun 3, 2021
7599e4f
css tweaks
fonsp Jun 3, 2021
d570c14
better support for multiple registries, docstrings
fonsp Jun 3, 2021
f2e64ef
comments
fonsp Jun 3, 2021
be519ae
add tests with custom registry
fonsp Jun 7, 2021
8dd43fb
oops
fonsp Jun 7, 2021
eddf95f
fix tests?
fonsp Jun 7, 2021
81f8c13
backwards forwards compat tests
fonsp Jun 7, 2021
874f078
windows fix
fonsp Jun 7, 2021
79d7615
Merge branch 'main' into experiment-pkg-ui-2
fonsp Jun 7, 2021
a77b4b0
fix tests
fonsp Jun 7, 2021
861f392
ugh windows
fonsp Jun 7, 2021
6f41427
asdf
fonsp Jun 7, 2021
a66667f
documentation
fonsp Jun 7, 2021
b2e7f1f
pkg cell test
fonsp Jun 7, 2021
39962ee
rename PkgTools to PkgCompat
fonsp Jun 9, 2021
00280ad
add PkgCompat tests
fonsp Jun 9, 2021
42cafec
less internal API for stdlibs
fonsp Jun 9, 2021
2638cd0
less internal API
fonsp Jun 9, 2021
61d7233
more compat
fonsp Jun 9, 2021
b886f17
more tests
fonsp Jun 9, 2021
2ad1dd9
more compat
fonsp Jun 9, 2021
5d66300
whitespace
fonsp Jun 9, 2021
9a5c1c5
Merge branch 'main' into experiment-pkg-ui-2
fonsp Jun 9, 2021
9a0b5ff
Update Test.yml
fonsp Jun 9, 2021
93817e8
fix 1.5 maybe
fonsp Jun 9, 2021
112ee31
fix tests?
fonsp Jun 9, 2021
6f44a4b
whops
fonsp Jun 9, 2021
e4d8adc
Add update button
fonsp Jun 9, 2021
9bb9b04
small things
fonsp Jun 9, 2021
f8dc631
Automatically recover from Pkg failure, tests
fonsp Jun 9, 2021
f0c36eb
Recover from corrupted Manifest in file
fonsp Jun 9, 2021
b09e212
generate test files on 1.5
fonsp Jun 9, 2021
07a0926
Julia 1.8 support
fonsp Jun 9, 2021
11dd6cb
skip some tests on nightly
fonsp Jun 9, 2021
b1a0ab5
js fix
fonsp Jun 9, 2021
800967d
Update with a button
fonsp Jun 9, 2021
2fa94cf
cleanup old code
fonsp Jun 10, 2021
eaa303e
export PkgUtils functions
fonsp Jun 10, 2021
19eb269
remove update backup when nothing changed
fonsp Jun 10, 2021
1cb7c8b
Update Plots.jl.jl
fonsp Jun 10, 2021
4be58fd
Update PlutoUI.jl.jl
fonsp Jun 10, 2021
cbe114f
Update JavaScript.jl
fonsp Jun 10, 2021
509812c
Update Basic.jl
fonsp Jun 10, 2021
90bf512
attempt to recover Project.toml when Manifest fails
fonsp Jun 10, 2021
d938cbc
Create old_artifacts_import.jl
fonsp Jun 10, 2021
a245f99
clear_stdlib_compat_entries
fonsp Jun 10, 2021
a4ef41d
whitespace
fonsp Jun 10, 2021
fb3f498
fixfixfix
fonsp Jun 10, 2021
731177c
fix tests
fonsp Jun 10, 2021
7333154
Reset LOAD_PATH when PlutoPkg is disabled
fonsp Jun 10, 2021
fd670b6
Update Plots.jl.jl
fonsp Jun 10, 2021
affda88
buggy bug
fonsp Jun 10, 2021
f4f2c0d
fix tests?
fonsp Jun 10, 2021
6e86196
cache installed versions & js tweaks
fonsp Jun 10, 2021
f7f9d3d
fixiefix
fonsp Jun 10, 2021
ed008bf
hopla
fonsp Jun 10, 2021
cceb694
help page link
fonsp Jun 10, 2021
b602cca
Delete xterm.js
fonsp Jun 10, 2021
9310121
fix floating marks!
fonsp Jun 10, 2021
3af1e4b
isinteractive() = false during add and resolve
fonsp Jun 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ jobs:
strategy:
matrix:
# We test quite a lot of versions because we do some OS and version specific things unfortunately
julia-version: ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "^1.6.0-0"]
os: [ubuntu-latest]
include:
# macOS and windows - only the extremes, linux covers pretty much everything already i think
- julia-version: "1.0"
os: macOS-latest
- julia-version: "^1.6.0-0"
os: macOS-latest
- julia-version: "1.0"
os: windows-latest
- julia-version: "^1.6.0-0"
os: windows-latest
julia-version: ["1.5", "^1.6.0-0"]
os: [ubuntu-latest, macOS-latest, windows-latest]
# include:
# macOS and windows - only the extremes, linux covers pretty much everything already i think
# - julia-version: "1.0"
# os: macOS-latest
# - julia-version: "^1.6.0-0"
# os: macOS-latest
# - julia-version: "1.0"
# os: windows-latest
# - julia-version: "^1.6.0-0"
# os: windows-latest

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
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.14.0"
version = "0.15.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand All @@ -27,7 +27,7 @@ HTTP = "0.8.18,0.9"
MsgPack = "1.1"
TableIOInterface = "0.1"
Tables = "1"
julia = "^1.0.4"
julia = "^1.5"

[extras]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
4 changes: 4 additions & 0 deletions frontend/components/Cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export const Cell = ({
focus_after_creation,
is_process_ready,
disable_input,
nbpkg_local,
nbpkg,
}) => {
let pluto_actions = useContext(PlutoContext)
// cm_forced_focus is null, except when a line needs to be highlighted because it is part of a stack trace
Expand Down Expand Up @@ -149,6 +151,8 @@ export const Cell = ({
}}
on_update_doc_query=${on_update_doc_query}
on_focus_neighbor=${on_focus_neighbor}
nbpkg_local=${nbpkg_local}
nbpkg=${nbpkg}
cell_id=${cell_id}
notebook_id=${notebook_id}
/>
Expand Down
122 changes: 113 additions & 9 deletions frontend/components/CellInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import observablehq_for_myself from "../common/SetupCellEnvironment.js"
import { utf8index_to_ut16index } from "../common/UnicodeTools.js"
import { map_cmd_to_ctrl_on_mac } from "../common/KeyboardShortcuts.js"
import { PlutoContext } from "../common/PlutoContext.js"
import { PkgStatusMark } from "./PkgStatusMark.js"

// @ts-ignore
const CodeMirror = window.CodeMirror
Expand All @@ -15,6 +16,24 @@ const clear_selection = (cm) => {

const last = (x) => x[x.length - 1]
const all_equal = (x) => x.every((y) => y === x[0])
const swap = (a, i, j) => {
;[a[i], a[j]] = [a[j], a[i]]
}
const range = (a, b) => {
const x = Math.min(a, b)
const y = Math.max(a, b)
return [...Array(y + 1 - x).keys()].map((i) => i + x)
}

const get = (map, key, creator) => {
if (map.has(key)) {
return map.get(key)
} else {
const val = creator()
map.set(key, val)
return val
}
}

// Adapted from https://gomakethings.com/how-to-test-if-an-element-is-in-the-viewport-with-vanilla-javascript/
var offsetFromViewport = function (elem) {
Expand Down Expand Up @@ -52,6 +71,8 @@ export const CellInput = ({
on_update_doc_query,
on_focus_neighbor,
on_drag_drop_events,
nbpkg_local,
nbpkg,
cell_id,
notebook_id,
}) => {
Expand All @@ -67,6 +88,24 @@ export const CellInput = ({
const time_last_being_force_focussed_ref = useRef(0)
const time_last_genuine_backspace = useRef(0)

const pkg_bubbles = useRef(new Map())

useEffect(() => {
pkg_bubbles.current.forEach((b) => {
b.on_nbpkg_local(nbpkg_local)
})
}, [nbpkg_local.packages, nbpkg_local.is_pluto_managed])

useEffect(
() => {
pkg_bubbles.current.forEach((b) => {
b.on_nbpkg(nbpkg)
})
console.log("effect!")
},
nbpkg == null ? [null] : [...Object.values(nbpkg), ...Object.keys(nbpkg.installed_versions), ...Object.values(nbpkg.installed_versions)]
)

useEffect(() => {
const current_value = cm_ref.current?.getValue() ?? ""
if (remote_code_ref.current == null && remote_code === "" && current_value !== "") {
Expand Down Expand Up @@ -196,14 +235,7 @@ export const CellInput = ({
cm.setSelections(new_selections)
}
}
const swap = (a, i, j) => {
;[a[i], a[j]] = [a[j], a[i]]
}
const range = (a, b) => {
const x = Math.min(a, b)
const y = Math.max(a, b)
return [...Array(y + 1 - x).keys()].map((i) => i + x)
}

const alt_move = (delta) => {
const selections = cm.listSelections()
const selected_lines = new Set([].concat(...selections.map((sel) => range(sel.anchor.line, sel.head.line))))
Expand Down Expand Up @@ -425,12 +457,81 @@ export const CellInput = ({
}, 0)
})

cm.on("change", (_, e) => {
cm.on("change", (cm, e) => {
// console.log(e)
const new_value = cm.getValue()
if (new_value.length > 1 && new_value[0] === "?") {
window.dispatchEvent(new CustomEvent("open_live_docs"))
}
on_change_ref.current(new_value)

// cm.replaceRange()
cm.getAllMarks().forEach((m) => {
const m_position = m.find()
if (e.from.line <= m_position.line && m_position.line <= e.to.line) {
m.clear()
}
})

// TODO: put this search in a function that returns the list of mathces
// we can use that when you submit the cell to definitively find the list of import
// and then purge the map?

// TODO: debounce _any_ edit to update all imports for this cell
// because adding #= to the start of a cell will remove imports later

range(e.from.line, e.to.line).map((line_i) => {
/** @type {string} */
const line = cm.getLine(line_i)
if (line != undefined) {
// dunno
// const re = /(using|import)\s*(\w+(?:\,\s*\w+)*)/g

// import A: b. c
// const re = /(using|import)(\s*\w+(\.\w+)*(\s*\:(\s*\w+\,)*(\s*\w+)?))/g

// import A, B, C
const re = /(using|import)(\s*\w+(\.\w+)*)(\s*\,\s*\w+(\.\w+)*)*/g
// const re = /(using|import)\s*(\w+)/g
for (const import_match of line.matchAll(re)) {
// console.log(import_match)

const start = import_match.index + import_match[1].length

const import_token = cm.getTokenAt({ line: line_i, ch: start }, true)

if (import_token.type === "keyword") {
const inner = import_match[0].substr(import_match[1].length)

const inner_re = /(\w+)(\.\w+)*/g
for (const package_match of inner.matchAll(inner_re)) {
const package_name = package_match[1]

if (package_name !== "Base" && package_name !== "Core") {
const widget = get(pkg_bubbles.current, package_name, () => {
const b = PkgStatusMark({
pluto_actions: pluto_actions,
package_name: package_name,
refresh_cm: () => cm.refresh(),
notebook_id: notebook_id,
})
b.on_nbpkg_local(nbpkg_local)
b.on_nbpkg(nbpkg)
return b
})

cm.setBookmark(
{ line: line_i, ch: start + package_match.index + package_match[0].length },
{
widget: widget,
}
)
}
}
}
}
}
})
})

cm.on("blur", () => {
Expand Down Expand Up @@ -463,6 +564,9 @@ export const CellInput = ({
document.fonts.ready.then(() => {
cm.refresh()
})

// we initialize with "" and then call setValue to trigger the "change" event
cm.setValue(local_code)
}, [])

// useEffect(() => {
Expand Down
Loading