Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

improvement: update hash in url when running in wasm (#1008)

Myles Scolnick0a43c1b2266c
diff --git a/frontend/src/core/pyodide/router.ts b/frontend/src/core/pyodide/router.ts
index 7a8677189c..7f926ed1bf 100644
--- a/frontend/src/core/pyodide/router.ts
+++ b/frontend/src/core/pyodide/router.ts
@@ -20,6 +20,10 @@ class URLPyodideRouter {
return hash.slice(prefix.length);
}
+ setCodeForHash(code: string) {
+ window.location.hash = `#code/${code}`;
+ }
+
private setSearchParam(key: string, value: string) {
const url = new URL(window.location.href);
url.searchParams.set(key, value);
diff --git a/frontend/src/core/pyodide/store.ts b/frontend/src/core/pyodide/store.ts
index cdc3856fdd..6a3363fe6e 100644
--- a/frontend/src/core/pyodide/store.ts
+++ b/frontend/src/core/pyodide/store.ts
@@ -1,6 +1,9 @@
/* Copyright 2024 Marimo. All rights reserved. */
import { TypedLocalStorage } from "@/utils/localStorage";
-import { decompressFromEncodedURIComponent } from "lz-string";
+import {
+ decompressFromEncodedURIComponent,
+ compressToEncodedURIComponent,
+} from "lz-string";
import { PyodideRouter } from "./router";
export interface FileStore {
@@ -20,7 +23,8 @@ export const localStorageFileStore: FileStore = {
const urlFileStore: FileStore = {
saveFile(contents: string) {
- // Do nothing
+ // Set the code in the URL
+ PyodideRouter.setCodeForHash(compressToEncodedURIComponent(contents));
},
readFile() {
const code =
diff --git a/marimo/_smoke_tests/third_party/holoviews.py b/marimo/_smoke_tests/third_party/holoviews.py
index 7d254f42fb..7972f7ec01 100644
--- a/marimo/_smoke_tests/third_party/holoviews.py
+++ b/marimo/_smoke_tests/third_party/holoviews.py
@@ -2,7 +2,7 @@
import marimo
-__generated_with = "0.2.7"
+__generated_with = "0.3.4"
app = marimo.App()