Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joncasey/modern-hta

Run modern code in an HTML Application
https://github.com/joncasey/modern-hta

babel es2015 es6 hta modern

Last synced: 28 days ago
JSON representation

Run modern code in an HTML Application

Awesome Lists containing this project

README

        

# modern-hta

modern-hta bundles [@babel/standalone](https://github.com/babel/babel/tree/master/packages/babel-standalone) and other [polyfills](#polyfills) to run modern code in an [HTML Application (HTA)](https://en.wikipedia.org/wiki/HTML_Application).

## Usage

Sample `hta` file using [cdn](https://unpkg.com/modern-hta/modern-hta.js).
```html

import $ from './$.mjs'
import data from './data.json'

log(`Hello World`)

```

Or, [install](#install) and run locally.

## Install

```
npm install modern-hta
```

```html

log(`Hello World`)

```

## What's Included...

## Polyfills

* [core-js](https://github.com/zloirock/core-js)
* [whatwg-fetch](https://github.com/github/fetch)
* `Array.from` - extended to support [Enumerator](https://msdn.microsoft.com/en-us/library/6ch9zb09(v=vs.84).aspx) and [FileSystemObject Collections](https://msdn.microsoft.com/en-us/library/x75sb7ff(v=vs.84).aspx)
* `Element.closest()`
* `Element.matches()`
* `NodeList.forEach`

## Globals (to be continued...)

```js
const Babel // export from @babel/standalone
const script // Element reference to the
const cwd // current working directory
const fso // instance of "Scripting.FileSystemObject"
const sys // instance of "Wscript.Shell"
const xhr // instance of "Msxml2.XMLHTTP"

function create (tag, html) {
// returns Element
}

function getSync (url) {
// returns xhr.responseText
}

function log (any) {
// returns HTMLDivElement
}

function require (src) {
// returns ES Module
}

function transform (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
}

function watchFile (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
}

function windowProps (resize, moveto) {
// this just simplifies window resizeTo & moveTo calls
// and, allows them to run as quickly as possible
// returns undefined
}
```