Skip to content

Commit a7fe593

Browse files
authored
Merge pull request #145 from pyscript/2024-10-1
2024 10 1
2 parents 9943caf + 5557821 commit a7fe593

File tree

6 files changed

+50
-14
lines changed

6 files changed

+50
-14
lines changed

docs/api.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,42 @@ store = await storage("my-data-store", storage_class=MyStorage)
417417
# The store object is now an instance of MyStorage.
418418
```
419419

420+
### `@pyscript/core/donkey`
421+
422+
Sometimes you need a Python worker ready and waiting to evaluate any code on
423+
your behalf. This is the concept behind the JavaScript "donkey". We couldn't
424+
think of a better way than "donkey" to describe something that is easy to
425+
understand and shoulders the burden without complaint. This feature
426+
means you're able to use PyScript without resorting to specialised
427+
`<script type="py">` style tags. It's just vanilla JavaScript.
428+
429+
Simply `import { donkey } from '@pyscript/core/dist/core.js'` and automatically
430+
have both a *pyscript* module running on your page and a utility to bootstrap a
431+
terminal based worker to evaluate any Python code as and when needed in the
432+
future.
433+
434+
```js title="A donkey worker"
435+
import { donkey } from '@pyscript/core/dist/core.js';
436+
437+
const {
438+
process, // process(code) code (visible in the terminal)
439+
execute, // execute(statement) in Python exec way
440+
evaluate, // evaluate(expression) in Python eval way
441+
clear, // clear() the terminal
442+
reset, // reset() the terminal (including colors)
443+
kill, // kill() the worker forever
444+
} = donkey({
445+
type: 'py' || 'mpy', // the Python interpreter to run
446+
persistent: false, // use `true` to track globals and locals
447+
terminal: '', // optionally set a target terminal container
448+
config: {}, // the worker config (packages, files, etc.)
449+
});
450+
```
451+
452+
By default PyScript creates a target terminal. If you don't want a terminal to
453+
appear on your page, use the `terminal` option to point to a CSS addressable
454+
container that is not visible (i.e. the target has `display: none`).
455+
420456
### `@pyscript/core/dist/storage.js`
421457

422458
The equivalent functionality based on the *JS* module can be found through our module.

docs/beginning-pyscript.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ module in the document's `<head>` tag:
117117
<meta charset="utf-8" />
118118
<meta name="viewport" content="width=device-width,initial-scale=1" />
119119
<title>🦜 Polyglot - Piratical PyScript</title>
120-
<link rel="stylesheet" href="https://pyscript.net/releases/2024.9.2/core.css">
121-
<script type="module" src="https://pyscript.net/releases/2024.9.2/core.js"></script>
120+
<link rel="stylesheet" href="https://pyscript.net/releases/2024.10.1/core.css">
121+
<script type="module" src="https://pyscript.net/releases/2024.10.1/core.js"></script>
122122
</head>
123123
<body>
124124

@@ -168,8 +168,8 @@ In the end, our HTML should look like this:
168168
<meta charset="utf-8" />
169169
<meta name="viewport" content="width=device-width,initial-scale=1" />
170170
<title>🦜 Polyglot - Piratical PyScript</title>
171-
<link rel="stylesheet" href="https://pyscript.net/releases/2024.9.2/core.css">
172-
<script type="module" src="https://pyscript.net/releases/2024.9.2/core.js"></script>
171+
<link rel="stylesheet" href="https://pyscript.net/releases/2024.10.1/core.css">
172+
<script type="module" src="https://pyscript.net/releases/2024.10.1/core.js"></script>
173173
</head>
174174
<body>
175175
<h1>Polyglot 🦜 💬 🇬🇧 ➡️ 🏴‍☠️</h1>

docs/user-guide/first-steps.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ CSS:
2020
<meta charset="UTF-8">
2121
<meta name="viewport" content="width=device-width,initial-scale=1.0">
2222
<!-- PyScript CSS -->
23-
<link rel="stylesheet" href="https://pyscript.net/releases/2024.9.2/core.css">
23+
<link rel="stylesheet" href="https://pyscript.net/releases/2024.10.1/core.css">
2424
<!-- This script tag bootstraps PyScript -->
25-
<script type="module" src="https://pyscript.net/releases/2024.9.2/core.js"></script>
25+
<script type="module" src="https://pyscript.net/releases/2024.10.1/core.js"></script>
2626
</head>
2727
<body>
2828
<!-- your code goes here... -->

docs/user-guide/plugins.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ For example, this will work because all references are contained within the
100100
registered function:
101101

102102
```js
103-
import { hooks } from "https://pyscript.net/releases/2024.9.2/core.js";
103+
import { hooks } from "https://pyscript.net/releases/2024.10.1/core.js";
104104

105105
hooks.worker.onReady.add(() => {
106106
// NOT suggested, just an example!
@@ -114,7 +114,7 @@ hooks.worker.onReady.add(() => {
114114
However, due to the outer reference to the variable `i`, this will fail:
115115

116116
```js
117-
import { hooks } from "https://pyscript.net/releases/2024.9.2/core.js";
117+
import { hooks } from "https://pyscript.net/releases/2024.10.1/core.js";
118118

119119
// NO NO NO NO NO! ☠️
120120
let i = 0;
@@ -147,7 +147,7 @@ the page.
147147

148148
```js title="log.js - a plugin that simply logs to the console."
149149
// import the hooks from PyScript first...
150-
import { hooks } from "https://pyscript.net/releases/2024.9.2/core.js";
150+
import { hooks } from "https://pyscript.net/releases/2024.10.1/core.js";
151151

152152
// The `hooks.main` attribute defines plugins that run on the main thread.
153153
hooks.main.onReady.add((wrap, element) => {
@@ -197,8 +197,8 @@ hooks.worker.onAfterRun.add(() => {
197197
<!-- JS plugins should be available before PyScript bootstraps -->
198198
<script type="module" src="./log.js"></script>
199199
<!-- PyScript -->
200-
<link rel="stylesheet" href="https://pyscript.net/releases/2024.9.2/core.css">
201-
<script type="module" src="https://pyscript.net/releases/2024.9.2/core.js"></script>
200+
<link rel="stylesheet" href="https://pyscript.net/releases/2024.10.1/core.css">
201+
<script type="module" src="https://pyscript.net/releases/2024.10.1/core.js"></script>
202202
</head>
203203
<body>
204204
<script type="mpy">

docs/user-guide/workers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ Here's how:
282282
<meta charset="utf-8">
283283
<meta name="viewport" content="width=device-width,initial-scale=1">
284284
<!-- PyScript CSS -->
285-
<link rel="stylesheet" href="https://pyscript.net/releases/2024.9.2/core.css">
285+
<link rel="stylesheet" href="https://pyscript.net/releases/2024.10.1/core.css">
286286
<!-- This script tag bootstraps PyScript -->
287-
<script type="module" src="https://pyscript.net/releases/2024.9.2/core.js"></script>
287+
<script type="module" src="https://pyscript.net/releases/2024.10.1/core.js"></script>
288288
<title>PyWorker - mpy bootstrapping pyodide example</title>
289289
<script type="mpy" src="main.py"></script>
290290
</head>

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "2024.9.2"
2+
"version": "2024.10.1"
33
}

0 commit comments

Comments
 (0)