react-ssml-dom
Advanced tools
Comparing version 2.0.0-experimental.3 to 2.0.0-experimental.4
@@ -62,2 +62,7 @@ import ReactReconciler from 'react-reconciler'; | ||
Node.prototype.toString = function () { | ||
var innerSSML = this.children.length | ||
? this.children.map(function (child) { return child.toString(); }).join(' ') | ||
: this.textContent; | ||
if (!this.type) | ||
return innerSSML; | ||
var tag = Object.keys(this.attributes).length | ||
@@ -71,5 +76,2 @@ ? "<".concat(this.type, " ").concat(Object.entries(this.attributes) | ||
: "<".concat(this.type, ">"); | ||
var innerSSML = this.children.length | ||
? this.children.map(function (child) { return child.toString(); }).join(' ') | ||
: this.textContent; | ||
return "".concat(tag).concat(innerSSML, "</").concat(this.type, ">") | ||
@@ -104,3 +106,2 @@ .replace(/\n/g, ' ') | ||
if (includeProlog === void 0) { includeProlog = false; } | ||
var _this = this; | ||
/* the xml document prolog */ | ||
@@ -112,10 +113,3 @@ this.xmlDeclaration = new XMLDeclaration(); | ||
this.body = null; | ||
// romise resolve callback function | ||
this.resolve = undefined; | ||
// promise side effect that can be awaited until the app is finalized | ||
this.isReady = new Promise(function (resolve) { | ||
_this.resolve = resolve; | ||
}); | ||
this.locale = locale; | ||
this.language = locale.slice(0, 2); | ||
this.includeProlog = includeProlog; | ||
@@ -126,8 +120,2 @@ if (addDefaultRoot) { | ||
} | ||
// resolves isReady | ||
Document.prototype.setReady = function () { | ||
if (this.resolve) { | ||
this.resolve(undefined); | ||
} | ||
}; | ||
Document.prototype.toString = function () { | ||
@@ -242,2 +230,8 @@ var _a, _b; | ||
}, | ||
renderToString: function (element) { | ||
// virtual node acts as an invisible container | ||
var virtualNode = new Node(''); | ||
this.render(element, virtualNode); | ||
return virtualNode.toString(); | ||
}, | ||
}; | ||
@@ -244,0 +238,0 @@ |
@@ -70,2 +70,7 @@ 'use strict'; | ||
Node.prototype.toString = function () { | ||
var innerSSML = this.children.length | ||
? this.children.map(function (child) { return child.toString(); }).join(' ') | ||
: this.textContent; | ||
if (!this.type) | ||
return innerSSML; | ||
var tag = Object.keys(this.attributes).length | ||
@@ -79,5 +84,2 @@ ? "<".concat(this.type, " ").concat(Object.entries(this.attributes) | ||
: "<".concat(this.type, ">"); | ||
var innerSSML = this.children.length | ||
? this.children.map(function (child) { return child.toString(); }).join(' ') | ||
: this.textContent; | ||
return "".concat(tag).concat(innerSSML, "</").concat(this.type, ">") | ||
@@ -112,3 +114,2 @@ .replace(/\n/g, ' ') | ||
if (includeProlog === void 0) { includeProlog = false; } | ||
var _this = this; | ||
/* the xml document prolog */ | ||
@@ -120,10 +121,3 @@ this.xmlDeclaration = new XMLDeclaration(); | ||
this.body = null; | ||
// romise resolve callback function | ||
this.resolve = undefined; | ||
// promise side effect that can be awaited until the app is finalized | ||
this.isReady = new Promise(function (resolve) { | ||
_this.resolve = resolve; | ||
}); | ||
this.locale = locale; | ||
this.language = locale.slice(0, 2); | ||
this.includeProlog = includeProlog; | ||
@@ -134,8 +128,2 @@ if (addDefaultRoot) { | ||
} | ||
// resolves isReady | ||
Document.prototype.setReady = function () { | ||
if (this.resolve) { | ||
this.resolve(undefined); | ||
} | ||
}; | ||
Document.prototype.toString = function () { | ||
@@ -250,2 +238,8 @@ var _a, _b; | ||
}, | ||
renderToString: function (element) { | ||
// virtual node acts as an invisible container | ||
var virtualNode = new Node(''); | ||
this.render(element, virtualNode); | ||
return virtualNode.toString(); | ||
}, | ||
}; | ||
@@ -252,0 +246,0 @@ |
@@ -9,3 +9,4 @@ /// <reference types="react" /> | ||
render(element: JSX.Element, container: Node): void; | ||
renderToString(element: JSX.Element): string; | ||
}; | ||
export default ReactSSML; |
@@ -7,9 +7,5 @@ import XMLDeclaration from './declaration'; | ||
locale: string; | ||
language: string; | ||
body: Node | null; | ||
resolve: ((value: unknown) => void) | undefined; | ||
constructor(locale?: string, addDefaultRoot?: boolean, includeProlog?: boolean); | ||
isReady: Promise<unknown>; | ||
setReady(): void; | ||
toString(): string; | ||
} |
{ | ||
"name": "react-ssml-dom", | ||
"version": "2.0.0-experimental.3", | ||
"version": "2.0.0-experimental.4", | ||
"description": "A proof of concept react host implementation for ssml strings", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68503
514