@popeindustries/lit-html
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -0,1 +1,47 @@ | ||
/* global window */ | ||
/* global ReadableStream */ | ||
import { render } from 'lit-html'; | ||
export * from 'lit-html'; | ||
const RENDER_ELEMENT = window.document.createElement('div'); | ||
/** | ||
* lit-html-server API parity | ||
* @param {import('lit-html').TemplateResult} result | ||
* @returns {ReadableStream} | ||
*/ | ||
export function renderToStream(result) { | ||
if (typeof ReadableStream === 'undefined') { | ||
throw Error('ReadableStream not supported on this platform'); | ||
} | ||
return new ReadableStream({ | ||
start(controller) { | ||
controller.enqueue(renderToBuffer(result)); | ||
controller.close(); | ||
} | ||
}); | ||
} | ||
/** | ||
* lit-html-server API parity | ||
* @param {import('lit-html').TemplateResult} result | ||
* @returns {Uint8Array} | ||
*/ | ||
export function renderToBuffer(result) { | ||
if (typeof TextEncoder === 'undefined') { | ||
throw Error('TextEncoder not supported on this platform'); | ||
} | ||
return new TextEncoder().encode(renderToString(result)); | ||
} | ||
/** | ||
* lit-html-server API parity | ||
* @param {import('lit-html').TemplateResult} result | ||
* @returns {string} html string | ||
*/ | ||
export function renderToString(result) { | ||
render(result, RENDER_ELEMENT); | ||
const htmlString = RENDER_ELEMENT.innerHTML; | ||
return htmlString; | ||
} |
@@ -1,10 +0,48 @@ | ||
import { TemplateResult as A } from 'lit-html'; | ||
import { TemplateResult as B } from '@popeindustries/lit-html-server'; | ||
declare module '@popeindustries/lit-html' { | ||
export * from 'lit-html'; | ||
export { | ||
renderToBuffer, | ||
renderToStream, | ||
renderToString | ||
} from '@popeindustries/lit-html/browser/index.js'; | ||
} | ||
type TemplateResult = A & B; | ||
declare module '@popeindustries/lit-html/directives/async-append.js' { | ||
export { asyncAppend } from 'lit-html/directives/async-append.js'; | ||
} | ||
export * from 'lit-html'; | ||
export { renderToBuffer, renderToStream, renderToString } from '@popeindustries/lit-html-server'; | ||
declare module '@popeindustries/lit-html/directives/async-replace.js' { | ||
export { asyncReplace } from 'lit-html/directives/async-replace.js'; | ||
} | ||
export function html(strings: TemplateStringsArray, ...values: Array<unknown>): TemplateResult; | ||
export function svg(strings: TemplateStringsArray, ...values: Array<unknown>): TemplateResult; | ||
declare module '@popeindustries/lit-html/directives/cache.js' { | ||
export { cache } from 'lit-html/directives/cache.js'; | ||
} | ||
declare module '@popeindustries/lit-html/directives/class-map.js' { | ||
export { classMap } from 'lit-html/directives/class-map.js'; | ||
} | ||
declare module '@popeindustries/lit-html/directives/guard.js' { | ||
export { guard } from 'lit-html/directives/guard.js'; | ||
} | ||
declare module '@popeindustries/lit-html/directives/if-defined.js' { | ||
export { ifDefined } from 'lit-html/directives/if-defined.js'; | ||
} | ||
declare module '@popeindustries/lit-html/directives/repeat.js' { | ||
export { repeat } from 'lit-html/directives/repeat.js'; | ||
} | ||
declare module '@popeindustries/lit-html/directives/style-map.js' { | ||
export { styleMap } from 'lit-html/directives/style-map.js'; | ||
} | ||
declare module '@popeindustries/lit-html/directives/unsafe-html.js' { | ||
export { unsafeHTML } from 'lit-html/directives/unsafe-html.js'; | ||
} | ||
declare module '@popeindustries/lit-html/directives/until.js' { | ||
export { until } from 'lit-html/directives/until.js'; | ||
} |
@@ -1,1 +0,1 @@ | ||
module.exports = require('@popeindustries/lit-html-server'); | ||
module.exports = require('@popeindustries/lit-html-server/index.js'); |
{ | ||
"name": "@popeindustries/lit-html", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Seamlessly render lit-html templates on the server and in the browser", | ||
"author": "Alexander Pope <alex@pope-industries.com>", | ||
"keywords": [ | ||
@@ -20,4 +19,2 @@ "html template", | ||
"./directives/async-append.mjs": "./browser/directives/async-append.js", | ||
"./directives/async-repeat.js": "./browser/directives/async-repeat.js", | ||
"./directives/async-repeat.mjs": "./browser/directives/async-repeat.js", | ||
"./directives/cache.js": "./browser/directives/cache.js", | ||
@@ -42,24 +39,27 @@ "./directives/cache.mjs": "./browser/directives/cache.js", | ||
"repository": "https://github.com/popeindustries/lit-html.git", | ||
"author": "Alexander Pope <alex@pope-industries.com>", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"peerDependencies": { | ||
"@popeindustries/lit-html-server": "^2.0.0", | ||
"lit-html": "^1.1.2" | ||
"@popeindustries/lit-html-server": "^1.3.0", | ||
"lit-html": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"@popeindustries/lit-html-server": "^2.0.0", | ||
"@popeindustries/lit-html-server": "^1.4.1", | ||
"babel-eslint": "^10.0.1", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.9.0", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"husky": "^4.0.10", | ||
"lint-staged": "^9.5.0", | ||
"dvlp": "^7.5.2", | ||
"eslint": "^6.1.0", | ||
"eslint-config-prettier": "^6.0.0", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"husky": "^3.0.2", | ||
"lint-staged": "^9.2.1", | ||
"lit-html": "^1.1.2", | ||
"prettier": "^1.19.1" | ||
"prettier": "^1.17.1" | ||
}, | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
"format": "prettier --write './{src,test}/**/*.{js,json}'", | ||
"lint": "eslint './{src,test}/**/*.js'" | ||
"lint": "eslint './{src,test}/**/*.js'", | ||
"test": "dvlp tests/" | ||
}, | ||
@@ -66,0 +66,0 @@ "husky": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
10484
109
10
34