spark_web 1.0.0-alpha.2 copy "spark_web: ^1.0.0-alpha.2" to clipboard
spark_web: ^1.0.0-alpha.2 copied to clipboard

Server-safe Web API abstraction for Dart. Mirrors the MDN Web API with identical naming so developers can rely on MDN documentation. Works on both the Dart VM (server) and dart2js (browser).

Changelog #

All notable changes to spark_web will be documented in this file.

1.0.0-alpha.2 #

Changed #

  • Updated Node.contains to accept EventTarget? instead of Node?. This fixes issues where event.target could not be passed directly to contains.

1.0.0-alpha.1 #

Initial release of the server-safe Web API abstraction.

Added #

Core types (core.dart)

  • EventTargetaddEventListener, removeEventListener, dispatchEvent
  • Eventtype, target, currentTarget, preventDefault, stopPropagation
  • MouseEventclientX/Y, pageX/Y, screenX/Y, button, modifier keys
  • KeyboardEventkey, code, repeat, location, modifier keys
  • InputEventdata, inputType, isComposing
  • Node — Full tree traversal, appendChild, removeChild, insertBefore, replaceChild, cloneNode, contains
  • NodeListlength, item()
  • MutationObserverobserve, disconnect, takeRecords
  • MutationRecordtype, target, addedNodes, removedNodes, attributeName, oldValue
  • MutationObserverInit — configuration data class

DOM types (dom.dart)

  • ElementtagName, id, className, innerHTML, outerHTML, classList, attributes, querySelector, querySelectorAll, getAttribute, setAttribute, removeAttribute, hasAttribute, remove, append
  • HTMLElementinnerText, hidden, title, style, shadowRoot, attachShadow
  • HTMLDivElement, HTMLSpanElement, HTMLParagraphElement
  • HTMLInputElementvalue, type, placeholder, disabled, checked, name
  • HTMLTextAreaElementvalue, placeholder, disabled, rows, cols
  • HTMLButtonElementdisabled, type
  • HTMLSelectElementvalue, selectedIndex, disabled
  • HTMLOptionElementvalue, text, selected
  • HTMLAnchorElementhref, target
  • HTMLImageElementsrc, alt, width, height
  • HTMLFormElementaction, method, submit(), reset(), reportValidity()
  • HTMLLabelElementhtmlFor
  • HTMLTemplateElementcontent
  • DocumentFragmentquerySelector, querySelectorAll
  • ShadowRoothost, mode, adoptedStyleSheets, firstElementChild
  • DocumentcreateElement, createElementNS, createTextNode, createComment, createDocumentFragment, getElementById, querySelector, querySelectorAll, documentElement, body, head
  • Textdata, wholeText
  • Commentdata

Collection types (collections.dart)

  • DOMTokenListadd, remove, toggle, contains, replace, item
  • NamedNodeMapitem, getNamedItem, removeNamedItem
  • Attrname, value

CSS types (css.dart)

  • CSSStyleSheetreplaceSync, replace
  • CSSStyleDeclarationgetPropertyValue, setProperty, removeProperty, display, visibility, opacity

Window types (window.dart)

  • Windowdocument, console, navigator, localStorage, sessionStorage, location, history, crypto, performance, customElements, alert, confirm, prompt, setTimeout, setInterval, requestAnimationFrame, btoa, atob
  • StoragegetItem, setItem, removeItem, clear, key, length
  • Locationhref, protocol, host, hostname, port, pathname, search, hash, origin, assign, replace, reload
  • HistorypushState, replaceState, back, forward, go, state, length
  • NavigatoruserAgent, language, languages, onLine, clipboard
  • Consolelog, warn, error, info, debug
  • CryptorandomUUID()
  • Performancenow()
  • CustomElementRegistrydefine, get, upgrade, whenDefined
  • ClipboardreadText, writeText

Global singletons

  • window — Pre-initialized Window instance
  • document — Pre-initialized Document instance
  • kIsBrowsertrue on browser, false on Dart VM

Factory functions

  • createMutationObserver() — Platform-aware constructor
  • createEvent() — Platform-aware constructor

Server implementations

  • All types are no-ops or provide Dart-native fallbacks
  • Storage backed by Map
  • Crypto.randomUUID() via dart:math
  • btoa/atob via dart:convert
  • Performance.now() via Stopwatch
  • Clipboard stores text in memory

Browser implementations

  • All types wrap package:web DOM objects
  • .raw property exposes the native JS object
1
likes
0
points
608
downloads

Publisher

verified publisherkleak.dev

Weekly Downloads

Server-safe Web API abstraction for Dart. Mirrors the MDN Web API with identical naming so developers can rely on MDN documentation. Works on both the Dart VM (server) and dart2js (browser).

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

meta, web

More

Packages that depend on spark_web