Updated react-bot-framework sample to SPFx 1.7 (#783)
* Updated to v1.7 * Fixed version history in readme
This commit is contained in:
parent
0a95601e37
commit
980b0b3fcd
|
@ -1,23 +1,13 @@
|
||||||
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
{
|
{
|
||||||
// The number of spaces a tab is equal to.
|
// Configure glob patterns for excluding files and folders in the file explorer.
|
||||||
"editor.tabSize": 2,
|
"files.exclude": {
|
||||||
|
"**/.git": true,
|
||||||
// When enabled, will trim trailing whitespace when you save a file.
|
"**/.DS_Store": true,
|
||||||
"files.trimTrailingWhitespace": true,
|
|
||||||
|
|
||||||
// Controls if the editor should automatically close brackets after opening them
|
|
||||||
"editor.autoClosingBrackets": false,
|
|
||||||
|
|
||||||
// Configure glob patterns for excluding files and folders.
|
|
||||||
"search.exclude": {
|
|
||||||
"**/bower_components": true,
|
"**/bower_components": true,
|
||||||
"**/node_modules": true,
|
"**/coverage": true,
|
||||||
"coverage": true,
|
"**/lib-amd": true,
|
||||||
"dist": true,
|
"src/**/*.scss.ts": true
|
||||||
"lib-amd": true,
|
},
|
||||||
"lib": true,
|
"typescript.tsdk": ".\\node_modules\\typescript\\lib"
|
||||||
"temp": true
|
|
||||||
}
|
|
||||||
,
|
|
||||||
"typescript.check.workspaceVersion": false
|
|
||||||
}
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
{
|
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=733558
|
|
||||||
// for the documentation about the tasks.json format
|
|
||||||
"version": "0.1.0",
|
|
||||||
"command": "gulp",
|
|
||||||
"isShellCommand": true,
|
|
||||||
"showOutput": "always",
|
|
||||||
"args": [
|
|
||||||
"--no-color"
|
|
||||||
],
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"taskName": "bundle",
|
|
||||||
"isBuildCommand": true,
|
|
||||||
"problemMatcher": [
|
|
||||||
"$tsc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"taskName": "test",
|
|
||||||
"isTestCommand": true,
|
|
||||||
"problemMatcher": [
|
|
||||||
"$tsc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"taskName": "serve",
|
|
||||||
"isWatching": true,
|
|
||||||
"problemMatcher": [
|
|
||||||
"$tsc"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,8 +1,12 @@
|
||||||
{
|
{
|
||||||
"@microsoft/generator-sharepoint": {
|
"@microsoft/generator-sharepoint": {
|
||||||
"libraryName": "sp-bot-chat-webpart",
|
"isCreatingSolution": true,
|
||||||
"framework": "react",
|
"environment": "spo",
|
||||||
"version": "1.0.0",
|
"version": "1.7.0",
|
||||||
"libraryId": "507162e8-724b-4c7a-b722-7362d7119389"
|
"libraryName": "react-bot-framework",
|
||||||
|
"libraryId": "1e3d14a8-d863-4a3d-b83a-dbd188d52015",
|
||||||
|
"packageManager": "npm",
|
||||||
|
"isDomainIsolated": false,
|
||||||
|
"componentType": "webpart"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,11 +10,12 @@ You can see this web part sample, including a sample VS 2015 bot application in
|
||||||
where sample was demonstrated.
|
where sample was demonstrated.
|
||||||
|
|
||||||
## Used SharePoint Framework Version
|
## Used SharePoint Framework Version
|
||||||
![drop](https://img.shields.io/badge/drop-GA-green.svg)
|
|
||||||
|
![drop](https://img.shields.io/badge/drop-1.7.0-green.svg)
|
||||||
|
|
||||||
## Applies to
|
## Applies to
|
||||||
|
|
||||||
* [SharePoint Framework Developer Preview](http://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview)
|
* [SharePoint Framework Developer](http://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview)
|
||||||
* [Office 365 developer tenant](http://dev.office.com/sharepoint/docs/spfx/set-up-your-developer-tenant)
|
* [Office 365 developer tenant](http://dev.office.com/sharepoint/docs/spfx/set-up-your-developer-tenant)
|
||||||
* [Microsoft Bot Framework](http://dev.botframework.com)
|
* [Microsoft Bot Framework](http://dev.botframework.com)
|
||||||
|
|
||||||
|
@ -40,7 +41,6 @@ under the [vs2015-bot-application](./vs2015-bot-application) folder. This is sim
|
||||||
Solution|Author(s)
|
Solution|Author(s)
|
||||||
--------|---------
|
--------|---------
|
||||||
bot-framework | Gary Pretty ([@garypretty](http://www.twitter.com/garypretty), [garypretty.co.uk](www.garypretty.co.uk))
|
bot-framework | Gary Pretty ([@garypretty](http://www.twitter.com/garypretty), [garypretty.co.uk](www.garypretty.co.uk))
|
||||||
RC0 Update / BugFixing | Raul Garita ([Raul.Garita@buildingi.com](mailto:raul.garita@buildingi.com), [Buildingi](http://www.buildingi.com))
|
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
@ -49,6 +49,8 @@ Version|Date|Comments
|
||||||
1.0|October 11th, 2016|Initial release
|
1.0|October 11th, 2016|Initial release
|
||||||
1.1|Jan 24th, 2017|Updated to RC0
|
1.1|Jan 24th, 2017|Updated to RC0
|
||||||
1.2|Feb 23rd, 2017|Initial load bug fix
|
1.2|Feb 23rd, 2017|Initial load bug fix
|
||||||
|
1.3|February 8, 2018|Updated to SPFx 1.7
|
||||||
|
|
||||||
|
|
||||||
## Disclaimer
|
## Disclaimer
|
||||||
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
{
|
{
|
||||||
"entries": [
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||||
|
"version": "2.0",
|
||||||
|
"bundles": {
|
||||||
|
"bot-framework-chat-web-part": {
|
||||||
|
"components": [
|
||||||
{
|
{
|
||||||
"entry": "./lib/webparts/botFrameworkChat/BotFrameworkChatWebPart.js",
|
"entrypoint": "./lib/webparts/botFrameworkChat/BotFrameworkChatWebPart.js",
|
||||||
"manifest": "./src/webparts/botFrameworkChat/BotFrameworkChatWebPart.manifest.json",
|
"manifest": "./src/webparts/botFrameworkChat/BotFrameworkChatWebPart.manifest.json"
|
||||||
"outputPath": "./dist/bot-framework-chat.bundle.js"
|
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"externals": {},
|
"externals": {},
|
||||||
"localizedResources": {
|
"localizedResources": {
|
||||||
"botFrameworkChatStrings": "webparts/botFrameworkChat/loc/{locale}.js"
|
"BotFrameworkChatWebPartStrings": "lib/webparts/botFrameworkChat/loc/{locale}.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||||
"deployCdnPath": "temp/deploy"
|
"deployCdnPath": "temp/deploy"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||||
"workingDir": "./temp/deploy/",
|
"workingDir": "./temp/deploy/",
|
||||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||||
"container": "sp-bot-chat-webpart",
|
"container": "react-bot-framework",
|
||||||
"accessKey": "<!-- ACCESS KEY -->"
|
"accessKey": "<!-- ACCESS KEY -->"
|
||||||
}
|
}
|
|
@ -1,10 +1,13 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||||
"solution": {
|
"solution": {
|
||||||
"name": "sp-bot-chat-webpart-client-side-solution",
|
"name": "react-bot-framework-client-side-solution",
|
||||||
"id": "507162e8-724b-4c7a-b722-7362d7119389",
|
"id": "1e3d14a8-d863-4a3d-b83a-dbd188d52015",
|
||||||
"version": "1.0.0.0"
|
"version": "1.0.0.0",
|
||||||
|
"includeClientSideAssets": true,
|
||||||
|
"isDomainIsolated": false
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
"zippedPackage": "solution/sp-bot-chat-webpart.sppkg"
|
"zippedPackage": "solution/react-bot-framework.sppkg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||||
"port": 4321,
|
"port": 4321,
|
||||||
"initialPage": "https://localhost:5432/workbench",
|
|
||||||
"https": true,
|
"https": true,
|
||||||
|
"initialPage": "https://localhost:5432/workbench",
|
||||||
"api": {
|
"api": {
|
||||||
"port": 5432,
|
"port": 5432,
|
||||||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
{
|
|
||||||
// Display errors as warnings
|
|
||||||
"displayAsWarning": true,
|
|
||||||
// The TSLint task may have been configured with several custom lint rules
|
|
||||||
// before this config file is read (for example lint rules from the tslint-microsoft-contrib
|
|
||||||
// project). If true, this flag will deactivate any of these rules.
|
|
||||||
"removeExistingRules": true,
|
|
||||||
// When true, the TSLint task is configured with some default TSLint "rules.":
|
|
||||||
"useDefaultConfigAsBase": false,
|
|
||||||
// Since removeExistingRules=true and useDefaultConfigAsBase=false, there will be no lint rules
|
|
||||||
// which are active, other than the list of rules below.
|
|
||||||
"lintConfig": {
|
|
||||||
// Opt-in to Lint rules which help to eliminate bugs in JavaScript
|
|
||||||
"rules": {
|
|
||||||
"class-name": false,
|
|
||||||
"export-name": false,
|
|
||||||
"forin": false,
|
|
||||||
"label-position": false,
|
|
||||||
"member-access": true,
|
|
||||||
"no-arg": false,
|
|
||||||
"no-console": false,
|
|
||||||
"no-construct": false,
|
|
||||||
"no-duplicate-case": true,
|
|
||||||
"no-duplicate-variable": true,
|
|
||||||
"no-eval": false,
|
|
||||||
"no-function-expression": true,
|
|
||||||
"no-internal-module": true,
|
|
||||||
"no-shadowed-variable": true,
|
|
||||||
"no-switch-case-fall-through": true,
|
|
||||||
"no-unnecessary-semicolons": true,
|
|
||||||
"no-unused-expression": true,
|
|
||||||
"no-unused-imports": true,
|
|
||||||
"no-use-before-declare": true,
|
|
||||||
"no-with-statement": true,
|
|
||||||
"semicolon": true,
|
|
||||||
"trailing-comma": false,
|
|
||||||
"typedef": false,
|
|
||||||
"typedef-whitespace": false,
|
|
||||||
"use-named-parameter": true,
|
|
||||||
"valid-typeof": true,
|
|
||||||
"variable-name": false,
|
|
||||||
"whitespace": false,
|
|
||||||
"prefer-const": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +1,4 @@
|
||||||
{
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||||
}
|
}
|
|
@ -2,5 +2,6 @@
|
||||||
|
|
||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
const build = require('@microsoft/sp-build-web');
|
const build = require('@microsoft/sp-build-web');
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||||
|
|
||||||
build.initialize(gulp);
|
build.initialize(gulp);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,36 +1,36 @@
|
||||||
{
|
{
|
||||||
"name": "sp-bot-chat-webpart",
|
"name": "sp-bot-chat-webpart",
|
||||||
"version": "0.0.3",
|
"version": "0.0.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
|
||||||
"@microsoft/sp-client-base": "~1.0.0",
|
|
||||||
"@microsoft/sp-core-library": "~1.0.0",
|
|
||||||
"@microsoft/sp-webpart-base": "~1.0.0",
|
|
||||||
"@types/react": "0.14.46",
|
|
||||||
"@types/react-addons-shallow-compare": "0.14.17",
|
|
||||||
"@types/react-addons-test-utils": "0.14.15",
|
|
||||||
"@types/react-addons-update": "0.14.14",
|
|
||||||
"@types/react-dom": "0.14.18",
|
|
||||||
"@types/webpack-env": ">=1.12.1 <1.14.0",
|
|
||||||
"office-ui-fabric-react": "0.69.0",
|
|
||||||
"react": "15.4.2",
|
|
||||||
"react-dom": "15.4.2",
|
|
||||||
"swagger-client": "^2.1.23"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@microsoft/sp-build-web": "~1.0.0",
|
|
||||||
"@microsoft/sp-module-interfaces": "~1.0.0",
|
|
||||||
"@microsoft/sp-webpart-workbench": "~1.0.0",
|
|
||||||
"gulp": "~3.9.1",
|
|
||||||
"@types/chai": ">=3.4.34 <3.6.0",
|
|
||||||
"@types/mocha": ">=2.2.33 <2.6.0"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gulp bundle",
|
"build": "gulp bundle",
|
||||||
"clean": "gulp clean",
|
"clean": "gulp clean",
|
||||||
"test": "gulp test"
|
"test": "gulp test"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@microsoft/sp-core-library": "1.7.0",
|
||||||
|
"@microsoft/sp-lodash-subset": "1.7.0",
|
||||||
|
"@microsoft/sp-office-ui-fabric-core": "1.7.0",
|
||||||
|
"@microsoft/sp-webpart-base": "1.7.0",
|
||||||
|
"@types/es6-promise": "0.0.33",
|
||||||
|
"@types/react": "16.4.2",
|
||||||
|
"@types/react-dom": "16.0.5",
|
||||||
|
"@types/webpack-env": "1.13.1",
|
||||||
|
"react": "16.3.2",
|
||||||
|
"react-dom": "16.3.2",
|
||||||
|
"swagger-client": "^2.1.23"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@microsoft/sp-build-web": "1.7.0",
|
||||||
|
"@microsoft/sp-tslint-rules": "1.7.0",
|
||||||
|
"@microsoft/sp-module-interfaces": "1.7.0",
|
||||||
|
"@microsoft/sp-webpart-workbench": "1.7.0",
|
||||||
|
"gulp": "~3.9.1",
|
||||||
|
"@types/chai": "3.4.34",
|
||||||
|
"@types/mocha": "2.2.38",
|
||||||
|
"ajv": "~5.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -1,5 +0,0 @@
|
||||||
var context = require.context('.', true, /.+\.test\.js?$/);
|
|
||||||
|
|
||||||
context.keys().forEach(context);
|
|
||||||
|
|
||||||
module.exports = context;
|
|
|
@ -4,12 +4,19 @@
|
||||||
"id": "54c37464-b267-494e-9b74-2bfe3e8e490a",
|
"id": "54c37464-b267-494e-9b74-2bfe3e8e490a",
|
||||||
"alias": "BotFrameworkChat",
|
"alias": "BotFrameworkChat",
|
||||||
"componentType": "WebPart",
|
"componentType": "WebPart",
|
||||||
"version": "0.0.3",
|
|
||||||
|
// The "*" signifies that the version should be taken from the package.json
|
||||||
|
"version": "*",
|
||||||
"manifestVersion": 2,
|
"manifestVersion": 2,
|
||||||
|
|
||||||
|
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||||
|
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||||
|
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||||
|
"requiresCustomScript": false,
|
||||||
|
|
||||||
"preconfiguredEntries": [{
|
"preconfiguredEntries": [{
|
||||||
"groupId": "54c37464-b267-494e-9b74-2bfe3e8e490a",
|
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||||
"group": { "default": "Under Development" },
|
"group": { "default": "Other" },
|
||||||
"title": { "default": "BotFrameworkChat" },
|
"title": { "default": "BotFrameworkChat" },
|
||||||
"description": { "default": "Bot Framework Chat description" },
|
"description": { "default": "Bot Framework Chat description" },
|
||||||
"officeFabricIconFontName": "Page",
|
"officeFabricIconFontName": "Page",
|
||||||
|
|
|
@ -1,18 +1,35 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as ReactDom from 'react-dom';
|
import * as ReactDom from 'react-dom';
|
||||||
|
import { Version } from '@microsoft/sp-core-library';
|
||||||
import {
|
import {
|
||||||
BaseClientSideWebPart,
|
BaseClientSideWebPart,
|
||||||
IPropertyPaneConfiguration,
|
IPropertyPaneConfiguration,
|
||||||
PropertyPaneTextField
|
PropertyPaneTextField
|
||||||
} from '@microsoft/sp-webpart-base';
|
} from '@microsoft/sp-webpart-base';
|
||||||
|
|
||||||
import BotFrameworkChat, { IBotFrameworkChatProps } from './components/BotFrameworkChat';
|
import * as strings from 'BotFrameworkChatWebPartStrings';
|
||||||
import { IBotFrameworkChatWebPartProps } from './IBotFrameworkChatWebPartProps';
|
import BotFrameworkChat from './components/BotFrameworkChat';
|
||||||
|
import { IBotFrameworkChatProps } from './components/IBotFrameworkChatProps';
|
||||||
|
|
||||||
|
export interface IBotFrameworkChatWebPartProps {
|
||||||
|
description: string;
|
||||||
|
message: string;
|
||||||
|
directLineSecret: string;
|
||||||
|
title: string;
|
||||||
|
placeholderText: string;
|
||||||
|
titleBarBackgroundColor : string;
|
||||||
|
botMessagesBackgroundColor: string;
|
||||||
|
botMessagesForegroundColor: string;
|
||||||
|
userMessagesBackgroundColor: string;
|
||||||
|
userMessagesForegroundColor: string;
|
||||||
|
}
|
||||||
|
|
||||||
export default class BotFrameworkChatWebPart extends BaseClientSideWebPart<IBotFrameworkChatWebPartProps> {
|
export default class BotFrameworkChatWebPart extends BaseClientSideWebPart<IBotFrameworkChatWebPartProps> {
|
||||||
|
|
||||||
public render(): void {
|
public render(): void {
|
||||||
const element: React.ReactElement<IBotFrameworkChatProps> = React.createElement(BotFrameworkChat, {
|
const element: React.ReactElement<IBotFrameworkChatProps > = React.createElement(
|
||||||
|
BotFrameworkChat,
|
||||||
|
{
|
||||||
description: this.properties.description,
|
description: this.properties.description,
|
||||||
message: '',
|
message: '',
|
||||||
title: this.properties.title,
|
title: this.properties.title,
|
||||||
|
@ -29,6 +46,14 @@ export default class BotFrameworkChatWebPart extends BaseClientSideWebPart<IBotF
|
||||||
ReactDom.render(element, this.domElement);
|
ReactDom.render(element, this.domElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected onDispose(): void {
|
||||||
|
ReactDom.unmountComponentAtNode(this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get dataVersion(): Version {
|
||||||
|
return Version.parse('1.0');
|
||||||
|
}
|
||||||
|
|
||||||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||||
return {
|
return {
|
||||||
pages: [
|
pages: [
|
||||||
|
@ -87,7 +112,6 @@ export default class BotFrameworkChatWebPart extends BaseClientSideWebPart<IBotF
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private _validateColorPropertyAsync(value: string): string {
|
private _validateColorPropertyAsync(value: string): string {
|
||||||
var colorRegex = /^([a-zA-Z0-9]){6}$/;
|
var colorRegex = /^([a-zA-Z0-9]){6}$/;
|
||||||
if (!value || colorRegex.test(value) == false) {
|
if (!value || colorRegex.test(value) == false) {
|
||||||
|
@ -96,5 +120,4 @@ export default class BotFrameworkChatWebPart extends BaseClientSideWebPart<IBotF
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,5 +53,6 @@
|
||||||
.messageBox input {
|
.messageBox input {
|
||||||
border: 3px #c8c8c8 solid !important;
|
border: 3px #c8c8c8 solid !important;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
padding: 15px;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,10 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { css } from 'office-ui-fabric-react';
|
import { css } from 'office-ui-fabric-react';
|
||||||
import { TextField } from 'office-ui-fabric-react';
|
import { TextField } from 'office-ui-fabric-react';
|
||||||
import styles from '../BotFrameworkChat.module.scss';
|
import styles from './BotFrameworkChat.module.scss';
|
||||||
import { IBotFrameworkChatWebPartProps } from '../IBotFrameworkChatWebPartProps';
|
import { IBotFrameworkChatProps } from './IBotFrameworkChatProps';
|
||||||
declare function require(path: string) : any;
|
declare function require(path: string) : any;
|
||||||
|
|
||||||
export interface IBotFrameworkChatProps extends IBotFrameworkChatWebPartProps {
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class BotFrameworkChat extends React.Component<IBotFrameworkChatProps, {}> {
|
export default class BotFrameworkChat extends React.Component<IBotFrameworkChatProps, {}> {
|
||||||
|
|
||||||
private pollInterval = 1000;
|
private pollInterval = 1000;
|
||||||
|
@ -38,13 +35,38 @@ export default class BotFrameworkChat extends React.Component<IBotFrameworkChatP
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentDidMount(){
|
public componentDidUpdate(prevProps: IBotFrameworkChatProps, prevState: {}, prevContext: any): void {
|
||||||
this.bindDirectLineSecret();
|
|
||||||
}
|
|
||||||
|
|
||||||
public componentDidUpdate(prevProps: IBotFrameworkChatWebPartProps, prevState: {}, prevContext: any): void {
|
|
||||||
if (this.props.directLineSecret !== prevProps.directLineSecret) {
|
if (this.props.directLineSecret !== prevProps.directLineSecret) {
|
||||||
this.bindDirectLineSecret();
|
if (this.props.directLineSecret) {
|
||||||
|
var Swagger = require('swagger-client');
|
||||||
|
var directLineSpec = require('./directline-swagger.json');
|
||||||
|
|
||||||
|
this.directLineClientSwagger = new Swagger(
|
||||||
|
{
|
||||||
|
spec: directLineSpec,
|
||||||
|
usePromise: true,
|
||||||
|
}).then((client) => {
|
||||||
|
client.clientAuthorizations.add('AuthorizationBotConnector', new Swagger.ApiKeyAuthorization('Authorization', 'BotConnector ' + this.props.directLineSecret, 'header'));
|
||||||
|
console.log('DirectLine client generated');
|
||||||
|
return client;
|
||||||
|
}).catch((err) =>
|
||||||
|
console.error('Error initializing DirectLine client', err));
|
||||||
|
|
||||||
|
this.directLineClientSwagger.then((client) => {
|
||||||
|
client.Conversations.Conversations_NewConversation()
|
||||||
|
.then((response) => response.obj.conversationId)
|
||||||
|
.then((conversationId) => {
|
||||||
|
|
||||||
|
this.conversationId = conversationId;
|
||||||
|
this.pollMessages(client, conversationId);
|
||||||
|
this.directLineClient = client;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sendAsUserName = this.props.context.pageContext.user.loginName;
|
||||||
|
|
||||||
|
this.printMessage = this.printMessage.bind(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,39 +108,6 @@ export default class BotFrameworkChat extends React.Component<IBotFrameworkChatP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bindDirectLineSecret(){
|
|
||||||
if (this.props.directLineSecret) {
|
|
||||||
var Swagger = require('swagger-client');
|
|
||||||
var directLineSpec = require('./directline-swagger.json');
|
|
||||||
|
|
||||||
this.directLineClientSwagger = new Swagger(
|
|
||||||
{
|
|
||||||
spec: directLineSpec,
|
|
||||||
usePromise: true,
|
|
||||||
}).then((client) => {
|
|
||||||
client.clientAuthorizations.add('AuthorizationBotConnector', new Swagger.ApiKeyAuthorization('Authorization', 'BotConnector ' + this.props.directLineSecret, 'header'));
|
|
||||||
console.log('DirectLine client generated');
|
|
||||||
return client;
|
|
||||||
}).catch((err) =>
|
|
||||||
console.error('Error initializing DirectLine client', err));
|
|
||||||
|
|
||||||
this.directLineClientSwagger.then((client) => {
|
|
||||||
client.Conversations.Conversations_NewConversation()
|
|
||||||
.then((response) => response.obj.conversationId)
|
|
||||||
.then((conversationId) => {
|
|
||||||
|
|
||||||
this.conversationId = conversationId;
|
|
||||||
this.pollMessages(client, conversationId);
|
|
||||||
this.directLineClient = client;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.sendAsUserName = this.props.context.pageContext.user.loginName;
|
|
||||||
|
|
||||||
this.printMessage = this.printMessage.bind(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected pollMessages(client, conversationId) {
|
protected pollMessages(client, conversationId) {
|
||||||
console.log('Starting polling message for conversationId: ' + conversationId);
|
console.log('Starting polling message for conversationId: ' + conversationId);
|
||||||
var watermark = null;
|
var watermark = null;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { IWebPartContext } from '@microsoft/sp-webpart-base';
|
import { IWebPartContext } from '@microsoft/sp-webpart-base';
|
||||||
|
|
||||||
export interface IBotFrameworkChatWebPartProps {
|
export interface IBotFrameworkChatProps {
|
||||||
description: string;
|
description: string;
|
||||||
message: string;
|
message: string;
|
||||||
directLineSecret: string;
|
directLineSecret: string;
|
|
@ -4,7 +4,7 @@ declare interface IBotFrameworkChatStrings {
|
||||||
DescriptionFieldLabel: string;
|
DescriptionFieldLabel: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'botFrameworkChatStrings' {
|
declare module 'BotFrameworkChatWebPartStrings' {
|
||||||
const strings: IBotFrameworkChatStrings;
|
const strings: IBotFrameworkChatStrings;
|
||||||
export = strings;
|
export = strings;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
/// <reference types="mocha" />
|
|
||||||
import { assert } from 'chai';
|
|
||||||
|
|
||||||
describe('BotFrameworkChatWebPart', () => {
|
|
||||||
it('should do something', () => {
|
|
||||||
assert.ok(true);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -2,14 +2,33 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"module": "commonjs",
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"outDir": "lib",
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types",
|
||||||
|
"./node_modules/@microsoft"
|
||||||
|
],
|
||||||
"types": [
|
"types": [
|
||||||
"es6-promise",
|
"es6-promise",
|
||||||
"es6-collections",
|
|
||||||
"webpack-env"
|
"webpack-env"
|
||||||
|
],
|
||||||
|
"lib": [
|
||||||
|
"es5",
|
||||||
|
"dom",
|
||||||
|
"es2015.collection"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"lib"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,3 +1,30 @@
|
||||||
{
|
{
|
||||||
"rulesDirectory": "./config"
|
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
|
||||||
|
"rules": {
|
||||||
|
"class-name": false,
|
||||||
|
"export-name": false,
|
||||||
|
"forin": false,
|
||||||
|
"label-position": false,
|
||||||
|
"member-access": true,
|
||||||
|
"no-arg": false,
|
||||||
|
"no-console": false,
|
||||||
|
"no-construct": false,
|
||||||
|
"no-duplicate-variable": true,
|
||||||
|
"no-eval": false,
|
||||||
|
"no-function-expression": true,
|
||||||
|
"no-internal-module": true,
|
||||||
|
"no-shadowed-variable": true,
|
||||||
|
"no-switch-case-fall-through": true,
|
||||||
|
"no-unnecessary-semicolons": true,
|
||||||
|
"no-unused-expression": true,
|
||||||
|
"no-use-before-declare": true,
|
||||||
|
"no-with-statement": true,
|
||||||
|
"semicolon": true,
|
||||||
|
"trailing-comma": false,
|
||||||
|
"typedef": false,
|
||||||
|
"typedef-whitespace": false,
|
||||||
|
"use-named-parameter": true,
|
||||||
|
"variable-name": false,
|
||||||
|
"whitespace": false
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
// Type definitions for assertion-error 1.0.0
|
||||||
|
// Project: https://github.com/chaijs/assertion-error
|
||||||
|
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||||
|
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||||
|
|
||||||
|
declare module 'assertion-error' {
|
||||||
|
class AssertionError implements Error {
|
||||||
|
constructor(message: string, props?: any, ssf?: Function);
|
||||||
|
name: string;
|
||||||
|
message: string;
|
||||||
|
showDiff: boolean;
|
||||||
|
stack: string;
|
||||||
|
}
|
||||||
|
export = AssertionError;
|
||||||
|
}
|
|
@ -0,0 +1,631 @@
|
||||||
|
// Type definitions for Knockout v3.2.0
|
||||||
|
// Project: http://knockoutjs.com
|
||||||
|
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Igor Oleinikov <https://github.com/Igorbek/>, Clément Bourgeois <https://github.com/moonpyk/>
|
||||||
|
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||||
|
|
||||||
|
|
||||||
|
interface KnockoutSubscribableFunctions<T> {
|
||||||
|
[key: string]: KnockoutBindingHandler;
|
||||||
|
|
||||||
|
notifySubscribers(valueToWrite?: T, event?: string): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutComputedFunctions<T> {
|
||||||
|
[key: string]: KnockoutBindingHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutObservableFunctions<T> {
|
||||||
|
[key: string]: KnockoutBindingHandler;
|
||||||
|
|
||||||
|
equalityComparer(a: any, b: any): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutObservableArrayFunctions<T> {
|
||||||
|
// General Array functions
|
||||||
|
indexOf(searchElement: T, fromIndex?: number): number;
|
||||||
|
slice(start: number, end?: number): T[];
|
||||||
|
splice(start: number): T[];
|
||||||
|
splice(start: number, deleteCount: number, ...items: T[]): T[];
|
||||||
|
pop(): T;
|
||||||
|
push(...items: T[]): void;
|
||||||
|
shift(): T;
|
||||||
|
unshift(...items: T[]): number;
|
||||||
|
reverse(): KnockoutObservableArray<T>;
|
||||||
|
sort(): KnockoutObservableArray<T>;
|
||||||
|
sort(compareFunction: (left: T, right: T) => number): KnockoutObservableArray<T>;
|
||||||
|
|
||||||
|
// Ko specific
|
||||||
|
[key: string]: KnockoutBindingHandler;
|
||||||
|
|
||||||
|
replace(oldItem: T, newItem: T): void;
|
||||||
|
|
||||||
|
remove(item: T): T[];
|
||||||
|
remove(removeFunction: (item: T) => boolean): T[];
|
||||||
|
removeAll(items: T[]): T[];
|
||||||
|
removeAll(): T[];
|
||||||
|
|
||||||
|
destroy(item: T): void;
|
||||||
|
destroy(destroyFunction: (item: T) => boolean): void;
|
||||||
|
destroyAll(items: T[]): void;
|
||||||
|
destroyAll(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutSubscribableStatic {
|
||||||
|
fn: KnockoutSubscribableFunctions<any>;
|
||||||
|
|
||||||
|
new <T>(): KnockoutSubscribable<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutSubscription {
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutSubscribable<T> extends KnockoutSubscribableFunctions<T> {
|
||||||
|
subscribe(callback: (newValue: T) => void, target?: any, event?: string): KnockoutSubscription;
|
||||||
|
subscribe<TEvent>(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription;
|
||||||
|
extend(requestedExtenders: { [key: string]: any; }): KnockoutSubscribable<T>;
|
||||||
|
getSubscriptionsCount(): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutComputedStatic {
|
||||||
|
fn: KnockoutComputedFunctions<any>;
|
||||||
|
|
||||||
|
<T>(): KnockoutComputed<T>;
|
||||||
|
<T>(func: () => T, context?: any, options?: any): KnockoutComputed<T>;
|
||||||
|
<T>(def: KnockoutComputedDefine<T>, context?: any): KnockoutComputed<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutComputed<T> extends KnockoutObservable<T>, KnockoutComputedFunctions<T> {
|
||||||
|
fn: KnockoutComputedFunctions<any>;
|
||||||
|
|
||||||
|
dispose(): void;
|
||||||
|
isActive(): boolean;
|
||||||
|
getDependenciesCount(): number;
|
||||||
|
extend(requestedExtenders: { [key: string]: any; }): KnockoutComputed<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutObservableArrayStatic {
|
||||||
|
fn: KnockoutObservableArrayFunctions<any>;
|
||||||
|
|
||||||
|
<T>(value?: T[]): KnockoutObservableArray<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutObservableArray<T> extends KnockoutObservable<T[]>, KnockoutObservableArrayFunctions<T> {
|
||||||
|
extend(requestedExtenders: { [key: string]: any; }): KnockoutObservableArray<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutObservableStatic {
|
||||||
|
fn: KnockoutObservableFunctions<any>;
|
||||||
|
|
||||||
|
<T>(value?: T): KnockoutObservable<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutObservable<T> extends KnockoutSubscribable<T>, KnockoutObservableFunctions<T> {
|
||||||
|
(): T;
|
||||||
|
(value: T): void;
|
||||||
|
|
||||||
|
peek(): T;
|
||||||
|
valueHasMutated?:{(): void;};
|
||||||
|
valueWillMutate?:{(): void;};
|
||||||
|
extend(requestedExtenders: { [key: string]: any; }): KnockoutObservable<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutComputedDefine<T> {
|
||||||
|
read(): T;
|
||||||
|
write? (value: T): void;
|
||||||
|
disposeWhenNodeIsRemoved?: Node;
|
||||||
|
disposeWhen? (): boolean;
|
||||||
|
owner?: any;
|
||||||
|
deferEvaluation?: boolean;
|
||||||
|
pure?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutBindingContext {
|
||||||
|
$parent: any;
|
||||||
|
$parents: any[];
|
||||||
|
$root: any;
|
||||||
|
$data: any;
|
||||||
|
$rawData: any | KnockoutObservable<any>;
|
||||||
|
$index?: KnockoutObservable<number>;
|
||||||
|
$parentContext?: KnockoutBindingContext;
|
||||||
|
$component: any;
|
||||||
|
$componentTemplateNodes: Node[];
|
||||||
|
|
||||||
|
extend(properties: any): any;
|
||||||
|
createChildContext(dataItemOrAccessor: any, dataItemAlias?: any, extendCallback?: Function): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutAllBindingsAccessor {
|
||||||
|
(): any;
|
||||||
|
get(name: string): any;
|
||||||
|
has(name: string): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutBindingHandler {
|
||||||
|
after?: Array<string>;
|
||||||
|
init?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void | { controlsDescendantBindings: boolean; };
|
||||||
|
update?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void;
|
||||||
|
options?: any;
|
||||||
|
preprocess?: (value: string, name: string, addBindingCallback?: (name: string, value: string) => void) => string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutBindingHandlers {
|
||||||
|
[bindingHandler: string]: KnockoutBindingHandler;
|
||||||
|
|
||||||
|
// Controlling text and appearance
|
||||||
|
visible: KnockoutBindingHandler;
|
||||||
|
text: KnockoutBindingHandler;
|
||||||
|
html: KnockoutBindingHandler;
|
||||||
|
css: KnockoutBindingHandler;
|
||||||
|
style: KnockoutBindingHandler;
|
||||||
|
attr: KnockoutBindingHandler;
|
||||||
|
|
||||||
|
// Control Flow
|
||||||
|
foreach: KnockoutBindingHandler;
|
||||||
|
if: KnockoutBindingHandler;
|
||||||
|
ifnot: KnockoutBindingHandler;
|
||||||
|
with: KnockoutBindingHandler;
|
||||||
|
|
||||||
|
// Working with form fields
|
||||||
|
click: KnockoutBindingHandler;
|
||||||
|
event: KnockoutBindingHandler;
|
||||||
|
submit: KnockoutBindingHandler;
|
||||||
|
enable: KnockoutBindingHandler;
|
||||||
|
disable: KnockoutBindingHandler;
|
||||||
|
value: KnockoutBindingHandler;
|
||||||
|
textInput: KnockoutBindingHandler;
|
||||||
|
hasfocus: KnockoutBindingHandler;
|
||||||
|
checked: KnockoutBindingHandler;
|
||||||
|
options: KnockoutBindingHandler;
|
||||||
|
selectedOptions: KnockoutBindingHandler;
|
||||||
|
uniqueName: KnockoutBindingHandler;
|
||||||
|
|
||||||
|
// Rendering templates
|
||||||
|
template: KnockoutBindingHandler;
|
||||||
|
|
||||||
|
// Components (new for v3.2)
|
||||||
|
component: KnockoutBindingHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutMemoization {
|
||||||
|
memoize(callback: () => string): string;
|
||||||
|
unmemoize(memoId: string, callbackParams: any[]): boolean;
|
||||||
|
unmemoizeDomNodeAndDescendants(domNode: any, extraCallbackParamsArray: any[]): boolean;
|
||||||
|
parseMemoText(memoText: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutVirtualElement {}
|
||||||
|
|
||||||
|
interface KnockoutVirtualElements {
|
||||||
|
allowedBindings: { [bindingName: string]: boolean; };
|
||||||
|
emptyNode(node: KnockoutVirtualElement ): void;
|
||||||
|
firstChild(node: KnockoutVirtualElement ): KnockoutVirtualElement;
|
||||||
|
insertAfter( container: KnockoutVirtualElement, nodeToInsert: Node, insertAfter: Node ): void;
|
||||||
|
nextSibling(node: KnockoutVirtualElement): Node;
|
||||||
|
prepend(node: KnockoutVirtualElement, toInsert: Node ): void;
|
||||||
|
setDomNodeChildren(node: KnockoutVirtualElement, newChildren: { length: number;[index: number]: Node; } ): void;
|
||||||
|
childNodes(node: KnockoutVirtualElement ): Node[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutExtenders {
|
||||||
|
throttle(target: any, timeout: number): KnockoutComputed<any>;
|
||||||
|
notify(target: any, notifyWhen: string): any;
|
||||||
|
|
||||||
|
rateLimit(target: any, timeout: number): any;
|
||||||
|
rateLimit(target: any, options: { timeout: number; method?: string; }): any;
|
||||||
|
|
||||||
|
trackArrayChanges(target: any): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// NOTE TO MAINTAINERS AND CONTRIBUTORS : pay attention to only include symbols that are
|
||||||
|
// publicly exported in the minified version of ko, without that you can give the false
|
||||||
|
// impression that some functions will be available in production builds.
|
||||||
|
//
|
||||||
|
interface KnockoutUtils {
|
||||||
|
//////////////////////////////////
|
||||||
|
// utils.domData.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
domData: {
|
||||||
|
get (node: Element, key: string): any;
|
||||||
|
|
||||||
|
set (node: Element, key: string, value: any): void;
|
||||||
|
|
||||||
|
getAll(node: Element, createIfNotFound: boolean): any;
|
||||||
|
|
||||||
|
clear(node: Element): boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// utils.domNodeDisposal.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
domNodeDisposal: {
|
||||||
|
addDisposeCallback(node: Element, callback: Function): void;
|
||||||
|
|
||||||
|
removeDisposeCallback(node: Element, callback: Function): void;
|
||||||
|
|
||||||
|
cleanNode(node: Node): Element;
|
||||||
|
|
||||||
|
removeNode(node: Node): void;
|
||||||
|
};
|
||||||
|
|
||||||
|
addOrRemoveItem<T>(array: T[] | KnockoutObservable<T>, value: T, included: T): void;
|
||||||
|
|
||||||
|
arrayFilter<T>(array: T[], predicate: (item: T) => boolean): T[];
|
||||||
|
|
||||||
|
arrayFirst<T>(array: T[], predicate: (item: T) => boolean, predicateOwner?: any): T;
|
||||||
|
|
||||||
|
arrayForEach<T>(array: T[], action: (item: T, index: number) => void): void;
|
||||||
|
|
||||||
|
arrayGetDistinctValues<T>(array: T[]): T[];
|
||||||
|
|
||||||
|
arrayIndexOf<T>(array: T[], item: T): number;
|
||||||
|
|
||||||
|
arrayMap<T, U>(array: T[], mapping: (item: T) => U): U[];
|
||||||
|
|
||||||
|
arrayPushAll<T>(array: T[] | KnockoutObservableArray<T>, valuesToPush: T[]): T[];
|
||||||
|
|
||||||
|
arrayRemoveItem(array: any[], itemToRemove: any): void;
|
||||||
|
|
||||||
|
compareArrays<T>(a: T[], b: T[]): Array<KnockoutArrayChange<T>>;
|
||||||
|
|
||||||
|
extend(target: Object, source: Object): Object;
|
||||||
|
|
||||||
|
fieldsIncludedWithJsonPost: any[];
|
||||||
|
|
||||||
|
getFormFields(form: any, fieldName: string): any[];
|
||||||
|
|
||||||
|
objectForEach(obj: any, action: (key: any, value: any) => void): void;
|
||||||
|
|
||||||
|
parseHtmlFragment(html: string): any[];
|
||||||
|
|
||||||
|
parseJson(jsonString: string): any;
|
||||||
|
|
||||||
|
postJson(urlOrForm: any, data: any, options: any): void;
|
||||||
|
|
||||||
|
peekObservable<T>(value: KnockoutObservable<T>): T;
|
||||||
|
|
||||||
|
range(min: any, max: any): any;
|
||||||
|
|
||||||
|
registerEventHandler(element: any, eventType: any, handler: Function): void;
|
||||||
|
|
||||||
|
setHtml(node: Element, html: () => string): void;
|
||||||
|
|
||||||
|
setHtml(node: Element, html: string): void;
|
||||||
|
|
||||||
|
setTextContent(element: any, textContent: string | KnockoutObservable<string>): void;
|
||||||
|
|
||||||
|
stringifyJson(data: any, replacer?: Function, space?: string): string;
|
||||||
|
|
||||||
|
toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: boolean): void;
|
||||||
|
|
||||||
|
triggerEvent(element: any, eventType: any): void;
|
||||||
|
|
||||||
|
unwrapObservable<T>(value: KnockoutObservable<T> | T): T;
|
||||||
|
|
||||||
|
// NOT PART OF THE MINIFIED API SURFACE (ONLY IN knockout-{version}.debug.js) https://github.com/SteveSanderson/knockout/issues/670
|
||||||
|
// forceRefresh(node: any): void;
|
||||||
|
// ieVersion: number;
|
||||||
|
// isIe6: boolean;
|
||||||
|
// isIe7: boolean;
|
||||||
|
// jQueryHtmlParse(html: string): any[];
|
||||||
|
// makeArray(arrayLikeObject: any): any[];
|
||||||
|
// moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement;
|
||||||
|
// replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void;
|
||||||
|
// setDomNodeChildren(domNode: any, childNodes: any[]): void;
|
||||||
|
// setElementName(element: any, name: string): void;
|
||||||
|
// setOptionNodeSelectionState(optionNode: any, isSelected: boolean): void;
|
||||||
|
// simpleHtmlParse(html: string): any[];
|
||||||
|
// stringStartsWith(str: string, startsWith: string): boolean;
|
||||||
|
// stringTokenize(str: string, delimiter: string): string[];
|
||||||
|
// stringTrim(str: string): string;
|
||||||
|
// tagNameLower(element: any): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutArrayChange<T> {
|
||||||
|
status: string;
|
||||||
|
value: T;
|
||||||
|
index: number;
|
||||||
|
moved?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// templateSources.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
interface KnockoutTemplateSourcesDomElement {
|
||||||
|
text(): any;
|
||||||
|
text(value: any): void;
|
||||||
|
|
||||||
|
data(key: string): any;
|
||||||
|
data(key: string, value: any): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutTemplateAnonymous extends KnockoutTemplateSourcesDomElement {
|
||||||
|
nodes(): any;
|
||||||
|
nodes(value: any): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutTemplateSources {
|
||||||
|
|
||||||
|
domElement: {
|
||||||
|
prototype: KnockoutTemplateSourcesDomElement
|
||||||
|
new (element: Element): KnockoutTemplateSourcesDomElement
|
||||||
|
};
|
||||||
|
|
||||||
|
anonymousTemplate: {
|
||||||
|
prototype: KnockoutTemplateAnonymous;
|
||||||
|
new (element: Element): KnockoutTemplateAnonymous;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// nativeTemplateEngine.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
interface KnockoutNativeTemplateEngine {
|
||||||
|
|
||||||
|
renderTemplateSource(templateSource: Object, bindingContext?: KnockoutBindingContext, options?: Object): any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// templateEngine.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
interface KnockoutTemplateEngine extends KnockoutNativeTemplateEngine {
|
||||||
|
|
||||||
|
createJavaScriptEvaluatorBlock(script: string): string;
|
||||||
|
|
||||||
|
makeTemplateSource(template: any, templateDocument?: Document): any;
|
||||||
|
|
||||||
|
renderTemplate(template: any, bindingContext: KnockoutBindingContext, options: Object, templateDocument: Document): any;
|
||||||
|
|
||||||
|
isTemplateRewritten(template: any, templateDocument: Document): boolean;
|
||||||
|
|
||||||
|
rewriteTemplate(template: any, rewriterCallback: Function, templateDocument: Document): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
interface KnockoutStatic {
|
||||||
|
utils: KnockoutUtils;
|
||||||
|
memoization: KnockoutMemoization;
|
||||||
|
|
||||||
|
bindingHandlers: KnockoutBindingHandlers;
|
||||||
|
getBindingHandler(handler: string): KnockoutBindingHandler;
|
||||||
|
|
||||||
|
virtualElements: KnockoutVirtualElements;
|
||||||
|
extenders: KnockoutExtenders;
|
||||||
|
|
||||||
|
applyBindings(viewModelOrBindingContext?: any, rootNode?: any): void;
|
||||||
|
applyBindingsToDescendants(viewModelOrBindingContext: any, rootNode: any): void;
|
||||||
|
applyBindingAccessorsToNode(node: Node, bindings: (bindingContext: KnockoutBindingContext, node: Node) => {}, bindingContext: KnockoutBindingContext): void;
|
||||||
|
applyBindingAccessorsToNode(node: Node, bindings: {}, bindingContext: KnockoutBindingContext): void;
|
||||||
|
applyBindingAccessorsToNode(node: Node, bindings: (bindingContext: KnockoutBindingContext, node: Node) => {}, viewModel: any): void;
|
||||||
|
applyBindingAccessorsToNode(node: Node, bindings: {}, viewModel: any): void;
|
||||||
|
applyBindingsToNode(node: Node, bindings: any, viewModelOrBindingContext?: any): any;
|
||||||
|
|
||||||
|
subscribable: KnockoutSubscribableStatic;
|
||||||
|
observable: KnockoutObservableStatic;
|
||||||
|
|
||||||
|
computed: KnockoutComputedStatic;
|
||||||
|
pureComputed<T>(evaluatorFunction: () => T, context?: any): KnockoutComputed<T>;
|
||||||
|
pureComputed<T>(options: KnockoutComputedDefine<T>, context?: any): KnockoutComputed<T>;
|
||||||
|
|
||||||
|
observableArray: KnockoutObservableArrayStatic;
|
||||||
|
|
||||||
|
contextFor(node: any): any;
|
||||||
|
isSubscribable(instance: any): boolean;
|
||||||
|
toJSON(viewModel: any, replacer?: Function, space?: any): string;
|
||||||
|
toJS(viewModel: any): any;
|
||||||
|
isObservable(instance: any): boolean;
|
||||||
|
isWriteableObservable(instance: any): boolean;
|
||||||
|
isComputed(instance: any): boolean;
|
||||||
|
dataFor(node: any): any;
|
||||||
|
removeNode(node: Element): void;
|
||||||
|
cleanNode(node: Element): Element;
|
||||||
|
renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any;
|
||||||
|
renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any;
|
||||||
|
unwrap<T>(value: KnockoutObservable<T> | T): T;
|
||||||
|
|
||||||
|
computedContext: KnockoutComputedContext;
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// templateSources.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
templateSources: KnockoutTemplateSources;
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// templateEngine.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
templateEngine: {
|
||||||
|
|
||||||
|
prototype: KnockoutTemplateEngine;
|
||||||
|
|
||||||
|
new (): KnockoutTemplateEngine;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// templateRewriting.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
templateRewriting: {
|
||||||
|
|
||||||
|
ensureTemplateIsRewritten(template: Node, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any;
|
||||||
|
ensureTemplateIsRewritten(template: string, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any;
|
||||||
|
|
||||||
|
memoizeBindingAttributeSyntax(htmlString: string, templateEngine: KnockoutTemplateEngine): any;
|
||||||
|
|
||||||
|
applyMemoizedBindingsToNextSibling(bindings: any, nodeName: string): string;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// nativeTemplateEngine.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
nativeTemplateEngine: {
|
||||||
|
|
||||||
|
prototype: KnockoutNativeTemplateEngine;
|
||||||
|
|
||||||
|
new (): KnockoutNativeTemplateEngine;
|
||||||
|
|
||||||
|
instance: KnockoutNativeTemplateEngine;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// jqueryTmplTemplateEngine.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
jqueryTmplTemplateEngine: {
|
||||||
|
|
||||||
|
prototype: KnockoutTemplateEngine;
|
||||||
|
|
||||||
|
renderTemplateSource(templateSource: Object, bindingContext: KnockoutBindingContext, options: Object): Node[];
|
||||||
|
|
||||||
|
createJavaScriptEvaluatorBlock(script: string): string;
|
||||||
|
|
||||||
|
addTemplate(templateName: string, templateMarkup: string): void;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// templating.js
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
setTemplateEngine(templateEngine: KnockoutNativeTemplateEngine): void;
|
||||||
|
|
||||||
|
renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
|
||||||
|
renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
|
||||||
|
renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
|
||||||
|
renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
|
||||||
|
renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
|
||||||
|
renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
|
||||||
|
renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
|
||||||
|
renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
|
||||||
|
|
||||||
|
renderTemplateForEach(template: Function, arrayOrObservableArray: any[], options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
|
||||||
|
renderTemplateForEach(template: any, arrayOrObservableArray: any[], options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
|
||||||
|
renderTemplateForEach(template: Function, arrayOrObservableArray: KnockoutObservable<any>, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
|
||||||
|
renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable<any>, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
|
||||||
|
|
||||||
|
expressionRewriting: {
|
||||||
|
bindingRewriteValidators: any;
|
||||||
|
parseObjectLiteral: { (objectLiteralString: string): any[] }
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
bindingProvider: {
|
||||||
|
instance: KnockoutBindingProvider;
|
||||||
|
new (): KnockoutBindingProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// selectExtensions.js
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
selectExtensions: {
|
||||||
|
|
||||||
|
readValue(element: HTMLElement): any;
|
||||||
|
|
||||||
|
writeValue(element: HTMLElement, value: any): void;
|
||||||
|
};
|
||||||
|
|
||||||
|
components: KnockoutComponents;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutBindingProvider {
|
||||||
|
nodeHasBindings(node: Node): boolean;
|
||||||
|
getBindings(node: Node, bindingContext: KnockoutBindingContext): {};
|
||||||
|
getBindingAccessors?(node: Node, bindingContext: KnockoutBindingContext): { [key: string]: string; };
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutComputedContext {
|
||||||
|
getDependenciesCount(): number;
|
||||||
|
isInitial: () => boolean;
|
||||||
|
isSleeping: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// refactored types into a namespace to reduce global pollution
|
||||||
|
// and used Union Types to simplify overloads (requires TypeScript 1.4)
|
||||||
|
//
|
||||||
|
declare module KnockoutComponentTypes {
|
||||||
|
|
||||||
|
interface Config {
|
||||||
|
viewModel?: ViewModelFunction | ViewModelSharedInstance | ViewModelFactoryFunction | AMDModule;
|
||||||
|
template: string | Node[]| DocumentFragment | TemplateElement | AMDModule;
|
||||||
|
synchronous?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ComponentConfig {
|
||||||
|
viewModel?: ViewModelFunction | ViewModelSharedInstance | ViewModelFactoryFunction | AMDModule;
|
||||||
|
template: any;
|
||||||
|
createViewModel?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EmptyConfig {
|
||||||
|
}
|
||||||
|
|
||||||
|
// common AMD type
|
||||||
|
interface AMDModule {
|
||||||
|
require: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// viewmodel types
|
||||||
|
interface ViewModelFunction {
|
||||||
|
(params?: any): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ViewModelSharedInstance {
|
||||||
|
instance: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ViewModelFactoryFunction {
|
||||||
|
createViewModel: (params?: any, componentInfo?: ComponentInfo) => any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ComponentInfo {
|
||||||
|
element: Node;
|
||||||
|
templateNodes: Node[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TemplateElement {
|
||||||
|
element: string | Node;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Loader {
|
||||||
|
getConfig? (componentName: string, callback: (result: ComponentConfig) => void): void;
|
||||||
|
loadComponent? (componentName: string, config: ComponentConfig, callback: (result: Definition) => void): void;
|
||||||
|
loadTemplate? (componentName: string, templateConfig: any, callback: (result: Node[]) => void): void;
|
||||||
|
loadViewModel? (componentName: string, viewModelConfig: any, callback: (result: any) => void): void;
|
||||||
|
suppressLoaderExceptions?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Definition {
|
||||||
|
template: Node[];
|
||||||
|
createViewModel? (params: any, options: { element: Node; }): any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnockoutComponents {
|
||||||
|
// overloads for register method:
|
||||||
|
register(componentName: string, config: KnockoutComponentTypes.Config | KnockoutComponentTypes.EmptyConfig): void;
|
||||||
|
|
||||||
|
isRegistered(componentName: string): boolean;
|
||||||
|
unregister(componentName: string): void;
|
||||||
|
get(componentName: string, callback: (definition: KnockoutComponentTypes.Definition) => void): void;
|
||||||
|
clearCachedDefinition(componentName: string): void
|
||||||
|
defaultLoader: KnockoutComponentTypes.Loader;
|
||||||
|
loaders: KnockoutComponentTypes.Loader[];
|
||||||
|
getComponentNameForNode(node: Node): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare var ko: KnockoutStatic;
|
||||||
|
|
||||||
|
declare module "knockout" {
|
||||||
|
export = ko;
|
||||||
|
}
|
|
@ -1 +1,3 @@
|
||||||
/// <reference path="@ms/odsp.d.ts" />
|
/// <reference path="@ms/odsp.d.ts" />
|
||||||
|
/// <reference path="assertion-error/assertion-error.d.ts" />
|
||||||
|
/// <reference path="knockout/knockout.d.ts" />
|
||||||
|
|
Loading…
Reference in New Issue