arm64js 0.4.0 → 0.5.0
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 +24 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,7 +121,20 @@ A VM can be created either from a base image or your own local snapshot.
|
|
|
121
121
|
- `image`: name of an image on the CDN ([all images](https://arm64js.com/images/)): `'alpine'` is the newest version of it, `'alpine:2'` a fixed one, `'alpine@sha256:<hash>'` an exact snapshot.
|
|
122
122
|
- `snapshotId`: a snapshot id (`snap.id`, 64 hex characters) loads one of your own snapshots made previously.
|
|
123
123
|
|
|
124
|
-
Additionally, you can specify an `onProgress` callback to track VM loading phases
|
|
124
|
+
Additionally, you can specify an `onProgress` callback to track VM loading phases and the number of virtual CPUs the VM will have (more is not always better).
|
|
125
|
+
|
|
126
|
+
onProgress gets one argument, a BootProgress object:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
interface BootProgress {
|
|
130
|
+
stage: 'resolve' | 'manifest' | 'start' | 'memory' | 'run' | 'done';
|
|
131
|
+
done?: number;
|
|
132
|
+
total?: number;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- the stages arrive in the following order: resolve → manifest → start → memory → run → done.
|
|
137
|
+
- done and total are optional, they are filled in during the `memory` stage when the VM data chunks load (the slowers part of the boot for larger VMs).
|
|
125
138
|
|
|
126
139
|
### Listener: `vm.onOutput(cb)` → unsubscribe
|
|
127
140
|
|
|
@@ -183,6 +196,16 @@ Copies `data` (a `Blob` or `File`, bytes, or a string) into the VM as the file `
|
|
|
183
196
|
|
|
184
197
|
The copy is kept in VM memory, so it has to fit there (`alpine` for example has 1 GiB). If you need to use a larger file, use `vm.mount` instead.
|
|
185
198
|
|
|
199
|
+
Here's an example how you can load a file from the URL in to the VM:
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
const file = await fetch('./test.txt');
|
|
203
|
+
const fileBlob = await file.blob();
|
|
204
|
+
await vm.writeFile('/tmp/test.txt', fileBlob);
|
|
205
|
+
const { output, exitCode } = await vm.exec('cat /tmp/test.txt');
|
|
206
|
+
console.log(output);
|
|
207
|
+
```
|
|
208
|
+
|
|
186
209
|
**Files become part of the VM, so when a snapshot is taken those files will be present in the snapshot.**
|
|
187
210
|
|
|
188
211
|
### `vm.readFile(path, { maxBytes?, timeoutMs? })` → `Blob`
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.5.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by scripts/stamp-version.mjs from package.json. Do not edit.
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.5.0";
|
package/package.json
CHANGED