spark_web 1.0.0-alpha.5
spark_web: ^1.0.0-alpha.5 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.5 #
Added #
- Feat: Added complete Notification Web API support (
notification.dart).Notificationabstract interface with properties:title,body,tag,icon,dir,lang,badge,requireInteraction,silent,timestamp,data, andclose().NotificationOptionsdata class for configuring notifications.NotificationPermissionenum (granted,denied,defaultValue).NotificationDirectionenum (auto,ltr,rtl).createNotification()factory function (platform-aware).requestNotificationPermission()async permission request.notificationPermissiongetter for current permission state.notificationMaxActionsgetter.- Server implementation returns safe defaults; browser implementation wraps the native
window.NotificationAPI.
- Added notification example page in the example app (
/notification) for manual testing of the Notification API.
1.0.0-alpha.4 #
Added #
- Added
BrowserHTMLDivElementandBrowserHTMLSpanElementwrappers so thatcreateElement('div')andcreateElement('span')return the correct typed wrappers. - Feat: Added
HTMLCollectionsupport andElement.children. - Feat: Added
activeElementtoDocument. - Feat: Added
focus()andblur()toHTMLElement.
1.0.0-alpha.3 #
Fixed #
- Fixed
Event.target,Event.currentTarget,FocusEvent.relatedTarget, andTouch.targetreturning genericEventTargetwrappers instead of specificNodewrappers (likeElement). This ensures thatis Nodechecks work correctly on event targets.
1.0.0-alpha.2 #
Changed #
- Updated
Node.containsto acceptEventTarget?instead ofNode?. This fixes issues whereevent.targetcould not be passed directly tocontains.
1.0.0-alpha.1 #
Initial release of the server-safe Web API abstraction.
Added #
Core types (core.dart)
EventTarget—addEventListener,removeEventListener,dispatchEventEvent—type,target,currentTarget,preventDefault,stopPropagationMouseEvent—clientX/Y,pageX/Y,screenX/Y,button, modifier keysKeyboardEvent—key,code,repeat,location, modifier keysInputEvent—data,inputType,isComposingNode— Full tree traversal,appendChild,removeChild,insertBefore,replaceChild,cloneNode,containsNodeList—length,item()MutationObserver—observe,disconnect,takeRecordsMutationRecord—type,target,addedNodes,removedNodes,attributeName,oldValueMutationObserverInit— configuration data class
DOM types (dom.dart)
Element—tagName,id,className,innerHTML,outerHTML,classList,attributes,querySelector,querySelectorAll,getAttribute,setAttribute,removeAttribute,hasAttribute,remove,appendHTMLElement—innerText,hidden,title,style,shadowRoot,attachShadowHTMLDivElement,HTMLSpanElement,HTMLParagraphElementHTMLInputElement—value,type,placeholder,disabled,checked,nameHTMLTextAreaElement—value,placeholder,disabled,rows,colsHTMLButtonElement—disabled,typeHTMLSelectElement—value,selectedIndex,disabledHTMLOptionElement—value,text,selectedHTMLAnchorElement—href,targetHTMLImageElement—src,alt,width,heightHTMLFormElement—action,method,submit(),reset(),reportValidity()HTMLLabelElement—htmlForHTMLTemplateElement—contentDocumentFragment—querySelector,querySelectorAllShadowRoot—host,mode,adoptedStyleSheets,firstElementChildDocument—createElement,createElementNS,createTextNode,createComment,createDocumentFragment,getElementById,querySelector,querySelectorAll,documentElement,body,headText—data,wholeTextComment—data
Collection types (collections.dart)
DOMTokenList—add,remove,toggle,contains,replace,itemNamedNodeMap—item,getNamedItem,removeNamedItemAttr—name,value
CSS types (css.dart)
CSSStyleSheet—replaceSync,replaceCSSStyleDeclaration—getPropertyValue,setProperty,removeProperty,display,visibility,opacity
Window types (window.dart)
Window—document,console,navigator,localStorage,sessionStorage,location,history,crypto,performance,customElements,alert,confirm,prompt,setTimeout,setInterval,requestAnimationFrame,btoa,atobStorage—getItem,setItem,removeItem,clear,key,lengthLocation—href,protocol,host,hostname,port,pathname,search,hash,origin,assign,replace,reloadHistory—pushState,replaceState,back,forward,go,state,lengthNavigator—userAgent,language,languages,onLine,clipboardConsole—log,warn,error,info,debugCrypto—randomUUID()Performance—now()CustomElementRegistry—define,get,upgrade,whenDefinedClipboard—readText,writeText
Global singletons
window— Pre-initializedWindowinstancedocument— Pre-initializedDocumentinstancekIsBrowser—trueon browser,falseon Dart VM
Factory functions
createMutationObserver()— Platform-aware constructorcreateEvent()— Platform-aware constructor
Server implementations
- All types are no-ops or provide Dart-native fallbacks
Storagebacked byMapCrypto.randomUUID()viadart:mathbtoa/atobviadart:convertPerformance.now()viaStopwatchClipboardstores text in memory
Browser implementations
- All types wrap
package:webDOM objects .rawproperty exposes the native JS object