Skip to content

Commit 5086848

Browse files
authored
fix: update wasm docs (#4962)
* fix: fix wasm docs for macos * more updates * more updates
1 parent 74ba8cc commit 5086848

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

apps/docs/docs/guides/wasm.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ git clone https://github.com/opensource-observer/marimo.git
7474
cd marimo
7575
```
7676

77-
Additionally, if you're on a macos with Apple Silicon, you may need to run the
78-
following command:
79-
80-
```bash
81-
pixi workspace platform add linux-aarch64
82-
```
83-
8477
Next, in one terminal start the frontend:
8578

8679
```bash
@@ -90,7 +83,7 @@ cd frontend
9083
# Start the frontend. You will want to set PYODIDE=true so that you can force the use of the
9184
# pyodide backend. Vite sometimes needs a bit more memory with the marimo frontend build.
9285
# Hence the `NODE_OPTIONS` setting.
93-
PYODIDE=true NODE_OPTIONS=--max-old-space-size=6144 pnpm vite --config oso.viteconfig.mts
86+
PYODIDE=true NODE_OPTIONS=--max-old-space-size=6144 pnpm vite --config oso.viteconfig.mts --host 127.0.0.1
9487
```
9588

9689
:::Note
@@ -113,10 +106,13 @@ The server will start listening on port 6008 by default.
113106
:::Note
114107
If you happen to be developing, using a remote development setup you will want
115108
to make sure you set the `PUBLIC_PACKAGES_HOST` to the correct host for your
116-
remote setup.
109+
remote setup. To ensure this set the `PUBLIC_PACKAGES_HOST` environment variable
110+
to the correct host. However, you _must_ access the proxy via this hostname in
111+
your browser or you may get cors or other unrelated domain errors and will cause
112+
errors on load.
117113
:::
118114

119-
To access the notebook now, you can navigate to `http://localhost:6008/notebook` in your
115+
To access the notebook now, you can navigate to `http://127.0.0.1:6008/notebook` in your
120116
browser. The `/notebook` endpoint is specific to OSO's wasm environment.
121117

122118
:::
@@ -230,3 +226,23 @@ Now you can go to your browser at http://localhost:6008/notebook.html.
230226
Python simple server does support reference html files without `.html`. This
231227
would be different behavior than something deployed on our production setup.
232228
:::
229+
230+
### Loading environment into wasm notebook
231+
232+
Both code and environment variables are loaded into the wasm notebook via the
233+
fragment identifier in the URL. The notebook treats anything in the fragment
234+
identifier as a set of query parameters. Testing this is a bit hard so we made a
235+
facility that should allow you to create the environment on manually via the
236+
browser debug console. Simply add the `debug=true` variable to the URL fragment
237+
and the `window.__fragmentStore` variable will be populated with the current
238+
`FragmentStore` instance for the notebook. This `FragmentStore` instance has a
239+
`setJSON` method you can use to add any json to the fragment identifier that
240+
you'd like. To add a `env` variable you do something like this:
241+
242+
```javascript
243+
window.__fragmentStore.setJSON("env", { MY_ENV_VAR: "my_value" });
244+
window.__fragmentStore.commit();
245+
```
246+
247+
Now if you refresh the browser, the `os.environ` in python will have your
248+
environment variable loaded.

0 commit comments

Comments
 (0)