1.0.3 • Published 3 years ago

@sheeptester/htmlifier v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

HTMLifier for Node

Package a Scratch project inside an HTML file with no optimisations.

Installation

$ npm install @sheeptester/htmlifier

Example usage

The following example HTMLifies Scratch 3.0 is here! and writes the result to a file named index.html.

import fs from 'fs/promises'
import Htmlifier from '@sheeptester/htmlifier'

async function main () {
  const html = await new Htmlifier()
    .htmlify({ type: 'id', id: '276660763' })
    .then(blob => blob.text())
  await fs.writeFile('./index.html', html)
}

main()

Because node-fetch is strictly an ES module, this package is also an ES module. If you're using a CommonJS module, you can use esm to import this package.

require = require('esm')(module)
const Htmlifier = require('@sheeptester/htmlifier')

The HTMLifier was primarily written for Deno and the web, so it uses Blobs and Files to pass binary data around. You can use fetch-blob to create Blobs and Files for the HTMLifier.

import Htmlifier from '@sheeptester/htmlifier'
import { fileFrom } from 'fetch-blob/from.js'

async function main () {
  const html = await new Htmlifier()
    .htmlify({ type: 'file', file: await fileFrom('./project.sb3') })
    .then(blob => blob.text())
  // ...
}

main()

Documentation

Auto-generated documentation is available courtesy of deno doc.