Skip to content

Commit

Permalink
Merge pull request #348 from billba/master
Browse files Browse the repository at this point in the history
generate declarations automatically, not manually
  • Loading branch information
billba authored Feb 24, 2017
2 parents c4c8145 + 9928db9 commit 77a0f1f
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 66 deletions.
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ Include `botchat.css` and `botchat.js` in your website, e.g.:
</head>
<body>
<div id="bot"/>
<script src="https://unpkg.com/botframework-webchat/botchat.js"/>
<script src="https://unpkg.com/botframework-webchat/botchat.js"></script>
<script>
BotChat.App({
directLine: { secret: direct_line_secret },
user: { id: 'userid' }
user: { id: 'userid' },
bot: { id: 'botid' }
}, document.getElementById("bot"));
</script>
</body>
Expand Down Expand Up @@ -112,16 +113,14 @@ Different projects have different build strategies, yours may vary considerably
2. `npm install`
3. `npm run build` (to build on every change `npm run watch`, to build production `npm run prepublish`)

`npm run build`/`watch`/`prepublish` build the following:
This builds the following:

* `/built/*.js` files compiled from the TypeScript sources in `/src/*.js` - `/built/BotChat.js` is the root
* `/build/*.js.map` sourcemaps for easier debugging
* `/built/*.js` compiled from the TypeScript sources in `/src/*.js` - `/built/BotChat.js` is the root
* `/built/*.d.ts` declarations for TypeScript users - `/built/BotChat.d.ts` is the root
* `/built/*.js.map` sourcemaps for easier debugging
* `/botchat.js` webpacked UMD file containing all dependencies (React, Redux, RxJS, polyfills, etc.)

The following files are static (not built) but key:

* `/botchat.css`
* `/botchat.d.ts` (for TypeScript users)
`/botchat.css` is currently static, but in the future it may be built

## Customizing WebChat

Expand All @@ -146,8 +145,8 @@ Behavioral customization will require changing the TypeScript files in `/src`. A
* `Chat` is the top-level React component
* `App` creates a React application consists solely of `Chat`
* `Chat` largely follows the Redux architecture layed out in [this video series](https://egghead.io/lessons/javascript-redux-the-single-immutable-state-tree)
* To handle async side effects of Redux actions, `Chat` uses Epics from [redux-observable](https://redux-observable.js.org) - here's a [video introduction](https://www.youtube.com/watch?v=sF5-V-Szo0c)
* Underlying `redux-observable` (and also [DirectLineJS](https://github.com/microsoft/botframework-directlinejs)) is the `RxJS` library, which implements the Observable pattern for wrangling async. For better or for worse, a minimal grasp of `RxJS` is key to understanding WebChat's plumbing.
* To handle async side effects of Redux actions, `Chat` uses `Epic` from [redux-observable](https://redux-observable.js.org) - here's a [video introduction](https://www.youtube.com/watch?v=sF5-V-Szo0c)
* Underlying `redux-observable` (and also [DirectLineJS](https://github.com/microsoft/botframework-directlinejs)) is the `RxJS` library, which implements the Observable pattern for wrangling async. A minimal grasp of `RxJS` is key to understanding WebChat's plumbing.

### Contributing

Expand Down Expand Up @@ -175,7 +174,7 @@ If you don't want to publish your Direct Line Secret (which lets anyone put your

DirectLineJS defaults to WebSocket for receiving messages from the bot. If WebSocket is not available, it will use GET polling. You can force it to use GET polling by passing `webSocket: false` in the options you pass to DirectLine.

Note: the standard WebChat channel does not currently use WebSocket, which is a compelling reason to use one of the above approaches.
Note: the standard WebChat channel does not currently use WebSocket, which is a compelling reason to use this project.

### Typing

Expand All @@ -187,7 +186,7 @@ You can supply WebChat with the id (and, optionally, a friendly name) of the cur

### Replacing DirectLineJS

You can give WebChat any object that matches the signature of DirectLineJS by passing `directLine: your_directline_replacement` to `App`/`Chat`.
You can give WebChat any object that implements `IBotConnection` by passing `botConnection: your_directline_replacement` to `App`/`Chat`.

### The Backchannel

Expand Down
40 changes: 0 additions & 40 deletions botchat.d.ts

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "botframework-webchat",
"version": "0.7.1",
"version": "0.9.0",
"description": "Embeddable web chat control for the Microsoft Bot Framework",
"main": "built/BotChat.js",
"types": "botchat.d.ts",
"types": "built/BotChat.d.ts",
"scripts": {
"build": "tsc && webpack",
"watch": "npm-run-all -p -r -l tsc-watch webpack-watch",
Expand All @@ -21,7 +21,7 @@
"author": "Microsoft Corp",
"license": "MIT",
"dependencies": {
"botframework-directlinejs": "^0.8.4",
"botframework-directlinejs": "^0.9.0",
"core-js": "^2.4.1",
"he": "^1.1.0",
"marked": "^0.3.6",
Expand Down
8 changes: 4 additions & 4 deletions src/ActivityView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ const Attachments = (props: {
</div>
}

interface Props {
export interface ActivityViewProps {
format: FormatState,
activity: Activity,
measureParentHorizontalOverflow?: () => number,
onCardAction: (type: string, value: string) => void,
onImageLoad: () => void
}

export class ActivityView extends React.Component<Props, {}> {
constructor(props: Props) {
export class ActivityView extends React.Component<ActivityViewProps, {}> {
constructor(props: ActivityViewProps) {
super(props)
}

shouldComponentUpdate(nextProps: Props) {
shouldComponentUpdate(nextProps: ActivityViewProps) {
return this.props.activity !== nextProps.activity || this.props.format !== nextProps.format;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Attachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const YOUTUBE_WWW_SHORT_DOMAIN = "www.youtu.be";
const VIMEO_DOMAIN = "vimeo.com";
const VIMEO_WWW_DOMAIN = "www.vimeo.com";

interface QueryParams {
export interface QueryParams {
[propName: string]: string;
}

Expand Down
2 changes: 1 addition & 1 deletion src/BotChat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { App, AppProps } from './App';
export { Chat, ChatProps, FormatOptions } from './Chat';
export { DirectLine } from 'botframework-directlinejs';
export * from 'botframework-directlinejs';
export { queryParams } from './Attachment';
// below are shims for compatibility with old browsers (IE 10 being the main culprit)
import 'core-js/modules/es6.string.starts-with';
Expand Down
6 changes: 3 additions & 3 deletions src/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { Attachment } from 'botframework-directlinejs';
import { AttachmentView } from './Attachment';
import { FormatState } from './Store';

interface CarouselProps {
export interface CarouselProps {
format: FormatState,
measureParentHorizontalOverflow?: () => number,
attachments: Attachment[],
onCardAction: (type: string, value: string) => void,
onImageLoad: ()=> void
}

interface CarouselState {
export interface CarouselState {
previousButtonEnabled: boolean;
nextButtonEnabled: boolean;
}
Expand Down Expand Up @@ -187,7 +187,7 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
}
}

interface CarouselAttachmentProps {
export interface CarouselAttachmentProps {
format: FormatState
attachments: Attachment[]
onCardAction: (type: string, value: string) => void
Expand Down
2 changes: 1 addition & 1 deletion src/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const measureOuterWidth = (el: HTMLElement): number => {
const suitableInterval = (current: Activity, next: Activity) =>
Date.parse(next.timestamp) - Date.parse(current.timestamp) > 5 * 60 * 1000;

interface WrappedActivityProps {
export interface WrappedActivityProps {
activity: Activity,
showTimestamp: boolean,
selected: boolean,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"declaration": true,
"importHelpers": true,
"jsx": "react",
"lib": [
Expand Down

0 comments on commit 77a0f1f

Please sign in to comment.