@polyengine/runtime 0.4.0-pre.gd7d6e28 → 0.4.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/esm/embedder/mod.js
CHANGED
|
@@ -25,7 +25,7 @@ export { COPY_URL, RUNTIME_VERSION } from "./copy.js";
|
|
|
25
25
|
// The A9 vocabulary, re-exported unchanged: embedder code needs no import
|
|
26
26
|
// change, and consumers that want the multi-copy-robust spellings get them
|
|
27
27
|
// from the same module they already import.
|
|
28
|
-
export { copyCensus, DROPPED, ERROR_CONTEXT, FUTURE, hasBrand, INVALID_HANDLE, isDroppedError, isInvalidHandleError, isPeerTrappedError, isStreamProducerError, isSuspending, isTrap, isComponentException, PEER_TRAPPED, PROTOCOL_GENERATION, registerRuntimeCopy, RESOURCE_STATE, runtimeCopies, STREAM, STREAM_PRODUCER, SUSPENDING, TRAP, COMPONENT_EXCEPTION, } from "@polyengine/protocol";
|
|
28
|
+
export { copyCensus, defineRealmLocal, DROPPED, ERROR_CONTEXT, fromCloneable, FUTURE, hasBrand, INVALID_HANDLE, isDroppedError, isInvalidHandleError, isPeerTrappedError, isRealmLocal, isStreamProducerError, isSuspending, isTrap, isComponentException, PEER_TRAPPED, PROTOCOL_GENERATION, REALM_LOCAL, registerRuntimeCopy, RESOURCE_STATE, runtimeCopies, STREAM, STREAM_PRODUCER, SUSPENDING, toCloneable, TRAP, COMPONENT_EXCEPTION, } from "@polyengine/protocol";
|
|
29
29
|
export { artifactsFromEnvelope, instantiate, instantiateEmbedder, resolveArtifacts, } from "./instantiate.js";
|
|
30
30
|
export { requiredImports } from "./imports.js";
|
|
31
31
|
export { DroppedError, InvalidHandleError, NameCollisionError, PeerTrappedError, Trap, ComponentException, } from "./errors.js";
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// | host receives borrow<R> | wrapper valid for the call | instance, mapping kept |
|
|
15
15
|
// | host passes own<R> | wrapper invalidated | instance registered |
|
|
16
16
|
// | host passes borrow<R> | wrapper stays valid | rep reused/allocated |
|
|
17
|
-
import { RESOURCE_STATE } from "@polyengine/protocol";
|
|
17
|
+
import { defineRealmLocal, RESOURCE_STATE } from "@polyengine/protocol";
|
|
18
18
|
import { hostDtorCall } from "../exec/boundary.js";
|
|
19
19
|
import { COPY_URL, describeCrossCopy } from "./copy.js";
|
|
20
20
|
import { InvalidHandleError } from "./errors.js";
|
|
@@ -33,6 +33,16 @@ import { camelCase, pascalCase } from "./casing.js";
|
|
|
33
33
|
const STATE = RESOURCE_STATE;
|
|
34
34
|
/** Base of every runtime-built guest-resource class. */
|
|
35
35
|
export class GuestResource {
|
|
36
|
+
constructor() {
|
|
37
|
+
// A20 (contracts/embedder-api.md §"Realm boundaries and
|
|
38
|
+
// structured-clone-safe forms"; issue #131): guest-resource wrappers are
|
|
39
|
+
// realm-local by principle (their machinery lives in the minting
|
|
40
|
+
// copy's tables, issue #129's identity rule) — the pill makes a raw
|
|
41
|
+
// structuredClone/postMessage of one throw instead of husking. NOTE:
|
|
42
|
+
// `makeWrapper` below mints via `Object.create`, which bypasses this
|
|
43
|
+
// constructor entirely — it installs the pill itself.
|
|
44
|
+
defineRealmLocal(this);
|
|
45
|
+
}
|
|
36
46
|
/** Drop the handle (alias of `[Symbol.dispose]`, so TS `using` works). */
|
|
37
47
|
drop() {
|
|
38
48
|
dropWrapper(this);
|
|
@@ -313,6 +323,9 @@ export function makeWrapper(
|
|
|
313
323
|
// deno-lint-ignore no-explicit-any
|
|
314
324
|
cls, rep, rt, owns) {
|
|
315
325
|
const w = Object.create(cls.prototype);
|
|
326
|
+
// A20: `Object.create` bypasses `GuestResource`'s constructor, so the
|
|
327
|
+
// realm-local pill is installed explicitly here (see that constructor).
|
|
328
|
+
defineRealmLocal(w);
|
|
316
329
|
initWrapper(w, {
|
|
317
330
|
rep,
|
|
318
331
|
valid: true,
|
package/esm/embedder/streams.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { despecialize } from "../cabi/types.js";
|
|
11
11
|
import { hostFuture, hostFutureFor, hostStream, hostStreamFor, } from "../exec/host_streams.js";
|
|
12
12
|
import { CopyResult, dropSharedForTeardown, poisonFailureOf, } from "../task/mod.js";
|
|
13
|
-
import { defineBrand, ERROR_CONTEXT, FUTURE, hasBrand, isStreamProducerError, STREAM, StreamProducerError, } from "@polyengine/protocol";
|
|
13
|
+
import { defineBrand, defineRealmLocal, ERROR_CONTEXT, FUTURE, hasBrand, isStreamProducerError, STREAM, StreamProducerError, } from "@polyengine/protocol";
|
|
14
14
|
import { describeCrossCopy } from "./copy.js";
|
|
15
15
|
import { DroppedError, PeerTrappedError } from "./errors.js";
|
|
16
16
|
// `StreamProducerError`'s canonical definition moved to `@polyengine/protocol`
|
|
@@ -102,6 +102,11 @@ export class Stream {
|
|
|
102
102
|
constructor(host, codec) {
|
|
103
103
|
this.#host = host;
|
|
104
104
|
this.#codec = codec;
|
|
105
|
+
// A20 (contracts/embedder-api.md §"Realm boundaries and
|
|
106
|
+
// structured-clone-safe forms"; issue #131): the realm-local pill —
|
|
107
|
+
// stateful handles must fail loud (DataCloneError) at a raw
|
|
108
|
+
// structuredClone/postMessage instead of husking silently.
|
|
109
|
+
defineRealmLocal(this);
|
|
105
110
|
}
|
|
106
111
|
/** Wrap a stream value that was lifted out of a guest. */
|
|
107
112
|
static fromLifted(value, codec) {
|
|
@@ -295,6 +300,8 @@ export class StreamWriter {
|
|
|
295
300
|
#stream;
|
|
296
301
|
constructor(stream) {
|
|
297
302
|
this.#stream = stream;
|
|
303
|
+
// A20 realm-local pill (see Stream's constructor above for rationale).
|
|
304
|
+
defineRealmLocal(this);
|
|
298
305
|
}
|
|
299
306
|
/**
|
|
300
307
|
* Offer values; resolves with how many the reader took.
|
|
@@ -376,6 +383,8 @@ export class Future {
|
|
|
376
383
|
this.#host = host;
|
|
377
384
|
this.#hostP = hostP;
|
|
378
385
|
this.#codec = codec;
|
|
386
|
+
// A20 realm-local pill (see Stream's constructor above for rationale).
|
|
387
|
+
defineRealmLocal(this);
|
|
379
388
|
}
|
|
380
389
|
static fromLifted(value, codec) {
|
|
381
390
|
const h = hostFutureFor(value);
|
|
@@ -527,6 +536,12 @@ export class ErrorContext {
|
|
|
527
536
|
constructor(internal) {
|
|
528
537
|
this.internal = internal;
|
|
529
538
|
this.message = internal.debugMessage;
|
|
539
|
+
// A20 realm-local pill (see Stream's constructor above for rationale).
|
|
540
|
+
// Note: envelope-encodable brands take precedence over the pill at
|
|
541
|
+
// toCloneable time (ErrorContext carries both ERROR_CONTEXT and the
|
|
542
|
+
// pill; it encodes) — the pill here is only the backstop for raw
|
|
543
|
+
// structuredClone/postMessage that skips toCloneable.
|
|
544
|
+
defineRealmLocal(this);
|
|
530
545
|
}
|
|
531
546
|
}
|
|
532
547
|
// A9 brands (contracts/embedder-api.md §"Module identity"): the three
|
package/esm/embedder/values.js
CHANGED
|
@@ -263,11 +263,20 @@ export function fromHost(v, t, o, inOption = false) {
|
|
|
263
263
|
}
|
|
264
264
|
if (v instanceof InternalErrorContext)
|
|
265
265
|
return v;
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
//
|
|
269
|
-
//
|
|
270
|
-
//
|
|
266
|
+
// A20 (contracts/embedder-api.md §"Error-context is message-valued";
|
|
267
|
+
// issue #131; definitions.py — an error-context's state is exactly
|
|
268
|
+
// its debug message): a branded carrier of a string `message`, from
|
|
269
|
+
// any copy (or hand-rolled), is accepted by minting a FRESH local
|
|
270
|
+
// context — never "the same" one, since there is nothing to alias.
|
|
271
|
+
if (hasBrand(v, ERROR_CONTEXT) &&
|
|
272
|
+
typeof v.message === "string") {
|
|
273
|
+
return new InternalErrorContext(v.message);
|
|
274
|
+
}
|
|
275
|
+
// Branded but no string `message` (amendment A9, superseded above only
|
|
276
|
+
// for the message-valued case): a genuinely foreign stateful handle —
|
|
277
|
+
// it lives in another copy's handle table, so it can never be lowered
|
|
278
|
+
// here — but "recognized and named" beats the generic "expected an
|
|
279
|
+
// ErrorContext" that sent issue #83 hunting in the wrong direction.
|
|
271
280
|
if (hasBrand(v, ERROR_CONTEXT)) {
|
|
272
281
|
throw new TypeError(`${o.where}: ${describeCrossCopy("this error-context")}`);
|
|
273
282
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polyengine/runtime",
|
|
3
|
-
"version": "0.4.0
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A WebAssembly Component Model host for JavaScript engines: plan executor, canonical ABI, 0.3 task scheduler, JSPI bridge, and embedder API.",
|
|
5
5
|
"homepage": "https://github.com/polymorph-components/polyengine#readme",
|
|
6
6
|
"repository": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@polyengine/protocol": "^0.2.
|
|
58
|
+
"@polyengine/protocol": "^0.2.1"
|
|
59
59
|
},
|
|
60
60
|
"_generatedBy": "dnt@0.43.2"
|
|
61
61
|
}
|
package/types/embedder/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { COPY_URL, RUNTIME_VERSION } from "./copy.js";
|
|
2
|
-
export { copyCensus, DROPPED, ERROR_CONTEXT, FUTURE, hasBrand, INVALID_HANDLE, isDroppedError, isInvalidHandleError, isPeerTrappedError, isStreamProducerError, isSuspending, isTrap, isComponentException, PEER_TRAPPED, PROTOCOL_GENERATION, registerRuntimeCopy, RESOURCE_STATE, type RuntimeCopy, runtimeCopies, STREAM, STREAM_PRODUCER, SUSPENDING, TRAP, COMPONENT_EXCEPTION, } from "@polyengine/protocol";
|
|
2
|
+
export { copyCensus, defineRealmLocal, DROPPED, ERROR_CONTEXT, fromCloneable, FUTURE, hasBrand, INVALID_HANDLE, isDroppedError, isInvalidHandleError, isPeerTrappedError, isRealmLocal, isStreamProducerError, isSuspending, isTrap, isComponentException, PEER_TRAPPED, PROTOCOL_GENERATION, REALM_LOCAL, registerRuntimeCopy, RESOURCE_STATE, type RuntimeCopy, runtimeCopies, STREAM, STREAM_PRODUCER, SUSPENDING, toCloneable, TRAP, COMPONENT_EXCEPTION, } from "@polyengine/protocol";
|
|
3
3
|
export { artifactsFromEnvelope, type ComponentArtifacts, type EmbedderInstance, type EmbedderOptions, type InstantiateSource, type UntranslatedArtifacts, instantiate, instantiateEmbedder, resolveArtifacts, } from "./instantiate.js";
|
|
4
4
|
export { type FuncSummary, type ImportLeaf, type PlanLike, requiredImports } from "./imports.js";
|
|
5
5
|
export { DroppedError, InvalidHandleError, NameCollisionError, PeerTrappedError, Trap, ComponentException, } from "./errors.js";
|
|
@@ -48,6 +48,7 @@ interface WrapperState {
|
|
|
48
48
|
/** Base of every runtime-built guest-resource class. */
|
|
49
49
|
export declare class GuestResource {
|
|
50
50
|
[STATE]: WrapperState;
|
|
51
|
+
constructor();
|
|
51
52
|
/** Drop the handle (alias of `[Symbol.dispose]`, so TS `using` works). */
|
|
52
53
|
drop(): void;
|
|
53
54
|
[Symbol.dispose](): void;
|