next => {
- function AdaptiveCardMiddleware({ activity, attachment }) {
- return attachment.contentType === 'application/vnd.microsoft.card.hero' ? (
-
- ) : attachment.contentType === 'application/vnd.microsoft.card.adaptive' ? (
-
- ) : attachment.contentType === 'application/vnd.microsoft.card.animation' ? (
-
- ) : attachment.contentType === 'application/vnd.microsoft.card.audio' ? (
-
- ) : attachment.contentType === 'application/vnd.microsoft.card.oauth' ? (
-
- ) : attachment.contentType === 'application/vnd.microsoft.card.receipt' ? (
-
- ) : attachment.contentType === 'application/vnd.microsoft.card.signin' ? (
-
- ) : attachment.contentType === 'application/vnd.microsoft.card.thumbnail' ? (
-
- ) : attachment.contentType === 'application/vnd.microsoft.card.video' ? (
-
- ) : (
- next({ activity, attachment })
- );
- }
+ // This is not returning a React component, but a render function.
+ /* eslint-disable-next-line react/display-name */
+ return () => next => (...args) => {
+ const [{ activity, attachment }] = args;
- AdaptiveCardMiddleware.propTypes = {
- activity: PropTypes.any.isRequired,
- attachment: PropTypes.shape({
- contentType: PropTypes.string.isRequired
- }).isRequired
- };
-
- return AdaptiveCardMiddleware;
+ return attachment.contentType === 'application/vnd.microsoft.card.hero' ? (
+
+ ) : attachment.contentType === 'application/vnd.microsoft.card.adaptive' ? (
+
+ ) : attachment.contentType === 'application/vnd.microsoft.card.animation' ? (
+
+ ) : attachment.contentType === 'application/vnd.microsoft.card.audio' ? (
+
+ ) : attachment.contentType === 'application/vnd.microsoft.card.oauth' ? (
+
+ ) : attachment.contentType === 'application/vnd.microsoft.card.receipt' ? (
+
+ ) : attachment.contentType === 'application/vnd.microsoft.card.signin' ? (
+
+ ) : attachment.contentType === 'application/vnd.microsoft.card.thumbnail' ? (
+
+ ) : attachment.contentType === 'application/vnd.microsoft.card.video' ? (
+
+ ) : (
+ next(...args)
+ );
};
}
diff --git a/packages/component/babel.config.json b/packages/component/babel.config.json
index e43758f909..cfadc9c45f 100644
--- a/packages/component/babel.config.json
+++ b/packages/component/babel.config.json
@@ -26,7 +26,7 @@
[
"transform-inline-environment-variables",
{
- "include": ["npm_package_version"]
+ "include": ["NODE_ENV", "node_env", "npm_package_version"]
}
]
],
diff --git a/packages/component/package-lock.json b/packages/component/package-lock.json
index df46196bc4..128f4d925d 100644
--- a/packages/component/package-lock.json
+++ b/packages/component/package-lock.json
@@ -33,7 +33,6 @@
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz",
"integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==",
- "dev": true,
"requires": {
"@babel/highlight": "^7.10.4"
}
@@ -255,6 +254,33 @@
}
}
},
+ "@babel/generator": {
+ "version": "7.12.1",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.12.1.tgz",
+ "integrity": "sha512-DB+6rafIdc9o72Yc3/Ph5h+6hUjeOp66pF0naQBgUFFuPqzQwIlPTm3xZR7YNvduIMtkDIj2t21LSQwnbCrXvg==",
+ "requires": {
+ "@babel/types": "^7.12.1",
+ "jsesc": "^2.5.1",
+ "source-map": "^0.5.0"
+ },
+ "dependencies": {
+ "@babel/types": {
+ "version": "7.12.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.12.1.tgz",
+ "integrity": "sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA==",
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.4",
+ "lodash": "^4.17.19",
+ "to-fast-properties": "^2.0.0"
+ }
+ },
+ "source-map": {
+ "version": "0.5.7",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
+ "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
+ }
+ }
+ },
"@babel/helper-annotate-as-pure": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.10.4.tgz",
@@ -610,6 +636,48 @@
}
}
},
+ "@babel/helper-function-name": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz",
+ "integrity": "sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ==",
+ "requires": {
+ "@babel/helper-get-function-arity": "^7.10.4",
+ "@babel/template": "^7.10.4",
+ "@babel/types": "^7.10.4"
+ },
+ "dependencies": {
+ "@babel/types": {
+ "version": "7.12.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.12.1.tgz",
+ "integrity": "sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA==",
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.4",
+ "lodash": "^4.17.19",
+ "to-fast-properties": "^2.0.0"
+ }
+ }
+ }
+ },
+ "@babel/helper-get-function-arity": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.4.tgz",
+ "integrity": "sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A==",
+ "requires": {
+ "@babel/types": "^7.10.4"
+ },
+ "dependencies": {
+ "@babel/types": {
+ "version": "7.12.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.12.1.tgz",
+ "integrity": "sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA==",
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.4",
+ "lodash": "^4.17.19",
+ "to-fast-properties": "^2.0.0"
+ }
+ }
+ }
+ },
"@babel/helper-hoist-variables": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.10.4.tgz",
@@ -1013,6 +1081,26 @@
}
}
},
+ "@babel/helper-split-export-declaration": {
+ "version": "7.11.0",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.11.0.tgz",
+ "integrity": "sha512-74Vejvp6mHkGE+m+k5vHY93FX2cAtrw1zXrZXRlG4l410Nm9PxfEiVTn1PjDPV5SnmieiueY4AFg2xqhNFuuZg==",
+ "requires": {
+ "@babel/types": "^7.11.0"
+ },
+ "dependencies": {
+ "@babel/types": {
+ "version": "7.12.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.12.1.tgz",
+ "integrity": "sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA==",
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.4",
+ "lodash": "^4.17.19",
+ "to-fast-properties": "^2.0.0"
+ }
+ }
+ }
+ },
"@babel/helper-validator-identifier": {
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz",
@@ -1252,13 +1340,17 @@
"version": "7.10.4",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz",
"integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==",
- "dev": true,
"requires": {
"@babel/helper-validator-identifier": "^7.10.4",
"chalk": "^2.0.0",
"js-tokens": "^4.0.0"
}
},
+ "@babel/parser": {
+ "version": "7.12.3",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.12.3.tgz",
+ "integrity": "sha512-kFsOS0IbsuhO5ojF8Hc8z/8vEIOkylVBrjiZUbLTE3XFe0Qi+uu6HjzQixkFaqr0ZPAMZcBVxEwmsnsLPZ2Xsw=="
+ },
"@babel/plugin-proposal-async-generator-functions": {
"version": "7.10.5",
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.10.5.tgz",
@@ -2558,6 +2650,56 @@
}
}
},
+ "@babel/template": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.4.tgz",
+ "integrity": "sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA==",
+ "requires": {
+ "@babel/code-frame": "^7.10.4",
+ "@babel/parser": "^7.10.4",
+ "@babel/types": "^7.10.4"
+ },
+ "dependencies": {
+ "@babel/types": {
+ "version": "7.12.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.12.1.tgz",
+ "integrity": "sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA==",
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.4",
+ "lodash": "^4.17.19",
+ "to-fast-properties": "^2.0.0"
+ }
+ }
+ }
+ },
+ "@babel/traverse": {
+ "version": "7.12.1",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.12.1.tgz",
+ "integrity": "sha512-MA3WPoRt1ZHo2ZmoGKNqi20YnPt0B1S0GTZEPhhd+hw2KGUzBlHuVunj6K4sNuK+reEvyiPwtp0cpaqLzJDmAw==",
+ "requires": {
+ "@babel/code-frame": "^7.10.4",
+ "@babel/generator": "^7.12.1",
+ "@babel/helper-function-name": "^7.10.4",
+ "@babel/helper-split-export-declaration": "^7.11.0",
+ "@babel/parser": "^7.12.1",
+ "@babel/types": "^7.12.1",
+ "debug": "^4.1.0",
+ "globals": "^11.1.0",
+ "lodash": "^4.17.19"
+ },
+ "dependencies": {
+ "@babel/types": {
+ "version": "7.12.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.12.1.tgz",
+ "integrity": "sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA==",
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.4",
+ "lodash": "^4.17.19",
+ "to-fast-properties": "^2.0.0"
+ }
+ }
+ }
+ },
"@babel/types": {
"version": "7.8.7",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.7.tgz",
@@ -2701,9 +2843,9 @@
"dev": true
},
"@types/json-schema": {
- "version": "7.0.5",
- "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.5.tgz",
- "integrity": "sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ=="
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz",
+ "integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw=="
},
"@types/node": {
"version": "14.6.0",
@@ -2916,12 +3058,6 @@
"resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz",
"integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ=="
},
- "abbrev": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
- "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
- "dev": true
- },
"acorn": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
@@ -2934,12 +3070,6 @@
"integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==",
"dev": true
},
- "adm-zip": {
- "version": "0.4.11",
- "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.11.tgz",
- "integrity": "sha512-L8vcjDTCOIJk7wFvmlEUN7AsSb8T+2JrdP7KINBjzr24TJ5Mwj590sLu3BC7zNZowvJWa/JtPmD8eJCzdtDWjA==",
- "dev": true
- },
"ajv": {
"version": "6.12.3",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz",
@@ -3061,23 +3191,15 @@
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
},
- "asn1": {
- "version": "0.2.4",
- "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
- "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
- "dev": true,
- "requires": {
- "safer-buffer": "~2.1.0"
- }
- },
"asn1.js": {
- "version": "4.10.1",
- "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz",
- "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==",
+ "version": "5.4.1",
+ "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz",
+ "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==",
"requires": {
"bn.js": "^4.0.0",
"inherits": "^2.0.1",
- "minimalistic-assert": "^1.0.0"
+ "minimalistic-assert": "^1.0.0",
+ "safer-buffer": "^2.1.0"
},
"dependencies": {
"bn.js": {
@@ -3111,12 +3233,6 @@
}
}
},
- "assert-plus": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
- "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
- "dev": true
- },
"assign-symbols": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz",
@@ -3134,29 +3250,11 @@
"integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==",
"optional": true
},
- "asynckit": {
- "version": "0.4.0",
- "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
- "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
- "dev": true
- },
"atob": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg=="
},
- "aws-sign2": {
- "version": "0.7.0",
- "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
- "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=",
- "dev": true
- },
- "aws4": {
- "version": "1.10.1",
- "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.1.tgz",
- "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==",
- "dev": true
- },
"babel-loader": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.1.0.tgz",
@@ -3268,15 +3366,6 @@
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
},
- "bcrypt-pbkdf": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
- "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
- "dev": true,
- "requires": {
- "tweetnacl": "^0.14.3"
- }
- },
"big.js": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
@@ -3303,9 +3392,9 @@
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
"bn.js": {
- "version": "5.1.2",
- "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.2.tgz",
- "integrity": "sha512-40rZaf3bUNKTVYu9sIeeEGOg7g14Yvnj9kH7b50EiwX0Q7A6umbvfI5tvHaOERH0XigqKkfLkFQxzb4e6CIXnA=="
+ "version": "5.1.3",
+ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.3.tgz",
+ "integrity": "sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ=="
},
"bowser": {
"version": "1.9.4",
@@ -3529,12 +3618,6 @@
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001118.tgz",
"integrity": "sha512-RNKPLojZo74a0cP7jFMidQI7nvLER40HgNfgKQEJ2PFm225L0ectUungNQoK3Xk3StQcFbpBPNEvoWD59436Hg=="
},
- "caseless": {
- "version": "0.12.0",
- "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
- "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=",
- "dev": true
- },
"ccount": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/ccount/-/ccount-1.0.4.tgz",
@@ -3638,74 +3721,6 @@
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.6.tgz",
"integrity": "sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q=="
},
- "cldr-data": {
- "version": "36.0.0",
- "resolved": "https://registry.npmjs.org/cldr-data/-/cldr-data-36.0.0.tgz",
- "integrity": "sha512-F3n+9DUs41vhys8eF/hsCgkmYlgXMCiwaE75uGZjUbS/jkszBnLylXj7xW3bBlMU1d2IuAptpoNAb6lTCu/RSg==",
- "dev": true,
- "requires": {
- "cldr-data-downloader": "0.3.x",
- "glob": "5.x.x"
- },
- "dependencies": {
- "glob": {
- "version": "5.0.15",
- "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz",
- "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=",
- "dev": true,
- "requires": {
- "inflight": "^1.0.4",
- "inherits": "2",
- "minimatch": "2 || 3",
- "once": "^1.3.0",
- "path-is-absolute": "^1.0.0"
- }
- }
- }
- },
- "cldr-data-downloader": {
- "version": "0.3.5",
- "resolved": "https://registry.npmjs.org/cldr-data-downloader/-/cldr-data-downloader-0.3.5.tgz",
- "integrity": "sha512-uyIMa1K98DAp/PE7dYpq2COIrkWn681Atjng1GgEzeJzYb1jANtugtp9wre6+voE+qzVC8jtWv6E/xZ1GTJdlw==",
- "dev": true,
- "requires": {
- "adm-zip": "0.4.11",
- "mkdirp": "0.5.0",
- "nopt": "3.0.x",
- "progress": "1.1.8",
- "q": "1.0.1",
- "request": "~2.87.0",
- "request-progress": "0.3.1"
- },
- "dependencies": {
- "minimist": {
- "version": "0.0.8",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
- "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
- "dev": true
- },
- "mkdirp": {
- "version": "0.5.0",
- "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz",
- "integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=",
- "dev": true,
- "requires": {
- "minimist": "0.0.8"
- }
- },
- "progress": {
- "version": "1.1.8",
- "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz",
- "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=",
- "dev": true
- }
- }
- },
- "cldrjs": {
- "version": "0.5.1",
- "resolved": "https://registry.npmjs.org/cldrjs/-/cldrjs-0.5.1.tgz",
- "integrity": "sha512-xyiP8uAm8K1IhmpDndZLraloW1yqu0L+HYdQ7O1aGPxx9Cr+BMnPANlNhSt++UKfxytL2hd2NPXgTjiy7k43Ew=="
- },
"cliui": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
@@ -3716,12 +3731,6 @@
"wrap-ansi": "^5.1.0"
}
},
- "co": {
- "version": "4.6.0",
- "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
- "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
- "dev": true
- },
"collapse-white-space": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.5.tgz",
@@ -3749,15 +3758,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
},
- "combined-stream": {
- "version": "1.0.8",
- "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
- "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
- "dev": true,
- "requires": {
- "delayed-stream": "~1.0.0"
- }
- },
"commander": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
@@ -3989,15 +3989,6 @@
"resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz",
"integrity": "sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk="
},
- "dashdash": {
- "version": "1.14.1",
- "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
- "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
- "dev": true,
- "requires": {
- "assert-plus": "^1.0.0"
- }
- },
"date-fns": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.15.0.tgz",
@@ -4085,12 +4076,6 @@
}
}
},
- "delayed-stream": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
- "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
- "dev": true
- },
"des.js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz",
@@ -4189,16 +4174,6 @@
"xtend": "^4.0.0"
}
},
- "ecc-jsbn": {
- "version": "0.1.2",
- "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
- "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
- "dev": true,
- "requires": {
- "jsbn": "~0.1.0",
- "safer-buffer": "^2.1.0"
- }
- },
"electron-to-chromium": {
"version": "1.3.549",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.549.tgz",
@@ -4343,60 +4318,6 @@
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
},
- "escodegen": {
- "version": "1.14.3",
- "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz",
- "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==",
- "dev": true,
- "requires": {
- "esprima": "^4.0.1",
- "estraverse": "^4.2.0",
- "esutils": "^2.0.2",
- "optionator": "^0.8.1",
- "source-map": "~0.6.1"
- },
- "dependencies": {
- "levn": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
- "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=",
- "dev": true,
- "requires": {
- "prelude-ls": "~1.1.2",
- "type-check": "~0.3.2"
- }
- },
- "optionator": {
- "version": "0.8.3",
- "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz",
- "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==",
- "dev": true,
- "requires": {
- "deep-is": "~0.1.3",
- "fast-levenshtein": "~2.0.6",
- "levn": "~0.3.0",
- "prelude-ls": "~1.1.2",
- "type-check": "~0.3.2",
- "word-wrap": "~1.2.3"
- }
- },
- "prelude-ls": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
- "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
- "dev": true
- },
- "type-check": {
- "version": "0.3.2",
- "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
- "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=",
- "dev": true,
- "requires": {
- "prelude-ls": "~1.1.2"
- }
- }
- }
- },
"eslint": {
"version": "7.7.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.7.0.tgz",
@@ -4685,14 +4606,6 @@
"webpack-cli": "3.3.12"
},
"dependencies": {
- "@babel/code-frame": {
- "version": "7.10.4",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz",
- "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==",
- "requires": {
- "@babel/highlight": "^7.10.4"
- }
- },
"@babel/core": {
"version": "7.11.1",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.11.1.tgz",
@@ -4716,87 +4629,10 @@
"source-map": "^0.5.0"
}
},
- "@babel/generator": {
- "version": "7.11.0",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.11.0.tgz",
- "integrity": "sha512-fEm3Uzw7Mc9Xi//qU20cBKatTfs2aOtKqmvy/Vm7RkJEGFQ4xc9myCfbXxqK//ZS8MR/ciOHw6meGASJuKmDfQ==",
- "requires": {
- "@babel/types": "^7.11.0",
- "jsesc": "^2.5.1",
- "source-map": "^0.5.0"
- }
- },
- "@babel/helper-function-name": {
- "version": "7.10.4",
- "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz",
- "integrity": "sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ==",
- "requires": {
- "@babel/helper-get-function-arity": "^7.10.4",
- "@babel/template": "^7.10.4",
- "@babel/types": "^7.10.4"
- }
- },
- "@babel/helper-get-function-arity": {
- "version": "7.10.4",
- "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.4.tgz",
- "integrity": "sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A==",
- "requires": {
- "@babel/types": "^7.10.4"
- }
- },
- "@babel/helper-split-export-declaration": {
- "version": "7.11.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.11.0.tgz",
- "integrity": "sha512-74Vejvp6mHkGE+m+k5vHY93FX2cAtrw1zXrZXRlG4l410Nm9PxfEiVTn1PjDPV5SnmieiueY4AFg2xqhNFuuZg==",
- "requires": {
- "@babel/types": "^7.11.0"
- }
- },
- "@babel/highlight": {
- "version": "7.10.4",
- "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz",
- "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==",
- "requires": {
- "@babel/helper-validator-identifier": "^7.10.4",
- "chalk": "^2.0.0",
- "js-tokens": "^4.0.0"
- }
- },
- "@babel/parser": {
- "version": "7.11.2",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.11.2.tgz",
- "integrity": "sha512-Vuj/+7vLo6l1Vi7uuO+1ngCDNeVmNbTngcJFKCR/oEtz8tKz0CJxZEGmPt9KcIloZhOZ3Zit6xbpXT2MDlS9Vw=="
- },
- "@babel/template": {
- "version": "7.10.4",
- "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.4.tgz",
- "integrity": "sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA==",
- "requires": {
- "@babel/code-frame": "^7.10.4",
- "@babel/parser": "^7.10.4",
- "@babel/types": "^7.10.4"
- }
- },
- "@babel/traverse": {
- "version": "7.11.0",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.11.0.tgz",
- "integrity": "sha512-ZB2V+LskoWKNpMq6E5UUCrjtDUh5IOTAyIl0dTjIEoXum/iKWkoIEKIRDnUucO6f+2FzNkE0oD4RLKoPIufDtg==",
- "requires": {
- "@babel/code-frame": "^7.10.4",
- "@babel/generator": "^7.11.0",
- "@babel/helper-function-name": "^7.10.4",
- "@babel/helper-split-export-declaration": "^7.11.0",
- "@babel/parser": "^7.11.0",
- "@babel/types": "^7.11.0",
- "debug": "^4.1.0",
- "globals": "^11.1.0",
- "lodash": "^4.17.19"
- }
- },
"@babel/types": {
- "version": "7.11.0",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.11.0.tgz",
- "integrity": "sha512-O53yME4ZZI0jO1EVGtF1ePGl0LHirG4P1ibcD80XyzZcKhcMFeCXmh4Xb1ifGBIV233Qg12x4rBfQgA+tmOukA==",
+ "version": "7.12.1",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.12.1.tgz",
+ "integrity": "sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA==",
"requires": {
"@babel/helper-validator-identifier": "^7.10.4",
"lodash": "^4.17.19",
@@ -4960,12 +4796,6 @@
}
}
},
- "extsprintf": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
- "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
- "dev": true
- },
"fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@@ -5119,23 +4949,6 @@
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
"integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA="
},
- "forever-agent": {
- "version": "0.6.1",
- "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
- "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=",
- "dev": true
- },
- "form-data": {
- "version": "2.3.3",
- "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
- "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
- "dev": true,
- "requires": {
- "asynckit": "^0.4.0",
- "combined-stream": "^1.0.6",
- "mime-types": "^2.1.12"
- }
- },
"fragment-cache": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz",
@@ -5217,15 +5030,6 @@
"resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz",
"integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg="
},
- "getpass": {
- "version": "0.1.7",
- "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
- "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
- "dev": true,
- "requires": {
- "assert-plus": "^1.0.0"
- }
- },
"glamor": {
"version": "2.20.40",
"resolved": "https://registry.npmjs.org/glamor/-/glamor-2.20.40.tgz",
@@ -5322,33 +5126,6 @@
}
}
},
- "globalize": {
- "version": "1.5.0",
- "resolved": "https://registry.npmjs.org/globalize/-/globalize-1.5.0.tgz",
- "integrity": "sha512-76fcPQO/WLthtSwjgIZ/Zv2XSXqv9ifvl1PwIxJNCZNFHigGCpg3fBZ0poJ30b2kdDgofPkYl478lVZA6esESQ==",
- "requires": {
- "cldrjs": "^0.5.0"
- }
- },
- "globalize-compiler": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/globalize-compiler/-/globalize-compiler-1.1.1.tgz",
- "integrity": "sha512-oZIwVp3L/waDidle7Qrw4FiCCmOLAqvdM9P7W8nEO4OfXO//l/abBiA+RL2+mYZPOpTAlRDVS2FLfFVWxHovWA==",
- "dev": true,
- "requires": {
- "escodegen": "^1.6.1",
- "esprima": "^2.3.0",
- "nopt": "^3.0.3"
- },
- "dependencies": {
- "esprima": {
- "version": "2.7.3",
- "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz",
- "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=",
- "dev": true
- }
- }
- },
"globals": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
@@ -5365,48 +5142,6 @@
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
"dev": true
},
- "har-schema": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
- "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=",
- "dev": true
- },
- "har-validator": {
- "version": "5.0.3",
- "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz",
- "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=",
- "dev": true,
- "requires": {
- "ajv": "^5.1.0",
- "har-schema": "^2.0.0"
- },
- "dependencies": {
- "ajv": {
- "version": "5.5.2",
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
- "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
- "dev": true,
- "requires": {
- "co": "^4.6.0",
- "fast-deep-equal": "^1.0.0",
- "fast-json-stable-stringify": "^2.0.0",
- "json-schema-traverse": "^0.3.0"
- }
- },
- "fast-deep-equal": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
- "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
- "dev": true
- },
- "json-schema-traverse": {
- "version": "0.3.1",
- "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
- "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=",
- "dev": true
- }
- }
- },
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
@@ -5534,17 +5269,6 @@
"entities": "^2.0.0"
}
},
- "http-signature": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
- "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
- "dev": true,
- "requires": {
- "assert-plus": "^1.0.0",
- "jsprim": "^1.2.2",
- "sshpk": "^1.7.0"
- }
- },
"https-browserify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
@@ -5555,12 +5279,6 @@
"resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.3.tgz",
"integrity": "sha512-EcuixamT82oplpoJ2XU4pDtKGWQ7b00CD9f1ug9IaQ3p1bkHMiKCZ9ut9QDI6qsa6cpUuB+A/I+zLtdNK4n2DQ=="
},
- "iana-tz-data": {
- "version": "2019.1.0",
- "resolved": "https://registry.npmjs.org/iana-tz-data/-/iana-tz-data-2019.1.0.tgz",
- "integrity": "sha512-T7+26Skkyxqjp4mg20/O065j9J5qP39nWVQj/2ArxQ0gSPkL+T9lwerRmiOAzFRNsNXepX45QqchqTVENwNvig==",
- "dev": true
- },
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
@@ -5884,12 +5602,6 @@
"has-symbols": "^1.0.1"
}
},
- "is-typedarray": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
- "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
- "dev": true
- },
"is-whitespace-character": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-whitespace-character/-/is-whitespace-character-1.0.3.tgz",
@@ -5934,12 +5646,6 @@
"whatwg-fetch": ">=0.10.0"
}
},
- "isstream": {
- "version": "0.1.2",
- "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
- "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
- "dev": true
- },
"istanbul-lib-coverage": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz",
@@ -5981,12 +5687,6 @@
"esprima": "^4.0.0"
}
},
- "jsbn": {
- "version": "0.1.1",
- "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
- "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
- "dev": true
- },
"jsesc": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
@@ -5997,12 +5697,6 @@
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw=="
},
- "json-schema": {
- "version": "0.2.3",
- "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
- "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=",
- "dev": true
- },
"json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
@@ -6014,12 +5708,6 @@
"integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=",
"dev": true
},
- "json-stringify-safe": {
- "version": "5.0.1",
- "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
- "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
- "dev": true
- },
"json5": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz",
@@ -6028,18 +5716,6 @@
"minimist": "^1.2.5"
}
},
- "jsprim": {
- "version": "1.4.1",
- "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
- "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
- "dev": true,
- "requires": {
- "assert-plus": "1.0.0",
- "extsprintf": "1.3.0",
- "json-schema": "0.2.3",
- "verror": "1.10.0"
- }
- },
"jsx-ast-utils": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.4.1.tgz",
@@ -6275,21 +5951,6 @@
}
}
},
- "mime-db": {
- "version": "1.44.0",
- "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
- "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==",
- "dev": true
- },
- "mime-types": {
- "version": "2.1.27",
- "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
- "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
- "dev": true,
- "requires": {
- "mime-db": "1.44.0"
- }
- },
"minimalistic-assert": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
@@ -6504,15 +6165,6 @@
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.60.tgz",
"integrity": "sha512-gsO4vjEdQaTusZAEebUWp2a5d7dF5DYoIpDG7WySnk7BuZDW+GPpHXoXXuYawRBr/9t5q54tirPz79kFIWg4dA=="
},
- "nopt": {
- "version": "3.0.6",
- "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz",
- "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=",
- "dev": true,
- "requires": {
- "abbrev": "1"
- }
- },
"normalize-package-data": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
@@ -6531,12 +6183,6 @@
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"optional": true
},
- "oauth-sign": {
- "version": "0.8.2",
- "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
- "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=",
- "dev": true
- },
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
@@ -6721,13 +6367,12 @@
}
},
"parse-asn1": {
- "version": "5.1.5",
- "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz",
- "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==",
+ "version": "5.1.6",
+ "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz",
+ "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==",
"requires": {
- "asn1.js": "^4.0.0",
+ "asn1.js": "^5.2.0",
"browserify-aes": "^1.0.0",
- "create-hash": "^1.1.0",
"evp_bytestokey": "^1.0.0",
"pbkdf2": "^3.0.3",
"safe-buffer": "^5.1.1"
@@ -6815,12 +6460,6 @@
"sha.js": "^2.4.8"
}
},
- "performance-now": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
- "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",
- "dev": true
- },
"picomatch": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
@@ -6986,18 +6625,6 @@
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
- "q": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/q/-/q-1.0.1.tgz",
- "integrity": "sha1-EYcq7t7okmgRCxCnGESP+xARKhQ=",
- "dev": true
- },
- "qs": {
- "version": "6.5.2",
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
- "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==",
- "dev": true
- },
"querystring": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
@@ -7313,43 +6940,6 @@
"resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
"integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs="
},
- "request": {
- "version": "2.87.0",
- "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz",
- "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==",
- "dev": true,
- "requires": {
- "aws-sign2": "~0.7.0",
- "aws4": "^1.6.0",
- "caseless": "~0.12.0",
- "combined-stream": "~1.0.5",
- "extend": "~3.0.1",
- "forever-agent": "~0.6.1",
- "form-data": "~2.3.1",
- "har-validator": "~5.0.3",
- "http-signature": "~1.2.0",
- "is-typedarray": "~1.0.0",
- "isstream": "~0.1.2",
- "json-stringify-safe": "~5.0.1",
- "mime-types": "~2.1.17",
- "oauth-sign": "~0.8.2",
- "performance-now": "^2.1.0",
- "qs": "~6.5.1",
- "safe-buffer": "^5.1.1",
- "tough-cookie": "~2.3.3",
- "tunnel-agent": "^0.6.0",
- "uuid": "^3.1.0"
- }
- },
- "request-progress": {
- "version": "0.3.1",
- "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-0.3.1.tgz",
- "integrity": "sha1-ByHBBdipasayzossia4tXs/Pazo=",
- "dev": true,
- "requires": {
- "throttleit": "~0.0.2"
- }
- },
"require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
@@ -7455,9 +7045,9 @@
}
},
"safe-buffer": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
- "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"safe-regex": {
"version": "1.1.0",
@@ -7484,13 +7074,26 @@
}
},
"schema-utils": {
- "version": "2.7.0",
- "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz",
- "integrity": "sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A==",
+ "version": "2.7.1",
+ "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.1.tgz",
+ "integrity": "sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==",
"requires": {
- "@types/json-schema": "^7.0.4",
- "ajv": "^6.12.2",
- "ajv-keywords": "^3.4.1"
+ "@types/json-schema": "^7.0.5",
+ "ajv": "^6.12.4",
+ "ajv-keywords": "^3.5.2"
+ },
+ "dependencies": {
+ "ajv": {
+ "version": "6.12.6",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
+ "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
+ "requires": {
+ "fast-deep-equal": "^3.1.1",
+ "fast-json-stable-stringify": "^2.0.0",
+ "json-schema-traverse": "^0.4.1",
+ "uri-js": "^4.2.2"
+ }
+ }
}
},
"semver": {
@@ -7499,9 +7102,9 @@
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
},
"serialize-javascript": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.1.0.tgz",
- "integrity": "sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
+ "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
"requires": {
"randombytes": "^2.1.0"
}
@@ -7828,23 +7431,6 @@
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
},
- "sshpk": {
- "version": "1.16.1",
- "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz",
- "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==",
- "dev": true,
- "requires": {
- "asn1": "~0.2.3",
- "assert-plus": "^1.0.0",
- "bcrypt-pbkdf": "^1.0.0",
- "dashdash": "^1.12.0",
- "ecc-jsbn": "~0.1.1",
- "getpass": "^0.1.1",
- "jsbn": "~0.1.0",
- "safer-buffer": "^2.0.2",
- "tweetnacl": "~0.14.0"
- }
- },
"ssri": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz",
@@ -8049,15 +7635,15 @@
}
},
"terser-webpack-plugin": {
- "version": "1.4.4",
- "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.4.tgz",
- "integrity": "sha512-U4mACBHIegmfoEe5fdongHESNJWqsGU+W0S/9+BmYGVQDw1+c2Ow05TpMhxjPK1sRb7cuYq1BPl1e5YHJMTCqA==",
+ "version": "1.4.5",
+ "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.5.tgz",
+ "integrity": "sha512-04Rfe496lN8EYruwi6oPQkG0vo8C+HT49X687FZnpPF0qMAIHONI6HEXYPKDOE8e5HjXTyKfqRd/agHtH0kOtw==",
"requires": {
"cacache": "^12.0.2",
"find-cache-dir": "^2.1.0",
"is-wsl": "^1.1.0",
"schema-utils": "^1.0.0",
- "serialize-javascript": "^3.1.0",
+ "serialize-javascript": "^4.0.0",
"source-map": "^0.6.1",
"terser": "^4.1.2",
"webpack-sources": "^1.4.0",
@@ -8093,12 +7679,6 @@
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true
},
- "throttleit": {
- "version": "0.0.2",
- "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz",
- "integrity": "sha1-z+34jmDADdlpe2H90qg0OptoDq8=",
- "dev": true
- },
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
@@ -8174,23 +7754,6 @@
"repeat-string": "^1.6.1"
}
},
- "tough-cookie": {
- "version": "2.3.4",
- "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
- "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
- "dev": true,
- "requires": {
- "punycode": "^1.4.1"
- },
- "dependencies": {
- "punycode": {
- "version": "1.4.1",
- "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
- "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
- "dev": true
- }
- }
- },
"tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
@@ -8222,21 +7785,6 @@
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY="
},
- "tunnel-agent": {
- "version": "0.6.0",
- "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
- "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
- "dev": true,
- "requires": {
- "safe-buffer": "^5.0.1"
- }
- },
- "tweetnacl": {
- "version": "0.14.5",
- "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
- "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
- "dev": true
- },
"type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@@ -8481,12 +8029,6 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
- "uuid": {
- "version": "3.4.0",
- "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
- "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
- "dev": true
- },
"v8-compile-cache": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
@@ -8502,17 +8044,6 @@
"spdx-expression-parse": "^3.0.0"
}
},
- "verror": {
- "version": "1.10.0",
- "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
- "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
- "dev": true,
- "requires": {
- "assert-plus": "^1.0.0",
- "core-util-is": "1.0.2",
- "extsprintf": "^1.2.0"
- }
- },
"vfile": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-3.0.1.tgz",
@@ -8595,9 +8126,9 @@
}
},
"chokidar": {
- "version": "3.4.2",
- "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.2.tgz",
- "integrity": "sha512-IZHaDeBeI+sZJRX7lGcXsdzgvZqKv6sECqsbErJA4mHWfpRrD8B97kSFN4cQz6nGBGiuFia1MKR4d6c1o8Cv7A==",
+ "version": "3.4.3",
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.3.tgz",
+ "integrity": "sha512-DtM3g7juCXQxFVSNPNByEC2+NImtBuxQQvWlHunpJIS5Ocr0lG306cC7FCi7cEA0fzmybPUIl4txBIobk1gGOQ==",
"optional": true,
"requires": {
"anymatch": "~3.1.1",
@@ -8607,7 +8138,7 @@
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
- "readdirp": "~3.4.0"
+ "readdirp": "~3.5.0"
}
},
"fill-range": {
@@ -8650,9 +8181,9 @@
"optional": true
},
"readdirp": {
- "version": "3.4.0",
- "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz",
- "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==",
+ "version": "3.5.0",
+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz",
+ "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==",
"optional": true,
"requires": {
"picomatch": "^2.2.1"
@@ -8709,9 +8240,9 @@
},
"dependencies": {
"acorn": {
- "version": "6.4.1",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz",
- "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA=="
+ "version": "6.4.2",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
+ "integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ=="
},
"eslint-scope": {
"version": "4.0.3",
diff --git a/packages/component/package.json b/packages/component/package.json
index 56b6fcce9a..a47bb78939 100644
--- a/packages/component/package.json
+++ b/packages/component/package.json
@@ -17,18 +17,15 @@
},
"homepage": "https://github.com/microsoft/BotFramework-WebChat/tree/master/packages/component#readme",
"scripts": {
- "build": "npm run build:typescript && npm run build:babel && npm run build:globalize",
+ "build": "npm run build:typescript && npm run build:babel",
"build:babel": "babel src --copy-files --extensions .js,.ts,.tsx --ignore **/*.spec.js,**/*.spec.ts,**/*.spec.tsx,**/*.test.js,**/*.test.ts,**/*.test.tsx,__tests__/**/*.js,__tests__/**/*.ts,__tests__/**/*.tsx --no-copy-ignored --out-dir lib --verbose",
- "build:globalize": "node scripts/createPrecompiledGlobalize.js",
"build:typescript": "tsc --project src/tsconfig.json",
"eslint": "eslint src/**/*.js src/**/*.ts",
"prestart": "npm run build:babel",
- "start": "concurrently --kill-others --names \"babel,globalize,tsc\" \"npm run start:babel\" \"npm run start:globalize\" \"npm run start:typescript\"",
+ "start": "concurrently --kill-others --names \"babel,tsc\" \"npm run start:babel\" \"npm run start:typescript\"",
"start:babel": "npm run build:babel -- --skip-initial-build --watch",
- "start:globalize": "node-dev --respawn scripts/createPrecompiledGlobalize.js",
"start:typescript": "npm run build:typescript -- --watch"
},
- "cldr-data-coverage": "full",
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.0",
@@ -39,27 +36,24 @@
"@types/react": "^16.9.47",
"babel-plugin-istanbul": "^6.0.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
- "cldr-data": "^36.0.0",
"concurrently": "^5.3.0",
"core-js": "^3.6.5",
"eslint": "^7.7.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
- "globalize-compiler": "^1.1.1",
- "iana-tz-data": "^2019.1.0",
"node-dev": "^5.2.0",
"prettier": "^2.1.1",
"typescript": "^4.0.2"
},
"dependencies": {
"base64-js": "1.3.1",
+ "botframework-webchat-api": "^0.0.0-0",
"botframework-webchat-core": "0.0.0-0",
"classnames": "2.2.6",
"create-emotion": "10.0.27",
"event-target-shim": "5.0.1",
"event-target-shim-es5": "1.2.0",
- "globalize": "1.5.0",
"markdown-it": "11.0.0",
"math-random": "2.0.1",
"memoize-one": "5.1.1",
diff --git a/packages/component/src/Activity/Bubble.js b/packages/component/src/Activity/Bubble.js
index d0bde715a0..f395661063 100644
--- a/packages/component/src/Activity/Bubble.js
+++ b/packages/component/src/Activity/Bubble.js
@@ -1,15 +1,16 @@
/* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2, 10] }] */
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import isZeroOrPositive from '../Utils/isZeroOrPositive';
-import useDirection from '../hooks/useDirection';
-import useStyleOptions from '../hooks/useStyleOptions';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
+const { useDirection, useStyleOptions } = hooks;
+
const ROOT_STYLE = {
'&.webchat__bubble': {
display: 'flex',
diff --git a/packages/component/src/Activity/CarouselFilmStrip.js b/packages/component/src/Activity/CarouselFilmStrip.js
index 547e5125c1..9fd5f939fd 100644
--- a/packages/component/src/Activity/CarouselFilmStrip.js
+++ b/packages/component/src/Activity/CarouselFilmStrip.js
@@ -1,5 +1,6 @@
/* eslint complexity: ["error", 30] */
+import { hooks } from 'botframework-webchat-api';
import { useItemContainerCallbackRef, useScrollableCallbackRef } from 'react-film';
import classNames from 'classnames';
import PropTypes from 'prop-types';
@@ -10,15 +11,12 @@ import connectToWebChat from '../connectToWebChat';
import isZeroOrPositive from '../Utils/isZeroOrPositive';
import ScreenReaderText from '../ScreenReaderText';
import textFormatToContentType from '../Utils/textFormatToContentType';
-import useAvatarForBot from '../hooks/useAvatarForBot';
-import useAvatarForUser from '../hooks/useAvatarForUser';
-import useDirection from '../hooks/useDirection';
-import useLocalizer from '../hooks/useLocalizer';
-import useStyleOptions from '../hooks/useStyleOptions';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
import useUniqueId from '../hooks/internal/useUniqueId';
+const { useAvatarForBot, useAvatarForUser, useDirection, useLocalizer, useStyleOptions } = hooks;
+
const ROOT_STYLE = {
'&.webchat__carousel-filmstrip': {
display: 'flex',
diff --git a/packages/component/src/Activity/CarouselLayout.js b/packages/component/src/Activity/CarouselLayout.js
index 8928497ede..f5bdf801b2 100644
--- a/packages/component/src/Activity/CarouselLayout.js
+++ b/packages/component/src/Activity/CarouselLayout.js
@@ -1,3 +1,4 @@
+import { hooks } from 'botframework-webchat-api';
import {
Composer as FilmComposer,
createBasicStyleSet as createBasicStyleSetForReactFilm,
@@ -12,12 +13,12 @@ import PropTypes from 'prop-types';
import React, { useMemo } from 'react';
import CarouselFilmStrip from './CarouselFilmStrip';
-import useDirection from '../hooks/useDirection';
-import useLocalizer from '../hooks/useLocalizer';
import useNonce from '../hooks/internal/useNonce';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
+const { useDirection, useLocalizer } = hooks;
+
const ROOT_STYLE = {
'&.webchat__carousel-layout': {
overflow: 'hidden',
diff --git a/packages/component/src/Activity/ScrollToEndButton.js b/packages/component/src/Activity/ScrollToEndButton.js
index 48a206f90e..f2a89479b9 100644
--- a/packages/component/src/Activity/ScrollToEndButton.js
+++ b/packages/component/src/Activity/ScrollToEndButton.js
@@ -1,13 +1,13 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React, { forwardRef, useCallback } from 'react';
-import useDirection from '../hooks/useDirection';
-import useLocalizer from '../hooks/useLocalizer';
+import { safari } from '../Utils/detectBrowser';
import useScrollToEnd from '../hooks/useScrollToEnd';
import useStyleSet from '../hooks/useStyleSet';
-import { safari } from '../Utils/detectBrowser';
+const { useDirection, useLocalizer } = hooks;
const ScrollToEndButton = forwardRef(
(
diff --git a/packages/component/src/Activity/Speak.js b/packages/component/src/Activity/Speak.js
index b083207152..feb9d8d015 100644
--- a/packages/component/src/Activity/Speak.js
+++ b/packages/component/src/Activity/Speak.js
@@ -1,12 +1,12 @@
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React, { useCallback, useMemo } from 'react';
import Say, { SayUtterance } from 'react-say';
import connectToWebChat from '../connectToWebChat';
import SayAlt from './SayAlt';
-import useMarkActivityAsSpoken from '../hooks/useMarkActivityAsSpoken';
-import useStyleOptions from '../hooks/useStyleOptions';
-import useVoiceSelector from '../hooks/useVoiceSelector';
+
+const { useMarkActivityAsSpoken, useStyleOptions, useVoiceSelector } = hooks;
// TODO: [P4] Consider moving this feature into BasicActivity
// And it has better DOM position for showing visual spoken text
diff --git a/packages/component/src/Activity/StackedLayout.js b/packages/component/src/Activity/StackedLayout.js
index 79eacd82cf..e8e9f757cd 100644
--- a/packages/component/src/Activity/StackedLayout.js
+++ b/packages/component/src/Activity/StackedLayout.js
@@ -1,5 +1,6 @@
/* eslint complexity: ["error", 30] */
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
@@ -9,14 +10,13 @@ import connectToWebChat from '../connectToWebChat';
import isZeroOrPositive from '../Utils/isZeroOrPositive';
import ScreenReaderText from '../ScreenReaderText';
import textFormatToContentType from '../Utils/textFormatToContentType';
-import useAvatarForBot from '../hooks/useAvatarForBot';
-import useAvatarForUser from '../hooks/useAvatarForUser';
-import useLocalizer from '../hooks/useLocalizer';
-import useStyleOptions from '../hooks/useStyleOptions';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
+
import useUniqueId from '../hooks/internal/useUniqueId';
+const { useAvatarForBot, useAvatarForUser, useLocalizer, useStyleOptions } = hooks;
+
const ROOT_STYLE = {
'&.webchat__stacked-layout': {
position: 'relative', // This is to keep screen reader text in the destinated area.
diff --git a/packages/component/src/Assets/TypingAnimation.js b/packages/component/src/Assets/TypingAnimation.js
index 2207f369d8..97f38f2b03 100644
--- a/packages/component/src/Assets/TypingAnimation.js
+++ b/packages/component/src/Assets/TypingAnimation.js
@@ -1,12 +1,14 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import React from 'react';
import ScreenReaderText from '../ScreenReaderText';
-import useDirection from '../hooks/useDirection';
-import useLocalizer from '../hooks/useLocalizer';
+
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
+const { useDirection, useLocalizer } = hooks;
+
const ROOT_STYLE = {
'&.webchat__typingIndicator.webchat__typingIndicator--rtl': { transform: 'scale(-1, 1)' }
};
diff --git a/packages/component/src/Attachment/FileContent.js b/packages/component/src/Attachment/FileContent.js
index c5aa45e1e4..1be2e1a897 100644
--- a/packages/component/src/Attachment/FileContent.js
+++ b/packages/component/src/Attachment/FileContent.js
@@ -1,15 +1,15 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import DownloadIcon from './Assets/DownloadIcon';
import ScreenReaderText from '../ScreenReaderText';
-import useByteFormatter from '../hooks/useByteFormatter';
-import useDirection from '../hooks/useDirection';
-import useLocalizer from '../hooks/useLocalizer';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
+const { useByteFormatter, useDirection, useLocalizer } = hooks;
+
const ROOT_STYLE = {
display: 'flex',
diff --git a/packages/component/src/Attachment/ImageContent.js b/packages/component/src/Attachment/ImageContent.js
index f6ef4761c9..0d666fa935 100644
--- a/packages/component/src/Attachment/ImageContent.js
+++ b/packages/component/src/Attachment/ImageContent.js
@@ -1,8 +1,10 @@
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React from 'react';
import CroppedImage from '../Utils/CroppedImage';
-import useStyleOptions from '../hooks/useStyleOptions';
+
+const { useStyleOptions } = hooks;
const ImageContent = ({ alt, src }) => {
const [{ bubbleImageHeight }] = useStyleOptions();
diff --git a/packages/component/src/Avatar/ImageAvatar.js b/packages/component/src/Avatar/ImageAvatar.js
index 1a25ecc3c7..8ddfcd8d95 100644
--- a/packages/component/src/Avatar/ImageAvatar.js
+++ b/packages/component/src/Avatar/ImageAvatar.js
@@ -1,13 +1,14 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import CroppedImage from '../Utils/CroppedImage';
-import useAvatarForBot from '../hooks/useAvatarForBot';
-import useAvatarForUser from '../hooks/useAvatarForUser';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
+const { useAvatarForBot, useAvatarForUser } = hooks;
+
const ROOT_STYLE = {
'& .webchat__imageAvatar__image': {
width: '100%'
diff --git a/packages/component/src/Avatar/InitialsAvatar.js b/packages/component/src/Avatar/InitialsAvatar.js
index ad4a150475..ff0d5d925f 100644
--- a/packages/component/src/Avatar/InitialsAvatar.js
+++ b/packages/component/src/Avatar/InitialsAvatar.js
@@ -1,12 +1,13 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
-import useAvatarForBot from '../hooks/useAvatarForBot';
-import useAvatarForUser from '../hooks/useAvatarForUser';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
+const { useAvatarForBot, useAvatarForUser } = hooks;
+
const ROOT_STYLE = {
alignItems: 'center',
display: 'flex',
diff --git a/packages/component/src/BasicConnectivityStatus.js b/packages/component/src/BasicConnectivityStatus.js
index eb97bf999b..2cf4e3da5d 100644
--- a/packages/component/src/BasicConnectivityStatus.js
+++ b/packages/component/src/BasicConnectivityStatus.js
@@ -1,10 +1,12 @@
+import { hooks } from 'botframework-webchat-api';
import React from 'react';
import ConnectivityStatusConnected from './ConnectivityStatus/Connected';
import ConnectivityStatusConnecting from './ConnectivityStatus/Connecting';
import ConnectivityStatusFailedToConnect from './ConnectivityStatus/FailedToConnect';
import ConnectivityStatusJavaScriptError from './ConnectivityStatus/JavaScriptError';
-import useDebouncedNotifications from './hooks/useDebouncedNotifications';
+
+const { useDebouncedNotifications } = hooks;
const BasicConnectivityStatus = () => {
const [{ connectivitystatus: connectivityStatus }] = useDebouncedNotifications();
diff --git a/packages/component/src/BasicSendBox.js b/packages/component/src/BasicSendBox.js
index 883be0ccdd..2e1d7a41c7 100644
--- a/packages/component/src/BasicSendBox.js
+++ b/packages/component/src/BasicSendBox.js
@@ -1,4 +1,5 @@
import { Constants } from 'botframework-webchat-core';
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
@@ -9,10 +10,6 @@ import SendButton from './SendBox/SendButton';
import SuggestedActions from './SendBox/SuggestedActions';
import TextBox from './SendBox/TextBox';
import UploadButton from './SendBox/UploadButton';
-import useActivities from './hooks/useActivities';
-import useDirection from './hooks/useDirection';
-import useDictateState from './hooks/useDictateState';
-import useStyleOptions from './hooks/useStyleOptions';
import useStyleSet from './hooks/useStyleSet';
import useStyleToEmotionObject from './hooks/internal/useStyleToEmotionObject';
import useWebSpeechPonyfill from './hooks/useWebSpeechPonyfill';
@@ -21,6 +18,8 @@ const {
DictateState: { DICTATING, STARTING }
} = Constants;
+const { useActivities, useDirection, useDictateState, useStyleOptions } = hooks;
+
const ROOT_STYLE = {
'& > .main': {
display: 'flex'
diff --git a/packages/component/src/BasicToast.js b/packages/component/src/BasicToast.js
index 7318e39ae5..ead8607fa5 100644
--- a/packages/component/src/BasicToast.js
+++ b/packages/component/src/BasicToast.js
@@ -1,6 +1,7 @@
/* eslint react/forbid-dom-props: "off" */
/* eslint react/no-danger: "off" */
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React, { useCallback, useMemo } from 'react';
@@ -9,12 +10,12 @@ import DismissIcon from './Toast/DismissIcon';
import NotificationIcon from './Toast/NotificationIcon';
import randomId from './Utils/randomId';
import ScreenReaderText from './ScreenReaderText';
-import useDismissNotification from './hooks/useDismissNotification';
import useInternalRenderMarkdownInline from './hooks/internal/useInternalRenderMarkdownInline';
-import useLocalizer from './hooks/useLocalizer';
import useStyleSet from './hooks/useStyleSet';
import useStyleToEmotionObject from './hooks/internal/useStyleToEmotionObject';
+const { useDismissNotification, useLocalizer } = hooks;
+
const ROOT_STYLE = {
display: 'flex',
diff --git a/packages/component/src/BasicToaster.js b/packages/component/src/BasicToaster.js
index 13daaf475f..7b13c36d84 100644
--- a/packages/component/src/BasicToaster.js
+++ b/packages/component/src/BasicToaster.js
@@ -1,6 +1,7 @@
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 3, 4, 5] }] */
/* eslint react/forbid-dom-props: "off" */
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
@@ -8,12 +9,11 @@ import CollapseIcon from './Toast/CollapseIcon';
import ExpandIcon from './Toast/ExpandIcon';
import NotificationIcon from './Toast/NotificationIcon';
import randomId from './Utils/randomId';
-import useDebouncedNotifications from './hooks/useDebouncedNotifications';
-import useLocalizer from './hooks/useLocalizer';
-import useRenderToast from './hooks/useRenderToast';
import useStyleSet from './hooks/useStyleSet';
import useStyleToEmotionObject from './hooks/internal/useStyleToEmotionObject';
+const { useDebouncedNotifications, useLocalizer, useRenderToast } = hooks;
+
const ROOT_STYLE = {
display: 'flex',
flexDirection: 'column',
diff --git a/packages/component/src/BasicTranscript.js b/packages/component/src/BasicTranscript.js
index ccdc753656..4cf0ccb40f 100644
--- a/packages/component/src/BasicTranscript.js
+++ b/packages/component/src/BasicTranscript.js
@@ -1,5 +1,6 @@
/* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1] }] */
+import { hooks } from 'botframework-webchat-api';
import { Panel as ScrollToBottomPanel, useAnimatingToEnd, useSticky } from 'react-scroll-to-bottom';
import classNames from 'classnames';
import PropTypes from 'prop-types';
@@ -15,20 +16,23 @@ import removeInline from './Utils/removeInline';
import ScreenReaderActivity from './ScreenReaderActivity';
import ScrollToEndButton from './Activity/ScrollToEndButton';
import SpeakActivity from './Activity/Speak';
-import useActivities from './hooks/useActivities';
-import useCreateActivityRenderer from './hooks/useCreateActivityRenderer';
-import useCreateActivityStatusRenderer from './hooks/useCreateActivityStatusRenderer';
-import useCreateAvatarRenderer from './hooks/useCreateAvatarRenderer';
-import useDirection from './hooks/useDirection';
import useFocus from './hooks/useFocus';
-import useGroupActivities from './hooks/useGroupActivities';
-import useLocalizer from './hooks/useLocalizer';
import useMemoize from './hooks/internal/useMemoize';
-import useStyleOptions from './hooks/useStyleOptions';
import useStyleSet from './hooks/useStyleSet';
+import useStyleToEmotionObject from './hooks/internal/useStyleToEmotionObject';
import useTranscriptActivityElementsRef from './hooks/internal/useTranscriptActivityElementsRef';
import useTranscriptRootElementRef from './hooks/internal/useTranscriptRootElementRef';
-import useStyleToEmotionObject from './hooks/internal/useStyleToEmotionObject';
+
+const {
+ useActivities,
+ useCreateActivityRenderer,
+ useCreateActivityStatusRenderer,
+ useCreateAvatarRenderer,
+ useDirection,
+ useGroupActivities,
+ useLocalizer,
+ useStyleOptions
+} = hooks;
const ROOT_STYLE = {
'&.webchat__basic-transcript': {
@@ -71,7 +75,7 @@ function validateAllActivitiesTagged(activities, bins) {
return activities.every(activity => bins.some(bin => bin.includes(activity)));
}
-const BasicTranscript2 = ({ className }) => {
+const BasicTranscript = ({ className }) => {
const [{ activity: activityStyleSet }] = useStyleSet();
const [
{ bubbleFromUserNubOffset, bubbleNubOffset, groupTimestamp, internalLiveRegionFadeAfter, showAvatarInGroup }
@@ -381,11 +385,11 @@ const BasicTranscript2 = ({ className }) => {
);
};
-BasicTranscript2.defaultProps = {
+BasicTranscript.defaultProps = {
className: ''
};
-BasicTranscript2.propTypes = {
+BasicTranscript.propTypes = {
className: PropTypes.string
};
@@ -522,4 +526,4 @@ InternalTranscriptScrollable.propTypes = {
children: PropTypes.arrayOf(PropTypes.element).isRequired
};
-export default BasicTranscript2;
+export default BasicTranscript;
diff --git a/packages/component/src/BasicTypingIndicator.js b/packages/component/src/BasicTypingIndicator.js
index dba311c6c8..0c9f09e5f2 100644
--- a/packages/component/src/BasicTypingIndicator.js
+++ b/packages/component/src/BasicTypingIndicator.js
@@ -1,5 +1,6 @@
-import useActiveTyping from './hooks/useActiveTyping';
-import useRenderTypingIndicator from './hooks/useRenderTypingIndicator';
+import { hooks } from 'botframework-webchat-api';
+
+const { useActiveTyping, useRenderTypingIndicator } = hooks;
function useTypingIndicatorVisible() {
const [activeTyping] = useActiveTyping();
diff --git a/packages/component/src/BasicWebChat.js b/packages/component/src/BasicWebChat.js
index 4f062aa2cf..5d834c721c 100644
--- a/packages/component/src/BasicWebChat.js
+++ b/packages/component/src/BasicWebChat.js
@@ -1,6 +1,7 @@
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2] }] */
/* eslint react/no-unsafe: off */
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
@@ -11,12 +12,12 @@ import BasicSendBox from './BasicSendBox';
import BasicToaster from './BasicToaster';
import BasicTranscript from './BasicTranscript';
import TypeFocusSinkBox from './Utils/TypeFocusSink';
-import useDisabled from './hooks/useDisabled';
import useSendBoxFocusRef from './hooks/internal/useSendBoxFocusRef';
-import useStyleOptions from './hooks/useStyleOptions';
import useStyleSet from './hooks/useStyleSet';
-import useTranscriptFocusRef from './hooks/internal/useTranscriptFocusRef';
import useStyleToEmotionObject from './hooks/internal/useStyleToEmotionObject';
+import useTranscriptFocusRef from './hooks/internal/useTranscriptFocusRef';
+
+const { useDisabled, useStyleOptions } = hooks;
const ROOT_STYLE = {
display: 'flex',
diff --git a/packages/component/src/Composer.js b/packages/component/src/Composer.js
index 18128c6479..5368f0693d 100644
--- a/packages/component/src/Composer.js
+++ b/packages/component/src/Composer.js
@@ -1,142 +1,39 @@
-/* eslint-disable react/prop-types */
-/* eslint-disable react/destructuring-assignment */
+import { Composer as APIComposer, hooks } from 'botframework-webchat-api';
import { Composer as SayComposer } from 'react-say';
import { Composer as ScrollToBottomComposer } from 'react-scroll-to-bottom';
-
-import { Provider } from 'react-redux';
import createEmotion from 'create-emotion';
+import createStyleSet from './Styles/createStyleSet';
import MarkdownIt from 'markdown-it';
import PropTypes from 'prop-types';
-import React, { isValidElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
-import updateIn from 'simple-update-in';
-
-import applyAttachmentForScreenReaderMiddleware from './Middleware/applyAttachmentForScreenReaderMiddleware';
-import createActivityRenderer from './Middleware/createActivityRenderer';
-import createActivityStatusRenderer from './Middleware/createActivityStatusRenderer';
-import createAttachmentRenderer from './Middleware/createAttachmentRenderer';
-import createAvatarRenderer from './Middleware/createAvatarRenderer';
-import createCSSKey from './Utils/createCSSKey';
-import createCustomEvent from './Utils/createCustomEvent';
-import createToastRenderer from './Middleware/createToastRenderer';
-import createTypingIndicatorRenderer from './Middleware/createTypingIndicatorRenderer';
-import ErrorBoundary from './ErrorBoundary';
-import getAllLocalizedStrings from './Localization/getAllLocalizedStrings';
-import isObject from './Utils/isObject';
-import normalizeLanguage from './Utils/normalizeLanguage';
-import PrecompiledGlobalize from './Utils/PrecompiledGlobalize';
-import useReferenceGrammarID from './hooks/useReferenceGrammarID';
+import React, { useCallback, useMemo, useRef, useState } from 'react';
import {
- clearSuggestedActions,
- connect as createConnectAction,
- createStore,
- disconnect,
- dismissNotification,
- emitTypingIndicator,
- markActivity,
- postActivity,
- sendEvent,
- sendFiles,
- sendMessage,
- sendMessageBack,
- sendPostBack,
- setDictateInterims,
- setDictateState,
- setLanguage,
- setNotification,
- setSendBox,
- setSendTimeout,
- setSendTypingIndicator,
- startDictate,
- startSpeakingActivity,
- stopDictate,
- stopSpeakingActivity,
- submitSendBox
-} from 'botframework-webchat-core';
-
+ speechSynthesis as bypassSpeechSynthesis,
+ SpeechSynthesisUtterance as BypassSpeechSynthesisUtterance
+} from './hooks/internal/BypassSpeechSynthesisPonyfill';
import addTargetBlankToHyperlinksMarkdown from './Utils/addTargetBlankToHyperlinksMarkdown';
-import concatMiddleware from './Middleware/concatMiddleware';
-import createCoreCardActionMiddleware from './Middleware/CardAction/createCoreMiddleware';
-import createDefaultGroupActivitiesMiddleware from './Middleware/GroupActivities/createCoreMiddleware';
-import createStyleSet from './Styles/createStyleSet';
-import defaultSelectVoice from './defaultSelectVoice';
+import createCSSKey from './Utils/createCSSKey';
+import createDefaultActivityMiddleware from './Middleware/Activity/createCoreMiddleware';
+import createDefaultActivityStatusMiddleware from './Middleware/ActivityStatus/createCoreMiddleware';
+import createDefaultAttachmentForScreenReaderMiddleware from './Middleware/AttachmentForScreenReader/createCoreMiddleware';
+import createDefaultAttachmentMiddleware from './Middleware/Attachment/createCoreMiddleware';
+import createDefaultAvatarMiddleware from './Middleware/Avatar/createCoreMiddleware';
+import createDefaultCardActionMiddleware from './Middleware/CardAction/createCoreMiddleware';
+import createDefaultToastMiddleware from './Middleware/Toast/createCoreMiddleware';
+import createDefaultTypingIndicatorMiddleware from './Middleware/TypingIndicator/createCoreMiddleware';
import Dictation from './Dictation';
+import downscaleImageToDataURL from './Utils/downscaleImageToDataURL';
+import ErrorBox from './ErrorBox';
import mapMap from './Utils/mapMap';
-import observableToPromise from './Utils/observableToPromise';
-import Tracker from './Tracker';
-import WebChatReduxContext, { useDispatch } from './WebChatReduxContext';
-import WebChatUIContext from './WebChatUIContext';
-
-import {
- speechSynthesis as bypassSpeechSynthesis,
- SpeechSynthesisUtterance as BypassSpeechSynthesisUtterance
-} from './Speech/BypassSpeechSynthesisPonyfill';
-
-// List of Redux actions factory we are hoisting as Web Chat functions
-const DISPATCHERS = {
- clearSuggestedActions,
- dismissNotification,
- emitTypingIndicator,
- markActivity,
- postActivity,
- sendEvent,
- sendFiles,
- sendMessage,
- sendMessageBack,
- sendPostBack,
- setDictateInterims,
- setDictateState,
- setNotification,
- setSendBox,
- setSendTimeout,
- startDictate,
- startSpeakingActivity,
- stopDictate,
- stopSpeakingActivity,
- submitSendBox
-};
+import singleToArray from './Utils/singleToArray';
+import UITracker from './hooks/internal/UITracker';
+import WebChatUIContext from './hooks/internal/WebChatUIContext';
-const emotionPool = {};
+const { useReferenceGrammarID, useStyleOptions } = hooks;
-function styleSetToEmotionObjects(styleToEmotionObject, styleSet) {
- return mapMap(styleSet, (style, key) => (key === 'options' ? style : styleToEmotionObject(style)));
-}
+const node_env = process.env.node_env || process.env.NODE_ENV;
-function createCardActionContext({ cardActionMiddleware, directLine, dispatch }) {
- const runMiddleware = concatMiddleware(cardActionMiddleware, createCoreCardActionMiddleware())({ dispatch });
-
- return {
- onCardAction: (cardAction, { target } = {}) =>
- runMiddleware(({ cardAction: { type } }) => {
- throw new Error(`Web Chat: received unknown card action "${type}"`);
- })({
- cardAction,
- getSignInUrl:
- cardAction.type === 'signin'
- ? () => {
- const { value } = cardAction;
-
- if (directLine.getSessionId) {
- // TODO: [P3] We should change this one to async/await.
- // This is the first place in this project to use async.
- // Thus, we need to add @babel/plugin-transform-runtime and @babel/runtime.
-
- return observableToPromise(directLine.getSessionId()).then(
- sessionId => `${value}${encodeURIComponent(`&code_challenge=${sessionId}`)}`
- );
- }
-
- console.warn(
- 'botframework-webchat: No-magic-code OAuth flow is not supported on this Direct Line adapter.'
- );
-
- return Promise.resolve(value);
- }
- : null,
- target
- })
- };
-}
+const emotionPool = {};
function createFocusContext({ sendBoxFocusRef, transcriptFocusRef }) {
return {
@@ -164,143 +61,36 @@ function createFocusContext({ sendBoxFocusRef, transcriptFocusRef }) {
};
}
-function createGroupActivitiesContext({ groupActivitiesMiddleware, groupTimestamp }) {
- const runMiddleware = concatMiddleware(
- groupActivitiesMiddleware,
- createDefaultGroupActivitiesMiddleware({ groupTimestamp })
- )()(() => {
- throw new Error('botframework-webchat internal: No middleware is execute for groupActivities.');
- });
-
- return {
- groupActivities: ({ activities }) => runMiddleware({ activities })
- };
-}
-
-function mergeStringsOverrides(localizedStrings, language, overrideLocalizedStrings) {
- if (!overrideLocalizedStrings) {
- return localizedStrings;
- } else if (typeof overrideLocalizedStrings === 'function') {
- const merged = overrideLocalizedStrings(localizedStrings, language);
-
- if (!isObject(merged)) {
- throw new Error('botframework-webchat: overrideLocalizedStrings function must return an object.');
- }
-
- return merged;
- }
-
- if (!isObject(overrideLocalizedStrings)) {
- throw new Error('botframework-webchat: overrideLocalizedStrings must be either a function, an object, or falsy.');
- }
-
- return { ...localizedStrings, ...overrideLocalizedStrings };
+function styleSetToEmotionObjects(styleToEmotionObject, styleSet) {
+ return mapMap(styleSet, (style, key) => (key === 'options' ? style : styleToEmotionObject(style)));
}
-const Composer = ({
- activityMiddleware,
- activityRenderer,
- activityStatusMiddleware,
- activityStatusRenderer,
- attachmentForScreenReaderMiddleware,
- attachmentMiddleware,
- attachmentRenderer,
- avatarMiddleware,
- avatarRenderer,
- cardActionMiddleware,
+const ComposerCore = ({
children,
- dir,
- directLine,
- disabled,
extraStyleSet,
- grammars,
- groupActivitiesMiddleware,
- groupTimestamp,
- locale,
nonce,
- onTelemetry,
- overrideLocalizedStrings,
renderMarkdown,
- selectVoice,
- sendTimeout,
- sendTypingIndicator,
- styleOptions,
styleSet,
suggestedActionsAccessKey,
- toastMiddleware,
- toastRenderer,
- typingIndicatorMiddleware,
- typingIndicatorRenderer,
- userID,
- username,
webSpeechPonyfillFactory
}) => {
const [dictateAbortable, setDictateAbortable] = useState();
const [referenceGrammarID] = useReferenceGrammarID();
- const dispatch = useDispatch();
+ const [styleOptions] = useStyleOptions();
+ const internalMarkdownIt = useMemo(() => new MarkdownIt(), []);
const sendBoxFocusRef = useRef();
- const telemetryDimensionsRef = useRef({});
+ const transcriptActivityElementsRef = useRef([]);
const transcriptFocusRef = useRef();
+ const transcriptRootElementRef = useRef();
- const patchedDir = useMemo(() => (dir === 'ltr' || dir === 'rtl' ? dir : 'auto'), [dir]);
- const patchedGrammars = useMemo(() => grammars || [], [grammars]);
-
- const patchedStyleOptions = useMemo(() => {
- const patchedStyleOptions = { ...styleOptions };
-
- if (typeof groupTimestamp !== 'undefined' && typeof patchedStyleOptions.groupTimestamp === 'undefined') {
- console.warn(
- 'Web Chat: "groupTimestamp" has been moved to "styleOptions". This deprecation migration will be removed on or after January 1 2022.'
- );
-
- patchedStyleOptions.groupTimestamp = groupTimestamp;
- }
-
- if (typeof sendTimeout !== 'undefined' && typeof patchedStyleOptions.sendTimeout === 'undefined') {
- console.warn(
- 'Web Chat: "sendTimeout" has been moved to "styleOptions". This deprecation migration will be removed on or after January 1 2022.'
- );
-
- patchedStyleOptions.sendTimeout = sendTimeout;
- }
-
- if (styleOptions.slowConnectionAfter < 0) {
- console.warn('Web Chat: "slowConnectionAfter" cannot be negative, will set to 0.');
-
- patchedStyleOptions.slowConnectionAfter = 0;
- }
-
- return patchedStyleOptions;
- }, [groupTimestamp, sendTimeout, styleOptions]);
-
- useEffect(() => {
- dispatch(setLanguage(locale));
- }, [dispatch, locale]);
-
- useEffect(() => {
- typeof sendTimeout === 'number' && dispatch(setSendTimeout(sendTimeout));
- }, [dispatch, sendTimeout]);
-
- useEffect(() => {
- dispatch(setSendTypingIndicator(!!sendTypingIndicator));
- }, [dispatch, sendTypingIndicator]);
-
- useEffect(() => {
- dispatch(
- createConnectAction({
- directLine,
- userID,
- username
- })
- );
-
- return () => {
- // TODO: [P3] disconnect() is an async call (pending -> fulfilled), we need to wait, or change it to reconnect()
- dispatch(disconnect());
- };
- }, [dispatch, directLine, userID, username]);
+ const dictationOnError = useCallback(err => {
+ console.error(err);
+ }, []);
- const internalMarkdownIt = useMemo(() => new MarkdownIt(), []);
+ const focusContext = useMemo(() => createFocusContext({ sendBoxFocusRef, transcriptFocusRef }), [
+ sendBoxFocusRef,
+ transcriptFocusRef
+ ]);
const internalRenderMarkdownInline = useMemo(
() => markdown => {
@@ -314,22 +104,6 @@ const Composer = ({
[internalMarkdownIt]
);
- const cardActionContext = useMemo(() => createCardActionContext({ cardActionMiddleware, directLine, dispatch }), [
- cardActionMiddleware,
- directLine,
- dispatch
- ]);
-
- const patchedSelectVoice = useMemo(() => selectVoice || defaultSelectVoice.bind(null, { language: locale }), [
- locale,
- selectVoice
- ]);
-
- const focusContext = useMemo(() => createFocusContext({ sendBoxFocusRef, transcriptFocusRef }), [
- sendBoxFocusRef,
- transcriptFocusRef
- ]);
-
const styleToEmotionObject = useMemo(() => {
// Emotion doesn't hash with nonce. We need to provide the pooling mechanism.
// 1. If 2 instances use different nonce, they should result in different hash;
@@ -343,24 +117,10 @@ const Composer = ({
const patchedStyleSet = useMemo(
() =>
styleSetToEmotionObjects(styleToEmotionObject, {
- ...(styleSet || createStyleSet(patchedStyleOptions)),
+ ...(styleSet || createStyleSet(styleOptions)),
...extraStyleSet
}),
- [extraStyleSet, patchedStyleOptions, styleSet, styleToEmotionObject]
- );
-
- const groupActivitiesContext = useMemo(
- () =>
- createGroupActivitiesContext({
- groupActivitiesMiddleware,
- groupTimestamp: patchedStyleSet.options.groupTimestamp
- }),
- [groupActivitiesMiddleware, patchedStyleSet.options.groupTimestamp]
- );
-
- const hoistedDispatchers = useMemo(
- () => mapMap(DISPATCHERS, dispatcher => (...args) => dispatch(dispatcher(...args))),
- [dispatch]
+ [extraStyleSet, styleOptions, styleSet, styleToEmotionObject]
);
const webSpeechPonyfill = useMemo(() => {
@@ -374,281 +134,172 @@ const Composer = ({
};
}, [referenceGrammarID, webSpeechPonyfillFactory]);
- const dictationOnError = useCallback(err => {
- console.error(err);
- }, []);
-
- const patchedLocalizedStrings = useMemo(
- () => mergeStringsOverrides(getAllLocalizedStrings()[normalizeLanguage(locale)], locale, overrideLocalizedStrings),
- [locale, overrideLocalizedStrings]
- );
-
- const localizedGlobalize = useMemo(() => {
- const { GLOBALIZE, GLOBALIZE_LANGUAGE } = patchedLocalizedStrings || {};
-
- return GLOBALIZE || (GLOBALIZE_LANGUAGE && PrecompiledGlobalize(GLOBALIZE_LANGUAGE)) || PrecompiledGlobalize('en');
- }, [patchedLocalizedStrings]);
-
- const trackDimension = useCallback(
- (name, data) => {
- if (!name || typeof name !== 'string') {
- return console.warn('botframework-webchat: Telemetry dimension name must be a string.');
- }
-
- const type = typeof data;
-
- if (type !== 'string' && type !== 'undefined') {
- return console.warn('botframework-webchat: Telemetry dimension data must be a string or undefined.');
- }
-
- telemetryDimensionsRef.current = updateIn(
- telemetryDimensionsRef.current,
- [name],
- type === 'undefined' ? data : () => data
- );
- },
- [telemetryDimensionsRef]
- );
-
- const patchedActivityRenderer = useMemo(() => {
- activityRenderer &&
- console.warn(
- 'Web Chat: "activityRenderer" is deprecated and will be removed on 2020-06-15, please use "activityMiddleware" instead.'
- );
-
- return activityRenderer || createActivityRenderer(activityMiddleware);
- }, [activityMiddleware, activityRenderer]);
-
- const patchedActivityStatusRenderer = useMemo(() => {
- activityStatusRenderer &&
- console.warn(
- 'Web Chat: "activityStatusRenderer" is deprecated and will be removed on 2020-06-15, please use "activityStatusMiddleware" instead.'
- );
-
- return activityStatusRenderer || createActivityStatusRenderer(activityStatusMiddleware);
- }, [activityStatusMiddleware, activityStatusRenderer]);
-
- const patchedAttachmentForScreenReaderRenderer = useMemo(() => {
- const patchedAttachmentForScreenReaderRenderer = applyAttachmentForScreenReaderMiddleware(
- attachmentForScreenReaderMiddleware
- );
-
- // The new function returned is for validating the result of attachmentForScreenReaderMiddleware.
- return (...args) => {
- const renderAttachmentForScreenReader = patchedAttachmentForScreenReaderRenderer(...args);
-
- if (renderAttachmentForScreenReader === false) {
- return false;
- } else if (typeof renderAttachmentForScreenReader === 'function') {
- return (...renderArgs) => {
- const element = renderAttachmentForScreenReader(...renderArgs);
-
- if (!isValidElement(element)) {
- console.error(
- 'botframework-webchat: Renderer of attachmentForScreenReaderMiddleware should return React element only.'
- );
- }
-
- return element;
- };
- }
-
- console.error(
- 'botframework-webchat: attachmentForScreenReaderMiddleware should only return either false or a render function.'
- );
-
- return false;
- };
- }, [attachmentForScreenReaderMiddleware]);
-
- const patchedAttachmentRenderer = useMemo(() => {
- attachmentRenderer &&
- console.warn(
- 'Web Chat: "attachmentRenderer" is deprecated and will be removed on 2020-06-15, please use "attachmentMiddleware" instead.'
- );
-
- return attachmentRenderer || createAttachmentRenderer(attachmentMiddleware);
- }, [attachmentMiddleware, attachmentRenderer]);
-
- const patchedAvatarRenderer = useMemo(() => {
- avatarRenderer &&
- console.warn(
- 'Web Chat: "avatarRenderer" is deprecated and will be removed on 2020-06-15, please use "avatarMiddleware" instead.'
- );
-
- return avatarRenderer || createAvatarRenderer(avatarMiddleware);
- }, [avatarMiddleware, avatarRenderer]);
-
- const patchedToastRenderer = useMemo(() => {
- toastRenderer &&
- console.warn(
- 'Web Chat: "toastRenderer" is deprecated and will be removed on 2020-06-15, please use "toastMiddleware" instead.'
- );
-
- return toastRenderer || createToastRenderer(toastMiddleware);
- }, [toastMiddleware, toastRenderer]);
-
- const patchedTypingIndicatorRenderer = useMemo(() => {
- typingIndicatorRenderer &&
- console.warn(
- 'Web Chat: "typingIndicatorRenderer" is deprecated and will be removed on 2020-06-15, please use "typingIndicatorMiddleware" instead.'
- );
-
- return typingIndicatorRenderer || createTypingIndicatorRenderer(typingIndicatorMiddleware);
- }, [typingIndicatorMiddleware, typingIndicatorRenderer]);
-
- const transcriptActivityElementsRef = useRef([]);
- const transcriptRootElementRef = useRef();
-
- // This is a heavy function, and it is expected to be only called when there is a need to recreate business logic, e.g.
- // - User ID changed, causing all send* functions to be updated
- // - send
-
- // TODO: [P3] We should think about if we allow the user to change onSendBoxValueChanged/sendBoxValue, e.g.
- // 1. Turns text into UPPERCASE
- // 2. Filter out profanity
-
- // TODO: [P4] Revisit all members of context
- // This context should consist of members that are not in the Redux store
- // i.e. members that are not interested in other types of UIs
const context = useMemo(
() => ({
- ...cardActionContext,
...focusContext,
- ...groupActivitiesContext,
- ...hoistedDispatchers,
- activityRenderer: patchedActivityRenderer,
- activityStatusRenderer: patchedActivityStatusRenderer,
- attachmentRenderer: patchedAttachmentRenderer,
- avatarRenderer: patchedAvatarRenderer,
- createAttachmentForScreenReaderRenderer: patchedAttachmentForScreenReaderRenderer,
dictateAbortable,
- dir: patchedDir,
- directLine,
- disabled,
- grammars: patchedGrammars,
internalMarkdownItState: [internalMarkdownIt],
internalRenderMarkdownInline,
- language: locale,
- localizedGlobalizeState: [localizedGlobalize],
- localizedStrings: patchedLocalizedStrings,
nonce,
- onTelemetry,
renderMarkdown,
- selectVoice: patchedSelectVoice,
sendBoxFocusRef,
- sendTypingIndicator,
setDictateAbortable,
- styleOptions,
styleSet: patchedStyleSet,
styleToEmotionObject,
suggestedActionsAccessKey,
- telemetryDimensionsRef,
- toastRenderer: patchedToastRenderer,
- trackDimension,
transcriptActivityElementsRef,
transcriptFocusRef,
transcriptRootElementRef,
- typingIndicatorRenderer: patchedTypingIndicatorRenderer,
- userID,
- username,
webSpeechPonyfill
}),
[
- cardActionContext,
dictateAbortable,
- directLine,
- disabled,
focusContext,
- groupActivitiesContext,
- hoistedDispatchers,
internalMarkdownIt,
internalRenderMarkdownInline,
- locale,
- localizedGlobalize,
nonce,
- onTelemetry,
- patchedActivityRenderer,
- patchedActivityStatusRenderer,
- patchedAttachmentForScreenReaderRenderer,
- patchedAttachmentRenderer,
- patchedAvatarRenderer,
- patchedDir,
- patchedGrammars,
- patchedLocalizedStrings,
- patchedSelectVoice,
patchedStyleSet,
- patchedToastRenderer,
- patchedTypingIndicatorRenderer,
renderMarkdown,
sendBoxFocusRef,
- sendTypingIndicator,
setDictateAbortable,
- styleOptions,
styleToEmotionObject,
suggestedActionsAccessKey,
- telemetryDimensionsRef,
- trackDimension,
transcriptActivityElementsRef,
transcriptFocusRef,
transcriptRootElementRef,
- userID,
- username,
webSpeechPonyfill
]
);
return (
-
+
- {typeof children === 'function' ? children(context) : children}
+
+ {children}
+
+
-
- {onTelemetry && }
-
+
);
};
-// We will create a Redux store if it was not passed in
-const ComposeWithStore = ({ onTelemetry, store, ...props }) => {
- const handleError = useCallback(
- ({ error }) => {
- onTelemetry && onTelemetry(createCustomEvent('exception', { error, fatal: true }));
- },
- [onTelemetry]
+ComposerCore.defaultProps = {
+ extraStyleSet: undefined,
+ nonce: undefined,
+ renderMarkdown: undefined,
+ styleSet: undefined,
+ suggestedActionsAccessKey: 'A a Å å',
+ webSpeechPonyfillFactory: undefined
+};
+
+ComposerCore.propTypes = {
+ extraStyleSet: PropTypes.any,
+ nonce: PropTypes.string,
+ renderMarkdown: PropTypes.func,
+ styleSet: PropTypes.any,
+ suggestedActionsAccessKey: PropTypes.oneOfType([PropTypes.oneOf([false]), PropTypes.string]),
+ webSpeechPonyfillFactory: PropTypes.func
+};
+
+const Composer = ({
+ activityMiddleware,
+ activityStatusMiddleware,
+ attachmentForScreenReaderMiddleware,
+ attachmentMiddleware,
+ avatarMiddleware,
+ cardActionMiddleware,
+ children,
+ extraStyleSet,
+ renderMarkdown,
+ styleSet,
+ suggestedActionsAccessKey,
+ toastMiddleware,
+ typingIndicatorMiddleware,
+ webSpeechPonyfillFactory,
+ ...composerProps
+}) => {
+ const { nonce, onTelemetry } = composerProps;
+
+ const patchedActivityMiddleware = useMemo(
+ () => [...singleToArray(activityMiddleware), ...createDefaultActivityMiddleware()],
+ [activityMiddleware]
);
- const memoizedStore = useMemo(() => store || createStore(), [store]);
+ const patchedActivityStatusMiddleware = useMemo(
+ () => [...singleToArray(activityStatusMiddleware), ...createDefaultActivityStatusMiddleware()],
+ [activityStatusMiddleware]
+ );
- return (
-
-
-
-
-
-
-
+ const patchedAttachmentForScreenReaderMiddleware = useMemo(
+ () => [
+ ...singleToArray(attachmentForScreenReaderMiddleware),
+ ...createDefaultAttachmentForScreenReaderMiddleware()
+ ],
+ [attachmentForScreenReaderMiddleware]
);
-};
-ComposeWithStore.defaultProps = {
- onTelemetry: undefined,
- store: undefined
-};
+ const patchedAttachmentMiddleware = useMemo(
+ () => [...singleToArray(attachmentMiddleware), ...createDefaultAttachmentMiddleware()],
+ [attachmentMiddleware]
+ );
-ComposeWithStore.propTypes = {
- onTelemetry: PropTypes.func,
- store: PropTypes.any
-};
+ const patchedAvatarMiddleware = useMemo(
+ () => [...singleToArray(avatarMiddleware), ...createDefaultAvatarMiddleware()],
+ [avatarMiddleware]
+ );
-export default ComposeWithStore;
+ const patchedCardActionMiddleware = useMemo(
+ () => [...singleToArray(cardActionMiddleware), ...createDefaultCardActionMiddleware()],
+ [cardActionMiddleware]
+ );
-// TODO: [P3] We should consider moving some data from Redux store to props
-// Although we use `connectToWebChat` to hide the details of accessor of Redux store,
-// we should clean up the responsibility between Context and Redux store
-// We should decide which data is needed for React but not in other environment such as CLI/VSCode
+ const patchedToastMiddleware = useMemo(() => [...singleToArray(toastMiddleware), ...createDefaultToastMiddleware()], [
+ toastMiddleware
+ ]);
+
+ const patchedTypingIndicatorMiddleware = useMemo(
+ () => [...singleToArray(typingIndicatorMiddleware), ...createDefaultTypingIndicatorMiddleware()],
+ [typingIndicatorMiddleware]
+ );
+
+ return (
+
+
+
+
+ {children}
+ {onTelemetry && }
+
+
+
+
+ );
+};
Composer.defaultProps = {
+ ...APIComposer.defaultProps,
+ ...ComposerCore.defaultProps,
activityMiddleware: undefined,
activityRenderer: undefined,
activityStatusMiddleware: undefined,
@@ -660,79 +311,36 @@ Composer.defaultProps = {
avatarRenderer: undefined,
cardActionMiddleware: undefined,
children: undefined,
- dir: 'auto',
- disabled: false,
- extraStyleSet: undefined,
- grammars: [],
- groupActivitiesMiddleware: undefined,
- groupTimestamp: undefined,
- locale: window.navigator.language || 'en-US',
nonce: undefined,
- onTelemetry: undefined,
- overrideLocalizedStrings: undefined,
renderMarkdown: undefined,
- selectVoice: undefined,
- sendTimeout: undefined,
- sendTypingIndicator: false,
- styleOptions: {},
- styleSet: undefined,
- suggestedActionsAccessKey: 'A a Å å',
toastMiddleware: undefined,
toastRenderer: undefined,
typingIndicatorMiddleware: undefined,
typingIndicatorRenderer: undefined,
- userID: '',
- username: '',
webSpeechPonyfillFactory: undefined
};
Composer.propTypes = {
- activityMiddleware: PropTypes.func,
+ ...APIComposer.propTypes,
+ ...ComposerCore.propTypes,
+ activityMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
activityRenderer: PropTypes.func,
- activityStatusMiddleware: PropTypes.func,
+ activityStatusMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
activityStatusRenderer: PropTypes.func,
- attachmentForScreenReaderMiddleware: PropTypes.func,
- attachmentMiddleware: PropTypes.func,
+ attachmentForScreenReaderMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
+ attachmentMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
attachmentRenderer: PropTypes.func,
- avatarMiddleware: PropTypes.func,
+ avatarMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
avatarRenderer: PropTypes.func,
cardActionMiddleware: PropTypes.func,
children: PropTypes.any,
- dir: PropTypes.oneOf(['auto', 'ltr', 'rtl']),
- directLine: PropTypes.shape({
- activity$: PropTypes.shape({
- subscribe: PropTypes.func.isRequired
- }).isRequired,
- connectionStatus$: PropTypes.shape({
- subscribe: PropTypes.func.isRequired
- }).isRequired,
- end: PropTypes.func,
- getSessionId: PropTypes.func,
- postActivity: PropTypes.func.isRequired,
- referenceGrammarID: PropTypes.string,
- token: PropTypes.string
- }).isRequired,
- disabled: PropTypes.bool,
- extraStyleSet: PropTypes.any,
- grammars: PropTypes.arrayOf(PropTypes.string),
- groupActivitiesMiddleware: PropTypes.func,
- groupTimestamp: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
- locale: PropTypes.string,
nonce: PropTypes.string,
- onTelemetry: PropTypes.func,
- overrideLocalizedStrings: PropTypes.oneOfType([PropTypes.any, PropTypes.func]),
renderMarkdown: PropTypes.func,
- selectVoice: PropTypes.func,
- sendTimeout: PropTypes.number,
- sendTypingIndicator: PropTypes.bool,
- styleOptions: PropTypes.any,
- styleSet: PropTypes.any,
- suggestedActionsAccessKey: PropTypes.oneOfType([PropTypes.oneOf([false]), PropTypes.string]),
- toastMiddleware: PropTypes.func,
+ toastMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
toastRenderer: PropTypes.func,
- typingIndicatorMiddleware: PropTypes.func,
+ typingIndicatorMiddleware: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.func), PropTypes.func]),
typingIndicatorRenderer: PropTypes.func,
- userID: PropTypes.string,
- username: PropTypes.string,
webSpeechPonyfillFactory: PropTypes.func
};
+
+export default Composer;
diff --git a/packages/component/src/ConnectivityStatus/Assets/ErrorNotificationIcon.js b/packages/component/src/ConnectivityStatus/Assets/ErrorNotificationIcon.js
index 1796b0b392..51652a0320 100644
--- a/packages/component/src/ConnectivityStatus/Assets/ErrorNotificationIcon.js
+++ b/packages/component/src/ConnectivityStatus/Assets/ErrorNotificationIcon.js
@@ -1,8 +1,9 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
-import useDirection from '../../hooks/useDirection';
+const { useDirection } = hooks;
const ICON_SIZE_FACTOR = 16;
diff --git a/packages/component/src/ConnectivityStatus/Assets/SpinnerAnimation.js b/packages/component/src/ConnectivityStatus/Assets/SpinnerAnimation.js
index 3329131066..8d9cad9f31 100644
--- a/packages/component/src/ConnectivityStatus/Assets/SpinnerAnimation.js
+++ b/packages/component/src/ConnectivityStatus/Assets/SpinnerAnimation.js
@@ -1,9 +1,11 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import React from 'react';
-import useDirection from '../../hooks/useDirection';
import useStyleSet from '../../hooks/useStyleSet';
+const { useDirection } = hooks;
+
const SpinnerAnimation = () => {
const [{ spinnerAnimation: spinnerAnimationStyleSet }] = useStyleSet();
const [direction] = useDirection();
diff --git a/packages/component/src/ConnectivityStatus/Assets/WarningNotificationIcon.js b/packages/component/src/ConnectivityStatus/Assets/WarningNotificationIcon.js
index 5d70632ced..ec0597fdac 100644
--- a/packages/component/src/ConnectivityStatus/Assets/WarningNotificationIcon.js
+++ b/packages/component/src/ConnectivityStatus/Assets/WarningNotificationIcon.js
@@ -1,8 +1,9 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
-import useDirection from '../../hooks/useDirection';
+const { useDirection } = hooks;
const ICON_SIZE_FACTOR = 16;
diff --git a/packages/component/src/ConnectivityStatus/Connected.js b/packages/component/src/ConnectivityStatus/Connected.js
index 117f4d0f67..0b753c40ab 100644
--- a/packages/component/src/ConnectivityStatus/Connected.js
+++ b/packages/component/src/ConnectivityStatus/Connected.js
@@ -1,7 +1,9 @@
+import { hooks } from 'botframework-webchat-api';
import React from 'react';
import ScreenReaderText from '../ScreenReaderText';
-import useLocalizer from '../hooks/useLocalizer';
+
+const { useLocalizer } = hooks;
const ConnectivityStatusConnected = () => {
const localize = useLocalizer();
diff --git a/packages/component/src/ConnectivityStatus/Connecting.js b/packages/component/src/ConnectivityStatus/Connecting.js
index 578175315c..417016f9c1 100644
--- a/packages/component/src/ConnectivityStatus/Connecting.js
+++ b/packages/component/src/ConnectivityStatus/Connecting.js
@@ -1,17 +1,17 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React, { useState } from 'react';
import ScreenReaderText from '../ScreenReaderText';
import SpinnerAnimation from './Assets/SpinnerAnimation';
-import useDirection from '../hooks/useDirection';
import useForceRender from '../hooks/internal/useForceRender';
-import useLocalizer from '../hooks/useLocalizer';
-import useStyleOptions from '../hooks/useStyleOptions';
import useStyleSet from '../hooks/useStyleSet';
import useTimer from '../hooks/internal/useTimer';
import WarningNotificationIcon from './Assets/WarningNotificationIcon';
+const { useDirection, useLocalizer, useStyleOptions } = hooks;
+
const ConnectivityStatusConnecting = ({ reconnect }) => {
const [{ slowConnectionAfter }] = useStyleOptions();
const [
diff --git a/packages/component/src/ConnectivityStatus/FailedToConnect.js b/packages/component/src/ConnectivityStatus/FailedToConnect.js
index b5e55788a1..716bc8fd06 100644
--- a/packages/component/src/ConnectivityStatus/FailedToConnect.js
+++ b/packages/component/src/ConnectivityStatus/FailedToConnect.js
@@ -1,12 +1,13 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import React from 'react';
import ErrorNotificationIcon from './Assets/ErrorNotificationIcon';
import ScreenReaderText from '../ScreenReaderText';
-import useDirection from '../hooks/useDirection';
-import useLocalizer from '../hooks/useLocalizer';
import useStyleSet from '../hooks/useStyleSet';
+const { useDirection, useLocalizer } = hooks;
+
const ConnectivityStatusFailedToConnect = () => {
const [{ errorNotification: errorNotificationStyleSet }] = useStyleSet();
const [direction] = useDirection();
diff --git a/packages/component/src/ConnectivityStatus/JavaScriptError.js b/packages/component/src/ConnectivityStatus/JavaScriptError.js
index ef77b619b0..d2e298efeb 100644
--- a/packages/component/src/ConnectivityStatus/JavaScriptError.js
+++ b/packages/component/src/ConnectivityStatus/JavaScriptError.js
@@ -1,12 +1,13 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import React from 'react';
import ErrorNotificationIcon from './Assets/ErrorNotificationIcon';
import ScreenReaderText from '../ScreenReaderText';
-import useDirection from '../hooks/useDirection';
-import useLocalizer from '../hooks/useLocalizer';
import useStyleSet from '../hooks/useStyleSet';
+const { useDirection, useLocalizer } = hooks;
+
const ConnectivityStatusJavaScriptError = () => {
const [{ errorNotification: errorNotificationStyleSet }] = useStyleSet();
const [direction] = useDirection();
diff --git a/packages/component/src/Dictation.js b/packages/component/src/Dictation.js
index 0c98889ede..dffc34083c 100644
--- a/packages/component/src/Dictation.js
+++ b/packages/component/src/Dictation.js
@@ -1,23 +1,29 @@
import { Composer as DictateComposer } from 'react-dictate-button';
import { Constants } from 'botframework-webchat-core';
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React, { useCallback, useMemo } from 'react';
-import useActivities from './hooks/useActivities';
-import useDictateInterims from './hooks/useDictateInterims';
-import useDictateState from './hooks/useDictateState';
-import useDisabled from './hooks/useDisabled';
-import useEmitTypingIndicator from './hooks/useEmitTypingIndicator';
-import useLanguage from './hooks/useLanguage';
-import useSendBoxValue from './hooks/useSendBoxValue';
-import useSendTypingIndicator from './hooks/useSendTypingIndicator';
-import useSetDictateState from './hooks/internal/useSetDictateState';
import useSettableDictateAbortable from './hooks/internal/useSettableDictateAbortable';
-import useShouldSpeakIncomingActivity from './hooks/useShouldSpeakIncomingActivity';
-import useStopDictate from './hooks/useStopDictate';
-import useSubmitSendBox from './hooks/useSubmitSendBox';
import useWebSpeechPonyfill from './hooks/useWebSpeechPonyfill';
+// TODO: [P1] #3350 No /lib/, we need to move setDictateState from bf-wc-core (Redux) to React Context.
+import useSetDictateState from 'botframework-webchat-api/lib/hooks/internal/useSetDictateState';
+
+const {
+ useActivities,
+ useDictateInterims,
+ useDictateState,
+ useDisabled,
+ useEmitTypingIndicator,
+ useLanguage,
+ useSendBoxValue,
+ useSendTypingIndicator,
+ useShouldSpeakIncomingActivity,
+ useStopDictate,
+ useSubmitSendBox
+} = hooks;
+
const {
DictateState: { DICTATING, IDLE, STARTING }
} = Constants;
diff --git a/packages/component/src/ErrorBoundary.js b/packages/component/src/ErrorBoundary.js
deleted file mode 100644
index 15a8dab035..0000000000
--- a/packages/component/src/ErrorBoundary.js
+++ /dev/null
@@ -1,31 +0,0 @@
-import PropTypes from 'prop-types';
-import React from 'react';
-
-class ErrorBoundary extends React.Component {
- // Currently, all errors caught are fatal errors.
- // We will bubble up the error and let React unmount us.
- componentDidCatch(error) {
- const { onError } = this.props;
- const errorEvent = new ErrorEvent('error', { error });
-
- onError && onError(errorEvent);
- }
-
- render() {
- const { children } = this.props;
-
- return children;
- }
-}
-
-ErrorBoundary.defaultProps = {
- children: false,
- onError: undefined
-};
-
-ErrorBoundary.propTypes = {
- children: PropTypes.any,
- onError: PropTypes.func
-};
-
-export default ErrorBoundary;
diff --git a/packages/component/src/ErrorBox.js b/packages/component/src/ErrorBox.js
index 0b95f5c590..120c9dea8a 100644
--- a/packages/component/src/ErrorBox.js
+++ b/packages/component/src/ErrorBox.js
@@ -1,34 +1,28 @@
/* eslint no-console: "off" */
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
-import React, { useEffect } from 'react';
+import React from 'react';
import ScreenReaderText from './ScreenReaderText';
-import useLocalizer from './hooks/useLocalizer';
import useStyleSet from './hooks/useStyleSet';
-import useTrackException from './hooks/useTrackException';
-const ErrorBox = ({ children, error, message }) => {
+const { useLocalizer } = hooks;
+
+const ErrorBox = ({ error, type }) => {
const [{ errorBox: errorBoxStyleSet }] = useStyleSet();
const localize = useLocalizer();
- const trackException = useTrackException();
-
- useEffect(() => {
- const errorObject = error || new Error(message);
-
- trackException(errorObject, false);
-
- console.group(`botframework-webchat: ${message}`);
- console.error(errorObject);
- console.groupEnd();
- }, [error, message, trackException]);
return (
-
{message}
-
{children}
+
{type}
+ {/* The callstack between production and development are different, thus, we should hide it for visual regression test */}
+
+ {error.message}
+ {error.stack}
+
);
@@ -37,13 +31,13 @@ const ErrorBox = ({ children, error, message }) => {
ErrorBox.defaultProps = {
children: undefined,
error: undefined,
- message: ''
+ type: ''
};
ErrorBox.propTypes = {
children: PropTypes.any,
- error: PropTypes.instanceOf(Error),
- message: PropTypes.string
+ error: PropTypes.instanceOf(Error).isRequired,
+ type: PropTypes.string
};
export default ErrorBox;
diff --git a/packages/component/src/Middleware/Activity/createCoreMiddleware.js b/packages/component/src/Middleware/Activity/createCoreMiddleware.js
index 98bd8c258a..63b6eee3c4 100644
--- a/packages/component/src/Middleware/Activity/createCoreMiddleware.js
+++ b/packages/component/src/Middleware/Activity/createCoreMiddleware.js
@@ -4,64 +4,66 @@ import CarouselLayout from '../../Activity/CarouselLayout';
import StackedLayout from '../../Activity/StackedLayout';
export default function createCoreMiddleware() {
- return () => next => (...args) => {
- const [{ activity }] = args;
+ return [
+ () => next => (...args) => {
+ const [{ activity }] = args;
- // TODO: [P4] Can we simplify these if-statement to something more readable?
+ // TODO: [P4] Can we simplify these if-statement to something more readable?
- const { type } = activity;
+ const { type } = activity;
- // Filter out activities that should not be visible
- if (type === 'conversationUpdate' || type === 'event' || type === 'invoke' || type === 'typing') {
- return false;
- } else if (type === 'message') {
- const { attachments = [], channelData, text } = activity;
+ // Filter out activities that should not be visible
+ if (type === 'conversationUpdate' || type === 'event' || type === 'invoke' || type === 'typing') {
+ return false;
+ } else if (type === 'message') {
+ const { attachments = [], channelData, text } = activity;
- if (
- // Do not show postback
- (channelData && channelData.postBack) ||
- // Do not show messageBack if displayText is undefined
- (channelData && channelData.messageBack && !channelData.messageBack.displayText) ||
- // Do not show empty bubbles (no text and attachments, and not "typing")
- !(text || attachments.length)
- ) {
+ if (
+ // Do not show postback
+ (channelData && channelData.postBack) ||
+ // Do not show messageBack if displayText is undefined
+ (channelData && channelData.messageBack && !channelData.messageBack.displayText) ||
+ // Do not show empty bubbles (no text and attachments, and not "typing")
+ !(text || attachments.length)
+ ) {
+ return false;
+ }
+ } else if (type === 'typing' && activity.from.role === 'user') {
+ // Do not show typing by oneself
return false;
}
- } else if (type === 'typing' && activity.from.role === 'user') {
- // Do not show typing by oneself
- return false;
- }
- if (type === 'message' || type === 'typing') {
- if (type === 'message' && (activity.attachments || []).length > 1 && activity.attachmentLayout === 'carousel') {
- // The following line is not a React functional component, it's a render function called by useCreateActivityRenderer() hook.
- // The function signature need to be compatible with older version of activity middleware, which was:
- //
- // renderActivity(
- // renderAttachment: ({ activity, attachment }) => React.Element
- // ) => React.Element
+ if (type === 'message' || type === 'typing') {
+ if (type === 'message' && (activity.attachments || []).length > 1 && activity.attachmentLayout === 'carousel') {
+ // The following line is not a React functional component, it's a render function called by useCreateActivityRenderer() hook.
+ // The function signature need to be compatible with older version of activity middleware, which was:
+ //
+ // renderActivity(
+ // renderAttachment: ({ activity, attachment }) => React.Element
+ // ) => React.Element
+
+ return function renderCarouselLayout(renderAttachment, props) {
+ typeof props === 'undefined' &&
+ console.warn(
+ 'botframework-webchat: One or more arguments were missing after passing through the activity middleware. Please check your custom activity middleware to make sure it passthrough all arguments.'
+ );
- return function renderCarouselLayout(renderAttachment, props) {
+ return
;
+ };
+ }
+
+ // The following line is not a React functional component, it's a render function called by useCreateActivityRenderer() hook.
+ return function renderStackedLayout(renderAttachment, props) {
typeof props === 'undefined' &&
console.warn(
'botframework-webchat: One or more arguments were missing after passing through the activity middleware. Please check your custom activity middleware to make sure it passthrough all arguments.'
);
- return
;
+ return
;
};
}
- // The following line is not a React functional component, it's a render function called by useCreateActivityRenderer() hook.
- return function renderStackedLayout(renderAttachment, props) {
- typeof props === 'undefined' &&
- console.warn(
- 'botframework-webchat: One or more arguments were missing after passing through the activity middleware. Please check your custom activity middleware to make sure it passthrough all arguments.'
- );
-
- return
;
- };
+ return next(...args);
}
-
- return next(...args);
- };
+ ];
}
diff --git a/packages/component/src/Middleware/ActivityStatus/AbsoluteTime.js b/packages/component/src/Middleware/ActivityStatus/AbsoluteTime.js
index 7fe6a3639b..bc4022e176 100644
--- a/packages/component/src/Middleware/ActivityStatus/AbsoluteTime.js
+++ b/packages/component/src/Middleware/ActivityStatus/AbsoluteTime.js
@@ -1,10 +1,10 @@
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React from 'react';
import ScreenReaderText from '../../ScreenReaderText';
-import useDateFormatter from '../../hooks/useDateFormatter';
-import useLocalizer from '../../hooks/useLocalizer';
+const { useDateFormatter, useLocalizer } = hooks;
const AbsoluteTime = ({ hide, value }) => {
const localize = useLocalizer();
diff --git a/packages/component/src/Middleware/ActivityStatus/RelativeTime.js b/packages/component/src/Middleware/ActivityStatus/RelativeTime.js
index 47a498ee30..47282129ca 100644
--- a/packages/component/src/Middleware/ActivityStatus/RelativeTime.js
+++ b/packages/component/src/Middleware/ActivityStatus/RelativeTime.js
@@ -1,11 +1,11 @@
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React from 'react';
import ScreenReaderText from '../../ScreenReaderText';
-import useDateFormatter from '../../hooks/useDateFormatter';
import useForceRenderAtInterval from '../../hooks/internal/useForceRenderAtInterval';
-import useLocalizer from '../../hooks/useLocalizer';
-import useRelativeTimeFormatter from '../../hooks/useRelativeTimeFormatter';
+
+const { useDateFormatter, useLocalizer, useRelativeTimeFormatter } = hooks;
const TIMER_INTERVAL = 60000;
diff --git a/packages/component/src/Middleware/ActivityStatus/SendStatus/SendFailedRetry.js b/packages/component/src/Middleware/ActivityStatus/SendStatus/SendFailedRetry.js
index bab21a14f8..708c92dd00 100644
--- a/packages/component/src/Middleware/ActivityStatus/SendStatus/SendFailedRetry.js
+++ b/packages/component/src/Middleware/ActivityStatus/SendStatus/SendFailedRetry.js
@@ -1,8 +1,10 @@
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React, { useCallback } from 'react';
import InlineMarkdown from '../../../Utils/InlineMarkdown';
-import useLocalizer from '../../../hooks/useLocalizer';
+
+const { useLocalizer } = hooks;
const MARKDOWN_REFERENCES = ['RETRY'];
diff --git a/packages/component/src/Middleware/ActivityStatus/SendStatus/SendStatus.js b/packages/component/src/Middleware/ActivityStatus/SendStatus/SendStatus.js
index 639eb7e8c3..8400f95310 100644
--- a/packages/component/src/Middleware/ActivityStatus/SendStatus/SendStatus.js
+++ b/packages/component/src/Middleware/ActivityStatus/SendStatus/SendStatus.js
@@ -1,4 +1,5 @@
import { Constants } from 'botframework-webchat-core';
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React, { useCallback } from 'react';
@@ -6,10 +7,10 @@ import connectToWebChat from '../../../connectToWebChat';
import ScreenReaderText from '../../../ScreenReaderText';
import SendFailedRetry from './SendFailedRetry';
import useFocus from '../../../hooks/useFocus';
-import useLocalizer from '../../../hooks/useLocalizer';
-import usePostActivity from '../../../hooks/usePostActivity';
import useStyleSet from '../../../hooks/useStyleSet';
+const { useLocalizer, usePostActivity } = hooks;
+
const {
ActivityClientState: { SEND_FAILED, SENDING }
} = Constants;
diff --git a/packages/component/src/Middleware/ActivityStatus/Timestamp.js b/packages/component/src/Middleware/ActivityStatus/Timestamp.js
index 3149522861..992cf996e4 100644
--- a/packages/component/src/Middleware/ActivityStatus/Timestamp.js
+++ b/packages/component/src/Middleware/ActivityStatus/Timestamp.js
@@ -1,12 +1,14 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import AbsoluteTime from './AbsoluteTime';
import RelativeTime from './RelativeTime';
-import useStyleOptions from '../../hooks/useStyleOptions';
import useStyleSet from '../../hooks/useStyleSet';
+const { useStyleOptions } = hooks;
+
const Timestamp = ({ activity: { timestamp }, className }) => {
const [{ timestampFormat }] = useStyleOptions();
const [{ timestamp: timestampStyleSet, sendStatus: sendStatusStyleSet }] = useStyleSet();
diff --git a/packages/component/src/Middleware/ActivityStatus/createCoreMiddleware.js b/packages/component/src/Middleware/ActivityStatus/createCoreMiddleware.js
index c157d820d2..080948748f 100644
--- a/packages/component/src/Middleware/ActivityStatus/createCoreMiddleware.js
+++ b/packages/component/src/Middleware/ActivityStatus/createCoreMiddleware.js
@@ -1,7 +1,6 @@
-import concatMiddleware from '../concatMiddleware';
import createSendStatusMiddleware from './createSendStatusMiddleware';
import createTimestampMiddleware from './createTimestampMiddleware';
export default function createCoreMiddleware() {
- return concatMiddleware(createSendStatusMiddleware(), createTimestampMiddleware());
+ return [createSendStatusMiddleware(), createTimestampMiddleware()];
}
diff --git a/packages/component/src/Middleware/Attachment/createCoreMiddleware.js b/packages/component/src/Middleware/Attachment/createCoreMiddleware.js
index 5d75af256c..7df54b5c19 100644
--- a/packages/component/src/Middleware/Attachment/createCoreMiddleware.js
+++ b/packages/component/src/Middleware/Attachment/createCoreMiddleware.js
@@ -1,4 +1,3 @@
-import PropTypes from 'prop-types';
import React from 'react';
import AudioAttachment from '../../Attachment/AudioAttachment';
@@ -9,14 +8,20 @@ import VideoAttachment from '../../Attachment/VideoAttachment';
// TODO: [P4] Rename this file or the whole middleware, it looks either too simple or too comprehensive now
export default function createCoreMiddleware() {
- return () => next => {
- const Attachment = ({
- activity = {},
- activity: { from: { role } = {} } = {},
- attachment,
- attachment: { contentType, contentUrl, thumbnailUrl } = {}
- }) =>
- role === 'user' && !/^text\//u.test(contentType) && !thumbnailUrl ? (
+ return [
+ // This is not returning a React component, but a render function.
+ /* eslint-disable-next-line react/display-name */
+ () => next => (...args) => {
+ const [
+ {
+ activity = {},
+ activity: { from: { role } = {} } = {},
+ attachment,
+ attachment: { contentType, contentUrl, thumbnailUrl } = {}
+ }
+ ] = args;
+
+ return role === 'user' && !/^text\//u.test(contentType) && !thumbnailUrl ? (
) : /^audio\//u.test(contentType) ? (
@@ -29,18 +34,8 @@ export default function createCoreMiddleware() {
) : /^text\//u.test(contentType) ? (
) : (
- next({ activity, attachment })
+ next(...args)
);
-
- Attachment.propTypes = {
- activity: PropTypes.any.isRequired,
- attachment: PropTypes.shape({
- contentType: PropTypes.string.isRequired,
- contentUrl: PropTypes.string,
- thumbnailUrl: PropTypes.string
- }).isRequired
- };
-
- return Attachment;
- };
+ }
+ ];
}
diff --git a/packages/component/src/Middleware/AttachmentForScreenReader/AudioAttachment.js b/packages/component/src/Middleware/AttachmentForScreenReader/AudioAttachment.js
index 168fd3ea22..866e7f5f3d 100644
--- a/packages/component/src/Middleware/AttachmentForScreenReader/AudioAttachment.js
+++ b/packages/component/src/Middleware/AttachmentForScreenReader/AudioAttachment.js
@@ -1,6 +1,7 @@
+import { hooks } from 'botframework-webchat-api';
import React from 'react';
-import useLocalizer from '../../hooks/useLocalizer';
+const { useLocalizer } = hooks;
const AudioAttachment = () => {
const localize = useLocalizer();
diff --git a/packages/component/src/Middleware/AttachmentForScreenReader/FileAttachment.js b/packages/component/src/Middleware/AttachmentForScreenReader/FileAttachment.js
index ef846fcd11..7b9e5788f7 100644
--- a/packages/component/src/Middleware/AttachmentForScreenReader/FileAttachment.js
+++ b/packages/component/src/Middleware/AttachmentForScreenReader/FileAttachment.js
@@ -1,7 +1,8 @@
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React from 'react';
-import useLocalizer from '../../hooks/useLocalizer';
+const { useLocalizer } = hooks;
const FileAttachment = ({ attachment: { name = '' } = {} }) => {
const localize = useLocalizer();
diff --git a/packages/component/src/Middleware/AttachmentForScreenReader/ImageAttachment.js b/packages/component/src/Middleware/AttachmentForScreenReader/ImageAttachment.js
index 804de52af2..cbebad14b9 100644
--- a/packages/component/src/Middleware/AttachmentForScreenReader/ImageAttachment.js
+++ b/packages/component/src/Middleware/AttachmentForScreenReader/ImageAttachment.js
@@ -1,6 +1,7 @@
+import { hooks } from 'botframework-webchat-api';
import React from 'react';
-import useLocalizer from '../../hooks/useLocalizer';
+const { useLocalizer } = hooks;
const ImageAttachment = () => {
const localize = useLocalizer();
diff --git a/packages/component/src/Middleware/AttachmentForScreenReader/TextAttachment.js b/packages/component/src/Middleware/AttachmentForScreenReader/TextAttachment.js
index 66d8fcca6d..0c5164ffc2 100644
--- a/packages/component/src/Middleware/AttachmentForScreenReader/TextAttachment.js
+++ b/packages/component/src/Middleware/AttachmentForScreenReader/TextAttachment.js
@@ -1,7 +1,8 @@
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React from 'react';
-import useLocalizer from '../../hooks/useLocalizer';
+const { useLocalizer } = hooks;
const TextAttachment = ({ attachment: { content = '' } = {} }) => {
const localize = useLocalizer();
diff --git a/packages/component/src/Middleware/AttachmentForScreenReader/VideoAttachment.js b/packages/component/src/Middleware/AttachmentForScreenReader/VideoAttachment.js
index 00d47970c1..b37da1040a 100644
--- a/packages/component/src/Middleware/AttachmentForScreenReader/VideoAttachment.js
+++ b/packages/component/src/Middleware/AttachmentForScreenReader/VideoAttachment.js
@@ -1,6 +1,7 @@
+import { hooks } from 'botframework-webchat-api';
import React from 'react';
-import useLocalizer from '../../hooks/useLocalizer';
+const { useLocalizer } = hooks;
const VideoAttachment = () => {
const localize = useLocalizer();
diff --git a/packages/component/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.js b/packages/component/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.js
index c8d3e7d56d..e136d88c18 100644
--- a/packages/component/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.js
+++ b/packages/component/src/Middleware/AttachmentForScreenReader/createCoreMiddleware.js
@@ -7,23 +7,29 @@ import TextAttachment from './TextAttachment';
import VideoAttachment from './VideoAttachment';
export default function createCoreMiddleware() {
- return () => next => (...args) => {
- const [
- { activity: { from: { role } = {} } = {}, attachment, attachment: { contentType, contentUrl, thumbnailUrl } = {} }
- ] = args;
+ return [
+ () => next => (...args) => {
+ const [
+ {
+ activity: { from: { role } = {} } = {},
+ attachment,
+ attachment: { contentType, contentUrl, thumbnailUrl } = {}
+ }
+ ] = args;
- return role === 'user' && !/^text\//u.test(contentType) && !thumbnailUrl
- ? () =>
- : /^audio\//u.test(contentType)
- ? () =>
- : /^image\//u.test(contentType)
- ? () =>
- : /^video\//u.test(contentType)
- ? () =>
- : contentUrl || contentType === 'application/octet-stream'
- ? () =>
- : /^text\//u.test(contentType)
- ? () =>
- : next(...args);
- };
+ return role === 'user' && !/^text\//u.test(contentType) && !thumbnailUrl
+ ? () =>
+ : /^audio\//u.test(contentType)
+ ? () =>
+ : /^image\//u.test(contentType)
+ ? () =>
+ : /^video\//u.test(contentType)
+ ? () =>
+ : contentUrl || contentType === 'application/octet-stream'
+ ? () =>
+ : /^text\//u.test(contentType)
+ ? () =>
+ : next(...args);
+ }
+ ];
}
diff --git a/packages/component/src/Middleware/Avatar/createCoreMiddleware.js b/packages/component/src/Middleware/Avatar/createCoreMiddleware.js
index a9d46ace1f..7b45f25f32 100644
--- a/packages/component/src/Middleware/Avatar/createCoreMiddleware.js
+++ b/packages/component/src/Middleware/Avatar/createCoreMiddleware.js
@@ -2,7 +2,6 @@ import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
-import concatMiddleware from '../concatMiddleware';
import ImageAvatar from '../../Avatar/ImageAvatar';
import InitialsAvatar from '../../Avatar/InitialsAvatar';
import useStyleSet from '../../hooks/useStyleSet';
@@ -52,16 +51,18 @@ DefaultAvatar.propTypes = {
};
export default function createCoreAvatarMiddleware() {
- return concatMiddleware(() => () => ({ fromUser, styleOptions }) => {
- const { botAvatarImage, botAvatarInitials, userAvatarImage, userAvatarInitials } = styleOptions;
+ return [
+ () => () => ({ fromUser, styleOptions }) => {
+ const { botAvatarImage, botAvatarInitials, userAvatarImage, userAvatarInitials } = styleOptions;
- if (fromUser ? userAvatarImage || userAvatarInitials : botAvatarImage || botAvatarInitials) {
- // eslint-disable-next-line react/display-name
- return () =>
;
- }
+ if (fromUser ? userAvatarImage || userAvatarInitials : botAvatarImage || botAvatarInitials) {
+ // eslint-disable-next-line react/display-name
+ return () =>
;
+ }
- return false;
- });
+ return false;
+ }
+ ];
}
export { DefaultAvatar };
diff --git a/packages/component/src/Middleware/CardAction/createCoreMiddleware.js b/packages/component/src/Middleware/CardAction/createCoreMiddleware.js
index d0d0bde5dd..20f588afb7 100644
--- a/packages/component/src/Middleware/CardAction/createCoreMiddleware.js
+++ b/packages/component/src/Middleware/CardAction/createCoreMiddleware.js
@@ -1,5 +1,3 @@
-import { sendMessage, sendMessageBack, sendPostBack } from 'botframework-webchat-core';
-
// This code is adopted from sanitize-html/naughtyScheme.
// sanitize-html is a dependency of Web Chat but the naughtScheme function is neither exposed nor reusable.
// https://github.com/apostrophecms/sanitize-html/blob/master/src/index.js#L526
@@ -30,59 +28,47 @@ function getScheme(href) {
const ALLOWED_SCHEMES = ['data', 'http', 'https', 'ftp', 'mailto', 'sip', 'tel'];
export default function createDefaultCardActionMiddleware() {
- return ({ dispatch }) => next => ({ cardAction, getSignInUrl }) => {
- const { displayText, text, type, value } = cardAction;
-
- switch (type) {
- case 'imBack':
- if (typeof value === 'string') {
- // TODO: [P4] Instead of calling dispatch, we should move to dispatchers instead for completeness
- dispatch(sendMessage(value, 'imBack'));
- } else {
- throw new Error('cannot send "imBack" with a non-string value');
+ return [
+ () => next => (...args) => {
+ const [
+ {
+ cardAction: { type, value },
+ getSignInUrl
}
-
- break;
-
- case 'messageBack':
- dispatch(sendMessageBack(value, text, displayText));
-
- break;
-
- case 'postBack':
- dispatch(sendPostBack(value));
-
- break;
-
- case 'call':
- case 'downloadFile':
- case 'openUrl':
- case 'playAudio':
- case 'playVideo':
- case 'showImage':
- if (ALLOWED_SCHEMES.includes(getScheme(value))) {
- window.open(value, '_blank', 'noopener noreferrer');
- } else {
- console.warn('botframework-webchat: Cannot open URL with disallowed schemes.', value);
+ ] = args;
+
+ switch (type) {
+ case 'call':
+ case 'downloadFile':
+ case 'openUrl':
+ case 'playAudio':
+ case 'playVideo':
+ case 'showImage':
+ if (ALLOWED_SCHEMES.includes(getScheme(value))) {
+ window.open(value, '_blank', 'noopener noreferrer');
+ } else {
+ console.warn('botframework-webchat: Cannot open URL with disallowed schemes.', value);
+ }
+
+ break;
+
+ case 'signin': {
+ // TODO: [P3] We should prime the URL into the OAuthCard directly, instead of calling getSessionId on-demand
+ // This is to eliminate the delay between window.open() and location.href call
+
+ (async function () {
+ const popup = window.open();
+ const url = await getSignInUrl();
+
+ popup.location.href = url;
+ })();
+
+ break;
}
- break;
-
- case 'signin': {
- // TODO: [P3] We should prime the URL into the OAuthCard directly, instead of calling getSessionId on-demand
- // This is to eliminate the delay between window.open() and location.href call
-
- const popup = window.open();
-
- getSignInUrl().then(url => {
- popup.location.href = url;
- });
-
- break;
+ default:
+ return next(...args);
}
-
- default:
- return next({ cardAction, getSignInUrl });
}
- };
+ ];
}
diff --git a/packages/component/src/Middleware/Toast/createCoreMiddleware.js b/packages/component/src/Middleware/Toast/createCoreMiddleware.js
index df8c194f00..0c85f6b0e0 100644
--- a/packages/component/src/Middleware/Toast/createCoreMiddleware.js
+++ b/packages/component/src/Middleware/Toast/createCoreMiddleware.js
@@ -1,8 +1,7 @@
-import concatMiddleware from '../concatMiddleware';
import createToastMiddleware from '../../Toast/createToastMiddleware';
function createCoreMiddleware() {
- return concatMiddleware(
+ return [
() => next => (...args) => {
const [
{
@@ -15,7 +14,7 @@ function createCoreMiddleware() {
return id !== 'connectivitystatus' && next(...args);
},
createToastMiddleware()
- );
+ ];
}
export default createCoreMiddleware;
diff --git a/packages/component/src/Middleware/TypingIndicator/createCoreMiddleware.js b/packages/component/src/Middleware/TypingIndicator/createCoreMiddleware.js
index 3a7d8e84c0..e4f5f55a7b 100644
--- a/packages/component/src/Middleware/TypingIndicator/createCoreMiddleware.js
+++ b/packages/component/src/Middleware/TypingIndicator/createCoreMiddleware.js
@@ -1,13 +1,14 @@
/* eslint react/prop-types: "off"*/
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import React from 'react';
import TypingAnimation from '../../Assets/TypingAnimation';
-import useDirection from '../../hooks/useDirection';
-import useLocalizer from '../../hooks/useLocalizer';
import useStyleSet from '../../hooks/useStyleSet';
+const { useDirection, useLocalizer } = hooks;
+
const DotIndicator = () => {
const [{ typingIndicator: typingIndicatorStyleSet }] = useStyleSet();
const [direction] = useDirection();
@@ -22,5 +23,5 @@ const DotIndicator = () => {
// TODO: [P4] Rename this file or the whole middleware, it looks either too simple or too comprehensive now
export default function createCoreMiddleware() {
- return () => () => ({ visible }) => visible &&
;
+ return [() => () => ({ visible }) => visible &&
];
}
diff --git a/packages/component/src/Middleware/applyAttachmentForScreenReaderMiddleware.js b/packages/component/src/Middleware/applyAttachmentForScreenReaderMiddleware.js
deleted file mode 100644
index 60922c1c1f..0000000000
--- a/packages/component/src/Middleware/applyAttachmentForScreenReaderMiddleware.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/* eslint no-magic-numbers: ["error", { "ignore": [2] }] */
-
-import React from 'react';
-
-import concatMiddleware from './concatMiddleware';
-import createCoreMiddleware from './AttachmentForScreenReader/createCoreMiddleware';
-import ErrorBox from '../ErrorBox';
-
-export default function applyAttachmentForScreenReaderMiddleware(additionalMiddleware) {
- const activityMiddleware = concatMiddleware(additionalMiddleware, createCoreMiddleware())({});
-
- return (...args) => {
- try {
- return activityMiddleware(() => false)(...args);
- } catch (err) {
- const FailedRenderAttachmentForScreenReader = () => (
-
- {JSON.stringify(err, null, 2)}
-
- );
-
- return FailedRenderAttachmentForScreenReader;
- }
- };
-}
diff --git a/packages/component/src/Middleware/concatMiddleware.js b/packages/component/src/Middleware/concatMiddleware.js
deleted file mode 100644
index c5c89ca1f9..0000000000
--- a/packages/component/src/Middleware/concatMiddleware.js
+++ /dev/null
@@ -1,16 +0,0 @@
-export default function concatMiddleware(...middlewares) {
- return options => {
- const setup = middlewares.reduce((setup, middleware) => (middleware ? [...setup, middleware(options)] : setup), []);
-
- return last => {
- const stack = setup.slice();
- const work = index => (...args) => {
- const next = stack[index];
-
- return (next ? next(work(index + 1)) : last)(...args);
- };
-
- return work(0);
- };
- };
-}
diff --git a/packages/component/src/Middleware/createActivityRenderer.js b/packages/component/src/Middleware/createActivityRenderer.js
deleted file mode 100644
index 10e193b79e..0000000000
--- a/packages/component/src/Middleware/createActivityRenderer.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/* eslint no-magic-numbers: ["error", { "ignore": [2] }] */
-
-import React, { useEffect } from 'react';
-import PropTypes from 'prop-types';
-
-import concatMiddleware from './concatMiddleware';
-import createCoreActivityMiddleware from './Activity/createCoreMiddleware';
-import ErrorBox from '../ErrorBox';
-import useTrackException from '../hooks/useTrackException';
-
-const SilentError = ({ message }) => {
- const trackException = useTrackException();
-
- useEffect(() => {
- trackException(new Error(message), false);
- }, [message, trackException]);
-
- return false;
-};
-
-SilentError.propTypes = {
- message: PropTypes.string.isRequired
-};
-
-export default function createActivityRenderer(additionalMiddleware) {
- const activityMiddleware = concatMiddleware(additionalMiddleware, createCoreActivityMiddleware())({});
-
- return (...args) => {
- try {
- return activityMiddleware(({ activity }) => () => (
-
- ))(...args);
- } catch (err) {
- const FailedRenderActivity = () => (
-
- {JSON.stringify(err, null, 2)}
-
- );
-
- return FailedRenderActivity;
- }
- };
-}
diff --git a/packages/component/src/Middleware/createActivityStatusRenderer.js b/packages/component/src/Middleware/createActivityStatusRenderer.js
deleted file mode 100644
index 38c26eeb06..0000000000
--- a/packages/component/src/Middleware/createActivityStatusRenderer.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/* eslint no-magic-numbers: ["error", { "ignore": [2] }] */
-
-import React from 'react';
-import concatMiddleware from './concatMiddleware';
-import createCoreActivityStatusMiddleware from './ActivityStatus/createCoreMiddleware';
-import ErrorBox from '../ErrorBox';
-
-export default function createActivityStatusRenderer(additionalMiddleware) {
- const activityStatusMiddleware = concatMiddleware(additionalMiddleware, createCoreActivityStatusMiddleware())({});
-
- return (...args) => {
- try {
- return activityStatusMiddleware(() => false)(...args);
- } catch (err) {
- const { message, stack } = err;
-
- // The next line is not a React component. It is a render function.
- // eslint-disable-next-line react/display-name
- return () => (
-
- {JSON.stringify({ message, stack }, null, 2)}
-
- );
- }
- };
-}
diff --git a/packages/component/src/Middleware/createAttachmentRenderer.js b/packages/component/src/Middleware/createAttachmentRenderer.js
deleted file mode 100644
index c1dd461ab0..0000000000
--- a/packages/component/src/Middleware/createAttachmentRenderer.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/* eslint no-magic-numbers: ["error", { "ignore": [2] }] */
-
-import React from 'react';
-import concatMiddleware from './concatMiddleware';
-import createCoreAttachmentMiddleware from './Attachment/createCoreMiddleware';
-import ErrorBox from '../ErrorBox';
-
-export default function createAttachmentRenderer(additionalMiddleware) {
- const attachmentMiddleware = concatMiddleware(additionalMiddleware, createCoreAttachmentMiddleware())({});
-
- return (...args) => {
- try {
- return attachmentMiddleware(({ attachment }) => (
-
- {JSON.stringify(attachment, null, 2)}
-
- ))(...args);
- } catch (err) {
- return (
-
- {JSON.stringify(err, null, 2)}
-
- );
- }
- };
-}
diff --git a/packages/component/src/Middleware/createAvatarRenderer.js b/packages/component/src/Middleware/createAvatarRenderer.js
deleted file mode 100644
index 8f2b3d0529..0000000000
--- a/packages/component/src/Middleware/createAvatarRenderer.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/* eslint no-magic-numbers: ["error", { "ignore": [2] }] */
-
-import React from 'react';
-import concatMiddleware from './concatMiddleware';
-import createCoreAvatarMiddleware from './Avatar/createCoreMiddleware';
-import ErrorBox from '../ErrorBox';
-
-export default function createAvatarRenderer(additionalMiddleware) {
- const avatarMiddleware = concatMiddleware(additionalMiddleware, createCoreAvatarMiddleware())({});
-
- return (...args) => {
- try {
- return avatarMiddleware(() => false)(...args);
- } catch (err) {
- const { message, stack } = err;
-
- console.error({ message, stack });
-
- return (
-
- {JSON.stringify({ message, stack }, null, 2)}
-
- );
- }
- };
-}
diff --git a/packages/component/src/Middleware/createToastRenderer.js b/packages/component/src/Middleware/createToastRenderer.js
deleted file mode 100644
index f69e78c50a..0000000000
--- a/packages/component/src/Middleware/createToastRenderer.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/* eslint no-magic-numbers: ["error", { "ignore": [2] }] */
-
-import React from 'react';
-import concatMiddleware from './concatMiddleware';
-import createCoreToastMiddleware from './Toast/createCoreMiddleware';
-import ErrorBox from '../ErrorBox';
-
-export default function createToastRenderer(additionalMiddleware) {
- const toastMiddleware = concatMiddleware(additionalMiddleware, createCoreToastMiddleware())({});
-
- return (...args) => {
- try {
- return toastMiddleware(({ notification }) => (
-
- {JSON.stringify(notification, null, 2)}
-
- ))(...args);
- } catch (err) {
- const { message, stack } = err;
-
- console.error({ message, stack });
-
- return (
-
- {JSON.stringify({ message, stack }, null, 2)}
-
- );
- }
- };
-}
diff --git a/packages/component/src/Middleware/createTypingIndicatorRenderer.js b/packages/component/src/Middleware/createTypingIndicatorRenderer.js
deleted file mode 100644
index bc40ed3b77..0000000000
--- a/packages/component/src/Middleware/createTypingIndicatorRenderer.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/* eslint no-magic-numbers: ["error", { "ignore": [2] }] */
-
-import React from 'react';
-import concatMiddleware from './concatMiddleware';
-import createCoreTypingIndicatorMiddleware from './TypingIndicator/createCoreMiddleware';
-import ErrorBox from '../ErrorBox';
-
-export default function createTypingIndicatorRenderer(additionalMiddleware) {
- const typingIndicatorMiddleware = concatMiddleware(additionalMiddleware, createCoreTypingIndicatorMiddleware())({});
-
- return (...args) => {
- try {
- return typingIndicatorMiddleware(({ activeTyping, typing, visible }) => (
-
- {JSON.stringify({ activeTyping, typing, visible }, null, 2)}
-
- ))(...args);
- } catch (err) {
- const { message, stack } = err;
-
- console.error({ message, stack });
-
- return (
-
- {JSON.stringify({ message, stack }, null, 2)}
-
- );
- }
- };
-}
diff --git a/packages/component/src/ScreenReaderActivity.js b/packages/component/src/ScreenReaderActivity.js
index 1d81dcb6d5..bfe142b775 100644
--- a/packages/component/src/ScreenReaderActivity.js
+++ b/packages/component/src/ScreenReaderActivity.js
@@ -1,17 +1,16 @@
/* eslint no-magic-numbers: ["error", { "ignore": [2] }] */
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import textFormatToContentType from './Utils/textFormatToContentType';
-import useAvatarForBot from './hooks/useAvatarForBot';
-import useCreateAttachmentForScreenReaderRenderer from './hooks/useCreateAttachmentForScreenReaderRenderer';
-import useDateFormatter from './hooks/useDateFormatter';
-import useLocalizer from './hooks/useLocalizer';
import useStripMarkdown from './hooks/internal/useStripMarkdown';
import useStyleToEmotionObject from './hooks/internal/useStyleToEmotionObject';
+const { useAvatarForBot, useCreateAttachmentForScreenReaderRenderer, useDateFormatter, useLocalizer } = hooks;
+
const ROOT_STYLE = {
'&.webchat__screen-reader-activity': {
color: 'transparent',
diff --git a/packages/component/src/SendBox/Assets/SendIcon.js b/packages/component/src/SendBox/Assets/SendIcon.js
index bc80b99524..b772b8cb68 100644
--- a/packages/component/src/SendBox/Assets/SendIcon.js
+++ b/packages/component/src/SendBox/Assets/SendIcon.js
@@ -1,9 +1,11 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import React from 'react';
-import useDirection from '../../hooks/useDirection';
import useStyleToEmotionObject from '../../hooks/internal/useStyleToEmotionObject';
+const { useDirection } = hooks;
+
const ROOT_STYLE = {
'&.webchat__send-icon': {
'&.webchat__send-icon--rtl': {
diff --git a/packages/component/src/SendBox/DictationInterims.js b/packages/component/src/SendBox/DictationInterims.js
index dfebebe79d..c0bb89f6f8 100644
--- a/packages/component/src/SendBox/DictationInterims.js
+++ b/packages/component/src/SendBox/DictationInterims.js
@@ -1,15 +1,12 @@
/* eslint react/no-array-index-key: "off" */
+import { Constants } from 'botframework-webchat-core';
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
-import { Constants } from 'botframework-webchat-core';
-
import connectToWebChat from '../connectToWebChat';
-import useDictateInterims from '../hooks/useDictateInterims';
-import useDictateState from '../hooks/useDictateState';
-import useLocalizer from '../hooks/useLocalizer';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
@@ -17,6 +14,8 @@ const {
DictateState: { DICTATING, STARTING, STOPPING }
} = Constants;
+const { useDictateInterims, useDictateState, useLocalizer } = hooks;
+
const ROOT_STYLE = {
alignItems: 'center',
display: 'flex'
diff --git a/packages/component/src/SendBox/MicrophoneButton.js b/packages/component/src/SendBox/MicrophoneButton.js
index ab81061e0b..eadfdcbe3d 100644
--- a/packages/component/src/SendBox/MicrophoneButton.js
+++ b/packages/component/src/SendBox/MicrophoneButton.js
@@ -2,6 +2,7 @@
/* eslint react/forbid-dom-props: "off" */
import { Constants } from 'botframework-webchat-core';
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import memoize from 'memoize-one';
import PropTypes from 'prop-types';
@@ -11,20 +12,23 @@ import connectToWebChat from '../connectToWebChat';
import IconButton from './IconButton';
import MicrophoneIcon from './Assets/MicrophoneIcon';
import useDictateAbortable from '../hooks/useDictateAbortable';
-import useDictateInterims from '../hooks/useDictateInterims';
-import useDictateState from '../hooks/useDictateState';
-import useDisabled from '../hooks/useDisabled';
-import useLocalizer from '../hooks/useLocalizer';
-import useSendBoxValue from '../hooks/useSendBoxValue';
-import useShouldSpeakIncomingActivity from '../hooks/useShouldSpeakIncomingActivity';
-import useStartDictate from '../hooks/useStartDictate';
-import useStopDictate from '../hooks/useStopDictate';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
import useWebSpeechPonyfill from '../hooks/useWebSpeechPonyfill';
const { DictateState } = Constants;
+const {
+ useDictateInterims,
+ useDictateState,
+ useDisabled,
+ useLocalizer,
+ useSendBoxValue,
+ useShouldSpeakIncomingActivity,
+ useStartDictate,
+ useStopDictate
+} = hooks;
+
const ROOT_STYLE = {
display: 'flex',
height: '100%',
diff --git a/packages/component/src/SendBox/SendButton.js b/packages/component/src/SendBox/SendButton.js
index ce5bf319cf..7d1afefb92 100644
--- a/packages/component/src/SendBox/SendButton.js
+++ b/packages/component/src/SendBox/SendButton.js
@@ -1,13 +1,13 @@
+import { hooks } from 'botframework-webchat-api';
import React, { useCallback } from 'react';
import connectToWebChat from '../connectToWebChat';
import IconButton from './IconButton';
import SendIcon from './Assets/SendIcon';
-import useDisabled from '../hooks/useDisabled';
import useFocus from '../hooks/useFocus';
-import useLocalizer from '../hooks/useLocalizer';
import useScrollToEnd from '../hooks/useScrollToEnd';
-import useSubmitSendBox from '../hooks/useSubmitSendBox';
+
+const { useDisabled, useLocalizer, useSubmitSendBox } = hooks;
const connectSendButton = (...selectors) =>
connectToWebChat(
diff --git a/packages/component/src/SendBox/SuggestedAction.js b/packages/component/src/SendBox/SuggestedAction.js
index 353dde3565..ea8c116cdc 100644
--- a/packages/component/src/SendBox/SuggestedAction.js
+++ b/packages/component/src/SendBox/SuggestedAction.js
@@ -1,20 +1,19 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React, { useCallback, useRef } from 'react';
import AccessibleButton from '../Utils/AccessibleButton';
import connectToWebChat from '../connectToWebChat';
-import useDirection from '../hooks/useDirection';
-import useDisabled from '../hooks/useDisabled';
import useFocus from '../hooks/useFocus';
import useFocusAccessKeyEffect from '../Utils/AccessKeySink/useFocusAccessKeyEffect';
import useLocalizeAccessKey from '../hooks/internal/useLocalizeAccessKey';
-import usePerformCardAction from '../hooks/usePerformCardAction';
import useScrollToEnd from '../hooks/useScrollToEnd';
+import useSuggestedActionsAccessKey from '../hooks/internal/useSuggestedActionsAccessKey';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
-import useSuggestedActions from '../hooks/useSuggestedActions';
-import useSuggestedActionsAccessKey from '../hooks/internal/useSuggestedActionsAccessKey';
+
+const { useDirection, useDisabled, usePerformCardAction, useSuggestedActions } = hooks;
const ROOT_STYLE = {
'&.webchat__suggested-action': {
diff --git a/packages/component/src/SendBox/SuggestedActions.js b/packages/component/src/SendBox/SuggestedActions.js
index d28bbe7525..ff073e0ea8 100644
--- a/packages/component/src/SendBox/SuggestedActions.js
+++ b/packages/component/src/SendBox/SuggestedActions.js
@@ -1,5 +1,6 @@
/* eslint react/no-array-index-key: "off" */
+import { hooks } from 'botframework-webchat-api';
import BasicFilm, { createBasicStyleSet as createBasicStyleSetForReactFilm } from 'react-film';
import classNames from 'classnames';
import PropTypes from 'prop-types';
@@ -8,16 +9,15 @@ import React, { useMemo } from 'react';
import connectToWebChat from '../connectToWebChat';
import ScreenReaderText from '../ScreenReaderText';
import SuggestedAction from './SuggestedAction';
-import useDirection from '../hooks/useDirection';
import useLocalizeAccessKey from '../hooks/internal/useLocalizeAccessKey';
-import useLocalizer from '../hooks/useLocalizer';
import useNonce from '../hooks/internal/useNonce';
-import useStyleOptions from '../hooks/useStyleOptions';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
import useSuggestedActionsAccessKey from '../hooks/internal/useSuggestedActionsAccessKey';
import useUniqueId from '../hooks/internal/useUniqueId';
+const { useDirection, useLocalizer, useStyleOptions } = hooks;
+
const ROOT_STYLE = {
'&.webchat__suggested-actions .webchat__suggested-actions__stack': {
display: 'flex',
diff --git a/packages/component/src/SendBox/TextBox.js b/packages/component/src/SendBox/TextBox.js
index afbdb71d92..5a1f997915 100644
--- a/packages/component/src/SendBox/TextBox.js
+++ b/packages/component/src/SendBox/TextBox.js
@@ -1,3 +1,4 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React, { forwardRef, useCallback, useEffect, useRef } from 'react';
@@ -6,18 +7,14 @@ import { Context as TypeFocusSinkContext } from '../Utils/TypeFocusSink';
import AccessibleInputText from '../Utils/AccessibleInputText';
import AccessibleTextArea from '../Utils/AccessibleTextArea';
import connectToWebChat from '../connectToWebChat';
-import useDisabled from '../hooks/useDisabled';
import useFocus from '../hooks/useFocus';
-import useLocalizer from '../hooks/useLocalizer';
import useReplaceEmoticon from '../hooks/internal/useReplaceEmoticon';
import useScrollToEnd from '../hooks/useScrollToEnd';
-import useSendBoxValue from '../hooks/useSendBoxValue';
-import useStopDictate from '../hooks/useStopDictate';
-import useStyleOptions from '../hooks/useStyleOptions';
import useStyleSet from '../hooks/useStyleSet';
-import useSubmitSendBox from '../hooks/useSubmitSendBox';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
+const { useDisabled, useLocalizer, useSendBoxValue, useStopDictate, useStyleOptions, useSubmitSendBox } = hooks;
+
const ROOT_STYLE = {
'&.webchat__send-box-text-box': {
display: 'flex',
diff --git a/packages/component/src/SendBox/UploadButton.js b/packages/component/src/SendBox/UploadButton.js
index a37a158c0e..995954a4d4 100644
--- a/packages/component/src/SendBox/UploadButton.js
+++ b/packages/component/src/SendBox/UploadButton.js
@@ -1,16 +1,17 @@
+import { hooks } from 'botframework-webchat-api';
import classNames from 'classnames';
import React, { useCallback, useRef } from 'react';
import AttachmentIcon from './Assets/AttachmentIcon';
import connectToWebChat from '../connectToWebChat';
-import downscaleImageToDataURL from '../Utils/downscaleImageToDataURL';
+import downscaleImageToDataURL from '../Utils/downscaleImageToDataURL/index';
import IconButton from './IconButton';
-import useDisabled from '../hooks/useDisabled';
-import useLocalizer from '../hooks/useLocalizer';
import useSendFiles from '../hooks/useSendFiles';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
+const { useDisabled, useLocalizer } = hooks;
+
const ROOT_STYLE = {
overflow: 'hidden',
position: 'relative',
diff --git a/packages/component/src/Toast/NotificationIcon.js b/packages/component/src/Toast/NotificationIcon.js
index af134e0972..d27b21bad9 100644
--- a/packages/component/src/Toast/NotificationIcon.js
+++ b/packages/component/src/Toast/NotificationIcon.js
@@ -1,9 +1,11 @@
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React from 'react';
import CheckMarkIcon from './CheckMarkIcon';
import ExclamationMarkIcon from './ExclamationMarkIcon';
-import useLocalizer from '../hooks/useLocalizer';
+
+const { useLocalizer } = hooks;
const NotificationIcon = ({ className, level }) => {
const localize = useLocalizer();
diff --git a/packages/component/src/Utils/InlineMarkdown.js b/packages/component/src/Utils/InlineMarkdown.js
index 85ace47525..3bf918548f 100644
--- a/packages/component/src/Utils/InlineMarkdown.js
+++ b/packages/component/src/Utils/InlineMarkdown.js
@@ -1,16 +1,18 @@
/* eslint react/no-danger: "off" */
+import { hooks } from 'botframework-webchat-api';
import PropTypes from 'prop-types';
import React, { useCallback, useMemo } from 'react';
import updateIn from 'simple-update-in';
-import createCustomEvent from '../Utils/createCustomEvent';
+import createCustomEvent from './createCustomEvent';
import randomId from './randomId';
import useInternalMarkdownIt from '../hooks/internal/useInternalMarkdownIt';
-import useStyleOptions from '../hooks/useStyleOptions';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
import walkMarkdownTokens from './walkMarkdownTokens';
+const { useStyleOptions } = hooks;
+
function replaceAnchorWithButton(markdownTokens) {
return walkMarkdownTokens(markdownTokens, markdownToken => {
markdownToken = { ...markdownToken };
@@ -87,11 +89,7 @@ const InlineMarkdown = ({ children, onReference, references }) => {
const html = useMemo(() => {
const tree = markdownIt.parseInline(children, {
- references: references.reduce(
- // (references, key) => ({ ...references, [key]: { href: `#${key}` } }),
- (references, key) => ({ ...references, [key]: { href: `#${refToHref[key]}` } }),
- {}
- )
+ references: references.reduce((references, key) => ({ ...references, [key]: { href: `#${refToHref[key]}` } }), {})
});
// Turn "
Retry" into "
"
diff --git a/packages/component/src/Utils/TypeFocusSink/Context.js b/packages/component/src/Utils/TypeFocusSink/Context.js
index cff54ee61e..575c41368d 100644
--- a/packages/component/src/Utils/TypeFocusSink/Context.js
+++ b/packages/component/src/Utils/TypeFocusSink/Context.js
@@ -1,6 +1,6 @@
-import React from 'react';
+import { createContext } from 'react';
-const context = React.createContext({
+const context = createContext({
focusableRef: undefined
});
diff --git a/packages/component/src/Utils/blobToArrayBuffer.js b/packages/component/src/Utils/downscaleImageToDataURL/blobToArrayBuffer.js
similarity index 100%
rename from packages/component/src/Utils/blobToArrayBuffer.js
rename to packages/component/src/Utils/downscaleImageToDataURL/blobToArrayBuffer.js
diff --git a/packages/component/src/Utils/downscaleImageToDataURLUsingBrowser.js b/packages/component/src/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingBrowser.js
similarity index 100%
rename from packages/component/src/Utils/downscaleImageToDataURLUsingBrowser.js
rename to packages/component/src/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingBrowser.js
diff --git a/packages/component/src/Utils/downscaleImageToDataURLUsingWorker.js b/packages/component/src/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker.js
similarity index 74%
rename from packages/component/src/Utils/downscaleImageToDataURLUsingWorker.js
rename to packages/component/src/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker.js
index 8a73616f72..e92b7cc0fc 100644
--- a/packages/component/src/Utils/downscaleImageToDataURLUsingWorker.js
+++ b/packages/component/src/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker.js
@@ -1,5 +1,4 @@
import blobToArrayBuffer from './blobToArrayBuffer';
-import memoizeOne from 'memoize-one';
import workerFunction from './downscaleImageToDataURLUsingWorker.worker';
function createWorker(fn) {
@@ -60,33 +59,47 @@ const checkSupportOffscreenCanvas = () => {
return typeof window.createImageBitmap !== 'undefined' && hasOffscreenCanvas && isOffscreenCanvasSupportGetContext2D;
};
-const checkSupportWebWorker = memoizeOne(async () => {
- if (typeof window.MessageChannel === 'undefined' || typeof window.Worker === 'undefined') {
- return false;
- }
+let checkSupportWebWorkerPromise;
- let worker;
+function checkSupportWebWorker() {
+ return (
+ checkSupportWebWorkerPromise ||
+ (checkSupportWebWorkerPromise = (async () => {
+ if (typeof window.MessageChannel === 'undefined' || typeof window.Worker === 'undefined') {
+ return false;
+ }
- try {
- worker = await createWorker('function(){postMessage("ready")}');
- } catch (err) {
- return false;
- }
+ let worker;
+
+ try {
+ worker = await createWorker('function(){postMessage("ready")}');
+ } catch (err) {
+ return false;
+ }
- worker.terminate();
+ worker.terminate();
- return true;
-});
+ return true;
+ })())
+ );
+}
-const checkSupport = memoizeOne(async () => {
- try {
- const results = await Promise.all([checkSupportOffscreenCanvas(), checkSupportWebWorker()]);
+let checkSupportPromise;
- return results.every(result => result);
- } catch (err) {
- return false;
- }
-});
+function checkSupport() {
+ return (
+ checkSupportPromise ||
+ (checkSupportPromise = (async () => {
+ try {
+ const results = await Promise.all([checkSupportOffscreenCanvas(), checkSupportWebWorker()]);
+
+ return results.every(result => result);
+ } catch (err) {
+ return false;
+ }
+ })())
+ );
+}
export default function downscaleImageToDataURLUsingWorker(blob, maxWidth, maxHeight, type, quality) {
return new Promise((resolve, reject) => {
diff --git a/packages/component/src/Utils/downscaleImageToDataURLUsingWorker.worker.js b/packages/component/src/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker.worker.js
similarity index 100%
rename from packages/component/src/Utils/downscaleImageToDataURLUsingWorker.worker.js
rename to packages/component/src/Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker.worker.js
diff --git a/packages/component/src/Utils/downscaleImageToDataURL.js b/packages/component/src/Utils/downscaleImageToDataURL/index.js
similarity index 100%
rename from packages/component/src/Utils/downscaleImageToDataURL.js
rename to packages/component/src/Utils/downscaleImageToDataURL/index.js
diff --git a/packages/component/src/Utils/singleToArray.js b/packages/component/src/Utils/singleToArray.js
new file mode 100644
index 0000000000..873ed8ef89
--- /dev/null
+++ b/packages/component/src/Utils/singleToArray.js
@@ -0,0 +1,3 @@
+export default function singleToArray(singleOrArray) {
+ return singleOrArray ? (Array.isArray(singleOrArray) ? singleOrArray : [singleOrArray]) : [];
+}
diff --git a/packages/component/src/WebChatUIContext.js b/packages/component/src/WebChatUIContext.js
deleted file mode 100644
index 27cf45b251..0000000000
--- a/packages/component/src/WebChatUIContext.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-
-const context = React.createContext({
- sendFocusRef: null
-});
-
-context.displayName = 'WebChatUIContext';
-
-export default context;
diff --git a/packages/component/src/connectToWebChat.js b/packages/component/src/connectToWebChat.js
index 84c1de44b8..6e32ad3afc 100644
--- a/packages/component/src/connectToWebChat.js
+++ b/packages/component/src/connectToWebChat.js
@@ -1,8 +1,8 @@
import { connect } from 'react-redux';
import React from 'react';
-import WebChatReduxContext from './WebChatReduxContext';
-import WebChatUIContext from './WebChatUIContext';
+import WebChatAPIContext from 'botframework-webchat-api/lib/hooks/internal/WebChatAPIContext';
+import WebChatReduxContext from 'botframework-webchat-api/lib/hooks/internal/WebChatReduxContext';
function removeUndefinedValues(map) {
return Object.keys(map).reduce((result, key) => {
@@ -43,9 +43,9 @@ export default function connectToWebChat(...selectors) {
)(Component);
const WebChatConnectedComponent = props => (
-
+
{context => }
-
+
);
return WebChatConnectedComponent;
diff --git a/packages/component/src/hooks/index.js b/packages/component/src/hooks/index.js
index 5b22d03271..bebd2a87cb 100644
--- a/packages/component/src/hooks/index.js
+++ b/packages/component/src/hooks/index.js
@@ -1,70 +1,12 @@
-import useActiveTyping from './useActiveTyping';
-import useActivities from './useActivities';
-import useAvatarForBot from './useAvatarForBot';
-import useAvatarForUser from './useAvatarForUser';
-import useByteFormatter from './useByteFormatter';
-import useConnectivityStatus from './useConnectivityStatus';
-import useCreateActivityRenderer from './useCreateActivityRenderer';
-import useCreateActivityStatusRenderer from './useCreateActivityStatusRenderer';
-import useCreateAttachmentForScreenReaderRenderer from './useCreateAttachmentForScreenReaderRenderer';
-import useCreateAvatarRenderer from './useCreateAvatarRenderer';
-import useDateFormatter from './useDateFormatter';
-import useDebouncedNotifications from './useDebouncedNotifications';
-import useDictateInterims from './useDictateInterims';
-import useDictateState from './useDictateState';
-import useDirection from './useDirection';
-import useDisabled from './useDisabled';
-import useDismissNotification from './useDismissNotification';
-import useEmitTypingIndicator from './useEmitTypingIndicator';
+import useDictateAbortable from './useDictateAbortable';
import useFocus from './useFocus';
import useFocusSendBox from './useFocusSendBox';
-import useGetSendTimeoutForActivity from './useGetSendTimeoutForActivity';
-import useGrammars from './useGrammars';
-import useGroupTimestamp from './useGroupTimestamp';
-import useLanguage from './useLanguage';
-import useLastTypingAt from './useLastTypingAt';
-import useLocalize from './useLocalize'; // Deprecated on or after 2022-02-12
-import useLocalizeDate from './useLocalizeDate'; // Deprecated on or after 2022-02-12
-import useLocalizer from './useLocalizer';
-import useMarkActivityAsSpoken from './useMarkActivityAsSpoken';
import useObserveScrollPosition from './useObserveScrollPosition';
-import usePerformCardAction from './usePerformCardAction';
-import usePostActivity from './usePostActivity';
-import useReferenceGrammarID from './useReferenceGrammarID';
-import useRelativeTimeFormatter from './useRelativeTimeFormatter';
-import useRenderActivity from './useRenderActivity';
-import useRenderActivityStatus from './useRenderActivityStatus';
-import useRenderAttachment from './useRenderAttachment';
-import useRenderAvatar from './useRenderAvatar';
import useRenderMarkdownAsHTML from './useRenderMarkdownAsHTML';
-import useRenderToast from './useRenderToast';
-import useRenderTypingIndicator from './useRenderTypingIndicator';
import useScrollTo from './useScrollTo';
import useScrollToEnd from './useScrollToEnd';
-import useSendBoxValue from './useSendBoxValue';
-import useSendEvent from './useSendEvent';
import useSendFiles from './useSendFiles';
-import useSendMessage from './useSendMessage';
-import useSendMessageBack from './useSendMessageBack';
-import useSendPostBack from './useSendPostBack';
-import useSendTimeoutForActivity from './useSendTimeoutForActivity';
-import useSendTypingIndicator from './useSendTypingIndicator';
-import useSetNotification from './useSetNotification';
-import useShouldSpeakIncomingActivity from './useShouldSpeakIncomingActivity';
-import useStartDictate from './useStartDictate';
-import useStopDictate from './useStopDictate';
-import useStyleOptions from './useStyleOptions';
import useStyleSet from './useStyleSet';
-import useSubmitSendBox from './useSubmitSendBox';
-import useSuggestedActions from './useSuggestedActions';
-import useTimeoutForSend from './useTimeoutForSend';
-import useTrackDimension from './useTrackDimension';
-import useTrackEvent from './useTrackEvent';
-import useTrackException from './useTrackException';
-import useTrackTiming from './useTrackTiming';
-import useUserID from './useUserID';
-import useUsername from './useUsername';
-import useVoiceSelector from './useVoiceSelector';
import useWebSpeechPonyfill from './useWebSpeechPonyfill';
import { useMicrophoneButtonClick, useMicrophoneButtonDisabled } from '../SendBox/MicrophoneButton';
@@ -73,78 +15,21 @@ import { useTextBoxSubmit, useTextBoxValue } from '../SendBox/TextBox';
import { useTypingIndicatorVisible } from '../BasicTypingIndicator';
export {
- useActiveTyping,
- useActivities,
- useAvatarForBot,
- useAvatarForUser,
- useByteFormatter,
- useConnectivityStatus,
- useCreateActivityRenderer,
- useCreateActivityStatusRenderer,
- useCreateAttachmentForScreenReaderRenderer,
- useCreateAvatarRenderer,
- useDateFormatter,
- useDebouncedNotifications,
- useDictateInterims,
- useDictateState,
- useDirection,
- useDisabled,
- useDismissNotification,
- useEmitTypingIndicator,
+ useDictateAbortable,
useFocus,
useFocusSendBox,
- useGetSendTimeoutForActivity,
- useGrammars,
- useGroupTimestamp,
- useLanguage,
- useLastTypingAt,
- useLocalize,
- useLocalizeDate,
- useLocalizer,
- useMarkActivityAsSpoken,
useMicrophoneButtonClick,
useMicrophoneButtonDisabled,
useObserveScrollPosition,
- usePerformCardAction,
- usePostActivity,
- useReferenceGrammarID,
- useRelativeTimeFormatter,
- useRenderActivity,
- useRenderActivityStatus,
- useRenderAttachment,
- useRenderAvatar,
useRenderMarkdownAsHTML,
- useRenderToast,
- useRenderTypingIndicator,
useScrollTo,
useScrollToEnd,
useSendBoxSpeechInterimsVisible,
- useSendBoxValue,
- useSendEvent,
+ // We are overwriting the `useSendFiles` hook from bf-wc-api and adding thumbnailing support.
useSendFiles,
- useSendMessage,
- useSendMessageBack,
- useSendPostBack,
- useSendTimeoutForActivity,
- useSendTypingIndicator,
- useSetNotification,
- useShouldSpeakIncomingActivity,
- useStartDictate,
- useStopDictate,
- useStyleOptions,
useStyleSet,
- useSubmitSendBox,
- useSuggestedActions,
useTextBoxSubmit,
useTextBoxValue,
- useTimeoutForSend,
- useTrackDimension,
- useTrackEvent,
- useTrackException,
- useTrackTiming,
useTypingIndicatorVisible,
- useUserID,
- useUsername,
- useVoiceSelector,
useWebSpeechPonyfill
};
diff --git a/packages/component/src/Speech/BypassSpeechSynthesisPonyfill.js b/packages/component/src/hooks/internal/BypassSpeechSynthesisPonyfill.js
similarity index 100%
rename from packages/component/src/Speech/BypassSpeechSynthesisPonyfill.js
rename to packages/component/src/hooks/internal/BypassSpeechSynthesisPonyfill.js
diff --git a/packages/component/src/hooks/internal/UITracker.js b/packages/component/src/hooks/internal/UITracker.js
new file mode 100644
index 0000000000..ff8afb4366
--- /dev/null
+++ b/packages/component/src/hooks/internal/UITracker.js
@@ -0,0 +1,30 @@
+import { hooks } from 'botframework-webchat-api';
+import { useEffect } from 'react';
+
+import { checkSupport as supportWorker } from '../../Utils/downscaleImageToDataURL/downscaleImageToDataURLUsingWorker';
+import { speechSynthesis } from './BypassSpeechSynthesisPonyfill';
+import useWebSpeechPonyfill from '../useWebSpeechPonyfill';
+
+const { useTrackDimension } = hooks;
+
+const Tracker = () => {
+ const [webSpeechPonyfill] = useWebSpeechPonyfill();
+ const trackDimension = useTrackDimension();
+
+ const speechRecognitionCapability = !!webSpeechPonyfill.SpeechRecognition;
+ const speechSynthesisCapability =
+ webSpeechPonyfill.speechSynthesis && webSpeechPonyfill.speechSynthesis !== speechSynthesis;
+
+ useEffect(() => {
+ trackDimension('capability:downscaleImage:workerType', supportWorker() ? 'web worker' : 'main');
+ trackDimension('capability:renderer', 'html');
+
+ // TODO: [P2] #2937 Differentiate between Cognitive Services and browser speech
+ trackDimension('prop:speechRecognition', !!speechRecognitionCapability + '');
+ trackDimension('prop:speechSynthesis', !!speechSynthesisCapability + '');
+ }, [trackDimension, speechRecognitionCapability, speechSynthesisCapability]);
+
+ return false;
+};
+
+export default Tracker;
diff --git a/packages/component/src/hooks/internal/WebChatUIContext.js b/packages/component/src/hooks/internal/WebChatUIContext.js
new file mode 100644
index 0000000000..bcfb4e6924
--- /dev/null
+++ b/packages/component/src/hooks/internal/WebChatUIContext.js
@@ -0,0 +1,5 @@
+import { createContext } from 'react';
+
+const context = createContext();
+
+export default context;
diff --git a/packages/component/src/hooks/internal/useDirFromProps.js b/packages/component/src/hooks/internal/useDirFromProps.js
deleted file mode 100644
index 1eaa09b034..0000000000
--- a/packages/component/src/hooks/internal/useDirFromProps.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './useWebChatUIContext';
-
-export default function useDirFromProps() {
- return [useWebChatUIContext().dir];
-}
diff --git a/packages/component/src/hooks/internal/useDisableOnBlurEffect.js b/packages/component/src/hooks/internal/useDisableOnBlurEffect.js
deleted file mode 100644
index f2bf2ffee7..0000000000
--- a/packages/component/src/hooks/internal/useDisableOnBlurEffect.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import { useEffect } from 'react';
-
-// Because different browser handling disabled-but-focused UI different, we are implementing a more general solution.
-// When the button is being disabled:
-// - If it is not currently focused, we will set "disabled";
-// - If it is currently focused, we will not set "disabled" until it is blurred (focus moved away).
-function disableElement(element) {
- element.setAttribute('disabled', 'disabled');
-}
-
-export default function useDisableOnBlurEffect(targetRef, disabled) {
- useEffect(() => {
- if (disabled) {
- const { current } = targetRef;
-
- if (current) {
- if (document.activeElement !== current) {
- current.setAttribute('disabled', 'disabled');
-
- return () => current.removeAttribute('disabled');
- }
-
- const blurHandler = disableElement.bind(null, current);
-
- current.addEventListener('blur', blurHandler);
-
- return () => {
- current.removeAttribute('disabled');
- current.removeEventListener('blur', blurHandler);
- };
- }
- }
- }, [disabled, targetRef]);
-}
diff --git a/packages/component/src/hooks/internal/useLocalizeAccessKey.js b/packages/component/src/hooks/internal/useLocalizeAccessKey.js
index 80c67ee6ae..e533b09fa7 100644
--- a/packages/component/src/hooks/internal/useLocalizeAccessKey.js
+++ b/packages/component/src/hooks/internal/useLocalizeAccessKey.js
@@ -1,8 +1,10 @@
import { useCallback } from 'react';
+import { hooks } from 'botframework-webchat-api';
-import useLocalizer from './../useLocalizer';
import useNavigatorPlatform from './useNavigatorPlatform';
+const { useLocalizer } = hooks;
+
export default function useLocalizeAccessKey() {
const [{ apple }] = useNavigatorPlatform();
const localize = useLocalizer();
diff --git a/packages/component/src/hooks/internal/useLocalizedGlobalize.js b/packages/component/src/hooks/internal/useLocalizedGlobalize.js
deleted file mode 100644
index 2aea086720..0000000000
--- a/packages/component/src/hooks/internal/useLocalizedGlobalize.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './useWebChatUIContext';
-
-export default function useLocalizedGlobalize() {
- return useWebChatUIContext().localizedGlobalizeState;
-}
diff --git a/packages/component/src/hooks/internal/useLocalizedStrings.js b/packages/component/src/hooks/internal/useLocalizedStrings.js
deleted file mode 100644
index d62d6a4ce9..0000000000
--- a/packages/component/src/hooks/internal/useLocalizedStrings.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import useWebChatUIContext from './useWebChatUIContext';
-
-export default function useLocalizedStrings() {
- const { localizedStrings } = useWebChatUIContext();
-
- return localizedStrings;
-}
diff --git a/packages/component/src/hooks/internal/useMarkActivity.js b/packages/component/src/hooks/internal/useMarkActivity.js
deleted file mode 100644
index 6c421b9635..0000000000
--- a/packages/component/src/hooks/internal/useMarkActivity.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './useWebChatUIContext';
-
-export default function useMarkActivity() {
- return useWebChatUIContext().markActivity;
-}
diff --git a/packages/component/src/hooks/internal/useReplaceEmoticon.js b/packages/component/src/hooks/internal/useReplaceEmoticon.js
index 3b653edcdb..6ca582a793 100644
--- a/packages/component/src/hooks/internal/useReplaceEmoticon.js
+++ b/packages/component/src/hooks/internal/useReplaceEmoticon.js
@@ -1,8 +1,9 @@
/*eslint require-unicode-regexp: "off" */
+import { hooks } from 'botframework-webchat-api';
import { useCallback } from 'react';
-import useStyleOptions from '../useStyleOptions';
+const { useStyleOptions } = hooks;
export default function useReplaceEmoticon() {
const [{ emojiSet }] = useStyleOptions();
diff --git a/packages/component/src/hooks/internal/useSetDictateState.js b/packages/component/src/hooks/internal/useSetDictateState.js
deleted file mode 100644
index 40042b6110..0000000000
--- a/packages/component/src/hooks/internal/useSetDictateState.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './useWebChatUIContext';
-
-export default function useSetDictateState() {
- return useWebChatUIContext().setDictateState;
-}
diff --git a/packages/component/src/hooks/internal/useTracker.js b/packages/component/src/hooks/internal/useTracker.js
deleted file mode 100644
index 276d0047b2..0000000000
--- a/packages/component/src/hooks/internal/useTracker.js
+++ /dev/null
@@ -1,51 +0,0 @@
-import { useEffect } from 'react';
-
-import { checkSupport as supportWorker } from '../../Utils/downscaleImageToDataURLUsingWorker';
-import { speechSynthesis } from '../../Speech/BypassSpeechSynthesisPonyfill';
-import useLanguage from '../useLanguage';
-import useTrackDimension from '../useTrackDimension';
-import useTrackEvent from '../useTrackEvent';
-import useWebSpeechPonyfill from '../useWebSpeechPonyfill';
-
-function useTracker() {
- const [language] = useLanguage();
- const [webSpeechPonyfill] = useWebSpeechPonyfill();
- const trackDimension = useTrackDimension();
- const trackEvent = useTrackEvent();
-
- // TODO: [P2] #2937 Track how many of them customized the following:
- // - activityMiddleware
- // - activityStatusMiddleware
- // - attachmentMiddleware
- // - cardActionMiddleware
- // - toastMiddleware
- // - styleOptions
-
- const speechRecognitionCapability = !!webSpeechPonyfill.SpeechRecognition;
- const speechSynthesisCapability =
- webSpeechPonyfill.speechSynthesis && webSpeechPonyfill.speechSynthesis !== speechSynthesis;
-
- useEffect(() => {
- trackDimension('prop:locale', language);
- }, [language, trackDimension]);
-
- useEffect(() => {
- // TODO: [P2] #2937 Differentiate between Cognitive Services and browser speech
- trackDimension('prop:speechRecognition', !!speechRecognitionCapability + '');
- }, [trackDimension, speechRecognitionCapability]);
-
- useEffect(() => {
- // TODO: [P2] #2937 Differentiate between Cognitive Services and browser speech
- trackDimension('prop:speechSynthesis', !!speechSynthesisCapability + '');
- }, [trackDimension, speechSynthesisCapability]);
-
- useEffect(() => {
- trackDimension('capability:downscaleImage:workerType', supportWorker() ? 'web worker' : 'main');
- }, [trackDimension]);
-
- useEffect(() => {
- trackEvent('init');
- }, [trackEvent]);
-}
-
-export default useTracker;
diff --git a/packages/component/src/hooks/internal/useWebChatUIContext.js b/packages/component/src/hooks/internal/useWebChatUIContext.js
index 89797ee6b7..c33adb32b3 100644
--- a/packages/component/src/hooks/internal/useWebChatUIContext.js
+++ b/packages/component/src/hooks/internal/useWebChatUIContext.js
@@ -1,6 +1,6 @@
import { useContext } from 'react';
-import WebChatUIContext from '../../WebChatUIContext';
+import WebChatUIContext from './WebChatUIContext';
export default function useWebChatUIContext() {
const context = useContext(WebChatUIContext);
diff --git a/packages/component/src/hooks/useCreateAttachmentForScreenReaderRenderer.js b/packages/component/src/hooks/useCreateAttachmentForScreenReaderRenderer.js
deleted file mode 100644
index f945ec439c..0000000000
--- a/packages/component/src/hooks/useCreateAttachmentForScreenReaderRenderer.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useCreateAttachmentForScreenReaderRenderer() {
- return useWebChatUIContext().createAttachmentForScreenReaderRenderer;
-}
diff --git a/packages/component/src/hooks/useDictateInterims.js b/packages/component/src/hooks/useDictateInterims.js
deleted file mode 100644
index 41bd858e67..0000000000
--- a/packages/component/src/hooks/useDictateInterims.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import { useSelector } from '../WebChatReduxContext';
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useDictateInterims() {
- return [useSelector(({ dictateInterims }) => dictateInterims) || [], useWebChatUIContext().setDictateInterims];
-}
diff --git a/packages/component/src/hooks/useDisabled.js b/packages/component/src/hooks/useDisabled.js
deleted file mode 100644
index 998aa26b7c..0000000000
--- a/packages/component/src/hooks/useDisabled.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useDisabled() {
- return [useWebChatUIContext().disabled];
-}
diff --git a/packages/component/src/hooks/useDismissNotification.js b/packages/component/src/hooks/useDismissNotification.js
deleted file mode 100644
index b5b7b9606f..0000000000
--- a/packages/component/src/hooks/useDismissNotification.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useDismissNotification() {
- return useWebChatUIContext().dismissNotification;
-}
diff --git a/packages/component/src/hooks/useEmitTypingIndicator.js b/packages/component/src/hooks/useEmitTypingIndicator.js
deleted file mode 100644
index 8407033d07..0000000000
--- a/packages/component/src/hooks/useEmitTypingIndicator.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useEmitTypingIndicator() {
- return useWebChatUIContext().emitTypingIndicator;
-}
diff --git a/packages/component/src/hooks/useGrammars.js b/packages/component/src/hooks/useGrammars.js
deleted file mode 100644
index 9c40af3436..0000000000
--- a/packages/component/src/hooks/useGrammars.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useGrammars() {
- return [useWebChatUIContext().grammars];
-}
diff --git a/packages/component/src/hooks/useGroupActivities.js b/packages/component/src/hooks/useGroupActivities.js
deleted file mode 100644
index 766572d070..0000000000
--- a/packages/component/src/hooks/useGroupActivities.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useGroupActivities() {
- return useWebChatUIContext().groupActivities;
-}
diff --git a/packages/component/src/hooks/usePerformCardAction.js b/packages/component/src/hooks/usePerformCardAction.js
deleted file mode 100644
index b2b55b5b5b..0000000000
--- a/packages/component/src/hooks/usePerformCardAction.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function usePerformCardAction() {
- return useWebChatUIContext().onCardAction;
-}
diff --git a/packages/component/src/hooks/usePostActivity.js b/packages/component/src/hooks/usePostActivity.js
deleted file mode 100644
index 424f009352..0000000000
--- a/packages/component/src/hooks/usePostActivity.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function usePostActivity() {
- return useWebChatUIContext().postActivity;
-}
diff --git a/packages/component/src/hooks/useRenderAttachment.js b/packages/component/src/hooks/useRenderAttachment.js
deleted file mode 100644
index 85b0d4bc1e..0000000000
--- a/packages/component/src/hooks/useRenderAttachment.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useRenderAttachment() {
- return useWebChatUIContext().attachmentRenderer;
-}
diff --git a/packages/component/src/hooks/useRenderMarkdownAsHTML.js b/packages/component/src/hooks/useRenderMarkdownAsHTML.js
index 250270429a..c82eb24ab8 100644
--- a/packages/component/src/hooks/useRenderMarkdownAsHTML.js
+++ b/packages/component/src/hooks/useRenderMarkdownAsHTML.js
@@ -1,8 +1,10 @@
+import { hooks } from 'botframework-webchat-api';
import { useMemo } from 'react';
-import useStyleOptions from '../hooks/useStyleOptions';
import useWebChatUIContext from './internal/useWebChatUIContext';
+const { useStyleOptions } = hooks;
+
export default function useRenderMarkdownAsHTML() {
const { renderMarkdown } = useWebChatUIContext();
const [styleOptions] = useStyleOptions();
diff --git a/packages/component/src/hooks/useRenderToast.js b/packages/component/src/hooks/useRenderToast.js
deleted file mode 100644
index c58aa2b571..0000000000
--- a/packages/component/src/hooks/useRenderToast.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useRenderToast() {
- return useWebChatUIContext().toastRenderer;
-}
diff --git a/packages/component/src/hooks/useRenderTypingIndicator.js b/packages/component/src/hooks/useRenderTypingIndicator.js
deleted file mode 100644
index a7fb615bce..0000000000
--- a/packages/component/src/hooks/useRenderTypingIndicator.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useRenderTypingIndicator() {
- return useWebChatUIContext().typingIndicatorRenderer;
-}
diff --git a/packages/component/src/hooks/useSendBoxValue.js b/packages/component/src/hooks/useSendBoxValue.js
deleted file mode 100644
index a0f7996155..0000000000
--- a/packages/component/src/hooks/useSendBoxValue.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import { useSelector } from '../WebChatReduxContext';
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useSendBoxValue() {
- return [useSelector(({ sendBoxValue }) => sendBoxValue), useWebChatUIContext().setSendBox];
-}
diff --git a/packages/component/src/hooks/useSendEvent.js b/packages/component/src/hooks/useSendEvent.js
deleted file mode 100644
index 5b0cd5917c..0000000000
--- a/packages/component/src/hooks/useSendEvent.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useSendEvent() {
- return useWebChatUIContext().sendEvent;
-}
diff --git a/packages/component/src/hooks/useSendFiles.js b/packages/component/src/hooks/useSendFiles.js
index 989930f2d8..f369cde835 100644
--- a/packages/component/src/hooks/useSendFiles.js
+++ b/packages/component/src/hooks/useSendFiles.js
@@ -1,12 +1,11 @@
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1024] }] */
+import { hooks } from 'botframework-webchat-api';
import { useCallback } from 'react';
-import downscaleImageToDataURL from '../Utils/downscaleImageToDataURL';
-import useStyleOptions from '../hooks/useStyleOptions';
-import useTrackEvent from '../hooks/useTrackEvent';
-import useTrackTiming from '../hooks/useTrackTiming';
-import useWebChatUIContext from './internal/useWebChatUIContext';
+import downscaleImageToDataURL from '../Utils/downscaleImageToDataURL/index';
+
+const { useSendFiles: useAPISendFiles, useStyleOptions, useTrackTiming } = hooks;
function canMakeThumbnail({ name }) {
return /\.(gif|jpe?g|png)$/iu.test(name);
@@ -21,7 +20,7 @@ async function makeThumbnail(file, width, height, contentType, quality) {
}
export default function useSendFiles() {
- const { sendFiles } = useWebChatUIContext();
+ const sendFiles = useAPISendFiles();
const [
{
enableUploadThumbnail,
@@ -31,7 +30,6 @@ export default function useSendFiles() {
uploadThumbnailWidth
}
] = useStyleOptions();
- const trackEvent = useTrackEvent();
const trackTiming = useTrackTiming();
return useCallback(
@@ -46,7 +44,7 @@ export default function useSendFiles() {
[].map.call(files, async file => {
let thumbnail;
- if (enableUploadThumbnail && canMakeThumbnail(file)) {
+ if (downscaleImageToDataURL && enableUploadThumbnail && canMakeThumbnail(file)) {
thumbnail = await trackTiming(
'sendFiles:makeThumbnail',
makeThumbnail(
@@ -69,17 +67,11 @@ export default function useSendFiles() {
);
sendFiles(attachments);
-
- trackEvent('sendFiles', {
- numFiles: files.length,
- sumSizeInKB: Math.round(files.reduce((total, { size }) => total + size, 0) / 1024)
- });
}
},
[
enableUploadThumbnail,
sendFiles,
- trackEvent,
trackTiming,
uploadThumbnailContentType,
uploadThumbnailHeight,
diff --git a/packages/component/src/hooks/useSendMessage.js b/packages/component/src/hooks/useSendMessage.js
deleted file mode 100644
index 9fc76ce578..0000000000
--- a/packages/component/src/hooks/useSendMessage.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useSendMessage() {
- return useWebChatUIContext().sendMessage;
-}
diff --git a/packages/component/src/hooks/useSendMessageBack.js b/packages/component/src/hooks/useSendMessageBack.js
deleted file mode 100644
index cab2adf271..0000000000
--- a/packages/component/src/hooks/useSendMessageBack.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useSendMessageBack() {
- return useWebChatUIContext().sendMessageBack;
-}
diff --git a/packages/component/src/hooks/useSendPostBack.js b/packages/component/src/hooks/useSendPostBack.js
deleted file mode 100644
index 3c8ae82a3a..0000000000
--- a/packages/component/src/hooks/useSendPostBack.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useSendPostBack() {
- return useWebChatUIContext().sendPostBack;
-}
diff --git a/packages/component/src/hooks/useSetNotification.js b/packages/component/src/hooks/useSetNotification.js
deleted file mode 100644
index 5c98e252db..0000000000
--- a/packages/component/src/hooks/useSetNotification.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useSetNotification() {
- return useWebChatUIContext().setNotification;
-}
diff --git a/packages/component/src/hooks/useStartDictate.js b/packages/component/src/hooks/useStartDictate.js
deleted file mode 100644
index d239864cb9..0000000000
--- a/packages/component/src/hooks/useStartDictate.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useStartDictate() {
- return useWebChatUIContext().startDictate;
-}
diff --git a/packages/component/src/hooks/useStopDictate.js b/packages/component/src/hooks/useStopDictate.js
deleted file mode 100644
index 755c39bd43..0000000000
--- a/packages/component/src/hooks/useStopDictate.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useStopDictate() {
- return useWebChatUIContext().stopDictate;
-}
diff --git a/packages/component/src/hooks/useStyleOptions.js b/packages/component/src/hooks/useStyleOptions.js
deleted file mode 100644
index 7370332786..0000000000
--- a/packages/component/src/hooks/useStyleOptions.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import useStyleSet from './useStyleSet';
-
-export default function useStyleOptions() {
- // Today, the "styleSet.options" is patched with missing values and "styleOptions" are unpatched.
- // Thus, we are using the "styleSet.options" version for now.
-
- return [useStyleSet()[0].options];
-}
diff --git a/packages/component/src/hooks/useTrackDimension.js b/packages/component/src/hooks/useTrackDimension.js
deleted file mode 100644
index a5c0c1480f..0000000000
--- a/packages/component/src/hooks/useTrackDimension.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useTrackDimension() {
- const { trackDimension } = useWebChatUIContext();
-
- return trackDimension;
-}
diff --git a/packages/component/src/hooks/useUserID.js b/packages/component/src/hooks/useUserID.js
deleted file mode 100644
index b081469fc4..0000000000
--- a/packages/component/src/hooks/useUserID.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useUserID() {
- return [useWebChatUIContext().userID];
-}
diff --git a/packages/component/src/hooks/useUsername.js b/packages/component/src/hooks/useUsername.js
deleted file mode 100644
index 80c67e277a..0000000000
--- a/packages/component/src/hooks/useUsername.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import useWebChatUIContext from './internal/useWebChatUIContext';
-
-export default function useUsername() {
- return [useWebChatUIContext().username];
-}
diff --git a/packages/component/src/index.tsx b/packages/component/src/index.tsx
index 9679c797ad..36f4848890 100644
--- a/packages/component/src/index.tsx
+++ b/packages/component/src/index.tsx
@@ -7,7 +7,6 @@ import BasicWebChat from './BasicWebChat';
import Avatar from './Activity/Avatar';
import Bubble from './Activity/Bubble';
import ErrorBox from './ErrorBox';
-import Localize, { localize } from './Localization/Localize';
import SendStatus, { connectSendStatus } from './Middleware/ActivityStatus/SendStatus/SendStatus';
import SpeakActivity, { connectSpeakActivity } from './Activity/Speak';
import Timestamp from './Middleware/ActivityStatus/Timestamp';
@@ -28,9 +27,8 @@ import SendTextBox, { connectSendTextBox } from './SendBox/TextBox';
import SuggestedActions, { connectSuggestedActions } from './SendBox/SuggestedActions';
import UploadButton, { connectUploadButton } from './SendBox/UploadButton';
-import concatMiddleware from './Middleware/concatMiddleware';
import connectToWebChat from './connectToWebChat';
-import Context from './WebChatUIContext';
+import Context from './hooks/internal/WebChatUIContext';
import createCoreActivityMiddleware from './Middleware/Activity/createCoreMiddleware';
import createCoreActivityStatusMiddleware from './Middleware/ActivityStatus/createCoreMiddleware';
import createCoreAttachmentMiddleware from './Middleware/Attachment/createCoreMiddleware';
@@ -38,7 +36,13 @@ import createStyleSet from './Styles/createStyleSet';
import defaultStyleOptions from './Styles/defaultStyleOptions';
import getTabIndex from './Utils/TypeFocusSink/getTabIndex';
-import * as hooks from './hooks/index';
+import { concatMiddleware, hooks as apiHooks, Localize, localize } from 'botframework-webchat-api';
+import * as componentHooks from './hooks/index';
+
+const hooks = {
+ ...apiHooks,
+ ...componentHooks
+};
const version = process.env.npm_package_version;
diff --git a/packages/core/src/sagas/postActivitySaga.js b/packages/core/src/sagas/postActivitySaga.js
index 85f5ab172b..23f0d6e819 100644
--- a/packages/core/src/sagas/postActivitySaga.js
+++ b/packages/core/src/sagas/postActivitySaga.js
@@ -82,7 +82,7 @@ function* postActivity(directLine, userID, username, numActivitiesPosted, { meta
// Quirks: We might receive INCOMING_ACTIVITY before the postActivity call completed
// So, we setup expectation first, then postActivity afterward
- const echoBackCall = call(function*() {
+ const echoBackCall = call(function* () {
for (;;) {
const {
payload: { activity }
@@ -114,6 +114,8 @@ function* postActivity(directLine, userID, username, numActivitiesPosted, { meta
yield put({ type: POST_ACTIVITY_FULFILLED, meta, payload: { activity: echoBack } });
} catch (err) {
+ console.error('botframework-webchat: Failed to post activity to chat adapter.', err);
+
yield put({ type: POST_ACTIVITY_REJECTED, error: true, meta, payload: err });
} finally {
if (yield cancelled()) {
diff --git a/packages/directlinespeech/src/DirectLineSpeech.js b/packages/directlinespeech/src/DirectLineSpeech.js
index 0b2603cdb4..5560304937 100644
--- a/packages/directlinespeech/src/DirectLineSpeech.js
+++ b/packages/directlinespeech/src/DirectLineSpeech.js
@@ -84,7 +84,9 @@ export default class DirectLineSpeech {
// Do not send the activity if it was from speech.
if (!isSpeech) {
- this.dialogServiceConnector.sendActivityAsync(activity);
+ // Starting from Speech SDK 1.13.0, they accept JSON text instead of JavaScript object.
+ // https://github.com/microsoft/cognitive-services-speech-sdk-js/commit/2f3a35446692b6d492a6c68e3237a48de67e293f
+ this.dialogServiceConnector.sendActivityAsync(JSON.stringify(activity));
}
this._activityObserver &&