-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.bs
More file actions
217 lines (163 loc) · 15.1 KB
/
index.bs
File metadata and controls
217 lines (163 loc) · 15.1 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
<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
Abstract: Minimum Common Web Platform API for Non-Browser ECMAScript-based runtimes.
Markup Shorthands: markdown 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. 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.
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.
<dfn>Web Platform</dfn> {#term-web-platform}
--------------------------------------------
the combination of technology standards defined by organizations such as the W3C, the WHATWG, and others as implemented by Web Browsers
<dfn>Web-interoperable Runtime</dfn> {#term-web-interoperable-runtime}
----------------------------------------------------------------------
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.
All of the following interfaces shall be exposed on the global object accessible through `globalThis`:
* {{AbortController}} [[!DOM]]
* {{AbortSignal}} [[!DOM]]
* {{Blob}} [[!FILEAPI]]
* {{ByteLengthQueuingStrategy}} [[!STREAMS]]
* {{CompressionStream}} [[!COMPRESSION]]
* {{CountQueuingStrategy}} [[!STREAMS]]
* {{Crypto}} [[!WEBCRYPTO]]
* {{CryptoKey}} [[!WEBCRYPTO]]
* {{CustomEvent}} [[!HTML]]
* {{DecompressionStream}} [[!COMPRESSION]]
* {{DOMException}} [[!WEBIDL]]
* {{ErrorEvent}} [[!HTML]]
* {{Event}} [[!DOM]]
* {{EventTarget}} [[!DOM]]
* {{File}} [[!FILEAPI]]
* {{FormData}} [[!XHR]]
* {{Headers}} [[!FETCH]]
* {{MessageChannel}} [[!HTML]]
* {{MessageEvent}} [[!HTML]]
* {{MessagePort}} [[!HTML]]
* {{Performance}} [[!HR-TIME]]
* {{PromiseRejectionEvent}} [[!HTML]]
* {{ReadableByteStreamController}} [[!STREAMS]]
* {{ReadableStream}} [[!STREAMS]]
* {{ReadableStreamBYOBReader}} [[!STREAMS]]
* {{ReadableStreamBYOBRequest}} [[!STREAMS]]
* {{ReadableStreamDefaultController}} [[!STREAMS]]
* {{ReadableStreamDefaultReader}} [[!STREAMS]]
* {{Request}} [[!FETCH]]
* {{Response}} [[!FETCH]]
* {{SubtleCrypto}} [[!WEBCRYPTO]]
* {{TextDecoder}} [[!ENCODING]]
* {{TextDecoderStream}} [[!ENCODING]]
* {{TextEncoder}} [[!ENCODING]]
* {{TextEncoderStream}} [[!ENCODING]]
* {{TransformStream}} [[!STREAMS]]
* {{TransformStreamDefaultController}} [[!STREAMS]]
* {{URL}} [[!URL]]
* {{URLPattern}} [[!URLPATTERN]]
* {{URLSearchParams}} [[!URL]]
* {{WebAssembly}}.<l spec="wasm-js-api-2">{{Global}}</l> [[!WASM-JS-API-2]]
* {{WebAssembly}}.{{Instance}} [[!WASM-JS-API-2]]
* {{WebAssembly}}.{{Memory}} [[!WASM-JS-API-2]]
* {{WebAssembly}}.{{Module}} [[!WASM-JS-API-2]]
* {{WebAssembly}}.{{Table}} [[!WASM-JS-API-2]]
* {{WebAssembly}}.{{Tag}} [[!WASM-JS-API-2]]
* {{WebAssembly}}.{{Exception}} [[!WASM-JS-API-2]]
* {{WebAssembly}}.{{CompileError}} [[!WASM-JS-API-2]]
* {{WebAssembly}}.{{LinkError}} [[!WASM-JS-API-2]]
* {{WebAssembly}}.{{RuntimeError}} [[!WASM-JS-API-2]]
* {{WritableStream}} [[!STREAMS]]
* {{WritableStreamDefaultController}} [[!STREAMS]]
* {{WritableStreamDefaultWriter}} [[!STREAMS]]
All of the following methods and properties shall be exposed on the global object accessible through `globalThis`, except as specified in [[#global-scope]]:
* {{globalThis}} [[!ECMASCRIPT]]
* `globalThis.`{{atob()}} [[!HTML]]
* `globalThis.`{{btoa()}} [[!HTML]]
* `globalThis.`{{clearTimeout()}} [[!HTML]]
* `globalThis.`{{clearInterval()}} [[!HTML]]
* `globalThis.`{{console}} [[!CONSOLE]]
* `globalThis.`{{crypto}} [[!WEBCRYPTO]]
* `globalThis.`{{fetch()}} [[!FETCH]]
* `globalThis.`{{navigator}}.{{userAgent}} [[!HTML]]
* `globalThis.`{{GlobalEventHandlers/onerror}} [[!HTML]]
* `globalThis.`{{WindowEventHandlers/onunhandledrejection}} [[!HTML]]
* `globalThis.`{{WindowEventHandlers/onrejectionhandled}} [[!HTML]]
* `globalThis.`{{performance}} [[!HR-TIME]]
* `globalThis.`{{queueMicrotask()}} [[!HTML]]
* `globalThis.`{{reportError()}} [[!HTML]]
* `globalThis.`{{Window/self}} [[!HTML]]
* `globalThis.`{{setTimeout()}} [[!HTML]]
* `globalThis.`{{setInterval()}} [[!HTML]]
* `globalThis.`{{structuredClone()}} [[!HTML]]
* `globalThis.`{{WebAssembly}}.{{WebAssembly/compile()}} [[!WASM-JS-API-2]]
* `globalThis.`{{WebAssembly}}.{{WebAssembly/compileStreaming()}} [[!WASM-WEB-API-2]]
* `globalThis.`{{WebAssembly}}.{{WebAssembly/instantiate()}} [[!WASM-JS-API-2]]
* `globalThis.`{{WebAssembly}}.{{WebAssembly/instantiateStreaming()}} [[!WASM-WEB-API-2]]
* `globalThis.`{{WebAssembly}}.{{WebAssembly/JSTag}} [[!WASM-JS-API-2]]
* `globalThis.`{{WebAssembly}}.{{WebAssembly/validate()}} [[!WASM-JS-API-2]]
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}},
{{WorkerGlobalScope/onunhandledrejection}}, {{WorkerGlobalScope/onrejectionhandled}} and
{{WorkerGlobalScope/self}},
except as specified in [[#global-scope]]. [[!HTML]]
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 must map 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).
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.
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'`.