Making backend development fun for frontend developers.
Clone or download
Pull request Compare This branch is 82 commits ahead, 128 commits behind jsdom:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
impl
scripts
webidl
.gitattributes
.gitignore
.prettierignore
.prettierrc
.travis.yml
LICENSE.md
README.md
evil.js
index.js
library.js
package-lock.json
package.json

README.md

Platform Parity

Making backend development fun for frontend developers.

Status

Below is a print-out of everything that's available in a Worker in Chrome (67). The goal of the platform parity project is to provide a reasonable implementation to all of these in node. Plenty won't have a reasonable implementation though. These should either be undefined or throw upon invocation (not sure which is better).

Global

WorkerGlobalContext

  • WorkerGlobalScope
  • WorkerNavigator
  • WorkerLocation
  • ErrorEvent
  • PromiseRejectionEvent
  • self
  • location
  • navigator
  • onerror
  • onlanguagechange (never fired)
  • onoffline (never fired)
  • ononline (never fired)
  • onrejectionhandled
  • onunhandledrejection
  • importScripts
  • origin
  • isSecureContext
  • atob
  • btoa
  • setTimeout
  • clearTimeout
  • setInterval
  • clearInterval

Streams API

  • ByteLengthQueuingStrategy
  • CountQueuingStrategy
  • ReadableStream
  • WritableStream
  • TransformStream

Encoding API

Supported through browser polypill, probably slow.

  • TextEncoder
  • TextDecoder

Web Cryptography API

Supported through @trust/web-crypto.

  • SubtleCrypto
  • CryptoKey
  • Crypto (not generated by webidl2js though)
  • crypto

Indexed Database

  • IDBVersionChangeEvent
  • IDBTransaction
  • IDBRequest
  • IDBOpenDBRequest
  • IDBObjectStore
  • IDBKeyRange
  • IDBIndex
  • IDBFactory
  • IDBDatabase
  • IDBCursorWithValue
  • IDBCursor
  • indexedDB

Dedicated worker stuff (I think)

  • DedicatedWorkerGlobalScope
  • CloseEvent
  • BroadcastChannel
  • MessagePort
  • MessageEvent
  • MessageChannel
  • onmessage
  • onmessageerror
  • postMessage
  • close

URL Standard

There's actually work to be done to alternate between polyfills and native impls for node 10+

  • URL
  • URLSearchParams

Fetch API

  • Response (certain props missing)
  • Request (certain props missing)
  • Headers (guards not implemented. e.g. immutable)
  • fetch (various getters missing; bugs)

Form data (part of XHR)

  • FormData

File API

  • Blob
  • File
  • FileList
  • FileReader
  • FileReaderSync
  • ProgressEvent

Events

  • EventTarget
  • Event
  • CustomEvent
  • addEventListener
  • removeEventListener
  • dispatchEvent

Aborting

  • AbortSignal
  • AbortController

Cache

Could implement on top of IndexedDB or just write response bodies to the file system...

  • Cache
  • CacheStorage
  • caches

Legacy?

  • EventSource
  • WebSocket
  • XMLHttpRequestUpload
  • XMLHttpRequestEventTarget
  • XMLHttpRequest

Uncategorized

  • ServiceWorkerRegistration
  • DOMStringList
  • DOMException
  • BigInt (part of node since v?)
  • WebAssembly (part of node since v?)

File systems and directories API or something

Could instead be implemented with a node prefix...

  • TEMPORARY
  • PERSISTENT
  • webkitRequestFileSystem
  • webkitRequestFileSystemSync
  • webkitResolveLocalFileSystemURL
  • webkitResolveLocalFileSystemSyncURL

DOM Geometry API

Not clear if these make sense in node.

  • DOMRectReadOnly
  • DOMRect
  • DOMQuad
  • DOMPointReadOnly
  • DOMPoint
  • DOMMatrixReadOnly
  • DOMMatrix

Weird image stuff

Actually part of the Worker API, I think. Investigate.

  • ImageData
  • ImageBitmap
  • createImageBitmap

Weird shit

  • PushSubscriptionOptions
  • PushSubscription
  • PushManager
  • PermissionStatus
  • Permissions
  • Notification
  • BudgetService
  • PerformanceServerTiming
  • SyncManager
  • NetworkInformation
  • PerformanceResourceTiming
  • PerformanceObserverEntryList
  • PerformanceObserver
  • PerformanceEntry
  • NavigationPreloadManager
  • StorageManager
  • performance

Navigator

These are not on the global object, but global.navigator:

Note that some results depend on the content of env variables PROTOCOL, HOSTNAME, and PORT, and default to http:, os.hostname() || 'localhost', and 3000.

  • hardwareConcurrency
  • appCodeName
  • appName
  • appVersion
  • platform
  • product
  • userAgent
  • onLine
  • connection
  • budget
  • permissions
  • deviceMemory
  • storage

Couple of notes:

  • Actually, the ServiceWorker would match the node environment more closely, but it makes too many assumptions. The goal (for now) is to provide commonly used stuff like fetch.
  • Having an IndexedDB implementation for close-enough persistence needs right inside of node would be awesome, but that would be a considerable undertaking and I'm not sure I'd release that under MIT. There's in-memory IndexedDB implementations though, could try to plug that one in.
  • Not clear what to do about the Cache API
  • Probably going to drop the DedicatedWorkerGlobalContext stuff. Makes no sense here, does it?
  • I've crossed out a couple of things I don't want to support at this point.
  • I haven't look at some of these at all. They probably don't make a lot of sense either