spark_web 1.0.0-alpha.10
spark_web: ^1.0.0-alpha.10 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.10 #
Added #
- Feat: Added
Element.closest()method support for both browser and server. - Feat: Added complete Permissions API support (
permissions.dart).PermissionStateenum (granted,denied,prompt).PermissionNameenum with constants for all standard permissions (geolocation,notifications,push,persistent-storage,clipboard-read,clipboard-write,camera,microphone,background-fetch,background-sync).PermissionDescriptorbase class and specialized descriptors:PushPermissionDescriptor,MidiPermissionDescriptor,DevicePermissionDescriptor.PermissionStatusabstract interface withstate,name, andonchange.Permissionsabstract interface withquery().Navigator.permissionsgetter for both browser and server.- Server implementation returns
PermissionState.promptfor all queries. - Browser implementation wraps native
window.navigator.permissionsAPI.
1.0.0-alpha.9 #
Added #
- Feat: Greatly improved
HTMLInputElementsupport by adding specialized interfaces for all input types (HTMLTextInputElement,HTMLNumericInputElement,HTMLCheckableInputElement,HTMLFileInputElement, andHTMLButtonInputElement). - Feat: Added support for
ValidityStateand constraint validation methods on input elements. - Feat: Added
HTMLDataListElementand support for thelistproperty on input elements. - Feat: Added
FileandFileListinterfaces with platform-appropriate implementations. - Feat: Added
Blobinterface andcreateBlobfactory function.Filenow extendsBlob. - Feat: Added many missing properties to
HTMLInputElementincludinglabels,defaultValue,selectionStart/End,valueAsNumber/Date, etc.
1.0.0-alpha.8 #
Added #
- Feat: Added specialized event factory functions:
createMouseEvent,createKeyboardEvent,createFocusEvent,createInputEvent,createWheelEvent,createPointerEvent,createTouchEvent,createDragEvent,createAnimationEvent,createTransitionEvent, andcreateCustomEvent. - Feat: Added missing browser-side element wrappers for
HTMLParagraphElement,HTMLHeadingElement,HTMLUListElement,HTMLPreElement,HTMLHRElement, andHTMLBRElement. - Feat: Improved
ServerDocument.createElementto return correctly typed element instances for almost all HTML tags. - Feat: Added missing server-side specialized event implementations.
Changed #
- Refactor: Refined
HTMLTableElement,HTMLTableSectionElement, andHTMLTableRowElementinterfaces to use more specific return types matching the MDN Web API.
Fixed #
- Tests: Achieved 100% test coverage across all modules.
- Fixed an issue where
BrowserHTMLMeterElement.valuecould be clamped incorrectly if set beforemax.
1.0.0-alpha.7 #
1.0.0-alpha.6 #
Added #
- Feat: Added idiomatic Dart API for
Geolocation.- Added
Future<GeolocationPosition> getPosition([PositionOptions? options]). - Added
Stream<GeolocationPosition> onPositionChanged([PositionOptions? options]). - Implementation provided for both Browser and Server (server returns appropriate errors).
- Added
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