194 个重大版本发布
新 0.197.0 | 2024 年 8 月 22 日 |
---|---|
0.195.0 | 2024 年 7 月 31 日 |
0.174.0 | 2024 年 3 月 28 日 |
0.160.0 | 2023 年 12 月 21 日 |
0.20.0 | 2020 年 11 月 23 日 |
#103 在 HTTP 服务器 中排名
15,512 每月下载量
被 64 个crate 使用(直接使用 24 个)
620KB
17K SLoC
deno web
实现了定时器以及以下API
- 事件
- TextEncoder
- TextDecoder
- 文件(规范:https://w3c.github.io/FileAPI)
注意:文本编码测试是通过 cli/ 中的 WPT 进行的。
使用示例
从 JavaScript 中,包含扩展的源代码
import * as infra from "ext:deno_web/00_infra.js";
import * as DOMException from "ext:deno_web/01_dom_exception.js";
import * as mimesniff from "ext:deno_web/01_mimesniff.js";
import * as event from "ext:deno_web/02_event.js";
import * as structuredClone from "ext:deno_web/02_structured_clone.js";
import * as timers from "ext:deno_web/02_timers.js";
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
import * as globalInterfaces from "ext:deno_web/04_global_interfaces.js";
import * as base64 from "ext:deno_web/05_base64.js";
import * as streams from "ext:deno_web/06_streams.js";
import * as encoding from "ext:deno_web/08_text_encoding.js";
import * as file from "ext:deno_web/09_file.js";
import * as fileReader from "ext:deno_web/10_filereader.js";
import * as location from "ext:deno_web/12_location.js";
import * as messagePort from "ext:deno_web/13_message_port.js";
import * as compression from "ext:deno_web/14_compression.js";
import * as performance from "ext:deno_web/15_performance.js";
import * as imageData from "ext:deno_web/16_image_data.js";
然后将以下属性赋值给全局作用域,例如以下示例
Object.defineProperty(globalThis, "AbortController", {
value: abortSignal.AbortController,
enumerable: false,
configurable: true,
writable: true,
});
名称 | 值 | 可枚举 | 可配置 | 可写 |
---|---|---|---|---|
AbortController | abortSignal.AbortController | false | true | true |
AbortSignal | abortSignal.AbortSignal | false | true | true |
Blob | file.Blob | false | true | true |
ByteLengthQueuingStrategy | streams.ByteLengthQueuingStrategy | |||
CloseEvent | event.CloseEvent | false | true | true |
CompressionStream | compression.CompressionStream | false | true | true |
CountQueuingStrategy | streams.CountQueuingStrategy | |||
CustomEvent | event.CustomEvent | false | true | true |
DecompressionStream | compression.DecompressionStream | false | true | true |
DOMException | DOMException | false | true | true |
ErrorEvent | event.ErrorEvent | false | true | true |
事件 | event.Event | false | true | true |
EventTarget | event.EventTarget | false | true | true |
File | file.File | false | true | true |
FileReader | fileReader.FileReader | false | true | true |
MessageEvent | event.MessageEvent | false | true | true |
Performance | performance.Performance | false | true | true |
PerformanceEntry | performance.PerformanceEntry | false | true | true |
PerformanceMark | performance.PerformanceMark | false | true | true |
PerformanceMeasure | performance.PerformanceMeasure | false | true | true |
PromiseRejectionEvent | event.PromiseRejectionEvent | false | true | true |
ProgressEvent | event.ProgressEvent | false | true | true |
可读流 | streams.ReadableStream | false | true | true |
ReadableStreamDefaultReader | streams.ReadableStreamDefaultReader | |||
TextDecoder | encoding.TextDecoder | false | true | true |
TextEncoder | encoding.TextEncoder | false | true | true |
TextDecoderStream | encoding.TextDecoderStream | false | true | true |
TextEncoderStream | encoding.TextEncoderStream | false | true | true |
TransformStream | streams.TransformStream | false | true | true |
MessageChannel | messagePort.MessageChannel | false | true | true |
MessagePort | messagePort.MessagePort | false | true | true |
可写流 | streams.WritableStream | false | true | true |
WritableStreamDefaultWriter | streams.WritableStreamDefaultWriter | |||
WritableStreamDefaultController | streams.WritableStreamDefaultController | |||
ReadableByteStreamController | streams.ReadableByteStreamController | |||
ReadableStreamBYOBReader | streams.ReadableStreamBYOBReader | |||
ReadableStreamBYOBRequest | streams.ReadableStreamBYOBRequest | |||
ReadableStreamDefaultController | streams.ReadableStreamDefaultController | |||
TransformStreamDefaultController | streams.TransformStreamDefaultController | |||
ImageData | imageData.ImageData | false | true | true |
atob | base64.atob | true | true | true |
btoa | base64.btoa | true | true | true |
clearInterval | timers.clearInterval | true | true | true |
clearTimeout | timers.clearTimeout | true | true | true |
performance | performance.performance | true | true | true |
reportError | event.reportError | true | true | true |
setInterval | timers.setInterval | true | true | true |
setTimeout | timers.setTimeout | true | true | true |
structuredClone | messagePort.structuredClone | true | true | true |
然后从Rust提供:deno_web::deno_web::init_ops_and_esm::<Permissions>(Arc<BlobStore>, Option<Url>)
在你的 RuntimeOptions
的 extensions
字段中
其中
Permissions
是一个实现了deno_web::TimersPermission
的结构体Arc<BlobStore>
可以通过Default::default()
提供Option<Url>
为某些操作提供一个可选的基本URL
依赖项
- deno_webidl:由
deno_webidl
包提供 - deno_console:由
deno_console
包提供 - deno_url:由
deno_url
包提供
提供的操作
以下操作已提供,可以通过 Deno.ops
访问
- op_base64_decode
- op_base64_encode
- op_base64_atob
- op_base64_btoa
- op_encoding_normalize_label
- op_encoding_decode_single
- op_encoding_decode_utf8
- op_encoding_new_decoder
- op_encoding_decode
- op_encoding_encode_into
- op_blob_create_part
- op_blob_slice_part
- op_blob_read_part
- op_blob_remove_part
- op_blob_create_object_url
- op_blob_revoke_object_url
- op_blob_from_object_url
- op_message_port_create_entangled
- op_message_port_post_message
- op_message_port_recv_message
- op_message_port_recv_message_sync
- op_compression_new
- op_compression_write
- op_compression_finish
- op_now
- op_defer
- op_readable_stream_resource_allocate
- op_readable_stream_resource_allocate_sized
- op_readable_stream_resource_get_sink
- op_readable_stream_resource_write_error
- op_readable_stream_resource_write_buf
- op_readable_stream_resource_write_sync
- op_readable_stream_resource_close
- op_readable_stream_resource_await_close
依赖项
~94MB
~2M SLoC