Skip to content

Commit b6d9cd9

Browse files
committed
Add editorial fixes from the published standard
These are fixes from the editorial reviews of the Minimum Common Web API spec.
1 parent 9b4e751 commit b6d9cd9

File tree

1 file changed

+173
-102
lines changed

1 file changed

+173
-102
lines changed

index.bs

Lines changed: 173 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Status: DRAFT
66
URL: https://min-common-api.proposal.wintertc.org/
77
Repository: https://github.com/WinterTC55/proposal-minimum-common-api
88
Editor: James M Snell, Cloudflare https://cloudflare.com/, [email protected]
9-
Abstract: Minimum Common Web Platform API for Non-Browser ECMAScript-based runtimes.
109
Markup Shorthands: markdown yes
10+
No Abstract: yes
1111
</pre>
1212
<pre class=link-defaults>
1313
spec:url; type:interface; text:URL
@@ -17,9 +17,9 @@ spec:fetch; type:method; text:fetch()
1717

1818
<h2 class="no-num" id="intro">Introduction</h2>
1919

20-
There is a wide base of ECMAScript runtime environments being used beyond web browsers, specifically in web server and edge platforms. An major benefit to this approach is the ability to use a single programming language across multiple contexts, reducing specialization and allowing for reuse of code across the server and client side.
20+
There is a wide base of ECMAScript runtime environments being used beyond web browsers, specifically in web server and edge platforms. A major benefit to this approach is the ability to use a single programming language across multiple contexts, reducing specialisation and allowing for reuse of code across the server and client side.
2121

22-
Since code running in web browsers makes up the vast majority of ECMAScript code, runtimes are incentivised to support the same APIs as web browsers. However without a specification of which web platform APIs to be implemented, the resulting landscape provides poor interoperability across such environments.
22+
Since code running in web browsers makes up the vast majority of ECMAScript code, runtimes are incentivised to support the same APIs as web browsers. However, without a specification of which web platform APIs to be implemented, the resulting landscape provides poor interoperability across such environments.
2323

2424
As such, this Ecma Standard defines the Minimum common web API specification, which defines a subset of Web Platform APIs for server runtimes to implement for interoperability with the web. This is the first edition of the standard, corresponding to the 2025 snapshot. As the web platform and web server runtimes grow and evolve, the committee will aim to publish with an annual cadence.
2525

@@ -79,123 +79,194 @@ Terms and definitions {#terminology}
7979

8080
For the purposes of this document, the terms and definitions given in ECMA-262, Compression Standard, Console Standard, DOM Standard, Encoding Standard, Fetch Standard, File API, High-Resolution Time, HTML Standard, Streams Standard, URL Standard, URL Pattern Standard, WebAssembly JavaScript Interface, WebAssembly Web API, W3C Web Cryptography Level 2, and the following apply. Externally-defined terms are mapped to source in Annex A.
8181

82-
<dfn>Web Platform</dfn> {#term-web-platform}
83-
--------------------------------------------
82+
<h3 class="no-toc" id="term-web-platform"><dfn>Web Platform</dfn></h3>
8483

85-
the combination of technology standards defined by organizations such as the W3C, the WHATWG, and others as implemented by Web Browsers
84+
combination of technology standards defined by organizations such as the W3C, the WHATWG, and others as implemented by Web Browsers
8685

87-
<dfn>Web-interoperable Runtime</dfn> {#term-web-interoperable-runtime}
88-
----------------------------------------------------------------------
86+
<h3 class="no-toc" id="term-web-interoperable-runtime"><dfn>Web-interoperable Runtime</dfn></h3>
8987

9088
ECMAScript-based runtime environment that implements this Standard
9189

9290
Note: Web Browsers are Web-interoperable Runtimes.<br>
9391
The term "Web-interoperable Runtime" is intentionally broad. The primary focus of this Standard is web server runtimes.
9492

95-
Common API Index {#api-index}
96-
=========================
93+
Common API index {#api-index}
94+
=============================
9795

9896
All <a>Web-interoperable Runtimes</a> conforming to this Standard shall implement each of the following <a>Web Platform</a> APIs. These should be implemented in accordance with their normative requirements except as specified in [[#global-scope]]. Where any runtime environment must diverge from a normative requirement for technical or structural reasons, clear documentation shall be provided. Documentation shall include both explanation and impact of deviation.
9997

10098
Note: For example, since web server runtimes do not have an [=origin=] concept, they must violate [[!FETCH]]'s requirement of appending an `Origin` header to network requests.
10199

102-
All of the following interfaces shall be exposed on the global object accessible through `globalThis`:
103-
104-
* {{AbortController}} [[!DOM]]
105-
* {{AbortSignal}} [[!DOM]]
106-
* {{Blob}} [[!FILEAPI]]
107-
* {{ByteLengthQueuingStrategy}} [[!STREAMS]]
108-
* {{CompressionStream}} [[!COMPRESSION]]
109-
* {{CountQueuingStrategy}} [[!STREAMS]]
110-
* {{Crypto}} [[!WEBCRYPTO]]
111-
* {{CryptoKey}} [[!WEBCRYPTO]]
112-
* {{CustomEvent}} [[!HTML]]
113-
* {{DecompressionStream}} [[!COMPRESSION]]
114-
* {{DOMException}} [[!WEBIDL]]
115-
* {{ErrorEvent}} [[!HTML]]
116-
* {{Event}} [[!DOM]]
117-
* {{EventTarget}} [[!DOM]]
118-
* {{File}} [[!FILEAPI]]
119-
* {{FormData}} [[!XHR]]
120-
* {{Headers}} [[!FETCH]]
121-
* {{MessageChannel}} [[!HTML]]
122-
* {{MessageEvent}} [[!HTML]]
123-
* {{MessagePort}} [[!HTML]]
124-
* {{Performance}} [[!HR-TIME]]
125-
* {{PromiseRejectionEvent}} [[!HTML]]
126-
* {{ReadableByteStreamController}} [[!STREAMS]]
127-
* {{ReadableStream}} [[!STREAMS]]
128-
* {{ReadableStreamBYOBReader}} [[!STREAMS]]
129-
* {{ReadableStreamBYOBRequest}} [[!STREAMS]]
130-
* {{ReadableStreamDefaultController}} [[!STREAMS]]
131-
* {{ReadableStreamDefaultReader}} [[!STREAMS]]
132-
* {{Request}} [[!FETCH]]
133-
* {{Response}} [[!FETCH]]
134-
* {{SubtleCrypto}} [[!WEBCRYPTO]]
135-
* {{TextDecoder}} [[!ENCODING]]
136-
* {{TextDecoderStream}} [[!ENCODING]]
137-
* {{TextEncoder}} [[!ENCODING]]
138-
* {{TextEncoderStream}} [[!ENCODING]]
139-
* {{TransformStream}} [[!STREAMS]]
140-
* {{TransformStreamDefaultController}} [[!STREAMS]]
141-
* {{URL}} [[!URL]]
142-
* {{URLPattern}} [[!URLPATTERN]]
143-
* {{URLSearchParams}} [[!URL]]
144-
* {{WebAssembly}}.<l spec="wasm-js-api-2">{{Global}}</l> [[!WASM-JS-API-2]]
145-
* {{WebAssembly}}.{{Instance}} [[!WASM-JS-API-2]]
146-
* {{WebAssembly}}.{{Memory}} [[!WASM-JS-API-2]]
147-
* {{WebAssembly}}.{{Module}} [[!WASM-JS-API-2]]
148-
* {{WebAssembly}}.{{Table}} [[!WASM-JS-API-2]]
149-
* {{WebAssembly}}.{{Tag}} [[!WASM-JS-API-2]]
150-
* {{WebAssembly}}.{{Exception}} [[!WASM-JS-API-2]]
151-
* {{WebAssembly}}.{{CompileError}} [[!WASM-JS-API-2]]
152-
* {{WebAssembly}}.{{LinkError}} [[!WASM-JS-API-2]]
153-
* {{WebAssembly}}.{{RuntimeError}} [[!WASM-JS-API-2]]
154-
* {{WritableStream}} [[!STREAMS]]
155-
* {{WritableStreamDefaultController}} [[!STREAMS]]
156-
* {{WritableStreamDefaultWriter}} [[!STREAMS]]
157-
158-
All of the following methods and properties shall be exposed on the global object accessible through `globalThis`, except as specified in [[#global-scope]]:
159-
160-
* {{globalThis}} [[!ECMASCRIPT]]
161-
* `globalThis.`{{atob()}} [[!HTML]]
162-
* `globalThis.`{{btoa()}} [[!HTML]]
163-
* `globalThis.`{{clearTimeout()}} [[!HTML]]
164-
* `globalThis.`{{clearInterval()}} [[!HTML]]
165-
* `globalThis.`{{console}} [[!CONSOLE]]
166-
* `globalThis.`{{crypto}} [[!WEBCRYPTO]]
167-
* `globalThis.`{{fetch()}} [[!FETCH]]
168-
* `globalThis.`{{navigator}}.{{userAgent}} [[!HTML]]
169-
* `globalThis.`{{GlobalEventHandlers/onerror}} [[!HTML]]
170-
* `globalThis.`{{WindowEventHandlers/onunhandledrejection}} [[!HTML]]
171-
* `globalThis.`{{WindowEventHandlers/onrejectionhandled}} [[!HTML]]
172-
* `globalThis.`{{performance}} [[!HR-TIME]]
173-
* `globalThis.`{{queueMicrotask()}} [[!HTML]]
174-
* `globalThis.`{{reportError()}} [[!HTML]]
175-
* `globalThis.`{{Window/self}} [[!HTML]]
176-
* `globalThis.`{{setTimeout()}} [[!HTML]]
177-
* `globalThis.`{{setInterval()}} [[!HTML]]
178-
* `globalThis.`{{structuredClone()}} [[!HTML]]
179-
* `globalThis.`{{WebAssembly}}.{{WebAssembly/compile()}} [[!WASM-JS-API-2]]
180-
* `globalThis.`{{WebAssembly}}.{{WebAssembly/compileStreaming()}} [[!WASM-WEB-API-2]]
181-
* `globalThis.`{{WebAssembly}}.{{WebAssembly/instantiate()}} [[!WASM-JS-API-2]]
182-
* `globalThis.`{{WebAssembly}}.{{WebAssembly/instantiateStreaming()}} [[!WASM-WEB-API-2]]
183-
* `globalThis.`{{WebAssembly}}.{{WebAssembly/JSTag}} [[!WASM-JS-API-2]]
184-
* `globalThis.`{{WebAssembly}}.{{WebAssembly/validate()}} [[!WASM-JS-API-2]]
185-
186-
This Standard does not require runtimes to support [=web workers=]. However, if a runtime has global scopes that map to {{WorkerGlobalScope}} (see [[#global-scope]]), then the global object shall also expose {{WorkerGlobalScope/onerror}},
187-
{{WorkerGlobalScope/onunhandledrejection}}, {{WorkerGlobalScope/onrejectionhandled}} and
188-
{{WorkerGlobalScope/self}},
189-
except as specified in [[#global-scope]]. [[!HTML]]
190-
191-
The Global Scope {#global-scope}
100+
Common interfaces {#api-interfaces}
101+
-----------------------------------
102+
103+
All of the following interfaces shall be exposed on the global object accessible through `globalThis`.
104+
105+
Interfaces defined in [[!DOM]]:
106+
107+
* {{AbortController}}
108+
* {{AbortSignal}}
109+
* {{Event}}
110+
* {{EventTarget}}
111+
112+
Interfaces defined in [[!HTML]]:
113+
114+
* {{CustomEvent}}
115+
* {{ErrorEvent}}
116+
* {{MessageChannel}}
117+
* {{MessageEvent}}
118+
* {{MessagePort}}
119+
* {{PromiseRejectionEvent}}
120+
121+
Interfaces defined in [[!WEBIDL]]:
122+
123+
* {{DOMException}}
124+
125+
Interfaces defined in [[!FETCH]]:
126+
127+
* {{Headers}}
128+
* {{Request}}
129+
* {{Response}}
130+
131+
Interfaces defined in [[!XHR]]:
132+
133+
* {{FormData}}
134+
135+
Note: The {{FormData}} constructor takes <i>optional</i> arguments of the types {{HTMLFormElement}} and {{HTMLElement}}, which are web API interfaces not included in the common API list in this Standard. Since both of these arguments are optional, the behavior when both are `undefined` or not given is always well-defined. The behavior in other cases for runtimes that do not implement such APIs is not well-defined by this Standard; future editions will provide greater clarity.
136+
137+
Interfaces defined in [[!FILEAPI]]:
138+
139+
* {{Blob}}
140+
* {{File}}
141+
142+
Interfaces defined in [[!COMPRESSION]]:
143+
144+
* {{CompressionStream}}
145+
* {{DecompressionStream}}
146+
147+
Interfaces defined in [[!STREAMS]]:
148+
149+
* {{ByteLengthQueuingStrategy}}
150+
* {{CountQueuingStrategy}}
151+
* {{ReadableByteStreamController}}
152+
* {{ReadableStream}}
153+
* {{ReadableStreamBYOBReader}}
154+
* {{ReadableStreamBYOBRequest}}
155+
* {{ReadableStreamDefaultController}}
156+
* {{ReadableStreamDefaultReader}}
157+
* {{TransformStream}}
158+
* {{TransformStreamDefaultController}}
159+
* {{WritableStream}}
160+
* {{WritableStreamDefaultController}}
161+
* {{WritableStreamDefaultWriter}}
162+
163+
Interfaces defined in [[!ENCODING]]:
164+
165+
* {{TextDecoder}}
166+
* {{TextDecoderStream}}
167+
* {{TextEncoder}}
168+
* {{TextEncoderStream}}
169+
170+
Interfaces defined in [[!URL]]:
171+
172+
* {{URL}}
173+
* {{URLSearchParams}}
174+
175+
Interfaces defined in [[!URLPATTERN]]:
176+
177+
* {{URLPattern}}
178+
179+
Interfaces defined in [[!WEBCRYPTO]]:
180+
181+
* {{Crypto}}
182+
* {{CryptoKey}}
183+
* {{SubtleCrypto}}
184+
185+
Interfaces defined in [[!HR-TIME]]:
186+
187+
* {{Performance}}
188+
189+
Interfaces defined in [[!WASM-JS-API-2]]:
190+
191+
* {{WebAssembly}}`.`<l spec="wasm-js-api-2">{{Global}}</l>
192+
* {{WebAssembly}}`.`{{Instance}}
193+
* {{WebAssembly}}`.`{{Memory}}
194+
* {{WebAssembly}}`.`{{Module}}
195+
* {{WebAssembly}}`.`{{Table}}
196+
* {{WebAssembly}}`.`{{Tag}}
197+
* {{WebAssembly}}`.`{{Exception}}
198+
* {{WebAssembly}}`.`{{CompileError}}
199+
* {{WebAssembly}}`.`{{LinkError}}
200+
* {{WebAssembly}}`.`{{RuntimeError}}
201+
202+
Common methods and properties {#api-methods}
203+
------------------------------------------
204+
205+
All of the following methods and properties shall be exposed on the global object accessible through `globalThis`, except as specified in [[#global-scope]].
206+
207+
* {{globalThis}} (as defined in [[!ECMASCRIPT]])
208+
209+
Methods and properties defined in [[!HTML]]:
210+
211+
* `globalThis.`{{atob()}}
212+
* `globalThis.`{{btoa()}}
213+
* `globalThis.`{{clearTimeout()}}
214+
* `globalThis.`{{clearInterval()}}
215+
* `globalThis.`{{navigator}}`.`{{userAgent}}
216+
* `globalThis.`{{GlobalEventHandlers/onerror}}
217+
* `globalThis.`{{WindowEventHandlers/onunhandledrejection}}
218+
* `globalThis.`{{WindowEventHandlers/onrejectionhandled}}
219+
* `globalThis.`{{queueMicrotask()}}
220+
* `globalThis.`{{reportError()}}
221+
* `globalThis.`{{Window/self}}
222+
* `globalThis.`{{setTimeout()}}
223+
* `globalThis.`{{setInterval()}}
224+
* `globalThis.`{{structuredClone()}}
225+
226+
Methods and properties defined in [[!FETCH]]:
227+
228+
* `globalThis.`{{fetch()}}
229+
230+
Methods and properties defined in [[!CONSOLE]]:
231+
232+
* `globalThis.`{{console}}
233+
234+
Methods and properties defined in [[!WEBCRYPTO]]:
235+
236+
* `globalThis.`{{crypto}}
237+
238+
Methods and properties defined in [[!HR-TIME]]:
239+
240+
* `globalThis.`{{performance}}
241+
242+
Methods and properties defined in [[!WASM-JS-API-2]]:
243+
244+
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/compile()}}
245+
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/compileStreaming()}}
246+
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/instantiate()}}
247+
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/instantiateStreaming()}}
248+
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/JSTag}}
249+
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/validate()}}
250+
251+
Web workers {#api-workers}
252+
--------------------------
253+
254+
This Standard does not require runtimes to support [=web workers=]. However, if a runtime has global scopes that map to {{WorkerGlobalScope}} (see [[#global-scope]]), then the global object shall also expose the following event handlers and attributes as defined in [[!HTML]],
255+
except as specified in [[#global-scope]].
256+
257+
* {{WorkerGlobalScope/onerror}}
258+
* {{WorkerGlobalScope/onunhandledrejection}}
259+
* {{WorkerGlobalScope/onrejectionhandled}}
260+
* {{WorkerGlobalScope/self}}
261+
262+
The global scope {#global-scope}
192263
================================
193264

194265
The exact type of the global scope (`globalThis`) can vary across runtimes. Most Web Platform APIs are defined in terms that assume Web Browser environments that specifically expose types like {{Window}}, {{WorkerGlobalScope}}, and so forth. To simplify conformance, this Standard does not require such global scope interfaces to be supported, but each global scope in a relevant runtime may be mapped to a global scope interface defined in web specifications. All interfaces, methods, and properties defined by this Standard which are required by web specifications to be exposed in a global scope interface shall be exposed on all of the runtime's corresponding global scopes (e.g., `globalThis.crypto`, `globalThis.ReadableStream`, etc).
195266

196-
Note: It is expected that a runtime's main global scope maps to {{Window}}, that web worker global scopes map to {{WorkerGlobalScope}}, etc. Global scopes that do not map to any global interface could only implement web APIs defined as {{Exposed|[Exposed=*]}}.
267+
Note: A runtime's main global scope should map to {{Window}}, web worker global scope should map to {{WorkerGlobalScope}}, etc. Global scopes that do not map to a specifically defined global interface can only implement web APIs defined as {{Exposed|[Exposed=*]}}.
197268

198-
With many runtimes, adding a new global-scoped property can introduce breaking changes when the new global conflicts with existing application code. Many Web Platform APIs define global properties using [=read only|the `readonly` attribute=]. [[!WEBIDL]] To avoid introducing breaking changes, runtimes conforming to this Standard may omit the `readonly` attribute for properties being added to the global scope. This allows users of these runtimes to delete or overwrite these properties if they conflict with existing application code.
269+
With many runtimes, adding a new global-scoped property can introduce breaking changes when the new global conflicts with existing application code. Many Web Platform APIs define global properties using [=read only|the `readonly` attribute=]. To avoid introducing breaking changes, runtimes conforming to this Standard may omit the `readonly` attribute for properties being added to the global scope. This allows users of these runtimes to delete or overwrite these properties if they conflict with existing application code.
199270

200271
Whenever the global object corresponds to the {{Window}} or {{WorkerGlobalScope}} global interfaces, it should be an instance of {{EventTarget}}. Web-interoperable runtimes should follow the <a>report an exception</a> algorithm, and the JavaScript <a href="https://tc39.es/ecma262/#sec-host-promise-rejection-tracker">HostPromiseRejectionTracker</a> host hook, as defined in [[!HTML]]. This includes firing the {{Window/error}}, {{Window/unhandledrejection}} and {{Window/rejectionhandled}} events on the global object.
201272

0 commit comments

Comments
 (0)