Skip to content

Commit 3419396

Browse files
refactor: serve runtime, host and std from cdn.edgepython.com path prefixes.
1 parent 574856c commit 3419396

24 files changed

Lines changed: 72 additions & 73 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ edge -h # List all commands
6666
<html>
6767
<head>
6868
<meta charset="UTF-8">
69-
<script type="module" src="https://runtime.edgepython.com/js/src/element.js"></script>
69+
<script type="module" src="https://cdn.edgepython.com/runtime/src/element.js"></script>
7070
</head>
7171
<body>
7272
<edge-python entry="./app/main.py" packages="./app/packages.json"></edge-python>

cli/src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::time::Instant;
1111
use crate::pkg::{self, Kind, Manifest};
1212

1313
// Production layout we mirror into dist/runtime/ and dist/.
14-
const RUNTIME_BASE: &str = "https://runtime.edgepython.com/js/";
14+
const RUNTIME_BASE: &str = "https://cdn.edgepython.com/runtime/";
1515
const COMPILER_WASM: &str = "https://cdn.edgepython.com/compiler.wasm";
1616
const RUNTIME_FILES: &[&str] = &[
1717
"src/index.js",

cli/src/pkg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn registry(name: &str) -> Option<(Kind, String)> {
4949
if STD.contains(&name) {
5050
Some((Kind::Std, std_url(name)))
5151
} else if HOST.contains(&name) {
52-
Some((Kind::Host, format!("https://host.edgepython.com/{name}/index.js")))
52+
Some((Kind::Host, format!("https://cdn.edgepython.com/host/{name}/index.js")))
5353
} else {
5454
None
5555
}
@@ -58,7 +58,7 @@ pub fn registry(name: &str) -> Option<(Kind, String)> {
5858
/// CDN url for a std package. Most ship as `.wasm`; `test` is pure Edge Python, served as `.py`. Mirrors runtime/src/defaults.js.
5959
fn std_url(name: &str) -> String {
6060
let ext = if name == "test" { "py" } else { "wasm" };
61-
format!("https://std.edgepython.com/{name}.{ext}")
61+
format!("https://cdn.edgepython.com/std/{name}.{ext}")
6262
}
6363

6464
/// Resolve `name` for the runtime: user manifest entry first, registry fallback.

cli/src/templates/harness.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<script type="module" src="https://runtime.edgepython.com/js/src/element.js"></script>
5+
<script type="module" src="https://cdn.edgepython.com/runtime/src/element.js"></script>
66
</head>
77
<body>
88
<edge-python id="ep" packages="packages.json"></edge-python>

cli/src/templates/scaffold.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>__EDGE_TITLE__</title>
6-
<script type="module" src="https://runtime.edgepython.com/js/src/element.js"></script>
6+
<script type="module" src="https://cdn.edgepython.com/runtime/src/element.js"></script>
77
</head>
88
<body>
99
<edge-python src="main.py" packages="packages.json"></edge-python>

cli/tests/cli.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@
2222
"given": { "packages.json": "{}\n" },
2323
"run": ["add", "math"],
2424
"stdout": ["+ math", "std"],
25-
"contains": { "packages.json": "std.edgepython.com/math.wasm" }
25+
"contains": { "packages.json": "cdn.edgepython.com/std/math.wasm" }
2626
},
2727
{
2828
"given": { "packages.json": "{}\n" },
2929
"run": ["add", "network"],
3030
"stdout": ["+ network", "host"],
31-
"contains": { "packages.json": "host.edgepython.com/network/index.js" }
31+
"contains": { "packages.json": "cdn.edgepython.com/host/network/index.js" }
3232
},
3333
{
3434
"given": { "packages.json": "{}\n" },
3535
"run": ["add", "test"],
3636
"stdout": ["+ test", "std"],
37-
"contains": { "packages.json": "std.edgepython.com/test.py" }
37+
"contains": { "packages.json": "cdn.edgepython.com/std/test.py" }
3838
},
3939
{
4040
"given": { "packages.json": "{}\n" },
@@ -57,7 +57,7 @@
5757
"fails": ["nothing to add"]
5858
},
5959
{
60-
"given": { "packages.json": "{\"imports\":{\"math\":\"https://std.edgepython.com/math.wasm\"}}\n" },
60+
"given": { "packages.json": "{\"imports\":{\"math\":\"https://cdn.edgepython.com/std/math.wasm\"}}\n" },
6161
"run": ["remove", "math"],
6262
"stdout": ["- math"]
6363
},
@@ -67,7 +67,7 @@
6767
"fails": ["not in"]
6868
},
6969
{
70-
"given": { "packages.json": "{\"imports\":{\"math\":\"https://std.edgepython.com/math.wasm\"}}\n" },
70+
"given": { "packages.json": "{\"imports\":{\"math\":\"https://cdn.edgepython.com/std/math.wasm\"}}\n" },
7171
"run": ["remove", "math", "mystery"],
7272
"fails": ["not in"],
7373
"contains": { "packages.json": "math.wasm" }
@@ -79,7 +79,7 @@
7979
{
8080
"given": { "custom.json": "{}\n" },
8181
"run": ["--packages", "custom.json", "add", "math"],
82-
"contains": { "custom.json": "std.edgepython.com/math.wasm" }
82+
"contains": { "custom.json": "cdn.edgepython.com/std/math.wasm" }
8383
},
8484
{
8585
"run": ["run", "no_such.py"],

demo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Static playground at [demo.edgepython.com](https://demo.edgepython.com/), runs E
1111

1212
## Local start
1313

14-
The page fetches WASM and uses a Web Worker, so it must be served over HTTP (`file://` fails with CORS). [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) is the easiest dev option. Runtime JS and `compiler.wasm` pull from `runtime.edgepython.com`, demo, runtime, and compiler version independently.
14+
The page fetches WASM and uses a Web Worker, so it must be served over HTTP (`file://` fails with CORS). [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) is the easiest dev option. Runtime JS and `compiler.wasm` pull from `cdn.edgepython.com`, demo, runtime, and compiler version independently.
1515

1616
### Cache and deploys
1717

demo/js/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const FETCH_OPTS = DEV ? { cache: 'no-store' } : {};
1414
/* Dev/prod switch for runtime JS: local checkout in dev, edge-python-runtime in prod. Mirrors index.html's Tailwind switch, preserves dev-edit-refresh loop without bundling. */
1515
const RUNTIME_URL = DEV
1616
? '../../runtime/src/index.js'
17-
: 'https://runtime.edgepython.com/js/src/index.js';
17+
: 'https://cdn.edgepython.com/runtime/src/index.js';
1818

1919
const { createWorker } = await import(RUNTIME_URL);
2020

docs/pages/getting-started/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In the browser, the runtime's `<edge-python>` element runs a `.py` file declarat
2222
<html>
2323
<head>
2424
<meta charset="UTF-8">
25-
<script type="module" src="https://runtime.edgepython.com/js/src/element.js"></script>
25+
<script type="module" src="https://cdn.edgepython.com/runtime/src/element.js"></script>
2626
</head>
2727
<body>
2828
<div id="app"></div>

docs/pages/reference/packages.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ print(data["name"]) # ada
3030
print(dumps({"k": [1, 2, 3], "ok": True})) # {"k":[1,2,3],"ok":true}
3131
```
3232

33-
Pre-built `.wasm` is served from `https://std.edgepython.com/json.wasm`. Full API: [`std/json/README.md`](https://github.com/dylan-sutton-chavez/edge-python/tree/main/std/json).
33+
Pre-built `.wasm` is served from `https://cdn.edgepython.com/std/json.wasm`. Full API: [`std/json/README.md`](https://github.com/dylan-sutton-chavez/edge-python/tree/main/std/json).
3434

3535
> **`json` is an external `.wasm` package, not built into `compiler.wasm`** — the browser runtime just resolves it by [default](#defaults), so `from json import ...` works with no manifest.
3636
@@ -46,7 +46,7 @@ print(sub(r'\s+', '_', 'a b c')) # a_b_c
4646
print(findall(r'\w+', 'one two three')) # ['one', 'two', 'three']
4747
```
4848

49-
Functions: `match`, `search`, `fullmatch`, `findall`, `groups`, `span`, `sub`; flags go inline (`(?i)`, `(?s)`, `(?m)`). Pre-built `.wasm` is served from `https://std.edgepython.com/re.wasm`. Full API: [`std/re/README.md`](https://github.com/dylan-sutton-chavez/edge-python/tree/main/std/re).
49+
Functions: `match`, `search`, `fullmatch`, `findall`, `groups`, `span`, `sub`; flags go inline (`(?i)`, `(?s)`, `(?m)`). Pre-built `.wasm` is served from `https://cdn.edgepython.com/std/re.wasm`. Full API: [`std/re/README.md`](https://github.com/dylan-sutton-chavez/edge-python/tree/main/std/re).
5050

5151
### `math`
5252

@@ -61,7 +61,7 @@ print(hypot(3, 4, 12)) # 13.0
6161
print(factorial(5)) # 120
6262
```
6363

64-
Integers are bounded by the VM's `i128`, so `factorial`, `comb`, `perm`, and `lcm` raise `ValueError` past that range, and there is no `complex` / `cmath`. Pre-built `.wasm` is served from `https://std.edgepython.com/math.wasm`. Full API: [`std/math/README.md`](https://github.com/dylan-sutton-chavez/edge-python/tree/main/std/math).
64+
Integers are bounded by the VM's `i128`, so `factorial`, `comb`, `perm`, and `lcm` raise `ValueError` past that range, and there is no `complex` / `cmath`. Pre-built `.wasm` is served from `https://cdn.edgepython.com/std/math.wasm`. Full API: [`std/math/README.md`](https://github.com/dylan-sutton-chavez/edge-python/tree/main/std/math).
6565

6666
### `test`
6767

@@ -88,7 +88,7 @@ run() # prints PASS/FAIL lines and a summary, then raises SystemExit(0 if all pa
8888

8989
`@fixture` registers a `def` under its name and injects it by keyword into the tests that ask for it; `@test(description, *uses)` registers a test plus the fixtures it pulls; `raises(ExcType)` is a context manager asserting the block raises `ExcType` (a subclass, or any type in a tuple); `run()` executes every registered test, prints `PASS` / `FAIL` / `ERROR` and a summary, then raises `SystemExit(1 if any failed, else 0)` so a host can read the result as a process exit code.
9090

91-
Unlike the other standard packages, `test` ships as **pure Edge Python source** (`src/entry.py`), not a compiled `.wasm`, so there is no `cargo` build; it is served from `https://std.edgepython.com/test.py` and the browser runtime resolves it by default, importing the `.py` directly (see [Defaults](#defaults)). Full API: [`std/test/README.md`](https://github.com/dylan-sutton-chavez/edge-python/tree/main/std/test).
91+
Unlike the other standard packages, `test` ships as **pure Edge Python source** (`src/entry.py`), not a compiled `.wasm`, so there is no `cargo` build; it is served from `https://cdn.edgepython.com/std/test.py` and the browser runtime resolves it by default, importing the `.py` directly (see [Defaults](#defaults)). Full API: [`std/test/README.md`](https://github.com/dylan-sutton-chavez/edge-python/tree/main/std/test).
9292

9393
## Host libraries
9494

@@ -161,7 +161,7 @@ Handlers: `time`, `time_ns`, `monotonic`, `monotonic_ns`, `perf_counter`, `perf_
161161

162162
```json
163163
{
164-
"imports": { "json": "https://std.edgepython.com/json.wasm" },
164+
"imports": { "json": "https://cdn.edgepython.com/std/json.wasm" },
165165
"host": { "dom": "./dom/src/index.js" }
166166
}
167167
```

0 commit comments

Comments
 (0)