Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"env": {
"test": {
"plugins": [
"babel-plugin-istanbul"
]
}
},
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-runtime"
],
"presets": [
"@babel/preset-typescript",
["@babel/preset-env", {
"forceAllTransforms": true,
"modules": "commonjs"
}]
]
}
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*]
charset=utf-8
insert_final_newline=true
indent_style=space
indent_size=2
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules
built
.vscode
/directLine.js
/directLine.js.map
/.idea
/built
/node_modules

npm-debug.log
/directLine.js
/directLine-instrumented.js
/stats.html
58 changes: 32 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
language: node_js
node_js:
- "10"
before_script:
- npx version-from-git --travis --no-git-tag-version
- npm run build
- "10"

before_install:
- npm ci
- npx version-from-git --travis

install:
- npm run prepublishOnly

deploy:
# Since we are using Lerna without hoist (conflict between babel@6 and babel@7), thus, we cannot use npm provider to deploy
- provider: npm
api_key:
secure: "W24mXQs7PztN6beyuVo2tLap4Lzu/xwWYocWg+HCOh8P86rlHpNSAZ3vU1QxuFTApaykimenE2m8Q62nz9wcCc++BvTZ1N5bDH63nzPF/KAnF/AHS2V0Rqc6BirMWQz9JmirnFpOCkaiQsewcG/5SyGriXqVfQixipjMRnqzcIP91wIRz+V71bqJRqiKwjT4Cg5Om6p5xTsw1mTMutPywNVcPPk7FcfxLAVG3aV/h1PbR+V4MWKHQUm6lUjZDSVpQ3VOJtb3+h7TMQIe9Z9YEms1S7Wyul0Qbw2bp3CY84voVnw+yksrfPMbrqTs6fzxkzfmz4m/t8PFRs6AKU0FVo+01A0Nev2kQurJfutZiOuNraTcItqwB1W0DvYL+fKdWiAFU/DEMVUDac2FEjC6HSqUGe5KSAih+WHXC2ovxc0AoeIDAw1HenxsPnJpNPda3zkos8TuqFAU7VTiqEE/P/CqvKNIum8WaG2qDIm4wBa0YcjGiN/c1+2E9MbI2geP/v94JUu7+TcYTrDOmI+4sw2fTBG+0oVv7f6bPDKTv0gwJCLcXTntlv4bKeqmTsOJD/CcNVzbutCMFL9y6Xlw/fMj+BJ+9G3yFsYFAc65erjmjc9En0lIF1MV75TKdlaD/moEjzTyguyRlWRatVzSMrgBa+uwtxwoEFK9GrWyJOQ="
email: "botframework@microsoft.com"
on:
branch: master
skip_cleanup: true
tag: master
- provider: npm
api_key:
secure: "W24mXQs7PztN6beyuVo2tLap4Lzu/xwWYocWg+HCOh8P86rlHpNSAZ3vU1QxuFTApaykimenE2m8Q62nz9wcCc++BvTZ1N5bDH63nzPF/KAnF/AHS2V0Rqc6BirMWQz9JmirnFpOCkaiQsewcG/5SyGriXqVfQixipjMRnqzcIP91wIRz+V71bqJRqiKwjT4Cg5Om6p5xTsw1mTMutPywNVcPPk7FcfxLAVG3aV/h1PbR+V4MWKHQUm6lUjZDSVpQ3VOJtb3+h7TMQIe9Z9YEms1S7Wyul0Qbw2bp3CY84voVnw+yksrfPMbrqTs6fzxkzfmz4m/t8PFRs6AKU0FVo+01A0Nev2kQurJfutZiOuNraTcItqwB1W0DvYL+fKdWiAFU/DEMVUDac2FEjC6HSqUGe5KSAih+WHXC2ovxc0AoeIDAw1HenxsPnJpNPda3zkos8TuqFAU7VTiqEE/P/CqvKNIum8WaG2qDIm4wBa0YcjGiN/c1+2E9MbI2geP/v94JUu7+TcYTrDOmI+4sw2fTBG+0oVv7f6bPDKTv0gwJCLcXTntlv4bKeqmTsOJD/CcNVzbutCMFL9y6Xlw/fMj+BJ+9G3yFsYFAc65erjmjc9En0lIF1MV75TKdlaD/moEjzTyguyRlWRatVzSMrgBa+uwtxwoEFK9GrWyJOQ="
email: "botframework@microsoft.com"
on:
tags: true
skip_cleanup: true
- provider: releases
api_key:
secure: "KauO88Sy2l65xZl5zWgj3YB8wyEV/xfio6yFzTjCTKTqJ+TTfyRzRCsD0fvfMqX+jT90o48dvLvhtw3aOyBmN6zA4o+YsOKFQwa4881gdtJDAv0hLhW6h3CkT+zlbTfIGyLAfQDNyLFDo0VSKKaQ6h/gRp1kgfiFWmisfaDgYRkAyPsC3hhjV66TgCoMbBW+jyqJhvgxTKwJTRuond5/vu4JANd/Emdmn1AqKQoIzVDSJ76sSQIq+tu+kUm/jYm4wO+suLeI69EovRIcS9SPV52N7hiMDAP1eRlOCeNXiB4vIsbShVtJhiFjXBh8fmwVXhV/eSmk1Anqmqt3KVoFwN92yRpC0dLZDzMlUqUQ2yTOKrYSXKoZBYKeHVhDPiztxOi3yWrAh8owA1TnRLt/6GC9pCHS1Xv2eechzdZ7IhXOkDm2GK8uyH1io6xHAdfhCvXTwH3CrQtt7qZrdPFYG2cq4UEdzGVI+PEx3revGCmCtwsZRJ0n1P5TSpEJmtUYkcz26YqfIAoh1KNT2LRWBaZv5dDBxQ49aAua4O79l5+6He9dilt7R+sNGOLO0JXBJylZUH/FfkKe9bPNuVCITLPu18llL73z7DKBq/qQLkmc2FLmLzq8nSZbu7Gq5VWNYuuvNl5w0ljqaV+PaDYaogntdkR6RukBklJ9fasQCHs="
on:
tags: true
skip_cleanup: true
- provider: npm
api_key:
secure: "W24mXQs7PztN6beyuVo2tLap4Lzu/xwWYocWg+HCOh8P86rlHpNSAZ3vU1QxuFTApaykimenE2m8Q62nz9wcCc++BvTZ1N5bDH63nzPF/KAnF/AHS2V0Rqc6BirMWQz9JmirnFpOCkaiQsewcG/5SyGriXqVfQixipjMRnqzcIP91wIRz+V71bqJRqiKwjT4Cg5Om6p5xTsw1mTMutPywNVcPPk7FcfxLAVG3aV/h1PbR+V4MWKHQUm6lUjZDSVpQ3VOJtb3+h7TMQIe9Z9YEms1S7Wyul0Qbw2bp3CY84voVnw+yksrfPMbrqTs6fzxkzfmz4m/t8PFRs6AKU0FVo+01A0Nev2kQurJfutZiOuNraTcItqwB1W0DvYL+fKdWiAFU/DEMVUDac2FEjC6HSqUGe5KSAih+WHXC2ovxc0AoeIDAw1HenxsPnJpNPda3zkos8TuqFAU7VTiqEE/P/CqvKNIum8WaG2qDIm4wBa0YcjGiN/c1+2E9MbI2geP/v94JUu7+TcYTrDOmI+4sw2fTBG+0oVv7f6bPDKTv0gwJCLcXTntlv4bKeqmTsOJD/CcNVzbutCMFL9y6Xlw/fMj+BJ+9G3yFsYFAc65erjmjc9En0lIF1MV75TKdlaD/moEjzTyguyRlWRatVzSMrgBa+uwtxwoEFK9GrWyJOQ="
email: "botframework@microsoft.com"
on:
branch: master
skip_cleanup: true
tag: master

- provider: npm
api_key:
secure: "W24mXQs7PztN6beyuVo2tLap4Lzu/xwWYocWg+HCOh8P86rlHpNSAZ3vU1QxuFTApaykimenE2m8Q62nz9wcCc++BvTZ1N5bDH63nzPF/KAnF/AHS2V0Rqc6BirMWQz9JmirnFpOCkaiQsewcG/5SyGriXqVfQixipjMRnqzcIP91wIRz+V71bqJRqiKwjT4Cg5Om6p5xTsw1mTMutPywNVcPPk7FcfxLAVG3aV/h1PbR+V4MWKHQUm6lUjZDSVpQ3VOJtb3+h7TMQIe9Z9YEms1S7Wyul0Qbw2bp3CY84voVnw+yksrfPMbrqTs6fzxkzfmz4m/t8PFRs6AKU0FVo+01A0Nev2kQurJfutZiOuNraTcItqwB1W0DvYL+fKdWiAFU/DEMVUDac2FEjC6HSqUGe5KSAih+WHXC2ovxc0AoeIDAw1HenxsPnJpNPda3zkos8TuqFAU7VTiqEE/P/CqvKNIum8WaG2qDIm4wBa0YcjGiN/c1+2E9MbI2geP/v94JUu7+TcYTrDOmI+4sw2fTBG+0oVv7f6bPDKTv0gwJCLcXTntlv4bKeqmTsOJD/CcNVzbutCMFL9y6Xlw/fMj+BJ+9G3yFsYFAc65erjmjc9En0lIF1MV75TKdlaD/moEjzTyguyRlWRatVzSMrgBa+uwtxwoEFK9GrWyJOQ="
email: "botframework@microsoft.com"
on:
tags: true
skip_cleanup: true

- provider: releases
api_key:
secure: "KauO88Sy2l65xZl5zWgj3YB8wyEV/xfio6yFzTjCTKTqJ+TTfyRzRCsD0fvfMqX+jT90o48dvLvhtw3aOyBmN6zA4o+YsOKFQwa4881gdtJDAv0hLhW6h3CkT+zlbTfIGyLAfQDNyLFDo0VSKKaQ6h/gRp1kgfiFWmisfaDgYRkAyPsC3hhjV66TgCoMbBW+jyqJhvgxTKwJTRuond5/vu4JANd/Emdmn1AqKQoIzVDSJ76sSQIq+tu+kUm/jYm4wO+suLeI69EovRIcS9SPV52N7hiMDAP1eRlOCeNXiB4vIsbShVtJhiFjXBh8fmwVXhV/eSmk1Anqmqt3KVoFwN92yRpC0dLZDzMlUqUQ2yTOKrYSXKoZBYKeHVhDPiztxOi3yWrAh8owA1TnRLt/6GC9pCHS1Xv2eechzdZ7IhXOkDm2GK8uyH1io6xHAdfhCvXTwH3CrQtt7qZrdPFYG2cq4UEdzGVI+PEx3revGCmCtwsZRJ0n1P5TSpEJmtUYkcz26YqfIAoh1KNT2LRWBaZv5dDBxQ49aAua4O79l5+6He9dilt7R+sNGOLO0JXBJylZUH/FfkKe9bPNuVCITLPu18llL73z7DKBq/qQLkmc2FLmLzq8nSZbu7Gq5VWNYuuvNl5w0ljqaV+PaDYaogntdkR6RukBklJ9fasQCHs="
on:
tags: true
skip_cleanup: true
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.tabSize": 2,
"editor.trimAutoWhitespace": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"search.exclude": {
"lib": true
}
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
-->

## [Unreleased]
### Changed
- Used `@babel/preset-typescript` and `webpack@4` to build, in PR [#156](https://github.com/Microsoft/BotFramework-DirectLineJS/pull/156)
- Moved to inline source map for pre-bundle
- Added `.editorconfig` and `.vscode` for new line and tab size rules

## [0.11.1] - 2019-01-31
### Fixed
Expand Down
39 changes: 39 additions & 0 deletions __tests__/createConversation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/// <reference path="../node_modules/@types/jest/index.d.ts" />

import createServer from './setup/createServer';
import { ConnectionStatus, DirectLine } from '../src/directLine';

const conversationId = Math.random();

test('Create conversation should set conversation ID', async () => {
const { dispose, port, promises } = await createServer({
playbacks: [{
req: { method: 'POST', url: '/v3/directline/conversations' },
res: { body: {
conversationId: conversationId
} }
}]
});

try {
const directLine = new DirectLine({
domain: `http://localhost:${ port }/v3/directline`,
webSocket: false
});

const subscription = directLine.activity$.subscribe(() => {});

await Promise.all([
promises[0],
new Promise(resolve => {
directLine.connectionStatus$.subscribe(value => value === ConnectionStatus.Online && resolve())
})
]);

expect(directLine).toHaveProperty('conversationId', conversationId);

subscription.unsubscribe();
} finally {
await dispose();
}
});
134 changes: 134 additions & 0 deletions __tests__/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<!DOCTYPE html>
<html>
<head>
<title>Direct Line JS</title>
<script src="/directLine.js"></script>
<!-- <script src="https://unpkg.com/botframework-directlinejs/directLine.js"></script> -->
<style type="text/css">
body {
font-family: Calibri, 'Helvetica Neue', Arial, sans-serif;
margin: 5px;
}

input {
box-sizing: border-box;
font-size: 2rem;
padding: 5px;
width: 100%;
}

input::placeholder {
color: #CCC;
}

ul#log {
list-style-type: none;
margin: 5px 0;
padding: 0;
}

ul#log > li {
border: solid 1px #CCC;
margin: 5px 0;
}

ul#log > li > * {
margin: 0;
padding: 5px;
}

ul#log > li > p:first-child {
background-color: #EEE;
}
</style>
</head>
<body>
<form>
<input
autofocus
placeholder="Type a message"
type="text"
value="Hello, World!"
/>
</form>
<ul id="log"></ul>
<script>
(async function () {
'use strict';

const { DirectLine } = window.DirectLine;
const searchParams = new URLSearchParams(location.search);
const secret = searchParams.get('s');
let token;

if (!secret) {
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });

token = (await res.json()).token;
}

const botConnection = new DirectLine({
domain: searchParams.get('domain'),
secret,
token
});

function log(...messages) {
const logElement = document.getElementById('log');
const entry = document.createElement('li');

messages.forEach(message => {
if (typeof message === 'string') {
const paragraphElement = document.createElement('p');

paragraphElement.innerText = message;
entry.appendChild(paragraphElement);
} else {
const preformattedElement = document.createElement('pre');

preformattedElement.innerText = JSON.stringify(message, null, 2);
entry.appendChild(preformattedElement);
}
});

logElement.appendChild(entry);
}

botConnection.activity$.subscribe({
next: activity => log(`Activity`, activity)
});

botConnection.connectionStatus$.subscribe({
next: connectionStatus => log('Connection status', connectionStatus)
});

document.getElementsByTagName('form')[0].addEventListener('submit', event => {
event.preventDefault();

const inputElement = document.getElementsByTagName('input')[0];
const { value } = inputElement;

if (value) {
inputElement.setAttribute('disabled', 'disabled');

botConnection.postActivity({
from: { id: 'direct-line-user' },
type: 'message',
value
}).subscribe(id => {
inputElement.removeAttribute('disabled');
inputElement.setAttribute('placeholder', id);
inputElement.value = '';
});
}
});

window.addEventListener('error', ({ error: { message, stack } }) => {
stack = stack.split('\n');

log('Uncaught error', { message, stack });
});
})().catch(console.error.bind(console));
</script>
</body>
</html>
23 changes: 23 additions & 0 deletions __tests__/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// <reference path="../node_modules/@types/jest/index.d.ts" />

import createServer from './setup/createServer';
import fetch from 'node-fetch';

test('setup correctly', () => {});

test('createServer setup correctly', async () => {
const { dispose, port } = await createServer({
playbacks: [{
req: { url: '/health.txt' },
res: { body: 'OK' }
}]
});

try {
const res = await fetch(`http://localhost:${ port }/health.txt`, {});

expect(res).toHaveProperty('ok', true);
} finally {
dispose();
}
});
Loading