@threadedstack/wmd-web 0.1.46 → 0.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,6 +69,7 @@ The interface this host implements is in [docs/host-interface.md](docs/host-inte
69
69
  | `src/host/stdio.js` | stdout/stderr rings in a SharedArrayBuffer. Workers write into them under a spin lock, and the page drains them every 16 ms. |
70
70
  | `src/host/layout.js` | Cell layout of the shared control block: tid counter, exit flag and code, pool slots, fd table, clock base, stub host-call counters. |
71
71
  | `src/host/monitor.js` | Page-side monitors: the kernel-panic scanner, the progress watchdog and the throttle meter. |
72
+ | `src/workers.json` | Every file wmd-web starts a Worker from (`new URL('./x.js', import.meta.url)`), as package paths; exported as `@threadedstack/wmd-web/workers.json`. A page that copies wmd-web's files by a list (a site build that does not follow `new Worker(new URL(...))`) reads this list, so a new Worker file in a release is not a 404 on its site. `test/unit/workers-list.test.js` keeps it equal to the source. |
72
73
  | `src/calib-worker.js` | The throttle detector's Worker: times a fixed integer loop and a 10 ms `Atomics.wait` every 2 s. |
73
74
  | `page/` | A small test page. `?case=arm64\|amd64\|hello\|wfi\|prog\|loop\|flush\|smpflush\|smc&mode=interp\|jit&auto=1` boots on load (other options: `arg=`, `env=`, `prog=`, `jitc=`, `brk=`, `share=`, `door=0`, `watchdog=`; see the head of `page/main.js`). State is on `window.wmd`, and the JIT counters are in a table on the page. `page/smc-initrd.js` builds the self-modifying-code initramfs. `page/jit-stress.html` is the multi-Worker JIT door stress test, and `page/wasm-mini.js` encodes its block-shaped test modules. `page/idb-bytes.js` is the IndexedDB byte store behind `?jitcache=1` (`=fresh` empties it first), on this page and the wmn test page. |
74
75
  | `src/fs/` | P-B4, the 9P2000.L file server (no browser wiring yet): the pack reader (`pack.js`), the overlay of pack lowers under an in-memory upper (`overlay.js`), the codec and server (`9p/codec.js`, `9p/server.js`) and Linux errno values (`errno.js`). See [docs/9p.md](docs/9p.md). |
package/RELEASE.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wmd-web",
3
3
  "version": "0.5.1",
4
- "commit": "2062620ce232ed2af82e1c1f4ad36a0b0adc176c",
4
+ "commit": "6472edd8cc5495ced418b3d8760fdc0ee77c5d64",
5
5
  "previous": null,
6
6
  "decisions": [
7
7
  "D-388",
@@ -80,29 +80,29 @@
80
80
  "D-661",
81
81
  "D-666"
82
82
  ],
83
- "vmSources": "3ac7f939f52426df0f781492d3ebf09069e84d44",
83
+ "vmSources": "3e3c540edec568f5142f2beab29f03613e70f033",
84
84
  "guest": {
85
85
  "arch": "arm64",
86
86
  "files": {
87
87
  "vm.wasm": {
88
- "sha256": "7f94f411f4041834981deedb5b8bb7f8961a0cbb8fa896e15ce5ee99a94a2853",
89
- "bytes": 1567689
88
+ "sha256": "ec00c59a70add068305168952885ac3c637b0bd274c1c7a7c28aac9e24fcc3de",
89
+ "bytes": 1575966
90
90
  },
91
91
  "Image": {
92
- "sha256": "0f17a1a3941f8827396265906e7b23cd70a85212caec47c20915abd5a45e19fe",
92
+ "sha256": "b7a8843d3469e2f5c32973ce2e6d663f90e07099ed2e9e9aee2ceac0e6a0685b",
93
93
  "bytes": 39049224
94
94
  },
95
95
  "Image-4k": {
96
- "sha256": "97ba5f7832895f2de857375d3802b9b016976258583613c4dbd903c271792e87",
96
+ "sha256": "55ab90773d080416f1539ae2caac0a49bb98e2bb34ce9384849725fb8e601551",
97
97
  "bytes": 38828040
98
98
  },
99
99
  "initramfs.cpio.gz": {
100
- "sha256": "1cac59f3a8bcf52a2b6b2d5769bf94dc237ec16c8b54df50686b4612bbe7bfef",
101
- "bytes": 4726602
100
+ "sha256": "ac7c0fc194b059579943c3d8ceaa0757c3e3e248231c2ad779260e97d5084cd3",
101
+ "bytes": 4729876
102
102
  },
103
103
  "features": {
104
- "sha256": "02693b8b6c099e10fdb7a092394102ee92971ce1e39d0d6e5327ff8be1d0ee74",
105
- "bytes": 113
104
+ "sha256": "4dc6f2a114c7c87a67eb9f0fe53c52b6b8128bb30830a6be498432a3701587f4",
105
+ "bytes": 123
106
106
  }
107
107
  }
108
108
  },
@@ -156,7 +156,7 @@
156
156
  }
157
157
  },
158
158
  "files": {
159
- "README.md": "b18b6bb6426b479098e02780feebedca613841da4c5da0eda0816761056db57a",
159
+ "README.md": "6ac8c77da8d0352ed0c9d7390f9ea648d46f5ab64b03fe26658165e0e3ec5a7b",
160
160
  "edge-site/own/HASHES.txt": "4d83edcb41399bb89eb7b1f89115886d739adac887bdde59a8d33e3a4602683a",
161
161
  "edge-site/own/NOTICES.txt": "8ceca5406ee5833737bd5fa4a41d434bf5e4d26eff6da1e42c693176ee113101",
162
162
  "edge-site/own/acorn/LICENSE": "76a876cf886ff9be2a8b5e2e86514fed06223c8c9f0c1e9ee9606e93841e00b7",
@@ -172,15 +172,15 @@
172
172
  "export-page/index.html": "f5450c89e63601bbbbffef421f03491b231d1f143070012c1c5315d4b0059f43",
173
173
  "export-page/run.css": "b57adf1e76553549c1f89ff157b7973409dedc21889cd3932948cd05b51adc6f",
174
174
  "export-page/run.js": "717636a632a40469106ddf1383e198eaac5d83651b5866d0699ec04b82462b7f",
175
- "guest/arm64/Image": "0f17a1a3941f8827396265906e7b23cd70a85212caec47c20915abd5a45e19fe",
176
- "guest/arm64/Image-4k": "97ba5f7832895f2de857375d3802b9b016976258583613c4dbd903c271792e87",
177
- "guest/arm64/features": "02693b8b6c099e10fdb7a092394102ee92971ce1e39d0d6e5327ff8be1d0ee74",
178
- "guest/arm64/initramfs.cpio.gz": "1cac59f3a8bcf52a2b6b2d5769bf94dc237ec16c8b54df50686b4612bbe7bfef",
179
- "guest/arm64/vm.wasm": "7f94f411f4041834981deedb5b8bb7f8961a0cbb8fa896e15ce5ee99a94a2853",
180
- "package.json": "7d43c05047d0a3ea56b4a7709f48a60de32e15c3bdf328d55435c46637981b40",
175
+ "guest/arm64/Image": "b7a8843d3469e2f5c32973ce2e6d663f90e07099ed2e9e9aee2ceac0e6a0685b",
176
+ "guest/arm64/Image-4k": "55ab90773d080416f1539ae2caac0a49bb98e2bb34ce9384849725fb8e601551",
177
+ "guest/arm64/features": "4dc6f2a114c7c87a67eb9f0fe53c52b6b8128bb30830a6be498432a3701587f4",
178
+ "guest/arm64/initramfs.cpio.gz": "ac7c0fc194b059579943c3d8ceaa0757c3e3e248231c2ad779260e97d5084cd3",
179
+ "guest/arm64/vm.wasm": "ec00c59a70add068305168952885ac3c637b0bd274c1c7a7c28aac9e24fcc3de",
180
+ "package.json": "6de9aa9fabdb395651d39997c17e094f01a574f54a36f0af31bd3ffaae53cda1",
181
181
  "src/base.js": "982f8e46dbb727ec542a494ebdb884ccd19a31ff4e091425b2d1fc01b0d4754a",
182
182
  "src/blob.js": "bb2a2f0d87ce236280a7be2f246c926010dfe07f649c27da5e70d8eb5eaf7061",
183
- "src/boot.js": "6da5caef172c7c7ce8798e360b2845511100850b118aa80a1545b8f057e3fdca",
183
+ "src/boot.js": "c84e0abb6c0f626395d8cc0d4ccbca70f50bccecce267e6e993cceda4ff08892",
184
184
  "src/build/builder.js": "c7794ec15b183213228776c8f4fb0950dec7e621f948358da7de8f90ef4f70ec",
185
185
  "src/build/context.js": "d38097c61dbdadc4d41290c010425a4422f499aba473fa2b83f2a5c41e543571",
186
186
  "src/build/dockerfile.js": "5957fe3d4ac8ff8b312f980ee04bd1d98ad4373a61f9a33e02f1ff1108b6ea53",
@@ -190,7 +190,7 @@
190
190
  "src/build/pin.js": "8c67f017ae3ec560d2638fdfc0bd91ddd758150af16c188bbe3bf2cb4d7e28b2",
191
191
  "src/build/tar.js": "25cf477488d9a60da9015be9ca5830bad3ad24428da1546f0621411cb7f44949",
192
192
  "src/calib-worker.js": "3d610591a1b3b58f59c3a2ab457f43c90727d95973cd43055b3b73b76180611d",
193
- "src/edge/auto.js": "2b8b7de6decd0dc66813256a9d61f19e0ddc7094824b805ad8deb5b04a29ca46",
193
+ "src/edge/auto.js": "6539a666d6858927777a32536acde696f1b4c09d1dfaedb3f74d8abeebf67684",
194
194
  "src/edge/base.js": "9493218ccc47f5e4c9c64959313b19119effc8f4d973bc805462acdd3b29b53a",
195
195
  "src/edge/bridge.js": "3fa5acb959c760d7665fc0acd45625e55c9043628bd656f8cc8250ae8988f5f9",
196
196
  "src/edge/codes.js": "1bb32c060d4a960a2e3b384d9ff8583329861de6e2b515b0d901b503f8b8a4a7",
@@ -233,6 +233,7 @@
233
233
  "src/edge/page.js": "0e08df63e1534dead4fa9ac891928daf6ad96878ff88e8baa17dbc60307c70c6",
234
234
  "src/edge/pins.js": "06e62a8298b95f7e7afb9acbbaad82d37202d9ac946ba498bb4db1d016ebfb0d",
235
235
  "src/edge/plan.js": "dffc6b94e9b22293f6b31cc4b44ad5b5330a969d8c015a1e5e1d745484482e88",
236
+ "src/edge/python-look.js": "2dbbf1f5954de8a730244a2d8b7b86efd4138063df0f2abe9f4151aa2315a922",
236
237
  "src/edge/python-module.js": "e6e608b5b03783c4ad14aae4ec10a989118ee1120f8fde8cbebca23d2fc98254",
237
238
  "src/edge/python-pins.js": "50e66db4df50553301acb66d8dcf48d5f8c54d384a1ac0af290bb43dc0231acf",
238
239
  "src/edge/python-plan.js": "1da9bf454fc1625b557f290d3b659db34ef2fedc07c7d2f99bc5028a4037dff6",
@@ -254,7 +255,7 @@
254
255
  "src/edge/sems.js": "f5bd680e67b7ec3eeb16b2f7ac9207b16491001400b435ff5ee3a34f050d8ceb",
255
256
  "src/edge/service-host.js": "f77664be9e3a0cc1cc9b283c5aeda7d94c7a9d61b8cecda5b90822295d315df6",
256
257
  "src/edge/service-port.js": "6daff74e083d8d6e4d3ce950004bafb8632e78c9fbf626197a2c18453ac96eeb",
257
- "src/edge/setup.js": "d91b73825ef6bf12c8abdef6e96dc3afe9b7e665d5a42a0fbdf00485fa278957",
258
+ "src/edge/setup.js": "a868fb062f7ed18f77a517c1b7c6521231d26c29e8e289f83d38415250cc05cf",
258
259
  "src/edge/shim.js": "25efa4dddd3bbdd4a2967d99116e10c011a41aa0a4bdd7ce670fbf6d01735a76",
259
260
  "src/edge/site.js": "ff63be7c751678b773fd03e79e551e6fe6e85caa0444b6413b7bb940b8316979",
260
261
  "src/edge/spawn-guard.js": "666cc6cca0628f3c07093f08da277a1d6291eebb91c19abebf0d422f6197e401",
@@ -344,7 +345,8 @@
344
345
  "src/registry/pull.js": "24f2e01a76c9f7f27896af69b989f8c97f0ca31712b3e8110aaa5b5e3148b04b",
345
346
  "src/registry/ref.js": "24038e0fbcb6ac143cb8e8f7b9fac4dd0803d0891961786dc88dba01a4402e7b",
346
347
  "src/registry/wasi-mem.js": "8a8474a090a778db9eabfc2610f8c57f7f66b684ba7b7f8994aabd3ecb07a65a",
347
- "src/worker.js": "c654be359e741d5b1fde1be05f8909968d4e00d1fca61be169e60ea691daa662"
348
+ "src/worker.js": "c654be359e741d5b1fde1be05f8909968d4e00d1fca61be169e60ea691daa662",
349
+ "src/workers.json": "2dd90729f76d5867a3a2974cdc958b610340383fc81a7a4d651272ba15c7e7dc"
348
350
  },
349
351
  "builder": {
350
352
  "arm64": {
package/guest/arm64/Image CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/guest/arm64/Image
3
3
  size: 39049224 bytes
4
- sha256: 0f17a1a3941f8827396265906e7b23cd70a85212caec47c20915abd5a45e19fe
4
+ sha256: b7a8843d3469e2f5c32973ce2e6d663f90e07099ed2e9e9aee2ceac0e6a0685b
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/guest/arm64/Image-4k
3
3
  size: 38828040 bytes
4
- sha256: 97ba5f7832895f2de857375d3802b9b016976258583613c4dbd903c271792e87
4
+ sha256: 55ab90773d080416f1539ae2caac0a49bb98e2bb34ce9384849725fb8e601551
@@ -1,4 +1,5 @@
1
1
  # What this guest build supports; the engine reads it next to initramfs.cpio.gz.
2
2
  edge-hold
3
+ binfmt-cc
3
4
  keep-running
4
5
  p9-names
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadedstack/wmd-web",
3
- "version": "0.1.46",
3
+ "version": "0.1.49",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/threadedstack/wmd-releases",
6
6
  "repository": {
@@ -9,14 +9,16 @@
9
9
  },
10
10
  "description": "Browser host for wmd's guest vm.wasm (Web Workers + shared memory + WASI preview1)",
11
11
  "wmd": {
12
- "tag": "v0.1.46",
13
- "commit": "2062620ce232ed2af82e1c1f4ad36a0b0adc176c",
12
+ "tag": "v0.1.49",
13
+ "commit": "6472edd8cc5495ced418b3d8760fdc0ee77c5d64",
14
14
  "web": "0.5.1"
15
15
  },
16
16
  "type": "module",
17
17
  "main": "./src/boot.js",
18
18
  "exports": {
19
19
  ".": "./src/boot.js",
20
+ "./build": "./src/build/builder.js",
21
+ "./workers.json": "./src/workers.json",
20
22
  "./src/*": "./src/*",
21
23
  "./relay/*": "./relay/*",
22
24
  "./page/sw.js": "./page/sw.js",
package/src/boot.js CHANGED
@@ -98,6 +98,24 @@ export async function edgeSetup(o = {}) {
98
98
  return edgeSetupIn(pinned ? { ...o, pinned } : o, edgePlanCounts)
99
99
  }
100
100
 
101
+ const pythonLooks = new WeakMap() // the look at a service's layers, once per service object (a restore's text choice asks again)
102
+ /** X25: {path, version, ms} of the image's python found in the 9P service's layers (src/edge/python-look.js), kept per service; never throws (a layer that cannot be read: no python). */
103
+ async function pythonLook(A, svc, env, e = {}) {
104
+ if (!svc.layers || !svc.layers.length) return null
105
+ let p = pythonLooks.get(svc)
106
+ if (!p) {
107
+ p = import('./edge/python-look.js')
108
+ .then(m => m.lookForPython(svc.layers, env, { at: svc.at ?? 'rootfs', ...(e.fetchLayer ? { fetchFn: e.fetchLayer } : {}) }))
109
+ .catch(() => ({ path: '', version: '', ms: 0 }))
110
+ pythonLooks.set(svc, p)
111
+ }
112
+ return p
113
+ }
114
+ const nodeMajorOf = env => {
115
+ const v = ((env || []).find(x => String(x).startsWith('NODE_VERSION=')) || '').slice(13)
116
+ return /^v?\d+/.test(v) ? v : ''
117
+ }
118
+
101
119
  /**
102
120
  * X5 option A: the whole setup of node in the frame for a container, from the options bootWmd got. Only `edge: { base }` (or `edge: {}`) asks for it;
103
121
  * `edge: false`, no `edge`, and the page bridge a page made itself (edgeSetup().bootOption(), it has onMessage) come back as they are. It reads the 9P
@@ -128,9 +146,14 @@ export async function edgeAuto(o, counts = edgePlanCounts) {
128
146
  } catch {
129
147
  return off('bundle/config/config.json is not JSON')
130
148
  }
131
- // a container that cannot use node in the frame loads no more of the edge code than the plan (the reason is counted)
149
+ // X25: the image's python, found in the service's layers (gone at once with `python: false` and for an image whose layers are not given)
150
+ const imagePython = e.python === false ? null : await pythonLook(A, svc, facts.env, e)
151
+ if (imagePython && typeof e.onLog === 'function') try { e.onLog(0, { type: 'python-look', ms: imagePython.ms, path: imagePython.path, version: imagePython.version }) } catch {} // the look's cost, for the page's own log
152
+ // a container that cannot use node in the frame loads no more of the edge code than the plan (the reason is counted); one that has a python the plan
153
+ // could take goes on without node (python only, src/edge/setup.js)
132
154
  const pre = A.preplan(facts, { rt: e.rt, win: e.win })
133
- if (!pre.use) return off(pre.reason)
155
+ const py = imagePython?.path ? A.pythonPlanFor(facts, imagePython, e, e.win) : { use: false }
156
+ if (!pre.use && !py.use) return off(imagePython?.path && !nodeMajorOf(facts.env) ? py.reason : pre.reason)
134
157
  const setup = await edgeSetup({
135
158
  ...e,
136
159
  edge: true,
@@ -141,9 +164,11 @@ export async function edgeAuto(o, counts = edgePlanCounts) {
141
164
  p9port: svc.port,
142
165
  root: svc.at ?? 'rootfs',
143
166
  settings: { hostname: facts.hostname, ...(facts.cpus ? { cpus: facts.cpus } : {}), ...(e.settings || {}) },
167
+ ...(imagePython?.path ? { imagePython } : {}),
144
168
  })
145
169
  if (!setup.use) return { o: { ...o, edge: undefined }, setup }
146
- const files = A.addEdgeMounts(svc.files, setup.edgeNode)
170
+ if (imagePython) setup.pythonLook = imagePython
171
+ const files = A.addEdgeMounts(svc.files, setup.edgeNode, undefined, setup.edgeTools || [])
147
172
  const services = o.channels.services.map(s => (s === svc ? { ...s, files } : s))
148
173
  return { o: { ...o, channels: { ...o.channels, services }, edge: setup.bootOption() }, setup }
149
174
  }
@@ -156,7 +181,7 @@ const ABLE_WIN = { SharedArrayBuffer: function SharedArrayBuffer() {}, crossOrig
156
181
  * (edge: false, no pins, no sources and a browser that cannot included): only the tools decide the text, as X6's twin does. null: no 9P service with a
157
182
  * spec, a spec that is not JSON, or an image without node (a checkpoint of such a container cannot have had node in the frame).
158
183
  */
159
- async function edgeTextOptions(plain) {
184
+ export async function edgeTextOptions(plain) {
160
185
  const A = await import('./edge/auto.js')
161
186
  const svc = A.findService(plain)
162
187
  if (!svc) return null
@@ -164,8 +189,11 @@ async function edgeTextOptions(plain) {
164
189
  const e = plain.edge && typeof plain.edge === 'object' ? plain.edge : {}
165
190
  const facts = A.containerFacts(svc.files, plain.args || [])
166
191
  const pre = A.preplan(facts, { rt: e.rt, win: ABLE_WIN })
167
- if (!pre.use) return null
168
- const files = A.addEdgeMounts(svc.files, pre.node)
192
+ // python's mounts by the same rule (the switch `python: false` is this boot's choice, not the text's): the checkpoint's key does not depend on it
193
+ const look = await pythonLook(A, svc, facts.env, e)
194
+ const py = look?.path ? A.pythonPlanFor(facts, look, { ...e, python: undefined }, ABLE_WIN) : { use: false }
195
+ if (!pre.use && !py.use) return null
196
+ const files = A.addEdgeMounts(svc.files, pre.use ? pre.node : undefined, undefined, py.use ? A.pythonSpecTools(py.python) : [])
169
197
  if (files === svc.files) return null // the spec already holds the mounts (the page made them itself): nothing to choose
170
198
  return { ...plain, channels: { ...plain.channels, services: plain.channels.services.map(x => (x === svc ? { ...x, files } : x)) } }
171
199
  } catch {
package/src/edge/auto.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // X5 option A item 3: what bootWmd reads from a container's files to set up node in the frame by itself (src/boot.js edgeAuto), and the one thing it
2
2
  // changes there: the three mounts of the image's node (src/host/ctl.js edgeSpecMounts). Plain functions, no browser.
3
- import { EDGE_CONTAINER_DIR, NODE_PATHS, edgeSpecMounts, planEdge } from './plan.js'
3
+ import { EDGE_CONTAINER_DIR, NODE_PATHS, edgeSpecMounts, planEdge, planPython, pythonSpecTools } from './plan.js'
4
+ import { addEdgeToolMounts } from '../host/ctl.js'
4
5
 
5
6
  export const BUNDLE_CONFIG = 'bundle/config/config.json'
6
7
  export const BUNDLE_IMAGE = 'bundle/config/imageconfig.json'
@@ -50,19 +51,23 @@ export function containerFacts(files, args = []) {
50
51
  }
51
52
 
52
53
  /**
53
- * The files with the edge mounts of the image's node added to the spec, once: a spec that already has them (containerBundle's `edgeNode`, or an earlier
54
- * call) comes back unchanged. The mounts go where containerBundle puts them (before the /etc files). A new files object; the caller's is not changed.
54
+ * The files with the edge mounts of the image's node (`node`, a path or none) and the stubs over its tools (`tools`, plan.js pythonSpecTools) added to the
55
+ * spec, once: a spec that already has them (containerBundle's `edgeNode` and `edge.tools`, or an earlier call) comes back unchanged. Node's mounts go where
56
+ * containerBundle puts them (before the /etc files), the tools' where addEdgeToolMounts puts them. A new files object; the caller's is not changed.
55
57
  */
56
- export function addEdgeMounts(files, node, rootfsPath = '/run/wmd9p/rootfs') {
58
+ export function addEdgeMounts(files, node, rootfsPath = '/run/wmd9p/rootfs', tools = []) {
57
59
  const text = textOf(files[BUNDLE_CONFIG])
58
60
  const spec = JSON.parse(text)
59
61
  const have = new Set((spec.mounts || []).map(m => m.destination))
60
62
  const root = spec.root?.path || rootfsPath
61
- const add = edgeSpecMounts(node, root).filter(m => !have.has(m.destination))
62
- if (!add.length) return files
63
- const mounts = [...(spec.mounts || [])]
64
- const at = mounts.findIndex(m => String(m.destination).startsWith('/etc/'))
65
- mounts.splice(at < 0 ? mounts.length : at, 0, ...add)
63
+ let mounts = [...(spec.mounts || [])]
64
+ const add = node ? edgeSpecMounts(node, root).filter(m => !have.has(m.destination)) : []
65
+ if (add.length) {
66
+ const at = mounts.findIndex(m => String(m.destination).startsWith('/etc/'))
67
+ mounts.splice(at < 0 ? mounts.length : at, 0, ...add)
68
+ }
69
+ if (tools.length) mounts = addEdgeToolMounts(mounts, tools)
70
+ if (mounts.length === (spec.mounts || []).length) return files
66
71
  const out = JSON.stringify({ ...spec, mounts }, null, 2) + '\n'
67
72
  return { ...files, [BUNDLE_CONFIG]: sameForm(files[BUNDLE_CONFIG], out) }
68
73
  }
@@ -75,3 +80,15 @@ export const browserOk = (g = globalThis) => typeof g.SharedArrayBuffer === 'fun
75
80
  /** planEdge for the facts of a container (see containerFacts). -> {use, node?, reason?} */
76
81
  export const preplan = (facts, { rt, win = globalThis } = {}) =>
77
82
  planEdge({ enabled: true, env: facts.env, user: facts.user, readonlyRoot: facts.readonlyRoot, hasTmpfs: facts.hasTmpfs, hasJspi: browserOk(win), rt, nodePath: NODE_PATHS[0] })
83
+
84
+ /**
85
+ * The plan for the image's python from what edgeAuto knows (the same planPython setup.js asks), for the spec text: -> {use, python?, version?, reason?}.
86
+ * `e` is the edge option's object (python, memoryMB, swapMB, ramMiB, rt).
87
+ */
88
+ export const pythonPlanFor = (facts, imagePython, e = {}, win = globalThis) =>
89
+ planPython({
90
+ enabled: true, env: facts.env, user: facts.user, readonlyRoot: facts.readonlyRoot, hasTmpfs: facts.hasTmpfs, hasJspi: browserOk(win), rt: e.rt,
91
+ python: e.python, imagePython, memoryMB: e.memoryMB || 0, swapMB: e.swapMB || 0, ramMiB: e.ramMiB || 0,
92
+ })
93
+
94
+ export { pythonSpecTools }
@@ -2,7 +2,7 @@
2
2
  // The files of node in the sandboxed frame: the path under a source (the option edge: { sources } of bootWmd), the role the frame gives the file, its
3
3
  // sha256 and its size. The page accepts a file only when it has exactly this sha256 and size. The notice files travel with the rest.
4
4
  // EDGE_PACKAGE is the package that holds these files, for the {name} {version} {file} of a registry source's url (null: none named).
5
- export const EDGE_PACKAGE = { name: '@threadedstack/wmd-node', version: '0.1.46' }
5
+ export const EDGE_PACKAGE = { name: '@threadedstack/wmd-node', version: '0.1.49' }
6
6
  export const EDGE_PINS = [
7
7
  { path: 'wmd_browser_bg.wasm', role: 'wasm', sha256: '1e3db7f2c5f4be0ee44e5f2c0205cf8ca11f906d9addd5512915fad4821661c2', size: 6334959 },
8
8
  { path: 'wmd_browser.js', role: 'glue', sha256: 'b389b072096881ba39b22cd705d3a230af02acc5409c61fb4f997d1081c4df6f', size: 75647 },
@@ -0,0 +1,23 @@
1
+ // X25: the image's python, found in the layers of the container's 9P service (the files bootWmd's service serves), for the setup of python in the frame.
2
+ // It opens the layers read-only as the 9P service does and asks src/edge/python-plan.js; the cost is measured (`ms`). Layers are urls (fetched; the browser's
3
+ // cache serves the boot's own fetch of the same urls) or bytes. No layer, or none with a python: {path: ''}.
4
+ import { Overlay } from '../fs/overlay.js'
5
+ import { Pack, bytesSource } from '../fs/pack.js'
6
+ import { findPython, imagePythonVersion } from './python-plan.js'
7
+
8
+ /** {path, version, ms} of the image's python, or {path: '', ms}: `layers` are urls or bytes, top first, `at` where the service puts the root. */
9
+ export async function lookForPython(layers, env, { at = 'rootfs', fetchFn = globalThis.fetch?.bind(globalThis) } = {}) {
10
+ const t0 = performance.now()
11
+ const ms = () => Math.round(performance.now() - t0)
12
+ if (!layers || !layers.length) return { path: '', version: '', ms: ms() }
13
+ const packs = await Promise.all(
14
+ layers.map(async (l, i) => {
15
+ const bytes = typeof l === 'string' ? new Uint8Array(await (await fetchFn(l)).arrayBuffer()) : l instanceof ArrayBuffer ? new Uint8Array(l) : l
16
+ return new Pack(bytesSource(bytes), `layer ${i}`)
17
+ }),
18
+ )
19
+ const fs = new Overlay({ layers: packs, at })
20
+ const root = fs.resolve(at)
21
+ const path = findPython(fs, root)
22
+ return { path, version: path ? imagePythonVersion(env, fs, root, path) : '', ms: ms() }
23
+ }
package/src/edge/setup.js CHANGED
@@ -143,7 +143,10 @@ export function edgeSetupIn(o, counts) {
143
143
  if (r.error) return r
144
144
  const files = copyAll(r.files)
145
145
  // python's module goes with them once it is in (a start that needs it waits for the gate below; a failed gate leaves python in the guest)
146
- if (pyGate && pyGate.state() === 'ready') {
146
+ // python only (no node planned): the frame is made for python alone, so it waits for the module (the gate ends in a result or an error, bounded by its progress rule)
147
+ // instead of going without it; with node planned, the frame does not wait (node's start must not pay for python)
148
+ if (pyGate && !nodePlan.use && pyGate.state() !== 'ready') pyGate.begin()
149
+ if (pyGate && (pyGate.state() === 'ready' || !nodePlan.use)) {
147
150
  const pr = await pyGate.join()
148
151
  if (!pr.error) Object.assign(files, copyAll(pr.files))
149
152
  }
@@ -0,0 +1,12 @@
1
+ [
2
+ "src/calib-worker.js",
3
+ "src/host/base-io.js",
4
+ "src/host/chan-service-entry.js",
5
+ "src/host/ckpt-io.js",
6
+ "src/host/disk-worker.js",
7
+ "src/host/gowasm-worker.js",
8
+ "src/host/jit-hub.js",
9
+ "src/net/net-worker.js",
10
+ "src/registry/pack-worker.js",
11
+ "src/worker.js"
12
+ ]
package/wmdpack.wasm CHANGED
Binary file