From 4dc779e1211d44a54fdfeac8ef08ced05966baa6 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Wed, 25 Nov 2026 11:39:28 -0600 Subject: [PATCH 1/2] Reorganizations and JS reference updates Just a bunch of drive-by updates made as part of union/overload work. --- design/mvp/Binary.md | 4 +- design/mvp/JS-Reference.md | 15 +-- design/mvp/Text.md | 219 ++++++++++++++++++++----------------- 3 files changed, 131 insertions(+), 107 deletions(-) diff --git a/design/mvp/Binary.md b/design/mvp/Binary.md index 194840c0..ae9a878b 100644 --- a/design/mvp/Binary.md +++ b/design/mvp/Binary.md @@ -433,8 +433,8 @@ Notes: `[method]`, `[static]`, πŸ“‘ `[get]`, or πŸ“‘ `[set]` only occur on `func` imports or exports. * Validation requires that, for `plainname`s annotated with `[constructor]`, - `[method]`, or `[static]`, the first `label` matches the `plainname` of a - preceding `resource` import or export, respectively, in the same scope + `[method]`, or `[static]`, the resource name `label` matches the `plainname` + of a preceding `resource` import or export, respectively, in the same scope (component, component type or instance type). * 🏷️ Validation requires that `implements`-annotated imports or exports are `instance`-typed and have a `plainname` name. diff --git a/design/mvp/JS-Reference.md b/design/mvp/JS-Reference.md index a092847e..0dc08baf 100644 --- a/design/mvp/JS-Reference.md +++ b/design/mvp/JS-Reference.md @@ -252,7 +252,7 @@ Dispatch on `componentValType`: - `flags "L"+` β†’ `ToJSValueFlags`(|componentValue|, the labels). - `enum "L"+` β†’ String, the label verbatim. - `option` not nested within another `option` β†’ **undefined** for `none`, else `ToJSValue`(the payload, T). -- `variant`, and nested `option`, and `result` outside return position β†’ `ToJSValueVariant`(|componentValue|, the cases). In return position a `result` is unwrapped instead, into a return value or a thrown `ComponentError` (see [Read the imports](#read-the-imports-object) and [Create the exports object](#create-the-exports-object)). +- `variant`, and nested `option`, and `result` outside return position β†’ `ToJSValueVariant`(|componentValue|). In return position a `result` is unwrapped instead, into a return value or a thrown `ComponentError` (see [Read the imports](#read-the-imports-object) and [Create the exports object](#create-the-exports-object)). - `map` β†’ `ToJSValueMap`(|componentValue|, K, V). - `own` / `borrow` β†’ See [Resource types](#resource-types). - `future` β†’ a Promise (TODO). @@ -293,11 +293,12 @@ The `scalar typed array class` is given by: 1. Perform `CreateDataPropertyOrThrow`(|object|, `CamelCase`(L), |value|'s `L` bit as a Boolean). 1. Return |object|. -`ToJSValueVariant(value, cases)`: +`ToJSValueVariant(value)`: +1. Let |case| be the current case of the variant |value|. 1. Let |object| be `OrdinaryObjectCreate`(**null**). -1. Perform `CreateDataPropertyOrThrow`(|object|, "kind", `CaseLabelOf`(|value|, |cases|)). -1. If that case has a payload of type T: - 1. Perform `CreateDataPropertyOrThrow`(|object|, "value", `ToJSValue`(`PayloadOf`(|value|), T)). +1. Perform `CreateDataPropertyOrThrow`(|object|, "kind", the label of |case|). +1. If |case| has a payload of type |T|: + 1. Perform `CreateDataPropertyOrThrow`(|object|, "value", `ToJSValue`(the payload of |value|, |T|)). 1. Return |object|. This operation is used for variant, and also cases in the above table where we can't specialize the behavior of `option` and `result`. @@ -1064,8 +1065,8 @@ To `create the exports object` given an [instance record](#instance-records) |in 1. Let |value| be ? `create the exports object` given |instance| and the exports of the exported instance. 1. **component**: 1. Let |value| be a new `Component` whose [[Component]] is |export|.Component. - 1. Perform `CreateDataPropertyOrThrow`(|exportsObject|, |key|, |value|). -1. Perform `SetIntegrityLevel`(|exportsObject|, "frozen"). + 1. Perform ? `CreateDataPropertyOrThrow`(|exportsObject|, |key|, |value|). +1. Perform ? `SetIntegrityLevel`(|exportsObject|, "frozen"). 1. Return |exportsObject|. TODO: We need a JSName for members that hit the `reserved class members` list. It needs to concatenate the resource name with the method name somehow. diff --git a/design/mvp/Text.md b/design/mvp/Text.md index fdfa18be..da9be205 100644 --- a/design/mvp/Text.md +++ b/design/mvp/Text.md @@ -2727,8 +2727,10 @@ plainname ::=