@threadedstack/wmd-web 0.1.51 → 0.1.52

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/RELEASE.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wmd-web",
3
3
  "version": "0.5.1",
4
- "commit": "8f7cfff4adf7a48395a945e15a1041b56c81e789",
4
+ "commit": "a476a64cf9fa30a12f104c1264550cb29b413ae8",
5
5
  "previous": null,
6
6
  "decisions": [
7
7
  "D-388",
@@ -255,7 +255,7 @@
255
255
  "src/edge/sems.js": "f5bd680e67b7ec3eeb16b2f7ac9207b16491001400b435ff5ee3a34f050d8ceb",
256
256
  "src/edge/service-host.js": "f77664be9e3a0cc1cc9b283c5aeda7d94c7a9d61b8cecda5b90822295d315df6",
257
257
  "src/edge/service-port.js": "6daff74e083d8d6e4d3ce950004bafb8632e78c9fbf626197a2c18453ac96eeb",
258
- "src/edge/setup.js": "a868fb062f7ed18f77a517c1b7c6521231d26c29e8e289f83d38415250cc05cf",
258
+ "src/edge/setup.js": "2ee13fbcb0dfd5978540598fb2e085269bd84021419fa71b0cc0ffb901e4cfec",
259
259
  "src/edge/shim.js": "25efa4dddd3bbdd4a2967d99116e10c011a41aa0a4bdd7ce670fbf6d01735a76",
260
260
  "src/edge/site.js": "ff63be7c751678b773fd03e79e551e6fe6e85caa0444b6413b7bb940b8316979",
261
261
  "src/edge/spawn-guard.js": "666cc6cca0628f3c07093f08da277a1d6291eebb91c19abebf0d422f6197e401",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadedstack/wmd-web",
3
- "version": "0.1.51",
3
+ "version": "0.1.52",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/threadedstack/wmd-releases",
6
6
  "repository": {
@@ -9,8 +9,8 @@
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.51",
13
- "commit": "8f7cfff4adf7a48395a945e15a1041b56c81e789",
12
+ "tag": "v0.1.52",
13
+ "commit": "a476a64cf9fa30a12f104c1264550cb29b413ae8",
14
14
  "web": "0.5.1"
15
15
  },
16
16
  "type": "module",
@@ -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.51' }
5
+ export const EDGE_PACKAGE = { name: '@threadedstack/wmd-node', version: '0.1.52' }
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 },
package/src/edge/setup.js CHANGED
@@ -85,12 +85,13 @@ const idleOf = g => (typeof g.requestIdleCallback === 'function' ? f => g.reques
85
85
  * @param {boolean} [o.fscache] false: no start keeps file answers (default on in every browser, src/edge/sbx/cap.js FSCACHE_OFF; a browser that fails the equality proof is off there only)
86
86
  * @param {number} [o.frameCap] the most frames of node this page has alive at once (default by browser, src/edge/sbx/cap.js); a start that needs a new one over it runs in the guest
87
87
  * @param {boolean} [o.prepare] false: no frame is made before the first node command (default true, with keepFrame)
88
+ * @param {boolean} [o.early] false: python's module and the runtime's files are fetched only from prepare() on (default: from the setup on, when python is planned)
88
89
  * @param {function} [o.onLog] (id, record) of each run, and the site's events ({type: 'site', ...})
89
90
  * @param {function} [o.onBridge] (bridge) when a machine's bridge is made
90
91
  * @param {{on: number, off: object}} counts the plan's decisions, counted (src/boot.js edgePlanCounts)
91
92
  */
92
93
  export function edgeSetupIn(o, counts) {
93
- const { origin: siteOrigin, sources, base, pinned = null, fetchFiles: fetchFilesOpt, fetchOpts = {}, filesWaitMs, filesRetryMs, filesProgressMs, frameCap: frameCapOpt, fscache: fscacheOpt, python: pythonAsk, imagePython, pythonMaxMiB, fetchPython: fetchPythonOpt, ramMiB = 0, main = [], memoryMB = 0, swapMB = 0, env = [], user = '', readonlyRoot = false, hasTmpfs = false, p9port = 564, root = 'rootfs', settings = {}, rt = RT_DEFAULT, handIn = null, watch = {}, prepare = true, shareSite = false, edgeWasm = '/wasm/edgejs.wasm', onLog = () => {}, onBridge = () => {}, doc = globalThis.document, win = globalThis } = o
94
+ const { origin: siteOrigin, sources, base, pinned = null, fetchFiles: fetchFilesOpt, fetchOpts = {}, filesWaitMs, filesRetryMs, filesProgressMs, frameCap: frameCapOpt, fscache: fscacheOpt, python: pythonAsk, imagePython, pythonMaxMiB, fetchPython: fetchPythonOpt, ramMiB = 0, main = [], memoryMB = 0, swapMB = 0, env = [], user = '', readonlyRoot = false, hasTmpfs = false, p9port = 564, root = 'rootfs', settings = {}, rt = RT_DEFAULT, handIn = null, watch = {}, prepare = true, early = true, shareSite = false, edgeWasm = '/wasm/edgejs.wasm', onLog = () => {}, onBridge = () => {}, doc = globalThis.document, win = globalThis } = o
94
95
  const sandbox = !siteOrigin
95
96
  const origin = sandbox ? SANDBOX : siteOrigin
96
97
  // X25: python in the frame follows the switch of node (`edge`) and has its own, `python: false`; the page's plan for the image's python is planPython
@@ -179,6 +180,14 @@ export function edgeSetupIn(o, counts) {
179
180
  ...(filesRetryMs !== undefined ? { retryMs: filesRetryMs } : {}),
180
181
  ...(filesProgressMs !== undefined ? { progressMs: filesProgressMs } : {}),
181
182
  })
183
+ // PYFRAME-1: a python start in the frame needs python's module and the runtime's files; the downloads begin now (before the boot, network only: no frame
184
+ // is made and nothing compiled here) instead of when the page is idle after the boot, which a command that comes right after the boot waited for.
185
+ // Only with a frame made ahead (prepare and keepFrame on); `early: false` keeps the old order.
186
+ const earlyPy = !!pyGate && early !== false && prepare && watch.keepFrame !== false
187
+ if (earlyPy) {
188
+ pyGate.begin()
189
+ gate.begin()
190
+ }
182
191
  const site = frameSite({ origin, probe: sandbox ? () => sbx.files().then(r => !r.error) : iframeProbe({ doc, win }), onEvent: e => onLog(0, e) })
183
192
  // what a start waits for: node's files (the gate of item 12); and when the page planned python, python's module too. A start that is python's goes to the guest while
184
193
  // python's module is loading or when its fetch failed; a start of node goes to the guest only while it is loading (a failed fetch leaves python in the guest).
@@ -235,6 +244,8 @@ export function edgeSetupIn(o, counts) {
235
244
  onMessage: (m, machine) => mine.onMessage(m, machine),
236
245
  }
237
246
  }
247
+ let holdSite = null // PYFRAME-1: the setup's own use of the site while its early-prepared frame waits for a machine
248
+ let closed = false
238
249
  const e = {
239
250
  use: true,
240
251
  reason: '',
@@ -260,7 +271,9 @@ export function edgeSetupIn(o, counts) {
260
271
  const go = async () => {
261
272
  if (sandbox) pyGate?.begin() // python's module comes with them
262
273
  if (sandbox) gate.begin() // the files come while the frame is made (a node start finds them in, or waits at most FILES_WAIT_MS)
263
- const { prepareEdge } = await import('./page.js')
274
+ const { prepareEdge, useSite } = await import('./page.js')
275
+ // PYFRAME-1: a frame prepared before the boot is held by the setup until close() (a boot that fails or never comes leaves no frame behind)
276
+ if (earlyPy && !holdSite && !closed) holdSite = useSite(owner, origin)
264
277
  if (sandbox) await sbx.loadCode()
265
278
  const cfg = { rt, ...runtimeConfig(rt, sandbox ? { ...handIn, sbx: true, ...fscHand } : handIn), edgeWasm: prepWasm, ...(sandbox ? { linuxSrc: 'sbx:linux.cjs' } : {}), linux: {}, ...(pyPlan.use && prepWasm !== nodeWasm ? { memoryMaxMiB: capMiB } : {}) }
266
279
  p.started = Math.round(performance.now())
@@ -273,9 +286,15 @@ export function edgeSetupIn(o, counts) {
273
286
  return p
274
287
  },
275
288
  close() {
289
+ closed = true
290
+ holdSite?.()
291
+ holdSite = null
276
292
  pers.forEach(per => per.close())
277
293
  if (!sandbox) releaseSite(doc, origin, owner)
278
294
  },
279
295
  }
296
+ // PYFRAME-1: with python planned the frame is made and python's module compiled while the machine boots (the page's idle time during the boot), not after
297
+ // it: the first python start then finds the module compiled. A boot's own prepare() call takes this one.
298
+ if (earlyPy) e.prepare()
280
299
  return e
281
300
  }
package/wmdpack.wasm CHANGED
Binary file