@iso4/sandbox 0.2.2 → 0.3.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 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -104,6 +104,30 @@ prefix.run({
|
|
|
104
104
|
})
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
+
## Async context (`AsyncLocalStorage`)
|
|
108
|
+
|
|
109
|
+
Run/postfix code can import a minimal, Node-compatible `AsyncLocalStorage` to
|
|
110
|
+
carry an ambient value across `await` points — concurrency-safe, unlike a
|
|
111
|
+
module variable:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
prefix.run({
|
|
115
|
+
code: `
|
|
116
|
+
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
117
|
+
const als = new AsyncLocalStorage()
|
|
118
|
+
export default await als.run('trace-42', async () => {
|
|
119
|
+
await somethingAsync()
|
|
120
|
+
return als.getStore() // 'trace-42', even several awaits deep
|
|
121
|
+
})
|
|
122
|
+
`,
|
|
123
|
+
})
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Only `run(store, callback, ...args)` and `getStore()` are provided. Built on
|
|
127
|
+
V8's continuation-preserved embedder data; no promise hooks, so it's free
|
|
128
|
+
unless used. Not available in `precompile()` (prefix) code — it's for the
|
|
129
|
+
postfix. See DESIGN.md §16.
|
|
130
|
+
|
|
107
131
|
## Result shape
|
|
108
132
|
|
|
109
133
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iso4/sandbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Fast, sandboxed V8 isolate runtime for agent-generated JavaScript. Two-process architecture for crash isolation.",
|
|
6
6
|
"keywords": [
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"vitest": "^4.1.5"
|
|
48
48
|
},
|
|
49
49
|
"optionalDependencies": {
|
|
50
|
-
"@iso4/v8-darwin-arm64": "^0.
|
|
51
|
-
"@iso4/v8-darwin-x64": "^0.
|
|
52
|
-
"@iso4/v8-linux-arm64-gnu": "^0.
|
|
53
|
-
"@iso4/v8-linux-x64-gnu": "^0.
|
|
50
|
+
"@iso4/v8-darwin-arm64": "^0.3.0",
|
|
51
|
+
"@iso4/v8-darwin-x64": "^0.3.0",
|
|
52
|
+
"@iso4/v8-linux-arm64-gnu": "^0.3.0",
|
|
53
|
+
"@iso4/v8-linux-x64-gnu": "^0.3.0"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=24.0.0"
|