- Notifications
You must be signed in to change notification settings - Fork2
Run modern code in an HTML Application
License
NotificationsYou must be signed in to change notification settings
joncasey/modern-hta
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
modern-hta bundles@babel/standalone and otherpolyfills to run modern code in anHTML Application (HTA).
Samplehta
file usingcdn.
<metahttp-equiv="x-ua-compatible"content="ie=11"><scriptsrc="https://unpkg.com/modern-hta">import$from'./$.mjs'importdatafrom'./data.json'log(`Hello World`)</script>
Or,install and run locally.
npm install modern-hta
<metahttp-equiv="x-ua-compatible"content="ie=11"><scriptsrc="node_modules/modern-hta/modern-hta.js">log(`Hello World`)</script>
- core-js
- whatwg-fetch
Array.from
- extended to supportEnumerator andFileSystemObject CollectionsElement.closest()
Element.matches()
NodeList.forEach
constBabel// export from@babel/standaloneconstscript// Element reference to the <script src=modern-hta>constcwd// current working directoryconstfso// instance of "Scripting.FileSystemObject"constsys// instance of "Wscript.Shell"constxhr// instance of "Msxml2.XMLHTTP"functioncreate(tag,html){// returns Element}functiongetSync(url){// returns xhr.responseText}functionlog(any){// returns HTMLDivElement}functionrequire(src){// returns ES Module}functiontransform(code,options){// runs Babel.transform w/presets "es2015", "es2016", "es2017", "stage-0"// which "stage-0" also includes "stage-1", "stage-2", "stage-3"// for my purposes this always runs synchronously// returns transpiledCode}functionwatchFile(file,onchange){// this intentionally is a quick/dirty-hack version// it runs a setTimeout and checks the last modified date// just wanted something super-simple & light-weight for now.// returns undefined}functionwindowProps(resize,moveto){// this just simplifies window resizeTo & moveTo calls// and, allows them to run as quickly as possible// returns undefined}