@poe-platform/safe-js 0.1.25 → 0.1.27
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 +39 -2
- package/dist/safe-js/chunks/{chunk-3WYMRVDP.js → chunk-6V2VGVEH.js} +2 -2
- package/dist/safe-js/chunks/{chunk-BWVASPJX.js → chunk-MCF7GT3X.js} +385 -99
- package/dist/safe-js/chunks/chunk-MCF7GT3X.js.map +7 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.d.ts +1 -1
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.d.ts +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/index.js.map +1 -1
- package/dist/safe-js/interp/host-capabilities.d.ts +11 -0
- package/dist/safe-js/interp/iteration.d.ts +9 -0
- package/dist/safe-js/interp/values.d.ts +2 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-BWVASPJX.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-3WYMRVDP.js.map → chunk-6V2VGVEH.js.map} +0 -0
package/README.md
CHANGED
|
@@ -55,6 +55,29 @@ const result = await run(`
|
|
|
55
55
|
|
|
56
56
|
Properties stay inside the interpreter, not on native host functions. Arrows and object methods remain nonconstructible. Prototype links between callable or exotic objects (such as arrays) and accessor descriptors are unsupported; native `Function.prototype` is never exposed.
|
|
57
57
|
|
|
58
|
+
<details>
|
|
59
|
+
<summary>Object inspection and prototypes</summary>
|
|
60
|
+
|
|
61
|
+
Ordinary objects inherit a sandbox-owned `Object.prototype`. Cached inspection works:
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const result = await run(`
|
|
65
|
+
const inspect = ({}).toString;
|
|
66
|
+
return [inspect.call([]), inspect.call(new Date(0)),
|
|
67
|
+
Object.getPrototypeOf({}) === Object.prototype];
|
|
68
|
+
`);
|
|
69
|
+
// result.returnValue: ["[object Array]", "[object Date]", true]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- `Object()` / `new Object()` create ordinary objects; passing an object preserves its identity.
|
|
73
|
+
- `toString`, `valueOf`, `hasOwnProperty`, `propertyIsEnumerable` and `isPrototypeOf` support ordinary inspection. Type tags use sandbox brands, not guest-supplied fields.
|
|
74
|
+
- Intrinsic methods are non-enumerable. Guest constructor prototypes inherit the ordinary Object prototype; explicit null/custom prototypes work with `Object.create`, `Object.setPrototypeOf` and literal `__proto__`. A computed `['__proto__']` remains an own data property.
|
|
75
|
+
- Prototype mutations stay inside the current run or persistent realm and consume its retained-data budget. They never change native prototypes or another realm.
|
|
76
|
+
|
|
77
|
+
Primitive boxing, inherited accessors, symbols and full Array/Function/exotic prototype graphs are unsupported. Use borrowed Object methods for inspecting those supported values. Explicit prototype links and mutated Object intrinsics are not portable checkpoint/copy data; project own data before crossing those boundaries. The conservative `AS011` lint rule still flags explicit `prototype`/`constructor` access; `run()` executes it without automatic linting.
|
|
78
|
+
|
|
79
|
+
</details>
|
|
80
|
+
|
|
58
81
|
<details>
|
|
59
82
|
<summary>Dates and clocks</summary>
|
|
60
83
|
|
|
@@ -189,7 +212,7 @@ The manifest requires `version: 1` and a nonempty `name`. Optional `capabilities
|
|
|
189
212
|
| `signal` | Realm cancellation signal; aborted on close or failure. |
|
|
190
213
|
| `onCleanup(fn)` | Register a sync/async disposer. Cleanup runs in reverse order, awaits every disposer, and reports failures without skipping the rest. |
|
|
191
214
|
| `chargeWork(units = 1)` | Charge a nonnegative integer against the shared execution budget. Fatal exhaustion cannot be swallowed to continue execution. |
|
|
192
|
-
| `createHostObject({ properties?, methods? })` | Create a realm-owned capability. Properties declare synchronous `get`/`set` functions; methods are host functions. Undeclared members expose no native prototype. |
|
|
215
|
+
| `createHostObject({ properties?, methods?, indexed? })` | Create a realm-owned capability. Properties declare synchronous `get`/`set` functions; methods are host functions. Optional `indexed` exposes a bounded live collection. Undeclared members expose no native prototype. |
|
|
193
216
|
| `invokeCallback(callback, { thisValue?, args? })` | Invoke a captured guest function with the realm's state, cancellation and budgets. Same operation as on the realm. |
|
|
194
217
|
| `releaseCallback(callback)` | Revoke the callback and release its retained guest state. |
|
|
195
218
|
| `retainGuestArguments(operation, from)` | During setup, opt an operation into opaque argument references starting at the zero-based index `from`. Requires declared and granted `guest:retain`. Earlier arguments keep normal conversion; live host methods preserve the declaration. |
|
|
@@ -201,7 +224,21 @@ For a timer-shaped `schedule(callback, delay, ...args)`, register `context.retai
|
|
|
201
224
|
|
|
202
225
|
Release each reference when the host no longer needs it; returning it does not release it. Retained graphs count against data budgets and `limits.guestReferences`. Synchronous native failure releases references captured for that call; asynchronous operations must release theirs in host cleanup. Close revokes all remaining references. Handles cannot be inspected, used in another realm, or serialized into replay/error data. Unmarked operations still copy values.
|
|
203
226
|
|
|
204
|
-
|
|
227
|
+
For a live collection, keep the elements in your adapter and expose virtual indices instead of declaring one getter per element:
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
const collection = context.createHostObject({ indexed: {
|
|
231
|
+
length: () => elements.length,
|
|
232
|
+
get: index => elements[index],
|
|
233
|
+
maxLength: 4096
|
|
234
|
+
} });
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
`length()` and `get(index)` must be synchronous. `maxLength` is required: an integer from 1 to 65,536. Every reported length must be a nonnegative integer within that cap and the execution array-length budget. Return existing `HostObject` handles for elements that need live identity; ordinary results use the normal copy boundary.
|
|
238
|
+
|
|
239
|
+
Saved collections observe current host contents. Index reads, `Object.keys`/`values`/`entries`, `Object.hasOwn`, `in`, `for...in`, `for...of`, array/object spread and `Array.from` use the live view. Enumerable keys include current indices and fixed members, but not `length`. `Array.from` preserves element identity and interleaves mapping with reads. Noncanonical and out-of-range indices never call `get`; fixed members cannot reuse `length` or canonical index names. Enumeration and traversal consume execution budgets, without eagerly allocating virtual properties.
|
|
240
|
+
|
|
241
|
+
Indexed members and their `length` are read-only. Live objects reject deletion, freezing, native prototype access, property-descriptor manipulation and portable serialization. Realm state is not a checkpoint: snapshot/replay and live-capability error-data conversion are rejected. Extensions are trusted native code; grants are a registration contract, not OS isolation. Native work still needs host timeouts and external process supervision for hard limits. No DOM, timers or browser engine are bundled.
|
|
205
242
|
|
|
206
243
|
For one-shot use, `run(source, { extensions, grants, ... })` accepts the same realm options plus `filename`, returns data only, and closes resources before settling. Run-only features such as snapshots, `entryPointArgs`, `importMeta`, custom random generators and telemetry are rejected in this mode rather than silently ignored.
|
|
207
244
|
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-MCF7GT3X.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8245,4 +8245,4 @@ export {
|
|
|
8245
8245
|
parseMcpConfig,
|
|
8246
8246
|
makeMcpModule
|
|
8247
8247
|
};
|
|
8248
|
-
//# sourceMappingURL=chunk-
|
|
8248
|
+
//# sourceMappingURL=chunk-6V2VGVEH.js.map
|