@popeindustries/lit-html-server
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -260,3 +260,3 @@ interface TemplateProcessor { | ||
export declare function renderToString( | ||
result: TemplateResult, | ||
result: unknown, | ||
options?: RenderOptions | ||
@@ -269,3 +269,3 @@ ): Promise<string>; | ||
export declare function renderToStream( | ||
result: TemplateResult, | ||
result: unknown, | ||
options?: RenderOptions | ||
@@ -278,4 +278,4 @@ ): import('stream').Readable; | ||
export declare function renderToBuffer( | ||
result: TemplateResult, | ||
result: unknown, | ||
options?: RenderOptions | ||
): Promise<Buffer>; |
54
index.js
@@ -51,3 +51,3 @@ 'use strict'; | ||
stack = undefined; | ||
} | ||
}, | ||
}, | ||
@@ -61,3 +61,3 @@ stack, | ||
this.process(); | ||
} | ||
}, | ||
}); | ||
@@ -165,3 +165,3 @@ } | ||
'<': '<', | ||
'>': '>' | ||
'>': '>', | ||
}; | ||
@@ -794,3 +794,3 @@ const RE_HTML = /["'&<>]/g; | ||
reject(err); | ||
} | ||
}, | ||
}, | ||
@@ -906,3 +906,5 @@ stack, | ||
*/ | ||
const lastAttributeNameRegex = /([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/; | ||
const lastAttributeNameRegex = | ||
// eslint-disable-next-line no-control-regex | ||
/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/; | ||
@@ -1208,2 +1210,11 @@ const EMPTY_STRING_BUFFER$1 = buffer.Buffer.from(''); | ||
/** | ||
* Default templateResult factory | ||
* | ||
* @param { unknown } value | ||
* @returns { TemplateResult } | ||
*/ | ||
// prettier-ignore | ||
const DEFAULT_TEMPLATE_FN = (value) => html`${value}`; | ||
const defaultTemplateProcessor = new DefaultTemplateProcessor(); | ||
@@ -1241,3 +1252,3 @@ const defaultTemplateResultProcessor = new DefaultTemplateResultProcessor(); | ||
* | ||
* @param { TemplateResult } result - a template result returned from call to "html`...`" | ||
* @param { unknown } result - a template result returned from call to "html`...`" | ||
* @param { RenderOptions } [options] | ||
@@ -1247,3 +1258,3 @@ * @returns { import('stream').Readable | ReadableStream } | ||
function renderToStream(result, options) { | ||
return streamRenderer(result, defaultTemplateResultProcessor, options); | ||
return streamRenderer(getRenderResult(result), defaultTemplateResultProcessor, options); | ||
} | ||
@@ -1254,3 +1265,3 @@ | ||
* | ||
* @param { TemplateResult } result - a template result returned from call to "html`...`" | ||
* @param { unknown } result - a template result returned from call to "html`...`" | ||
* @param { RenderOptions } [options] | ||
@@ -1260,3 +1271,8 @@ * @returns { Promise<string> } | ||
function renderToString(result, options) { | ||
return promiseTemplateRenderer(result, defaultTemplateResultProcessor, false, options); | ||
return promiseTemplateRenderer( | ||
getRenderResult(result), | ||
defaultTemplateResultProcessor, | ||
false, | ||
options | ||
); | ||
} | ||
@@ -1267,3 +1283,3 @@ | ||
* | ||
* @param { TemplateResult } result - a template result returned from call to "html`...`" | ||
* @param { unknown } result - a template result returned from call to "html`...`" | ||
* @param { RenderOptions } [options] | ||
@@ -1273,5 +1289,21 @@ * @returns { Promise<Buffer> } | ||
function renderToBuffer(result, options) { | ||
return promiseTemplateRenderer(result, defaultTemplateResultProcessor, true, options); | ||
return promiseTemplateRenderer( | ||
getRenderResult(result), | ||
defaultTemplateResultProcessor, | ||
true, | ||
options | ||
); | ||
} | ||
/** | ||
* Retrieve TemplateResult for render | ||
* | ||
* @param { unknown} result | ||
* @returns { TemplateResult } | ||
*/ | ||
function getRenderResult(result) { | ||
// @ts-ignore | ||
return !isTemplateResult(result) ? DEFAULT_TEMPLATE_FN(result) : result; | ||
} | ||
Object.defineProperty(exports, 'directive', { | ||
@@ -1278,0 +1310,0 @@ enumerable: true, |
{ | ||
"name": "@popeindustries/lit-html-server", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Render lit-html templates on the server", | ||
@@ -42,5 +42,5 @@ "author": "Alexander Pope <alex@pope-industries.com>", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^11.0.2", | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
"@types/node": "^13.9.1", | ||
"@rollup/plugin-commonjs": "^11.1.0", | ||
"@rollup/plugin-node-resolve": "^7.1.3", | ||
"@types/node": "^13.11.1", | ||
"autocannon": "^4.6.0", | ||
@@ -50,12 +50,12 @@ "babel-eslint": "^10.1.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.0", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"get-stream": "^5.1.0", | ||
"husky": "^4.2.3", | ||
"lint-staged": "^10.0.8", | ||
"lit-html": "^1.1.0", | ||
"mocha": "^7.1.0", | ||
"prettier": "^1.19.1", | ||
"husky": "^4.2.5", | ||
"lint-staged": "^10.1.3", | ||
"lit-html": "^1.2.1", | ||
"mocha": "^7.1.1", | ||
"prettier": "^2.0.4", | ||
"puppeteer": "^2.1.1", | ||
"rollup": "^2.0.6", | ||
"rollup": "^2.6.1", | ||
"send": "^0.17.1", | ||
@@ -70,3 +70,3 @@ "typescript": "^3.8.3" | ||
"prepublishOnly": "npm run build", | ||
"test": "npm run lint && npm run test:unit && npm run test:browser", | ||
"test": "npm run build && npm run lint && npm run test:unit && npm run test:browser", | ||
"test:unit": "NODE_ENV=test mocha \"test/*-test.js\" --reporter spec --bail --timeout 2000", | ||
@@ -76,2 +76,8 @@ "test:browser": "node ./test/browser/cli.js", | ||
}, | ||
"prettier": { | ||
"arrowParens": "always", | ||
"htmlWhitespaceSensitivity": "ignore", | ||
"printWidth": 100, | ||
"singleQuote": true | ||
}, | ||
"husky": { | ||
@@ -78,0 +84,0 @@ "hooks": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
154985
4405