Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

react-ssml-dom

Package Overview
Dependencies
7
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-experimental.4 to 2.0.0

18

dist/index.d.ts

@@ -1,8 +0,12 @@

import Document from './ssml-dom/document';
import Root from './ssml-dom/root';
import XMLDeclaration from './ssml-dom/declaration';
import Node from './ssml-dom/node';
import TextNode from './ssml-dom/text';
import ReactSSML from './ReactSSML';
/// <reference types="react" />
import { Node } from 'ssml-dom';
declare const ReactSSML: {
/**
* @param {JSX.Element} element what to render
* @param {Node} container where to render
*/
render(element: JSX.Element, container: Node): void;
renderToString(element: JSX.Element): string;
};
export { ReactSSML };
export default ReactSSML;
export { ReactSSML, Document, Root, XMLDeclaration, Node, TextNode };
import ReactReconciler from 'react-reconciler';
import { Node, TextNode } from 'ssml-dom';
var XMLDeclaration = /** @class */ (function () {
function XMLDeclaration() {
this.version = '1.0';
}
XMLDeclaration.prototype.toString = function () {
return "<?xml version=\"".concat(this.version, "\"?>");
};
return XMLDeclaration;
}());
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var Node = /** @class */ (function () {
function Node(type) {
this.type = '';
this.textContent = '';
this.attributes = {};
this.children = [];
this.type = type;
}
Node.prototype.setAttribute = function (key, value) {
this.attributes[key] = value;
};
Node.prototype.appendChild = function (child) {
this.children.push(child);
};
Node.prototype.removeChild = function (child) {
this.children = this.children.filter(function (item) { return item !== child; });
};
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
? "<".concat(this.type, " ").concat(Object.entries(this.attributes)
.map(function (_a) {
var key = _a[0], value = _a[1];
return "".concat(key, "=\"").concat(value, "\"");
})
.join(' '), ">")
: "<".concat(this.type, ">");
return "".concat(tag).concat(innerSSML, "</").concat(this.type, ">")
.replace(/\n/g, ' ')
.replace(/\s+/g, ' ')
.trim();
};
return Node;
}());
var Root = /** @class */ (function (_super) {
__extends(Root, _super);
function Root(locale, addDefaults) {
if (locale === void 0) { locale = 'en-US'; }
if (addDefaults === void 0) { addDefaults = false; }
var _this = _super.call(this, 'speak') || this;
if (addDefaults) {
_this.setAttribute('version', '1.1');
_this.setAttribute('xml:lang', locale);
_this.setAttribute('xmlns', 'http://www.w3.org/2001/10/synthesis');
}
return _this;
}
return Root;
}(Node));
var Document = /** @class */ (function () {
function Document(locale, addDefaultRoot, includeProlog) {
if (locale === void 0) { locale = 'en-US'; }
if (addDefaultRoot === void 0) { addDefaultRoot = true; }
if (includeProlog === void 0) { includeProlog = false; }
/* the xml document prolog */
this.xmlDeclaration = new XMLDeclaration();
// include prolog in string version
this.includeProlog = false;
// the document body, usually of type speak
this.body = null;
this.locale = locale;
this.includeProlog = includeProlog;
if (addDefaultRoot) {
this.body = new Root(locale, true);
}
}
Document.prototype.toString = function () {
var _a, _b;
if (this.includeProlog) {
return "\n ".concat(this.xmlDeclaration.toString(), "\n ").concat((_a = this.body) === null || _a === void 0 ? void 0 : _a.toString(), "\n ")
.replace(/\n/g, ' ')
.replace(/\s+/g, ' ')
.trim();
}
return ((_b = this.body) === null || _b === void 0 ? void 0 : _b.toString()) || '';
};
return Document;
}());
var TextNode = /** @class */ (function () {
function TextNode(text) {
this.type = "text";
this.text = '';
this.text = text;
}
TextNode.prototype.toString = function () {
return this.text;
};
return TextNode;
}());
var rootHostContext = {};

@@ -233,5 +96,3 @@ var childHostContext = {};

// ssml-dom
export { Document, Node, ReactSSML, Root, TextNode, XMLDeclaration, ReactSSML as default };
export { ReactSSML, ReactSSML as default };
//# sourceMappingURL=index.es.js.map

@@ -6,2 +6,3 @@ 'use strict';

var ReactReconciler = require('react-reconciler');
var ssmlDom = require('ssml-dom');

@@ -12,140 +13,2 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var XMLDeclaration = /** @class */ (function () {
function XMLDeclaration() {
this.version = '1.0';
}
XMLDeclaration.prototype.toString = function () {
return "<?xml version=\"".concat(this.version, "\"?>");
};
return XMLDeclaration;
}());
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var Node = /** @class */ (function () {
function Node(type) {
this.type = '';
this.textContent = '';
this.attributes = {};
this.children = [];
this.type = type;
}
Node.prototype.setAttribute = function (key, value) {
this.attributes[key] = value;
};
Node.prototype.appendChild = function (child) {
this.children.push(child);
};
Node.prototype.removeChild = function (child) {
this.children = this.children.filter(function (item) { return item !== child; });
};
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
? "<".concat(this.type, " ").concat(Object.entries(this.attributes)
.map(function (_a) {
var key = _a[0], value = _a[1];
return "".concat(key, "=\"").concat(value, "\"");
})
.join(' '), ">")
: "<".concat(this.type, ">");
return "".concat(tag).concat(innerSSML, "</").concat(this.type, ">")
.replace(/\n/g, ' ')
.replace(/\s+/g, ' ')
.trim();
};
return Node;
}());
var Root = /** @class */ (function (_super) {
__extends(Root, _super);
function Root(locale, addDefaults) {
if (locale === void 0) { locale = 'en-US'; }
if (addDefaults === void 0) { addDefaults = false; }
var _this = _super.call(this, 'speak') || this;
if (addDefaults) {
_this.setAttribute('version', '1.1');
_this.setAttribute('xml:lang', locale);
_this.setAttribute('xmlns', 'http://www.w3.org/2001/10/synthesis');
}
return _this;
}
return Root;
}(Node));
var Document = /** @class */ (function () {
function Document(locale, addDefaultRoot, includeProlog) {
if (locale === void 0) { locale = 'en-US'; }
if (addDefaultRoot === void 0) { addDefaultRoot = true; }
if (includeProlog === void 0) { includeProlog = false; }
/* the xml document prolog */
this.xmlDeclaration = new XMLDeclaration();
// include prolog in string version
this.includeProlog = false;
// the document body, usually of type speak
this.body = null;
this.locale = locale;
this.includeProlog = includeProlog;
if (addDefaultRoot) {
this.body = new Root(locale, true);
}
}
Document.prototype.toString = function () {
var _a, _b;
if (this.includeProlog) {
return "\n ".concat(this.xmlDeclaration.toString(), "\n ").concat((_a = this.body) === null || _a === void 0 ? void 0 : _a.toString(), "\n ")
.replace(/\n/g, ' ')
.replace(/\s+/g, ' ')
.trim();
}
return ((_b = this.body) === null || _b === void 0 ? void 0 : _b.toString()) || '';
};
return Document;
}());
var TextNode = /** @class */ (function () {
function TextNode(text) {
this.type = "text";
this.text = '';
this.text = text;
}
TextNode.prototype.toString = function () {
return this.text;
};
return TextNode;
}());
var rootHostContext = {};

@@ -167,3 +30,3 @@ var childHostContext = {};

createInstance: function (type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
var domElement = new Node(type);
var domElement = new ssmlDom.Node(type);
Object.keys(props).forEach(function (propName) {

@@ -182,3 +45,3 @@ var propValue = props[propName];

},
createTextInstance: function (text) { return new TextNode(text); },
createTextInstance: function (text) { return new ssmlDom.TextNode(text); },
appendChildToContainer: function (container, child) {

@@ -239,3 +102,3 @@ container.appendChild(child);

// virtual node acts as an invisible container
var virtualNode = new Node('');
var virtualNode = new ssmlDom.Node('');
this.render(element, virtualNode);

@@ -246,11 +109,4 @@ return virtualNode.toString();

// ssml-dom
exports.Document = Document;
exports.Node = Node;
exports.ReactSSML = ReactSSML;
exports.Root = Root;
exports.TextNode = TextNode;
exports.XMLDeclaration = XMLDeclaration;
exports["default"] = ReactSSML;
//# sourceMappingURL=index.js.map
{
"name": "react-ssml-dom",
"version": "2.0.0-experimental.4",
"description": "A proof of concept react host implementation for ssml strings",
"main": "dist/index.js",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"files": [
"dist"
],
"scripts": {
"clean": "rimraf ./dist",
"lint": "eslint .",
"prepublish": "npm run clean && npm run lint && npm run test && npm run build",
"publish:package": "npm run prepublish && npm publish",
"build:demo": "cd demo/ && webpack --mode development",
"start:demo": "node demo-build/main.js",
"build": "rollup -c",
"start": "rollup -c -w"
},
"author": "Andre Landgraf",
"repository": {
"type": "git",
"url": "https://github.com/andrelandgraf/react-ssml-dom.git"
},
"license": "ISC",
"dependencies": {
"eslint": "^8.11.0",
"prop-types": "^15.7.2",
"react-reconciler": "^0.26.2"
},
"devDependencies": {
"@babel/core": "^7.11.4",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/preset-env": "^7.11.0",
"@babel/preset-react": "^7.10.4",
"@rollup/plugin-commonjs": "^21.0.2",
"@types/react-reconciler": "^0.26.4",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.0",
"babel-loader": "^8.1.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-html": "^6.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-react": "^7.29.3",
"express": "^4.17.1",
"helmet": "^4.1.0",
"prettier": "^1.19.1",
"react": "^18.0.0-beta-24dd07bd2-20211208",
"rollup": "^2.26.5",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.31.2",
"typescript": "^4.6.2",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^3.11.0"
}
"name": "react-ssml-dom",
"version": "2.0.0",
"description": "Utilize React to render SSML output for voice applications.",
"main": "dist/index.js",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"files": [
"dist"
],
"scripts": {
"build": "rollup -c",
"start": "rollup -c -w"
},
"author": "Andre Landgraf",
"repository": {
"type": "git",
"url": "https://github.com/andrelandgraf/react-ssml-dom.git"
},
"license": "MIT",
"dependencies": {
"react-reconciler": "^0.26.2",
"ssml-dom": "^0.0.3"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.3",
"@types/react-reconciler": "^0.26.4",
"rollup": "^2.70.1",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.31.2",
"typescript": "^4.6.3"
}
}

@@ -1,7 +0,2 @@

<h1 align="center">
ReactSSML
</h1>
<div align="center">
<img src="code.png" alt="Hello World SSML" />
</div>
# ReactSSML

@@ -14,14 +9,14 @@ Utilize the full power of React to develop voice UIs. ReactSSML provides a simple custom React renderer that let's you use React and JSX to create [SSML](https://www.w3.org/TR/speech-synthesis11/) output.

- [Motivation](#-motivation)
- [Installation Guide](#-installing-reactssml)
- [Demo](#-try-out-the-demo)
- [Documentation](#-documentation)
- [Architecture](#-how-it-works)
- [Example Apps](#-example-apps-using-reactssml)
- [Motivation](#-motivation)
- [Installation Guide](#-installing-reactssml)
- [Demo](#-try-out-the-demo)
- [Documentation](#-documentation)
- [Architecture](#-how-it-works)
- [Example Apps](#-example-apps-using-reactssml)
## 🌟 Motivation
- Building SSML speech responses with strings is cumbersome.
- Let's treat voice apps as UI.
- Enable composition and declarative syntax.
- Building SSML speech responses with strings is cumbersome.
- Let's treat voice apps as UI.
- Enable composition and declarative syntax.

@@ -47,9 +42,9 @@ I wrote a small article about [my motivation](https://medium.com/@andre.timo.landgraf/a-react-renderer-for-ssml-91cdd1d66b3e).

<App>
<SearchProvider>
<Introduction long="{firstSession}" />
<BrandedAudio />
<OfferHelp />
{ showHint && <NewestFeatureHint />
}
</SearchProvider>
<SearchProvider>
<Introduction long="{firstSession}" />
<BrandedAudio />
<OfferHelp />
{ showHint && <NewestFeatureHint />
}
</SearchProvider>
</App>

@@ -98,3 +93,3 @@ ```

<speak>
<s>Hello World!</s>
<s>Hello World!</s>
</speak>

@@ -146,3 +141,3 @@ ```

{
"ssml": "<speak version=\"1.1\" xml:lang=\"en-US\" xmlns=\"http://www.w3.org/2001/10/synthesis\">Hello World!</speak>"
"ssml": "<speak version=\"1.1\" xml:lang=\"en-US\" xmlns=\"http://www.w3.org/2001/10/synthesis\">Hello World!</speak>"
}

@@ -155,14 +150,14 @@ ```

- ReactSSML
- **_ssml-dom_**
- Document
- XMLDeclaration
- Root
- Node
- TextNoode
- **_conversation_**
- Conversation
- **_builders_**
- withRaw
- withAoG
- ReactSSML
- **_ssml-dom_**
- Document
- XMLDeclaration
- Root
- Node
- TextNoode
- **_conversation_**
- Conversation
- **_builders_**
- withRaw
- withAoG

@@ -222,3 +217,3 @@ ### ReactSSML

App.propTypes = {
doc: documentType,
doc: documentType,
};

@@ -231,4 +226,4 @@ ```

- Add a default XMLDeclaration to the Document by setting the `includeProlog` parameter to true
- You can always alter the XMLDeclaration like so:
- Add a default XMLDeclaration to the Document by setting the `includeProlog` parameter to true
- You can always alter the XMLDeclaration like so:

@@ -331,3 +326,3 @@ ```javascript

App.propTypes = {
conv: conversationType,
conv: conversationType,
};

@@ -343,4 +338,4 @@ ```

- withRaw
- withAoG
- withRaw
- withAoG

@@ -379,5 +374,5 @@ ### conversation: builder withRaw

const aogMap = {
parameters: {
'geo-country': value => (Array.isArray(value) ? 'countries' : 'country'),
},
parameters: {
'geo-country': (value) => (Array.isArray(value) ? 'countries' : 'country'),
},
};

@@ -419,2 +414,2 @@ ```

- [Covid-19 Stats in SSML](https://github.com/andrelandgraf/covid-stats-ssml)
- [Covid-19 Stats in SSML](https://github.com/andrelandgraf/covid-stats-ssml)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc