-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.bs
More file actions
290 lines (191 loc) · 15.8 KB
/
index.bs
File metadata and controls
290 lines (191 loc) · 15.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<pre class='metadata'>
Title: Minimum common web API
Shortname: minimum-common-api
Group: wintertc
Status: DRAFT
URL: https://min-common-api.proposal.wintertc.org/
Repository: https://github.com/WinterTC55/proposal-minimum-common-api
Editor: James M Snell, Cloudflare https://cloudflare.com/, jsnell@cloudflare.com
Markup Shorthands: markdown yes
No Abstract: yes
</pre>
<pre class=link-defaults>
spec:url; type:interface; text:URL
spec:html; type:attribute; for:Window; text:navigator
spec:fetch; type:method; text:fetch()
</pre>
<h2 class="no-num" id="intro">Introduction</h2>
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.
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.
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.
This Ecma Standard was developed by Technical Committee 55 and was adopted by the General Assembly of December 2025.
<h2 class="no-num">Copyright</h2>
*ALTERNATIVE COPYRIGHT NOTICE AND COPYRIGHT LICENSE*
*© 2025 Ecma International*
*By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.*
*Permission under Ecma’s copyright to copy, modify, prepare derivative works of, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications:*
*(i) The full text of this COPYRIGHT NOTICE AND COPYRIGHT LICENSE in a location viewable to users of the redistributed or derivative work.*
*(ii) Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the Ecma alternative copyright notice should be included.*
*(iii) Notice of any changes or modifications, through a copyright statement on the document such as “This document includes material copied from or derived from [title and URL of the Ecma document]. Copyright © Ecma International.”*
**Disclaimers**
*THIS WORK IS PROVIDED “AS IS,” AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.*
*COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT.*
*The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders.*
Scope {#scope}
==========================
This Standard defines the 2025 snapshot of the Minimum common web API, a curated subset of APIs defined by web platform standards from W3C and WHATWG, which is intended to define a minimum set of capabilities common to browser and web server runtime environments based on ECMAScript.
The intended audience for this Standard is for web server runtime environments that want to be interoperable with the web platform. However, the set of APIs it describes may be implemented by any ECMAScript-based runtime environment that aims to be web-interoperable, even if its primary purpose is unrelated to web servers.
Conformance {#conformance}
==========================
A conforming implementation of this Standard shall provide the interfaces and properties listed in this specification, according to their definition in the corresponding W3C or WHATWG standard. A conforming implementation shall also conform to ECMA-262.
Runtime-specific extensions to any Web Platform API may be implemented by conforming runtimes. Such extensions shall be defined so that their use neither contradicts, nor causes the non-conformance of, normative functionality of any Web Platform API. Extending API surface, even without modifying existing API behaviours, should be avoided as it can reduce interoperability and portability of code across runtimes.
Runtimes may implement Web Platform APIs beyond those listed in this Standard.
Note: For example, the {{Performance}} API could be extended with additional methods or properties beyond those defined in the [[HR-TIME]] specifications, such as those defined in the [[PERFORMANCE-TIMELINE]] or [[USER-TIMING]] specifications.
Normative references {#TODO}
============================
The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.
<div data-fill-with="references"></div>
Terms and definitions {#terminology}
====================================
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.
<h3 class="no-toc" id="term-web-platform"><dfn>Web Platform</dfn></h3>
combination of technology standards defined by organizations such as the W3C, the WHATWG, and others as implemented by Web Browsers
<h3 class="no-toc" id="term-web-interoperable-runtime"><dfn>Web-interoperable Runtime</dfn></h3>
ECMAScript-based runtime environment that implements this Standard
Note: Web Browsers are Web-interoperable Runtimes.<br>
The term "Web-interoperable Runtime" is intentionally broad. The primary focus of this Standard is web server runtimes.
Common API index {#api-index}
=============================
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.
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.
Common interfaces {#api-interfaces}
-----------------------------------
All of the following interfaces shall be exposed on the global object accessible through `globalThis`.
Interfaces defined in [[!DOM]]:
* {{AbortController}}
* {{AbortSignal}}
* {{Event}}
* {{EventTarget}}
Interfaces defined in [[!HTML]]:
* {{CustomEvent}}
* {{ErrorEvent}}
* {{MessageChannel}}
* {{MessageEvent}}
* {{MessagePort}}
* {{PromiseRejectionEvent}}
Interfaces defined in [[!WEBIDL]]:
* {{DOMException}}
Interfaces defined in [[!FETCH]]:
* {{Headers}}
* {{Request}}
* {{Response}}
Interfaces defined in [[!XHR]]:
* {{FormData}}
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.
Interfaces defined in [[!FILEAPI]]:
* {{Blob}}
* {{File}}
Interfaces defined in [[!COMPRESSION]]:
* {{CompressionStream}}
* {{DecompressionStream}}
Interfaces defined in [[!STREAMS]]:
* {{ByteLengthQueuingStrategy}}
* {{CountQueuingStrategy}}
* {{ReadableByteStreamController}}
* {{ReadableStream}}
* {{ReadableStreamBYOBReader}}
* {{ReadableStreamBYOBRequest}}
* {{ReadableStreamDefaultController}}
* {{ReadableStreamDefaultReader}}
* {{TransformStream}}
* {{TransformStreamDefaultController}}
* {{WritableStream}}
* {{WritableStreamDefaultController}}
* {{WritableStreamDefaultWriter}}
Interfaces defined in [[!ENCODING]]:
* {{TextDecoder}}
* {{TextDecoderStream}}
* {{TextEncoder}}
* {{TextEncoderStream}}
Interfaces defined in [[!URL]]:
* {{URL}}
* {{URLSearchParams}}
Interfaces defined in [[!URLPATTERN]]:
* {{URLPattern}}
Interfaces defined in [[!WEBCRYPTO]]:
* {{Crypto}}
* {{CryptoKey}}
* {{SubtleCrypto}}
Interfaces defined in [[!HR-TIME]]:
* {{Performance}}
Interfaces defined in [[!WASM-JS-API-2]]:
* {{WebAssembly}}`.`<l spec="wasm-js-api-2">{{Global}}</l>
* {{WebAssembly}}`.`{{Instance}}
* {{WebAssembly}}`.`{{Memory}}
* {{WebAssembly}}`.`{{Module}}
* {{WebAssembly}}`.`{{Table}}
* {{WebAssembly}}`.`{{Tag}}
* {{WebAssembly}}`.`{{Exception}}
* {{WebAssembly}}`.`{{CompileError}}
* {{WebAssembly}}`.`{{LinkError}}
* {{WebAssembly}}`.`{{RuntimeError}}
Common methods and properties {#api-methods}
------------------------------------------
All of the following methods and properties shall be exposed on the global object accessible through `globalThis`, except as specified in [[#global-scope]].
* {{globalThis}} (as defined in [[!ECMASCRIPT]])
Methods and properties defined in [[!HTML]]:
* `globalThis.`{{atob()}}
* `globalThis.`{{btoa()}}
* `globalThis.`{{clearTimeout()}}
* `globalThis.`{{clearInterval()}}
* `globalThis.`{{navigator}}`.`{{userAgent}}
* `globalThis.`{{GlobalEventHandlers/onerror}}
* `globalThis.`{{WindowEventHandlers/onunhandledrejection}}
* `globalThis.`{{WindowEventHandlers/onrejectionhandled}}
* `globalThis.`{{queueMicrotask()}}
* `globalThis.`{{reportError()}}
* `globalThis.`{{Window/self}}
* `globalThis.`{{setTimeout()}}
* `globalThis.`{{setInterval()}}
* `globalThis.`{{structuredClone()}}
Methods and properties defined in [[!FETCH]]:
* `globalThis.`{{fetch()}}
Methods and properties defined in [[!CONSOLE]]:
* `globalThis.`{{console}}
Methods and properties defined in [[!WEBCRYPTO]]:
* `globalThis.`{{crypto}}
Methods and properties defined in [[!HR-TIME]]:
* `globalThis.`{{performance}}
Methods and properties defined in [[!WASM-JS-API-2]]:
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/compile()}}
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/compileStreaming()}}
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/instantiate()}}
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/instantiateStreaming()}}
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/JSTag}}
* `globalThis.`{{WebAssembly}}`.`{{WebAssembly/validate()}}
Web workers {#api-workers}
--------------------------
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]],
except as specified in [[#global-scope]].
* {{WorkerGlobalScope/onerror}}
* {{WorkerGlobalScope/onunhandledrejection}}
* {{WorkerGlobalScope/onrejectionhandled}}
* {{WorkerGlobalScope/self}}
The global scope {#global-scope}
================================
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).
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=*]}}.
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.
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.
In cases where it is not possible to have such global objects be an instance of {{EventTarget}} due to legacy reasons, the relevant events shall still be fired through a suitable alternative mechanism available at the global scope. This mechanism shall provide at least the same information that is provided by the relevant event interfaces if the global object were to be an {{EventTarget}}. Such runtimes shall not support the {{GlobalEventHandlers/onerror}}, {{WindowEventHandlers/onunhandledrejection}} and {{WindowEventHandlers/onrejectionhandled}} global properties. Such runtimes are not required to implement the {{ErrorEvent}} and {{PromiseRejectionEvent}} interfaces.
Note: For example, in Node.js the global object does not implement {{EventTarget}}, and the relevant events are fired on the `globalThis.process` object with the names `uncaughtException`, `unhandledRejection` and `rejectionHandled`, respectively.
Requirements for default User-Agent value {#useragent-requirements}
========================================================================
The [=default `User-Agent` value=] is provided such that application code can reliably identify the runtime within which it is running. The value shall be a string conforming to the <code class="idl"><a data-link-type="idl" href="https://datatracker.ietf.org/doc/html/rfc7231#section-5.5.3">`User-Agent`</a></code> construction in [[!RFC7231]]:
<pre>
User-Agent = product *( RWS ( product / comment ) )
product = token ["/" product-version]
product-version = token
</pre>
The [=default `User-Agent` value=] should be treated by application code as a single, complete, opaque, unstructured value. It is recommended that the value be limited to a single `product` token excluding the optional `product-version`. The value should not include any `comment` components.
Note: For instance, `navigator.userAgent` could be set to `'MyRuntime'`.