mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
Merge branch 'master' of https://github.com/dolanmiu/DefinitelyTyped
This commit is contained in:
@@ -1,22 +1,2 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Custom for Visual Studio
|
||||
*.cs diff=csharp
|
||||
*.sln merge=union
|
||||
*.csproj merge=union
|
||||
*.vbproj merge=union
|
||||
*.fsproj merge=union
|
||||
*.dbproj merge=union
|
||||
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
- [ ] I tried using the `@types/xxxx` package and had problems.
|
||||
- [ ] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
|
||||
- [ ] I have a question that is inappropriate for [StackOverflow](https://stackoverflow.com/). (Please ask any appropriate questions there).
|
||||
- [ ] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see `Definitions by:` in `index.d.ts`) so they can respond.
|
||||
- Authors: @....
|
||||
@@ -0,0 +1,25 @@
|
||||
Please fill in this template.
|
||||
|
||||
- [ ] Use a meaningful title for the pull request. Include the name of the package modified.
|
||||
- [ ] Test the change in your own code. (Compile and run.)
|
||||
- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request).
|
||||
- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes).
|
||||
- [ ] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present).
|
||||
|
||||
Select one of these and delete the others:
|
||||
|
||||
If adding a new definition:
|
||||
- [ ] The package does not provide its own types, and you can not add them.
|
||||
- [ ] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
|
||||
- [ ] Create it with `dts-gen --dt`, not by basing it on an existing project.
|
||||
- [ ] `tslint.json` should be present, and `tsconfig.json` should have `noImplicitAny`, `noImplicitThis`, and `strictNullChecks` set to `true`.
|
||||
|
||||
If changing an existing definition:
|
||||
- [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <<url here>>
|
||||
- [ ] Increase the version number in the header if appropriate.
|
||||
- [ ] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "dtslint/dt.json" }`.
|
||||
|
||||
If removing a declaration:
|
||||
- [ ] If a package was never on DefinitelyTyped, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.)
|
||||
- [ ] Delete the package's directory.
|
||||
- [ ] Add it to `notNeededPackages.json`.
|
||||
+11
-3
@@ -9,11 +9,9 @@
|
||||
*.cs
|
||||
*.sln
|
||||
*.csproj
|
||||
*.txt
|
||||
*.map
|
||||
*.swp
|
||||
.DS_Store
|
||||
npm-debug.log
|
||||
|
||||
_Resharper.DefinitelyTyped
|
||||
bin
|
||||
@@ -26,18 +24,28 @@ Properties
|
||||
# test folder
|
||||
_infrastructure/tests/build
|
||||
|
||||
# IntelliJ based IDEs
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
*.js.map
|
||||
!*.js/
|
||||
!scripts/new-package.js
|
||||
!scripts/not-needed.js
|
||||
!scripts/lint.js
|
||||
|
||||
# npm
|
||||
node_modules
|
||||
package-lock.json
|
||||
npm-debug.log
|
||||
|
||||
# Sublime
|
||||
.sublimets
|
||||
.settings/launch.json
|
||||
|
||||
# Visual Studio Code
|
||||
.settings/launch.json
|
||||
.vs
|
||||
.vscode
|
||||
|
||||
# yarn
|
||||
yarn.lock
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 6.9.2
|
||||
- node
|
||||
|
||||
sudo: false
|
||||
|
||||
|
||||
Vendored
-1500
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"3d-bin-packing-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Please see the [contribution guide](http://definitelytyped.org/guides/contributing.html) at [definitelytyped.org](http://definitelytyped.org/guides/contributing.html) for information on how to contribute to DefinitelyTyped.
|
||||
-1893
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
||||
- [ ] I tried using the latest `xxxx/xxxx.d.ts` file in this repo and had problems.
|
||||
- [ ] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
|
||||
- [ ] I have a question that is inappropriate for [StackOverflow](https://stackoverflow.com/). (Please ask any appropriate questions there).
|
||||
- [ ] I want to talk about `xxxx/xxxx.d.ts`.
|
||||
- The authors of that type definition are cc/ @....
|
||||
@@ -1,18 +0,0 @@
|
||||
Please fill in this template.
|
||||
|
||||
- [ ] Make your PR against the `master` branch.
|
||||
- [ ] Use a meaningful title for the pull request. Include the name of the package modified.
|
||||
- [ ] Test the change in your own code.
|
||||
- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped#make-a-pull-request).
|
||||
- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes).
|
||||
- [ ] Run `npm run lint -- package-name` if a `tslint.json` is present.
|
||||
|
||||
If adding a new definition:
|
||||
- [ ] The package does not provide its own types, and you can not add them.
|
||||
- [ ] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
|
||||
- [ ] Run `tsc` without errors.
|
||||
- [ ] Include the required [files](https://github.com/DefinitelyTyped/DefinitelyTyped#create-a-new-package) and header. Base these on the README, *not* on an existing project.
|
||||
|
||||
If changing an existing definition:
|
||||
- [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <<url here>>
|
||||
- [ ] Increase the version number in the header if appropriate.
|
||||
@@ -38,7 +38,7 @@ or just look for any ".d.ts" files in the package and manually include them with
|
||||
These can be used by TypeScript 1.0.
|
||||
|
||||
* [Typings](https://github.com/typings/typings)
|
||||
* [NuGet](http://nuget.org/Tpackages?q=DefinitelyTyped)
|
||||
* ~~[NuGet](http://nuget.org/Tpackages?q=DefinitelyTyped)~~ (use preferred alternatives, nuget DT type publishing has been turned off)
|
||||
* Manually download from the `master` branch of this repository
|
||||
|
||||
You may need to add manual [references](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html).
|
||||
@@ -71,7 +71,9 @@ Add to your `tsconfig.json`:
|
||||
Create `types/foo/index.d.ts` containing declarations for the module "foo".
|
||||
You should now be able import from `"foo"` in your code and it will route to the new type definition.
|
||||
Then build *and* run the code to make sure your type definition actually corresponds to what happens at runtime.
|
||||
Once you've tested your definitions with real code, make a PR contributing the definition by copying `types/foo` to `DefinitelyTyped/foo` and adding a `tsconfig.json` and `foo-tests.ts`.
|
||||
Once you've tested your definitions with real code, make a [PR](#make-a-pull-request)
|
||||
then follow the instructions to [edit an existing package](#edit-an-existing-package) or
|
||||
[create a new package](#create-a-new-package).
|
||||
|
||||
|
||||
### Make a pull request
|
||||
@@ -83,9 +85,17 @@ First, [fork](https://guides.github.com/activities/forking/) this repository, in
|
||||
|
||||
#### Edit an existing package
|
||||
|
||||
* `cd my-package-to-edit`
|
||||
* `cd types/my-package-to-edit`
|
||||
* Make changes. Remember to edit tests.
|
||||
* You may also want to add yourself to "Definitions by" section of the package header.
|
||||
- Do this by adding your name to the end of the line, as in `// Definitions by: Alice <https://github.com/alice>, Bob <https://github.com/bob>`.
|
||||
- Or if there are more people, it can be multiline
|
||||
```typescript
|
||||
// Definitions by: Alice <https://github.com/alice>
|
||||
// Bob <https://github.com/bob>
|
||||
// Steve <https://github.com/steve>
|
||||
// John <https://github.com/john>
|
||||
```
|
||||
* `npm install -g typescript@2.0` and run `tsc`.
|
||||
|
||||
When you make a PR to edit an existing package, `dt-bot` should @-mention previous authors.
|
||||
@@ -109,29 +119,24 @@ Your package should have this structure:
|
||||
| tsconfig.json | This allows you to run `tsc` within the package. |
|
||||
| tslint.json | Enables linting. |
|
||||
|
||||
Generate these by running `npm run new-package -- new-package-name`.
|
||||
Generate these by running `npm install -g dts-gen` and `dts-gen --dt --name my-package-name --template module`.
|
||||
See all options at [dts-gen](https://github.com/Microsoft/dts-gen).
|
||||
|
||||
You may edit the `tsconfig.json` to add new files or to add the `"jsx"` compiler option.
|
||||
You may edit the `tsconfig.json` to add new files, to add `"target": "es6"` (needed for async functions), to add to `"lib"`, or to add the `"jsx"` compiler option.
|
||||
|
||||
DefinitelyTyped members routinely monitor for new PRs, though keep in mind that the number of other PRs may slow things down.
|
||||
|
||||
For a good example package, see [base64-js](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/base64-js).
|
||||
For a good example package, see [base64-js](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/base64-js).
|
||||
|
||||
|
||||
#### Common mistakes
|
||||
|
||||
* First, follow advice from the [handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html).
|
||||
* Formatting: Either use all tabs, or always use 4 spaces. Also, always use semicolons, and use egyptian braces.
|
||||
* `interface X {}`: An empty interface is essentially the `{}` type: it places no constraints on an object.
|
||||
* `interface IFoo {}`: Don't add `I` to the front of an interface name.
|
||||
* Formatting: Either use all tabs, or always use 4 spaces.
|
||||
* `interface Foo { new(): Foo; }`:
|
||||
This defines a type of objects that are new-able. You probably want `declare class Foo { constructor(); }`.
|
||||
* `const Class: { new(): IClass; }`:
|
||||
Prefer to use a class declaration `class Class { constructor(); }` instead of a new-able constant.
|
||||
* `namespace foo {}`:
|
||||
Do not add a namespace just so that the `import * as foo` syntax will work.
|
||||
If it is commonJs module with a single export, you should use the `import foo = require("foo")` syntax.
|
||||
See more explanation [here](https://stackoverflow.com/questions/39415661/why-cant-i-import-a-class-or-function-with-import-as-x-from-y).
|
||||
* `getMeAT<T>(): T`:
|
||||
If a type parameter does not appear in the types of any parameters, you don't really have a generic function, you just have a disguised type assertion.
|
||||
Prefer to use a real type assertion, e.g. `getMeAT() as number`.
|
||||
@@ -157,23 +162,23 @@ If a package was never on DefinitelyTyped, it does not need to be added to `notN
|
||||
|
||||
#### Lint
|
||||
|
||||
To lint a package, just add a `tslint.json` to that package containing `{ "extends": "../tslint.json" }`. All new packages must be linted.
|
||||
To lint a package, just add a `tslint.json` to that package containing `{ "extends": "dtslint/dt.json" }`. All new packages must be linted.
|
||||
If a `tslint.json` turns rules off, this is because that hasn't been fixed yet. For example:
|
||||
|
||||
```json
|
||||
```js
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// This package uses the Function type, and it will take effort to fix.
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
(To indicate that a lint rule truly does not apply, use `// tslint:disable:rule-name` or better, `//tslint:disable-next-line:rule-name`.)
|
||||
(To indicate that a lint rule truly does not apply, use `// tslint:disable rule-name` or better, `//tslint:disable-next-line rule-name`.)
|
||||
|
||||
Only `.d.ts` files are linted.
|
||||
Test the linter by running `npm run lint -- package-name`. Do not use a globally installed tslint.
|
||||
Test by running `npm run lint package-name` where `package-name` is the name of your package.
|
||||
This script uses [dtslint](https://github.com/Microsoft/dtslint).
|
||||
|
||||
|
||||
## FAQ
|
||||
@@ -188,19 +193,14 @@ This usually happens within an hour of changes being merged.
|
||||
If the module you're referencing is an external module (uses `export`), use an import.
|
||||
If the module you're referencing is an ambient module (uses `declare module`, or just declares globals), use `<reference types="" />`.
|
||||
|
||||
#### What do I do about older versions of typings?
|
||||
|
||||
Currently we don't support this, though it is [planned](https://github.com/Microsoft/types-publisher/issues/3).
|
||||
If you're adding a new major version of a library, you can copy `index.d.ts` to `foo-v2.3.d.ts` and edit `index.d.ts` to be the new version.
|
||||
|
||||
#### I notice some packages having a `package.json` here.
|
||||
|
||||
Usually you won't need this. When publishing a package we will normally automatically create a `package.json` for it.
|
||||
A `package.json` may be included for the sake of specifying dependencies. Here's an [example](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/pikaday/package.json).
|
||||
A `package.json` may be included for the sake of specifying dependencies. Here's an [example](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pikaday/package.json).
|
||||
We do not allow other fields, such as `"description"`, to be defined manually.
|
||||
Also, if you need to reference an older version of typings, you must do that by adding `"dependencies": { "@types/foo": "x.y.z" }` to the package.json.
|
||||
|
||||
#### I notice some `tsconfig.json` are missing `"noImplicitAny": true`, `"noImplicitThis": true`, or `"strictNullChecks": true`.
|
||||
#### Some packages have no `tslint.json`, and some `tsconfig.json` are missing `"noImplicitAny": true`, `"noImplicitThis": true`, or `"strictNullChecks": true`.
|
||||
|
||||
Then they are wrong. You can help by submitting a pull request to fix them.
|
||||
|
||||
@@ -212,16 +212,62 @@ Here are the [currently requested definitions](https://github.com/DefinitelyType
|
||||
|
||||
If types are part of a web standard, they should be contributed to [TSJS-lib-generator](https://github.com/Microsoft/TSJS-lib-generator) so that they can become part of the default `lib.dom.d.ts`.
|
||||
|
||||
### A package uses `export =`, but I prefer to use default imports. Can I change `export =` to `export default`?
|
||||
#### A package uses `export =`, but I prefer to use default imports. Can I change `export =` to `export default`?
|
||||
|
||||
If default imports work in your environment, consider turning on the [`--allowSyntheticDefaultImports`](http://www.typescriptlang.org/docs/handbook/compiler-options.html) compiler option.
|
||||
Do not change the type definition if it is accurate.
|
||||
For an NPM package, `export =` is accurate if `node -p 'require("foo")'` is the export, and `export default` is accurate if `node -p 'require("foo").default'` is the export.
|
||||
|
||||
#### I want to use features from TypeScript 2.1.
|
||||
#### I want to use features from TypeScript 2.1 or above.
|
||||
|
||||
Then you will have to add a comment to your definition header: `// TypeScript Version: 2.1`.
|
||||
If it is merged before January 7, it will be published as a prerelease version, such as `4.3.0-next.0`.
|
||||
Then you will have to add a comment to the last line of your definition header (after `// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped`): `// TypeScript Version: 2.1`.
|
||||
|
||||
#### I want to add a DOM API not present in TypeScript by default.
|
||||
|
||||
This may belong in [TSJS-Lib-Generator](https://github.com/Microsoft/TSJS-lib-generator#readme). See the guidelines there.
|
||||
If the standard is still a draft, it belongs here.
|
||||
Use a name beginning with `dom-` and include a link to the standard as the "Project" link in the header.
|
||||
When it graduates draft mode, we may remove it from DefinitelyTyped and deprecate the associated `@types` package.
|
||||
|
||||
#### I want to update a package to a new major version
|
||||
|
||||
Before making your change, please create a new subfolder with the current version e.g. `v2`, and copy existing files to it. You will need to:
|
||||
|
||||
1. Update the relative paths in `tsconfig.json` as well as `tslint.json`.
|
||||
2. Add path mapping rules to ensure that tests are running against the intended version.
|
||||
|
||||
For example [history v2 `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/history/v2/tsconfig.json) looks like:
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": ["../../"],
|
||||
"paths": {
|
||||
"history": [ "history/v2" ]
|
||||
},
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"history-tests.ts"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Please note that unless upgrading something backwards-compatible like `node`, all packages depending of the updated package need a path mapping to it, as well as packages depending on *those*.
|
||||
For example, `react-router` depends on `history@2`, so [react-router `tsconfig.json`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router/tsconfig.json) has a path mapping to `"history": [ "history/v2" ]`;
|
||||
transitively `react-router-bootstrap` (which depends on `react-router`) also adds a path mapping in its [tsconfig.json](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-router-bootstrap/tsconfig.json).
|
||||
|
||||
Also, `/// <reference types=".." />` will not work with path mapping, so dependencies must use `import`.
|
||||
|
||||
#### What about scoped packages?
|
||||
|
||||
Types for a scoped package `@foo/bar` should go in `types/foo__bar`. Note the double underscore.
|
||||
|
||||
|
||||
#### The file history in GitHub looks incomplete.
|
||||
|
||||
GitHub doesn't [support](http://stackoverflow.com/questions/5646174/how-to-make-github-follow-directory-history-after-renames) file history for renamed files. Use [`git log --follow`](https://www.git-scm.com/docs/git-log) instead.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
import Abs from 'abs';
|
||||
|
||||
const x: string = Abs('/foo');
|
||||
Vendored
-13
@@ -1,13 +0,0 @@
|
||||
// Type definitions for abs 1.1.0
|
||||
// Project: https://github.com/IonicaBizau/node-abs
|
||||
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
/**
|
||||
* Compute the absolute path of an input.
|
||||
* @param input The input path.
|
||||
*/
|
||||
declare function Abs(input: string): string;
|
||||
|
||||
export default Abs;
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"abs-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"absolute-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-113
@@ -1,113 +0,0 @@
|
||||
// Type definitions for acc-wizard
|
||||
// Project: https://github.com/sathomas/acc-wizard
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface AccWizardOptions {
|
||||
/**
|
||||
* @summary Add next/prev buttons to panels.
|
||||
* @type {boolean}
|
||||
*/
|
||||
addButtons: boolean;
|
||||
|
||||
/**
|
||||
* @summary Selector for task sidebar.
|
||||
* @type {string}
|
||||
*/
|
||||
sidebar: string;
|
||||
|
||||
/**
|
||||
* @summary Class to indicate the active task in sidebar.
|
||||
* @type {string}
|
||||
*/
|
||||
activeClass: string;
|
||||
|
||||
/**
|
||||
* @summary Class to indicate task is complete.
|
||||
* @type {string}
|
||||
*/
|
||||
completedClass: string;
|
||||
|
||||
/**
|
||||
* @summary Class to indicate task is still pending.
|
||||
* @type {string}
|
||||
*/
|
||||
todoClass: string;
|
||||
|
||||
/**
|
||||
* @summary Class for step buttons within panels.
|
||||
* @type {string}
|
||||
*/
|
||||
stepClass: string;
|
||||
|
||||
/**
|
||||
* @summary Text for next button.
|
||||
* @type {string}
|
||||
*/
|
||||
nextText: string;
|
||||
|
||||
/**
|
||||
* @summary Text for back button.
|
||||
* @type {string}
|
||||
*/
|
||||
backText: string;
|
||||
|
||||
/**
|
||||
* @summary HTML input type for next button. (default: "submit")
|
||||
* @type {string}
|
||||
*/
|
||||
nextType: string;
|
||||
|
||||
/**
|
||||
* @summary HTML input type for back button. (default: "reset")
|
||||
* @type {string}
|
||||
*/
|
||||
backType: string;
|
||||
|
||||
/**
|
||||
* @summary Class(es) for next button.
|
||||
* @type {string}
|
||||
*/
|
||||
nextClasses: string;
|
||||
|
||||
/**
|
||||
* @summary Class(es) for back button.
|
||||
* @type {string}
|
||||
*/
|
||||
backClasses: string;
|
||||
|
||||
/**
|
||||
* @summary Auto-scrolling.
|
||||
* @type {boolean}
|
||||
*/
|
||||
autoScrolling: boolean;
|
||||
|
||||
/**
|
||||
* @summary Function to call on next step.
|
||||
*/
|
||||
onNext: Function;
|
||||
|
||||
/**
|
||||
* @summary Function to call on back up.
|
||||
*/
|
||||
onBack: Function;
|
||||
|
||||
/**
|
||||
* @summary A chance to hook initialization.
|
||||
*/
|
||||
onInit: Function;
|
||||
|
||||
/**
|
||||
* @summary A chance to hook destruction.
|
||||
*/
|
||||
onDestroy: Function;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Interface for "acc-wizard" JQuery plugin.
|
||||
* @author Cyril Schumacher
|
||||
* @version 1.0
|
||||
*/
|
||||
interface JQuery {
|
||||
accwizard(options?: AccWizardOptions): void;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"acc-wizard-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-31
@@ -1,31 +0,0 @@
|
||||
// Type definitions for accepts 1.3
|
||||
// Project: https://github.com/jshttp/accepts
|
||||
// Definitions by: Stefan Reichel <https://github.com/bomret>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
import { IncomingMessage } from "http";
|
||||
|
||||
declare namespace accepts {
|
||||
export interface Accepts {
|
||||
charset(charsets: string[]): string | string[] | boolean;
|
||||
charset(...charsets: string[]): string | string[] | boolean;
|
||||
charsets(): string[];
|
||||
|
||||
encoding(encodings: string[]): string | string[] | boolean;
|
||||
encoding(...encodings: string[]): string | string[] | boolean;
|
||||
encodings(): string[];
|
||||
|
||||
language(languages: string[]): string | string[] | boolean;
|
||||
language(...languages: string[]): string | string[] | boolean;
|
||||
languages(): string[];
|
||||
|
||||
type(types: string[]): string | string[] | boolean;
|
||||
type(...types: string[]): string | string[] | boolean;
|
||||
types(): string[];
|
||||
}
|
||||
}
|
||||
|
||||
declare function accepts(req: IncomingMessage): accepts.Accepts;
|
||||
|
||||
export = accepts;
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"accepts-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-74
@@ -1,74 +0,0 @@
|
||||
// Type definitions for accounting.js 0.3
|
||||
// Project: http://josscrowcroft.github.io/accounting.js/
|
||||
// Definitions by: Sergey Gerasimov <https://github.com/gerich-home/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace accounting {
|
||||
interface CurrencyFormat {
|
||||
pos: string; // for positive values, eg. "$ 1.00"
|
||||
neg?: string; // for negative values, eg. "$ (1.00)"
|
||||
zero?: string; // for zero values, eg. "$ --"
|
||||
}
|
||||
|
||||
interface CurrencySettings<TFormat> {
|
||||
symbol?: string; // default currency symbol is '$'
|
||||
format?: TFormat; // controls output: %s = symbol, %v = value/number
|
||||
decimal?: string; // decimal point separator
|
||||
thousand?: string; // thousands separator
|
||||
precision?: number; // decimal places
|
||||
}
|
||||
|
||||
interface NumberSettings {
|
||||
precision?: number; // default precision on numbers is 0
|
||||
thousand?: string;
|
||||
decimal?: string;
|
||||
}
|
||||
|
||||
interface Settings {
|
||||
currency: CurrencySettings<any>; // IAccountingCurrencySettings<string> or IAccountingCurrencySettings<IAccountingCurrencyFormat>
|
||||
number: NumberSettings;
|
||||
}
|
||||
|
||||
interface Static {
|
||||
// format any number into currency
|
||||
formatMoney(number: number, symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string;
|
||||
formatMoney(number: number, options: CurrencySettings<string> | CurrencySettings<CurrencyFormat>): string;
|
||||
|
||||
formatMoney(numbers: number[], symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string[];
|
||||
formatMoney(numbers: number[], options: CurrencySettings<string> | CurrencySettings<CurrencyFormat>): string[];
|
||||
|
||||
// generic case (any array of numbers)
|
||||
formatMoney(numbers: any[], symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): any[];
|
||||
formatMoney(numbers: any[], options: CurrencySettings<string> | CurrencySettings<CurrencyFormat>): any[];
|
||||
|
||||
// format a list of values for column-display
|
||||
formatColumn(numbers: number[], symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string[];
|
||||
formatColumn(numbers: number[], options: CurrencySettings<string> | CurrencySettings<CurrencyFormat>): string[];
|
||||
|
||||
formatColumn(numbers: number[][], symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string[][];
|
||||
formatColumn(numbers: number[][], options: CurrencySettings<string> | CurrencySettings<CurrencyFormat>): string[][];
|
||||
|
||||
// format a number with custom precision and localisation
|
||||
formatNumber(number: number, precision?: number, thousand?: string, decimal?: string): string;
|
||||
formatNumber(number: number, options: NumberSettings): string;
|
||||
|
||||
formatNumber(number: number[], precision?: number, thousand?: string, decimal?: string): string[];
|
||||
formatNumber(number: number[], options: NumberSettings): string[];
|
||||
|
||||
formatNumber(number: any[], precision?: number, thousand?: string, decimal?: string): any[];
|
||||
formatNumber(number: any[], options: NumberSettings): any[];
|
||||
|
||||
// better rounding for floating point numbers
|
||||
toFixed(number: number, precision?: number): string;
|
||||
|
||||
// get a value from any formatted number/currency string
|
||||
unformat(string: string, decimal?: string): number;
|
||||
|
||||
// settings object that controls default parameters for library methods
|
||||
settings: Settings;
|
||||
}
|
||||
}
|
||||
|
||||
declare var accounting: accounting.Static;
|
||||
export = accounting;
|
||||
export as namespace accounting;
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"accounting-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
@@ -1,26 +0,0 @@
|
||||
|
||||
|
||||
var exports: any;
|
||||
var assert: any;
|
||||
var MockRenderer: any = null;
|
||||
var JavaScriptMode: any = null;
|
||||
|
||||
/// <reference path="tests/ace-default-tests.ts" />
|
||||
/// <reference path="tests/ace-background_tokenizer-tests.ts" />
|
||||
/// <reference path="tests/ace-document-tests.ts" />
|
||||
/// <reference path="tests/ace-edit_session-tests.ts" />
|
||||
/// <reference path="tests/ace-editor1-tests.ts" />
|
||||
/// <reference path="tests/ace-editor_highlight_selected_word-tests.ts" />
|
||||
/// <reference path="tests/ace-editor_navigation-tests.ts" />
|
||||
/// <reference path="tests/ace-editor_text_edit-tests.ts" />
|
||||
/// <reference path="tests/ace-multi_select-tests.ts" />
|
||||
/// <reference path="tests/ace-placeholder-tests.ts" />
|
||||
/// <reference path="tests/ace-range_list-tests.ts" />
|
||||
/// <reference path="tests/ace-range-tests.ts" />
|
||||
/// <reference path="tests/ace-search-tests.ts" />
|
||||
/// <reference path="tests/ace-selection-tests.ts" />
|
||||
/// <reference path="tests/ace-token_iterator-tests.ts" />
|
||||
/// <reference path="tests/ace-virtual_renderer-tests.ts" />
|
||||
|
||||
|
||||
|
||||
Vendored
-2983
File diff suppressed because it is too large
Load Diff
@@ -1,132 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
|
||||
"test create anchor" : function() {
|
||||
var doc = new AceAjax.Document("juhu");
|
||||
var anchor = new AceAjax.Anchor(doc, 0, 0);
|
||||
|
||||
assert.position(anchor.getPosition(), 0, 0);
|
||||
assert.equal(anchor.getDocument(), doc);
|
||||
},
|
||||
|
||||
"test insert text in same row before cursor should move anchor column": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
doc.insert({row: 1, column: 1}, "123");
|
||||
assert.position(anchor.getPosition(), 1, 7);
|
||||
},
|
||||
|
||||
"test insert lines before cursor should move anchor row": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
doc.insertLines(1, ["123", "456"]);
|
||||
assert.position(anchor.getPosition(), 3, 4);
|
||||
},
|
||||
|
||||
"test insert new line before cursor should move anchor column": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
doc.insertNewLine({row: 0, column: 0});
|
||||
assert.position(anchor.getPosition(), 2, 4);
|
||||
},
|
||||
|
||||
"test insert new line in anchor line before anchor should move anchor column and row": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
doc.insertNewLine({row: 1, column: 2});
|
||||
assert.position(anchor.getPosition(), 2, 2);
|
||||
},
|
||||
|
||||
"test delete text in anchor line before anchor should move anchor column": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
doc.remove(new AceAjax.Range(1, 1, 1, 3));
|
||||
assert.position(anchor.getPosition(), 1, 2);
|
||||
},
|
||||
|
||||
"test remove range which contains the anchor should move the anchor to the start of the range": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 0, 3);
|
||||
|
||||
doc.remove(new AceAjax.Range(0, 1, 1, 3));
|
||||
assert.position(anchor.getPosition(), 0, 1);
|
||||
},
|
||||
|
||||
"test delete character before the anchor should have no effect": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
doc.remove(new AceAjax.Range(1, 4, 1, 5));
|
||||
assert.position(anchor.getPosition(), 1, 4);
|
||||
},
|
||||
|
||||
"test delete lines in anchor line before anchor should move anchor row": function() {
|
||||
var doc = new AceAjax.Document("juhu\n1\n2\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 3, 4);
|
||||
|
||||
doc.removeLines(1, 2);
|
||||
assert.position(anchor.getPosition(), 1, 4);
|
||||
},
|
||||
|
||||
"test remove new line before the cursor": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
doc.removeNewLine(0);
|
||||
assert.position(anchor.getPosition(), 0, 8);
|
||||
},
|
||||
|
||||
"test delete range which contains the anchor should move anchor to the end of the range": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 4);
|
||||
|
||||
doc.remove(new AceAjax.Range(0, 2, 1, 2));
|
||||
assert.position(anchor.getPosition(), 0, 4);
|
||||
},
|
||||
|
||||
"test delete line which contains the anchor should move anchor to the end of the range": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners\n123");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 5);
|
||||
|
||||
doc.removeLines(1, 1);
|
||||
assert.position(anchor.getPosition(), 1, 0);
|
||||
},
|
||||
|
||||
"test remove after the anchor should have no effect": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners\n123");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 2);
|
||||
|
||||
doc.remove(new AceAjax.Range(1, 4, 2, 2));
|
||||
assert.position(anchor.getPosition(), 1, 2);
|
||||
},
|
||||
|
||||
"test anchor changes triggered by document changes should emit change event": function(next) {
|
||||
var doc = new AceAjax.Document("juhu\nkinners\n123");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 5);
|
||||
|
||||
anchor.on("change", function(e) {
|
||||
assert.position(anchor.getPosition(), 0, 0);
|
||||
next();
|
||||
});
|
||||
|
||||
doc.remove(new AceAjax.Range(0, 0, 2, 1));
|
||||
},
|
||||
|
||||
"test only fire change event if position changes": function() {
|
||||
var doc = new AceAjax.Document("juhu\nkinners\n123");
|
||||
var anchor = new AceAjax.Anchor(doc, 1, 5);
|
||||
|
||||
anchor.on("change", function(e) {
|
||||
assert.fail();
|
||||
});
|
||||
|
||||
doc.remove(new AceAjax.Range(2, 0, 2, 1));
|
||||
}
|
||||
};
|
||||
@@ -1,41 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
|
||||
function forceTokenize(session) {
|
||||
for (var i = 0, l = session.getLength(); i < l; i++)
|
||||
session.getTokens(i)
|
||||
}
|
||||
|
||||
function testStates(session, states) {
|
||||
for (var i = 0, l = session.getLength(); i < l; i++)
|
||||
assert.equal(session.bgTokenizer.states[i], states[i])
|
||||
assert.ok(l == states.length)
|
||||
}
|
||||
|
||||
var exports = {
|
||||
|
||||
"test background tokenizer update on session change": function() {
|
||||
var doc = new AceAjax.EditSession([
|
||||
"/*",
|
||||
"*/",
|
||||
"var juhu"
|
||||
]);
|
||||
doc.setMode("./mode/javascript")
|
||||
|
||||
forceTokenize(doc)
|
||||
testStates(doc, ["comment", "start", "start"])
|
||||
|
||||
doc.remove(new AceAjax.Range(0, 2, 1, 2))
|
||||
testStates(doc, [null, "start"])
|
||||
|
||||
forceTokenize(doc)
|
||||
testStates(doc, ["comment", "comment"])
|
||||
|
||||
doc.insert({ row: 0, column: 2 }, "\n*/")
|
||||
testStates(doc, [undefined, undefined, "comment"])
|
||||
|
||||
forceTokenize(doc)
|
||||
testStates(doc, ["comment", "start", "start"])
|
||||
}
|
||||
};
|
||||
@@ -1,454 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/monokai");
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
|
||||
editor.on("blur", (e) => e);
|
||||
editor.on("change", (e) => e);
|
||||
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
|
||||
editor.setValue("the new text here"); // or session.setValue
|
||||
editor.getValue(); // or session.getValue
|
||||
|
||||
editor.session.getTextRange(editor.getSelectionRange());
|
||||
|
||||
editor.insert("Something cool");
|
||||
|
||||
editor.selection.getCursor();
|
||||
|
||||
editor.gotoLine(123);
|
||||
|
||||
editor.session.getLength();
|
||||
|
||||
editor.getSession().setTabSize(4);
|
||||
|
||||
editor.getSession().setUseSoftTabs(true);
|
||||
|
||||
document.getElementById('editor').style.fontSize = '12px';
|
||||
|
||||
editor.getSession().setUseWrapMode(true);
|
||||
|
||||
editor.setHighlightActiveLine(false);
|
||||
|
||||
editor.setShowPrintMargin(false);
|
||||
|
||||
editor.setReadOnly(true); // false to make it editable
|
||||
|
||||
editor.resize()
|
||||
|
||||
editor.find('needle', {
|
||||
backwards: false,
|
||||
wrap: false,
|
||||
caseSensitive: false,
|
||||
wholeWord: false,
|
||||
regExp: false
|
||||
});
|
||||
editor.findNext();
|
||||
editor.findPrevious();
|
||||
|
||||
editor.find('foo');
|
||||
editor.replace('bar');
|
||||
|
||||
editor.replaceAll('bar');
|
||||
|
||||
editor.getSession().on('change', function (e) {
|
||||
// e.type, etc
|
||||
});
|
||||
|
||||
editor.getSession().selection.on('changeSelection', function (e) {
|
||||
});
|
||||
|
||||
editor.getSession().selection.on('changeCursor', function (e) {
|
||||
});
|
||||
|
||||
editor.commands.addCommand({
|
||||
name: 'myCommand',
|
||||
bindKey: { win: 'Ctrl-M', mac: 'Command-M' },
|
||||
exec: function (editor) {
|
||||
//...
|
||||
},
|
||||
readOnly: true // false if this command should not apply in readOnly mode
|
||||
});
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.removeLines();
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
editor.moveCursorTo(3, 0);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
editor.moveCursorTo(1, 3);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.indent();
|
||||
|
||||
var range = editor.getSelectionRange();
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.indent();
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.onTextInput("\n");
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.getSelection().selectDown();
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.blockOutdent();
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.removeLines();
|
||||
|
||||
var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n"));
|
||||
|
||||
assert.equal(session.toString(), "a\nc\nd");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(session.toString(), "a\nd");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(session.toString(), "a");
|
||||
assert.position(editor.getCursorPosition(), 0, 1);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(session.toString(), "");
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.removeLines();
|
||||
assert.equal(session.toString(), "a\nd");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(session.toString(), "b\nc");
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
|
||||
|
||||
editor.moveCursorTo(3, 0);
|
||||
|
||||
editor.removeLines();
|
||||
assert.equal(session.toString(), "a\nb\nc");
|
||||
assert.position(editor.getCursorPosition(), 2, 1);
|
||||
|
||||
editor.removeLines();
|
||||
assert.equal(session.toString(), "a\nb");
|
||||
assert.position(editor.getCursorPosition(), 1, 1);
|
||||
|
||||
|
||||
editor.moveCursorTo(1, 3);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.indent();
|
||||
|
||||
assert.equal(["a12345", " b12345", " c12345"].join("\n"), session.toString());
|
||||
|
||||
assert.position(editor.getCursorPosition(), 2, 7);
|
||||
|
||||
range = editor.getSelectionRange();
|
||||
assert.position(range.start, 1, 7);
|
||||
assert.position(range.end, 2, 7);
|
||||
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.indent();
|
||||
assert.equal(["a12345", " b12345", "c12345"].join("\n"), session.toString());
|
||||
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.onTextInput("\n");
|
||||
assert.equal(["", "{"].join("\n"), session.toString());
|
||||
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.getSelection().selectDown();
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.blockOutdent();
|
||||
assert.equal(session.toString(), [" a12345", "b12345", " c12345"].join("\n"));
|
||||
|
||||
assert.position(editor.getCursorPosition(), 2, 1);
|
||||
|
||||
range = editor.getSelectionRange();
|
||||
assert.position(range.start, 0, 1);
|
||||
assert.position(range.end, 2, 1);
|
||||
|
||||
editor.blockOutdent();
|
||||
assert.equal(session.toString(), ["a12345", "b12345", "c12345"].join("\n"));
|
||||
|
||||
range = editor.getSelectionRange();
|
||||
assert.position(range.start, 0, 0);
|
||||
assert.position(range.end, 2, 0);
|
||||
|
||||
|
||||
editor.moveCursorTo(0, 3);
|
||||
editor.blockOutdent(" ");
|
||||
|
||||
assert.equal(session.toString(), " 12");
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
|
||||
|
||||
editor.moveCursorTo(0, 2);
|
||||
editor.getSelection().selectDown();
|
||||
editor.toggleCommentLines();
|
||||
|
||||
assert.equal(["// abc", "//cde"].join("\n"), session.toString());
|
||||
|
||||
var selection = editor.getSelectionRange();
|
||||
assert.position(selection.start, 0, 4);
|
||||
assert.position(selection.end, 1, 4);
|
||||
|
||||
|
||||
editor.moveCursorTo(0, 1);
|
||||
editor.getSelection().selectDown();
|
||||
editor.getSelection().selectRight();
|
||||
editor.getSelection().selectRight();
|
||||
|
||||
editor.toggleCommentLines();
|
||||
|
||||
assert.equal([" abc", "cde"].join("\n"), session.toString());
|
||||
assert.range(editor.getSelectionRange(), 0, 0, 1, 1);
|
||||
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.getSelection().selectDown();
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.toggleCommentLines();
|
||||
editor.toggleCommentLines();
|
||||
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
|
||||
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.toggleCommentLines();
|
||||
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
|
||||
|
||||
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectUp();
|
||||
|
||||
editor.toggleCommentLines();
|
||||
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
|
||||
|
||||
|
||||
editor.moveCursorTo(0, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["33", "11", "22", "44"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["33", "44", "11", "22"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 2, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 2);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 2, 0);
|
||||
|
||||
// moving again should have no effect
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["33", "44", "11", "22"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 2, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 2);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 2, 0);
|
||||
|
||||
|
||||
editor.moveCursorTo(2, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.moveLinesUp();
|
||||
assert.equal(session.toString(), ["11", "33", "44", "22"].join("\n"));
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||
|
||||
editor.moveLinesUp();
|
||||
assert.equal(session.toString(), ["33", "44", "11", "22"].join("\n"));
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 2, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 0, 0);
|
||||
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.clearSelection();
|
||||
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["11", "33", "22", "44"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 2, 1);
|
||||
|
||||
editor.clearSelection();
|
||||
|
||||
editor.moveLinesUp();
|
||||
assert.equal(["11", "22", "33", "44"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 1, 1);
|
||||
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.copyLinesDown();
|
||||
assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString());
|
||||
|
||||
assert.position(editor.getCursorPosition(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 5, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 3, 0);
|
||||
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.copyLinesUp();
|
||||
assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString());
|
||||
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||
|
||||
|
||||
session.setTabSize(2);
|
||||
session.setUseSoftTabs(true);
|
||||
|
||||
editor.onTextInput("\t");
|
||||
assert.equal(session.toString(), " ");
|
||||
|
||||
session.setTabSize(5);
|
||||
editor.onTextInput("\t");
|
||||
assert.equal(session.toString(), " ");
|
||||
|
||||
|
||||
session.setUseSoftTabs(false);
|
||||
|
||||
editor.onTextInput("\t");
|
||||
assert.equal(session.toString(), "\t");
|
||||
|
||||
editor.removeLines();
|
||||
var step1 = session.toString();
|
||||
assert.equal(step1, "222\n333");
|
||||
|
||||
editor.removeLines();
|
||||
var step2 = session.toString();
|
||||
assert.equal(step2, "333");
|
||||
|
||||
editor.removeLines();
|
||||
var step3 = session.toString();
|
||||
assert.equal(step3, "");
|
||||
|
||||
var undoManager = new AceAjax.UndoManager();
|
||||
|
||||
undoManager.undo();
|
||||
assert.equal(session.toString(), step2);
|
||||
|
||||
undoManager.undo();
|
||||
assert.equal(session.toString(), step1);
|
||||
|
||||
undoManager.undo();
|
||||
assert.equal(session.toString(), "");
|
||||
|
||||
undoManager.undo();
|
||||
assert.equal(session.toString(), "");
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.remove("left");
|
||||
assert.equal(session.toString(), "123\n56");
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.remove("left");
|
||||
assert.equal(session.toString(), "123456");
|
||||
|
||||
session.setUseSoftTabs(true);
|
||||
session.setTabSize(4);
|
||||
|
||||
editor.moveCursorTo(1, 8);
|
||||
editor.remove("left");
|
||||
assert.equal(session.toString(), "123\n 456");
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.transposeLetters();
|
||||
|
||||
assert.equal(session.getValue(), ["123", "4567", "89"].join("\n"));
|
||||
|
||||
editor.moveCursorTo(1, 2);
|
||||
editor.transposeLetters();
|
||||
|
||||
assert.equal(session.getValue(), ["123", "4657", "89"].join("\n"));
|
||||
|
||||
editor.moveCursorTo(1, 4);
|
||||
editor.transposeLetters();
|
||||
|
||||
assert.equal(session.getValue(), ["123", "4576", "89"].join("\n"));
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectRight();
|
||||
editor.transposeLetters();
|
||||
|
||||
assert.equal(session.getValue(), ["123", "4567", "89"].join("\n"));
|
||||
|
||||
editor.moveCursorTo(1, 2);
|
||||
editor.transposeLetters();
|
||||
assert.position(editor.getCursorPosition(), 1, 3);
|
||||
|
||||
editor.moveCursorTo(1, 2);
|
||||
editor.removeToLineEnd();
|
||||
assert.equal(session.getValue(), ["123", "45", "89"].join("\n"));
|
||||
|
||||
editor.moveCursorTo(1, 4);
|
||||
editor.removeToLineEnd();
|
||||
assert.position(editor.getCursorPosition(), 1, 4);
|
||||
assert.equal(session.getValue(), ["123", "456789"].join("\n"));
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectLineEnd();
|
||||
editor.toUpperCase()
|
||||
assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n"));
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.toUpperCase()
|
||||
assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n"));
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectLineEnd();
|
||||
editor.toLowerCase()
|
||||
assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n"));
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.toLowerCase()
|
||||
assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n"));
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
@@ -1,255 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
"test: insert text in line": function() {
|
||||
var doc = new AceAjax.Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.insert({ row: 0, column: 1 }, "juhu");
|
||||
assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: insert new line": function() {
|
||||
var doc = new AceAjax.Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertNewLine({ row: 0, column: 1 });
|
||||
assert.equal(doc.getValue(), ["1", "2", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1", "2", "34"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: insert lines at the beginning": function() {
|
||||
var doc = new AceAjax.Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertLines(0, ["aa", "bb"]);
|
||||
assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: insert lines at the end": function() {
|
||||
var doc = new AceAjax.Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertLines(2, ["aa", "bb"]);
|
||||
assert.equal(doc.getValue(), ["12", "34", "aa", "bb"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: insert lines in the middle": function() {
|
||||
var doc = new AceAjax.Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertLines(1, ["aa", "bb"]);
|
||||
assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: insert multi line string at the start": function() {
|
||||
var doc = new AceAjax.Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.insert({ row: 0, column: 0 }, "aa\nbb\ncc");
|
||||
assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: insert multi line string at the end": function() {
|
||||
var doc = new AceAjax.Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.insert({ row: 2, column: 0 }, "aa\nbb\ncc");
|
||||
assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: insert multi line string in the middle": function() {
|
||||
var doc = new AceAjax.Document(["12", "34"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.insert({ row: 0, column: 1 }, "aa\nbb\ncc");
|
||||
assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12", "34"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: delete in line": function() {
|
||||
var doc = new AceAjax.Document(["1234", "5678"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.remove(new AceAjax.Range(0, 1, 0, 3));
|
||||
assert.equal(doc.getValue(), ["14", "5678"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1234", "5678"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["14", "5678"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: delete new line": function() {
|
||||
var doc = new AceAjax.Document(["1234", "5678"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.remove(new AceAjax.Range(0, 4, 1, 0));
|
||||
assert.equal(doc.getValue(), ["12345678"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1234", "5678"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12345678"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: delete multi line range line": function() {
|
||||
var doc = new AceAjax.Document(["1234", "5678", "abcd"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.remove(new AceAjax.Range(0, 2, 2, 2));
|
||||
assert.equal(doc.getValue(), ["12cd"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
doc.revertDeltas(d);
|
||||
assert.equal(doc.getValue(), ["1234", "5678", "abcd"].join("\n"));
|
||||
|
||||
doc.applyDeltas(d);
|
||||
assert.equal(doc.getValue(), ["12cd"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: delete full lines": function() {
|
||||
var doc = new AceAjax.Document(["1234", "5678", "abcd"]);
|
||||
|
||||
var deltas = [];
|
||||
doc.on("change", function (e) { deltas.push(e.data); });
|
||||
|
||||
doc.remove(new AceAjax.Range(1, 0, 3, 0));
|
||||
assert.equal(doc.getValue(), ["1234", ""].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: remove lines should return the removed lines": function() {
|
||||
var doc = new AceAjax.Document(["1234", "5678", "abcd"]);
|
||||
|
||||
var removed = doc.removeLines(1, 2);
|
||||
assert.equal(removed.join("\n"), ["5678", "abcd"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: should handle unix style new lines": function() {
|
||||
var doc = new AceAjax.Document(["1", "2", "3"]);
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: should handle windows style new lines": function() {
|
||||
var doc = new AceAjax.Document(["1", "2", "3"].join("\r\n"));
|
||||
|
||||
doc.setNewLineMode("unix");
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: set new line mode to 'windows' should use '\\r\\n' as new lines": function() {
|
||||
var doc = new AceAjax.Document(["1", "2", "3"].join("\n"));
|
||||
doc.setNewLineMode("windows");
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\r\n"));
|
||||
} ,
|
||||
|
||||
"test: set new line mode to 'unix' should use '\\n' as new lines": function() {
|
||||
var doc = new AceAjax.Document(["1", "2", "3"].join("\r\n"));
|
||||
|
||||
doc.setNewLineMode("unix");
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: set new line mode to 'auto' should detect the incoming nl type": function() {
|
||||
var doc = new AceAjax.Document(["1", "2", "3"].join("\n"));
|
||||
|
||||
doc.setNewLineMode("auto");
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\n"));
|
||||
|
||||
var doc = new AceAjax.Document(["1", "2", "3"].join("\r\n"));
|
||||
|
||||
doc.setNewLineMode("auto");
|
||||
assert.equal(doc.getValue(), ["1", "2", "3"].join("\r\n"));
|
||||
|
||||
doc.replace(new AceAjax.Range(0, 0, 2, 1), ["4", "5", "6"].join("\n"));
|
||||
assert.equal(["4", "5", "6"].join("\n"), doc.getValue());
|
||||
} ,
|
||||
|
||||
"test: set value": function() {
|
||||
var doc = new AceAjax.Document("1");
|
||||
assert.equal("1", doc.getValue());
|
||||
|
||||
doc.setValue(doc.getValue());
|
||||
assert.equal("1", doc.getValue());
|
||||
|
||||
var doc = new AceAjax.Document("1\n2");
|
||||
assert.equal("1\n2", doc.getValue());
|
||||
|
||||
doc.setValue(doc.getValue());
|
||||
assert.equal("1\n2", doc.getValue());
|
||||
}
|
||||
};
|
||||
@@ -1,920 +0,0 @@
|
||||
|
||||
|
||||
var lang: any;
|
||||
var assert: any;
|
||||
|
||||
function createFoldTestSession() {
|
||||
var lines = [
|
||||
"function foo(items) {",
|
||||
" for (var i=0; i<items.length; i++) {",
|
||||
" alert(items[i] + \"juhu\");",
|
||||
" } // Real Tab.",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"));
|
||||
session.setUndoManager(new AceAjax.UndoManager());
|
||||
session.addFold("args...", new AceAjax.Range(0, 13, 0, 18));
|
||||
session.addFold("foo...", new AceAjax.Range(1, 10, 2, 10));
|
||||
session.addFold("bar...", new AceAjax.Range(2, 20, 2, 25));
|
||||
return session;
|
||||
}
|
||||
|
||||
function assertArray(a, b) {
|
||||
assert.equal(a + "", b + "");
|
||||
assert.ok(a.length == b.length);
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
assert.equal(a[i], b[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var exports = {
|
||||
|
||||
"test: find matching opening bracket in Text mode": function() {
|
||||
var session = new AceAjax.EditSession(["(()(", "())))"]);
|
||||
|
||||
assert.position(session.findMatchingBracket({ row: 0, column: 3 }), 0, 1);
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 2 }), 1, 0);
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 3 }), 0, 3);
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 4 }), 0, 0);
|
||||
assert.equal(session.findMatchingBracket({ row: 1, column: 5 }), null);
|
||||
} ,
|
||||
|
||||
"test: find matching closing bracket in Text mode": function() {
|
||||
var session = new AceAjax.EditSession(["(()(", "())))"]);
|
||||
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 1 }), 1, 1);
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 1 }), 1, 1);
|
||||
assert.position(session.findMatchingBracket({ row: 0, column: 4 }), 1, 2);
|
||||
assert.position(session.findMatchingBracket({ row: 0, column: 2 }), 0, 2);
|
||||
assert.position(session.findMatchingBracket({ row: 0, column: 1 }), 1, 3);
|
||||
assert.equal(session.findMatchingBracket({ row: 0, column: 0 }), null);
|
||||
} ,
|
||||
|
||||
"test: find matching opening bracket in JavaScript mode": function() {
|
||||
var lines = [
|
||||
"function foo() {",
|
||||
" var str = \"{ foo()\";",
|
||||
" if (debug) {",
|
||||
" // write str (a string) to the console",
|
||||
" console.log(str);",
|
||||
" }",
|
||||
" str += \" bar() }\";",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"), null);
|
||||
|
||||
assert.position(session.findMatchingBracket({ row: 0, column: 14 }), 0, 12);
|
||||
assert.position(session.findMatchingBracket({ row: 7, column: 1 }), 0, 15);
|
||||
assert.position(session.findMatchingBracket({ row: 6, column: 20 }), 1, 15);
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 22 }), 1, 20);
|
||||
assert.position(session.findMatchingBracket({ row: 3, column: 31 }), 3, 21);
|
||||
assert.position(session.findMatchingBracket({ row: 4, column: 24 }), 4, 19);
|
||||
assert.equal(session.findMatchingBracket({ row: 0, column: 1 }), null);
|
||||
} ,
|
||||
|
||||
"test: find matching closing bracket in JavaScript mode": function() {
|
||||
var lines = [
|
||||
"function foo() {",
|
||||
" var str = \"{ foo()\";",
|
||||
" if (debug) {",
|
||||
" // write str (a string) to the console",
|
||||
" console.log(str);",
|
||||
" }",
|
||||
" str += \" bar() }\";",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"), null);
|
||||
|
||||
assert.position(session.findMatchingBracket({ row: 0, column: 13 }), 0, 13);
|
||||
assert.position(session.findMatchingBracket({ row: 0, column: 16 }), 7, 0);
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 16 }), 6, 19);
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 21 }), 1, 21);
|
||||
assert.position(session.findMatchingBracket({ row: 3, column: 22 }), 3, 30);
|
||||
assert.position(session.findMatchingBracket({ row: 4, column: 20 }), 4, 23);
|
||||
} ,
|
||||
|
||||
"test: handle unbalanced brackets in JavaScript mode": function() {
|
||||
var lines = [
|
||||
"function foo() {",
|
||||
" var str = \"{ foo()\";",
|
||||
" if (debug) {",
|
||||
" // write str a string) to the console",
|
||||
" console.log(str);",
|
||||
" ",
|
||||
" str += \" bar() \";",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"), null);
|
||||
|
||||
assert.equal(session.findMatchingBracket({ row: 0, column: 16 }), null);
|
||||
assert.equal(session.findMatchingBracket({ row: 3, column: 30 }), null);
|
||||
assert.equal(session.findMatchingBracket({ row: 1, column: 16 }), null);
|
||||
} ,
|
||||
|
||||
"test: match different bracket types": function() {
|
||||
var session = new AceAjax.EditSession(["({[", ")]}"]);
|
||||
|
||||
assert.position(session.findMatchingBracket({ row: 0, column: 1 }), 1, 0);
|
||||
assert.position(session.findMatchingBracket({ row: 0, column: 2 }), 1, 2);
|
||||
assert.position(session.findMatchingBracket({ row: 0, column: 3 }), 1, 1);
|
||||
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 1 }), 0, 0);
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 2 }), 0, 2);
|
||||
assert.position(session.findMatchingBracket({ row: 1, column: 3 }), 0, 1);
|
||||
} ,
|
||||
|
||||
"test: move lines down": function() {
|
||||
var session = new AceAjax.EditSession(["a1", "a2", "a3", "a4"]);
|
||||
|
||||
session.moveLinesDown(0, 1);
|
||||
assert.equal(session.getValue(), ["a3", "a1", "a2", "a4"].join("\n"));
|
||||
|
||||
session.moveLinesDown(1, 2);
|
||||
assert.equal(session.getValue(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
session.moveLinesDown(2, 3);
|
||||
assert.equal(session.getValue(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
session.moveLinesDown(2, 2);
|
||||
assert.equal(session.getValue(), ["a3", "a4", "a2", "a1"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: move lines up": function() {
|
||||
var session = new AceAjax.EditSession(["a1", "a2", "a3", "a4"]);
|
||||
|
||||
session.moveLinesUp(2, 3);
|
||||
assert.equal(session.getValue(), ["a1", "a3", "a4", "a2"].join("\n"));
|
||||
|
||||
session.moveLinesUp(1, 2);
|
||||
assert.equal(session.getValue(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
session.moveLinesUp(0, 1);
|
||||
assert.equal(session.getValue(), ["a3", "a4", "a1", "a2"].join("\n"));
|
||||
|
||||
session.moveLinesUp(2, 2);
|
||||
assert.equal(session.getValue(), ["a3", "a1", "a4", "a2"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: duplicate lines": function() {
|
||||
var session = new AceAjax.EditSession(["1", "2", "3", "4"]);
|
||||
|
||||
session.duplicateLines(1, 2);
|
||||
assert.equal(session.getValue(), ["1", "2", "3", "2", "3", "4"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: duplicate last line": function() {
|
||||
var session = new AceAjax.EditSession(["1", "2", "3"]);
|
||||
|
||||
session.duplicateLines(2, 2);
|
||||
assert.equal(session.getValue(), ["1", "2", "3", "3"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: duplicate first line": function() {
|
||||
var session = new AceAjax.EditSession(["1", "2", "3"]);
|
||||
|
||||
session.duplicateLines(0, 0);
|
||||
assert.equal(session.getValue(), ["1", "1", "2", "3"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test: getScreenLastRowColumn": function() {
|
||||
var session = new AceAjax.EditSession([
|
||||
"juhu",
|
||||
"12\t\t34",
|
||||
"??a"
|
||||
]);
|
||||
|
||||
assert.equal(session.getScreenLastRowColumn(0), 4);
|
||||
assert.equal(session.getScreenLastRowColumn(1), 10);
|
||||
assert.equal(session.getScreenLastRowColumn(2), 5);
|
||||
} ,
|
||||
|
||||
"test: convert document to screen coordinates": function() {
|
||||
var session = new AceAjax.EditSession("01234\t567890\t1234");
|
||||
session.setTabSize(4);
|
||||
|
||||
assert.equal(session.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(session.documentToScreenColumn(0, 4), 4);
|
||||
assert.equal(session.documentToScreenColumn(0, 5), 5);
|
||||
assert.equal(session.documentToScreenColumn(0, 6), 8);
|
||||
assert.equal(session.documentToScreenColumn(0, 12), 14);
|
||||
assert.equal(session.documentToScreenColumn(0, 13), 16);
|
||||
|
||||
session.setTabSize(2);
|
||||
|
||||
assert.equal(session.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(session.documentToScreenColumn(0, 4), 4);
|
||||
assert.equal(session.documentToScreenColumn(0, 5), 5);
|
||||
assert.equal(session.documentToScreenColumn(0, 6), 6);
|
||||
assert.equal(session.documentToScreenColumn(0, 7), 7);
|
||||
assert.equal(session.documentToScreenColumn(0, 12), 12);
|
||||
assert.equal(session.documentToScreenColumn(0, 13), 14);
|
||||
} ,
|
||||
|
||||
"test: convert document to screen coordinates with leading tabs": function() {
|
||||
var session = new AceAjax.EditSession("\t\t123");
|
||||
session.setTabSize(4);
|
||||
|
||||
assert.equal(session.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(session.documentToScreenColumn(0, 1), 4);
|
||||
assert.equal(session.documentToScreenColumn(0, 2), 8);
|
||||
assert.equal(session.documentToScreenColumn(0, 3), 9);
|
||||
} ,
|
||||
|
||||
"test: documentToScreen without soft wrap": function() {
|
||||
var session = new AceAjax.EditSession([
|
||||
"juhu",
|
||||
"12\t\t34",
|
||||
"??a"
|
||||
]);
|
||||
|
||||
assert.position(session.documentToScreenPosition(0, 3), 0, 3);
|
||||
assert.position(session.documentToScreenPosition(1, 3), 1, 4);
|
||||
assert.position(session.documentToScreenPosition(1, 4), 1, 8);
|
||||
assert.position(session.documentToScreenPosition(2, 2), 2, 4);
|
||||
} ,
|
||||
|
||||
"test: documentToScreen with soft wrap": function() {
|
||||
var session = new AceAjax.EditSession(["foo bar foo bar"]);
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(12, 12);
|
||||
session.adjustWrapLimit(80);
|
||||
|
||||
assert.position(session.documentToScreenPosition(0, 11), 0, 11);
|
||||
assert.position(session.documentToScreenPosition(0, 12), 1, 0);
|
||||
} ,
|
||||
|
||||
"test: documentToScreen with soft wrap and multibyte characters": function() {
|
||||
var session = new AceAjax.EditSession(["??a"]);
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(2, 2);
|
||||
session.adjustWrapLimit(80);
|
||||
|
||||
assert.position(session.documentToScreenPosition(0, 1), 1, 0);
|
||||
assert.position(session.documentToScreenPosition(0, 2), 2, 0);
|
||||
assert.position(session.documentToScreenPosition(0, 4), 2, 1);
|
||||
} ,
|
||||
|
||||
"test: documentToScreen should clip position to the document boundaries": function() {
|
||||
var session = new AceAjax.EditSession("foo bar\njuhu kinners");
|
||||
|
||||
assert.position(session.documentToScreenPosition(-1, 4), 0, 0);
|
||||
assert.position(session.documentToScreenPosition(3, 0), 1, 12);
|
||||
} ,
|
||||
|
||||
"test: convert screen to document coordinates": function() {
|
||||
var session = new AceAjax.EditSession("01234\t567890\t1234");
|
||||
session.setTabSize(4);
|
||||
|
||||
assert.equal(session.screenToDocumentColumn(0, 0), 0);
|
||||
assert.equal(session.screenToDocumentColumn(0, 4), 4);
|
||||
assert.equal(session.screenToDocumentColumn(0, 5), 5);
|
||||
assert.equal(session.screenToDocumentColumn(0, 6), 5);
|
||||
assert.equal(session.screenToDocumentColumn(0, 7), 5);
|
||||
assert.equal(session.screenToDocumentColumn(0, 8), 6);
|
||||
assert.equal(session.screenToDocumentColumn(0, 9), 7);
|
||||
assert.equal(session.screenToDocumentColumn(0, 15), 12);
|
||||
assert.equal(session.screenToDocumentColumn(0, 19), 16);
|
||||
|
||||
session.setTabSize(2);
|
||||
|
||||
assert.equal(session.screenToDocumentColumn(0, 0), 0);
|
||||
assert.equal(session.screenToDocumentColumn(0, 4), 4);
|
||||
assert.equal(session.screenToDocumentColumn(0, 5), 5);
|
||||
assert.equal(session.screenToDocumentColumn(0, 6), 6);
|
||||
assert.equal(session.screenToDocumentColumn(0, 12), 12);
|
||||
assert.equal(session.screenToDocumentColumn(0, 13), 12);
|
||||
assert.equal(session.screenToDocumentColumn(0, 14), 13);
|
||||
} ,
|
||||
|
||||
"test: screenToDocument with soft wrap": function() {
|
||||
var session = new AceAjax.EditSession(["foo bar foo bar"]);
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(12, 12);
|
||||
session.adjustWrapLimit(80);
|
||||
|
||||
assert.position(session.screenToDocumentPosition(1, 0), 0, 12);
|
||||
assert.position(session.screenToDocumentPosition(0, 11), 0, 11);
|
||||
// Check if the position is clamped the right way.
|
||||
assert.position(session.screenToDocumentPosition(0, 12), 0, 11);
|
||||
assert.position(session.screenToDocumentPosition(0, 20), 0, 11);
|
||||
} ,
|
||||
|
||||
"test: screenToDocument with soft wrap and multi byte characters": function() {
|
||||
var session = new AceAjax.EditSession(["? a"]);
|
||||
session.setUseWrapMode(true);
|
||||
session.adjustWrapLimit(80);
|
||||
|
||||
assert.position(session.screenToDocumentPosition(0, 1), 0, 0);
|
||||
assert.position(session.screenToDocumentPosition(0, 2), 0, 1);
|
||||
assert.position(session.screenToDocumentPosition(0, 3), 0, 2);
|
||||
assert.position(session.screenToDocumentPosition(0, 4), 0, 3);
|
||||
assert.position(session.screenToDocumentPosition(0, 5), 0, 3);
|
||||
} ,
|
||||
|
||||
"test: screenToDocument should clip position to the document boundaries": function() {
|
||||
var session = new AceAjax.EditSession("foo bar\njuhu kinners");
|
||||
|
||||
assert.position(session.screenToDocumentPosition(-1, 4), 0, 0);
|
||||
assert.position(session.screenToDocumentPosition(0, -1), 0, 0);
|
||||
assert.position(session.screenToDocumentPosition(0, 30), 0, 7);
|
||||
assert.position(session.screenToDocumentPosition(2, 4), 1, 12);
|
||||
assert.position(session.screenToDocumentPosition(1, 30), 1, 12);
|
||||
assert.position(session.screenToDocumentPosition(20, 50), 1, 12);
|
||||
assert.position(session.screenToDocumentPosition(20, 5), 1, 12);
|
||||
|
||||
// and the same for folded rows
|
||||
session.addFold("...", new AceAjax.Range(0, 1, 1, 3));
|
||||
assert.position(session.screenToDocumentPosition(1, 2), 1, 12);
|
||||
// for wrapped rows
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(5, 5);
|
||||
assert.position(session.screenToDocumentPosition(4, 1), 1, 12);
|
||||
} ,
|
||||
|
||||
"test: wrapLine split function": function() {
|
||||
function computeAndAssert(line, assertEqual, wrapLimit?, tabSize?) {
|
||||
wrapLimit = wrapLimit || 12;
|
||||
tabSize = tabSize || 4;
|
||||
line = lang.stringTrimRight(line);
|
||||
var tokens = AceAjax.EditSession.prototype.$getDisplayTokens(line);
|
||||
var splits = AceAjax.EditSession.prototype.$computeWrapSplits(tokens, wrapLimit, tabSize);
|
||||
// console.log("String:", line, "Result:", splits, "Expected:", assertEqual);
|
||||
assert.ok(splits.length == assertEqual.length);
|
||||
for (var i = 0; i < splits.length; i++) {
|
||||
assert.ok(splits[i] == assertEqual[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Basic splitting.
|
||||
computeAndAssert("foo bar foo bar", [12]);
|
||||
computeAndAssert("foo bar f bar", [12]);
|
||||
computeAndAssert("foo bar f r", [14]);
|
||||
computeAndAssert("foo bar foo bar foo bara foo", [12, 25]);
|
||||
|
||||
// Don't split if there is only whitespaces/tabs at the end of the line.
|
||||
computeAndAssert("foo foo foo \t \t", []);
|
||||
|
||||
// If there is no space to split, force split.
|
||||
computeAndAssert("foooooooooooooo", [12]);
|
||||
computeAndAssert("fooooooooooooooooooooooooooo", [12, 24]);
|
||||
computeAndAssert("foo bar fooooooooooobooooooo", [8, 20]);
|
||||
|
||||
// Basic splitting + tabs.
|
||||
computeAndAssert("foo \t\tbar", [6]);
|
||||
computeAndAssert("foo \t \tbar", [7]);
|
||||
|
||||
// Ignore spaces/tabs at beginning of split.
|
||||
computeAndAssert("foo \t \t \t \t bar", [14]);
|
||||
|
||||
// Test wrapping for asian characters.
|
||||
computeAndAssert("??", [1], 2);
|
||||
computeAndAssert(" ??", [1, 2], 2);
|
||||
computeAndAssert(" ?\t?", [1, 3], 2);
|
||||
computeAndAssert(" ??\t?", [1, 4], 4);
|
||||
|
||||
// Test wrapping for punctuation.
|
||||
computeAndAssert(" ab.c;ef++", [1, 3, 5, 7, 8], 2);
|
||||
computeAndAssert(" a.b", [1, 2, 3], 1);
|
||||
computeAndAssert("#>>", [1, 2], 1);
|
||||
} ,
|
||||
|
||||
"test get longest line": function() {
|
||||
var session = new AceAjax.EditSession(["12"]);
|
||||
session.setTabSize(4);
|
||||
assert.equal(session.getScreenWidth(), 2);
|
||||
|
||||
session.doc.insertNewLine({ row: 0, column: Infinity });
|
||||
session.doc.insertLines(1, ["123"]);
|
||||
assert.equal(session.getScreenWidth(), 3);
|
||||
|
||||
session.doc.insertNewLine({ row: 0, column: Infinity });
|
||||
session.doc.insertLines(1, ["\t\t"]);
|
||||
|
||||
assert.equal(session.getScreenWidth(), 8);
|
||||
|
||||
session.setTabSize(2);
|
||||
assert.equal(session.getScreenWidth(), 4);
|
||||
} ,
|
||||
|
||||
"test issue 83": function() {
|
||||
var session = new AceAjax.EditSession("");
|
||||
var editor = new AceAjax.Editor(null, session);
|
||||
var document = session.getDocument();
|
||||
|
||||
session.setUseWrapMode(true);
|
||||
|
||||
document.insertLines(0, ["a", "b"]);
|
||||
document.insertLines(2, ["c", "d"]);
|
||||
document.removeLines(1, 2);
|
||||
} ,
|
||||
|
||||
"test wrapMode init has to create wrapData array": function() {
|
||||
var session = new AceAjax.EditSession("foo bar\nfoo bar");
|
||||
var editor = new AceAjax.Editor(null, session);
|
||||
var document = session.getDocument();
|
||||
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(3, 3);
|
||||
session.adjustWrapLimit(80);
|
||||
} ,
|
||||
|
||||
"test first line blank with wrap": function() {
|
||||
var session = new AceAjax.EditSession("\nfoo");
|
||||
session.setUseWrapMode(true);
|
||||
assert.equal(session.doc.getValue(), ["", "foo"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test first line blank with wrap 2": function() {
|
||||
var session = new AceAjax.EditSession("");
|
||||
session.setUseWrapMode(true);
|
||||
session.setValue("\nfoo");
|
||||
|
||||
assert.equal(session.doc.getValue(), ["", "foo"].join("\n"));
|
||||
} ,
|
||||
|
||||
"test fold getFoldDisplayLine": function() {
|
||||
var session = createFoldTestSession();
|
||||
function assertDisplayLine(foldLine, str) {
|
||||
var line = session.getLine(foldLine.end.row);
|
||||
var displayLine =
|
||||
session.getFoldDisplayLine(foldLine, foldLine.end.row, line.length);
|
||||
assert.equal(displayLine, str);
|
||||
}
|
||||
} ,
|
||||
|
||||
"test foldLine idxToPosition": function() {
|
||||
var session = createFoldTestSession();
|
||||
|
||||
function assertIdx2Pos(foldLineIdx, idx, row, column) {
|
||||
var foldLine = null;
|
||||
assert.position(foldLine.idxToPosition(idx), row, column);
|
||||
}
|
||||
|
||||
// "function foo(items) {",
|
||||
// " for (var i=0; i<items.length; i++) {",
|
||||
// " alert(items[i] + \"juhu\");",
|
||||
// " } // Real Tab.",
|
||||
// "}"
|
||||
|
||||
assertIdx2Pos(0, 12, 0, 12);
|
||||
assertIdx2Pos(0, 13, 0, 13);
|
||||
assertIdx2Pos(0, 14, 0, 13);
|
||||
assertIdx2Pos(0, 19, 0, 13);
|
||||
assertIdx2Pos(0, 20, 0, 18);
|
||||
|
||||
assertIdx2Pos(1, 10, 1, 10);
|
||||
assertIdx2Pos(1, 11, 1, 10);
|
||||
assertIdx2Pos(1, 15, 1, 10);
|
||||
assertIdx2Pos(1, 16, 2, 10);
|
||||
assertIdx2Pos(1, 26, 2, 20);
|
||||
assertIdx2Pos(1, 27, 2, 20);
|
||||
assertIdx2Pos(1, 32, 2, 25);
|
||||
} ,
|
||||
|
||||
"test fold documentToScreen": function() {
|
||||
var session = createFoldTestSession();
|
||||
function assertDoc2Screen(docRow, docCol, screenRow, screenCol) {
|
||||
assert.position(
|
||||
session.documentToScreenPosition(docRow, docCol),
|
||||
screenRow, screenCol
|
||||
);
|
||||
}
|
||||
|
||||
// One fold ending in the same row.
|
||||
assertDoc2Screen(0, 0, 0, 0);
|
||||
assertDoc2Screen(0, 13, 0, 13);
|
||||
assertDoc2Screen(0, 14, 0, 13);
|
||||
assertDoc2Screen(0, 17, 0, 13);
|
||||
assertDoc2Screen(0, 18, 0, 20);
|
||||
|
||||
// Fold ending on some other row.
|
||||
assertDoc2Screen(1, 0, 1, 0);
|
||||
assertDoc2Screen(1, 10, 1, 10);
|
||||
assertDoc2Screen(1, 11, 1, 10);
|
||||
assertDoc2Screen(1, 99, 1, 10);
|
||||
|
||||
assertDoc2Screen(2, 0, 1, 10);
|
||||
assertDoc2Screen(2, 9, 1, 10);
|
||||
assertDoc2Screen(2, 10, 1, 16);
|
||||
assertDoc2Screen(2, 11, 1, 17);
|
||||
|
||||
// Fold in the same row with fold over more then one row in the same row.
|
||||
assertDoc2Screen(2, 19, 1, 25);
|
||||
assertDoc2Screen(2, 20, 1, 26);
|
||||
assertDoc2Screen(2, 21, 1, 26);
|
||||
|
||||
assertDoc2Screen(2, 24, 1, 26);
|
||||
assertDoc2Screen(2, 25, 1, 32);
|
||||
assertDoc2Screen(2, 26, 1, 33);
|
||||
assertDoc2Screen(2, 99, 1, 40);
|
||||
|
||||
// Test one position after the folds. Should be all like normal.
|
||||
assertDoc2Screen(3, 0, 2, 0);
|
||||
} ,
|
||||
|
||||
"test fold screenToDocument": function() {
|
||||
var session = createFoldTestSession();
|
||||
function assertScreen2Doc(docRow, docCol, screenRow, screenCol) {
|
||||
assert.position(
|
||||
session.screenToDocumentPosition(screenRow, screenCol),
|
||||
docRow, docCol
|
||||
);
|
||||
}
|
||||
|
||||
// One fold ending in the same row.
|
||||
assertScreen2Doc(0, 0, 0, 0);
|
||||
assertScreen2Doc(0, 13, 0, 13);
|
||||
assertScreen2Doc(0, 13, 0, 14);
|
||||
assertScreen2Doc(0, 18, 0, 20);
|
||||
assertScreen2Doc(0, 19, 0, 21);
|
||||
|
||||
// Fold ending on some other row.
|
||||
assertScreen2Doc(1, 0, 1, 0);
|
||||
assertScreen2Doc(1, 10, 1, 10);
|
||||
assertScreen2Doc(1, 10, 1, 11);
|
||||
|
||||
assertScreen2Doc(1, 10, 1, 15);
|
||||
assertScreen2Doc(2, 10, 1, 16);
|
||||
assertScreen2Doc(2, 11, 1, 17);
|
||||
|
||||
// Fold in the same row with fold over more then one row in the same row.
|
||||
assertScreen2Doc(2, 19, 1, 25);
|
||||
assertScreen2Doc(2, 20, 1, 26);
|
||||
assertScreen2Doc(2, 20, 1, 27);
|
||||
|
||||
assertScreen2Doc(2, 20, 1, 31);
|
||||
assertScreen2Doc(2, 25, 1, 32);
|
||||
assertScreen2Doc(2, 26, 1, 33);
|
||||
assertScreen2Doc(2, 33, 1, 99);
|
||||
|
||||
// Test one position after the folds. Should be all like normal.
|
||||
assertScreen2Doc(3, 0, 2, 0);
|
||||
} ,
|
||||
|
||||
"test getFoldsInRange()": function() {
|
||||
var session = createFoldTestSession();
|
||||
var foldLines = null;
|
||||
var folds = foldLines[0].folds.concat(foldLines[1].folds);
|
||||
|
||||
function test(startRow, startColumn, endColumn, endRow, folds) {
|
||||
var r = new AceAjax.Range(startRow, startColumn, endColumn, endRow);
|
||||
var retFolds = session.getFoldsInRange(r);
|
||||
|
||||
assert.ok(retFolds.length == folds.length);
|
||||
for (var i = 0; i < retFolds.length; i++) {
|
||||
assert.equal(retFolds[i].range + "", folds[i].range + "");
|
||||
}
|
||||
}
|
||||
|
||||
test(0, 0, 0, 13, []);
|
||||
test(0, 0, 0, 14, [folds[0]]);
|
||||
test(0, 0, 0, 18, [folds[0]]);
|
||||
test(0, 0, 1, 10, [folds[0]]);
|
||||
test(0, 0, 1, 11, [folds[0], folds[1]]);
|
||||
test(0, 18, 1, 11, [folds[1]]);
|
||||
test(2, 0, 2, 13, [folds[1]]);
|
||||
test(2, 10, 2, 20, []);
|
||||
test(2, 10, 2, 11, []);
|
||||
test(2, 19, 2, 20, []);
|
||||
} ,
|
||||
|
||||
"test fold one-line text insert": function() {
|
||||
// These are mostly test for the FoldLine.addRemoveChars function.
|
||||
var session = createFoldTestSession();
|
||||
var undoManager = session.getUndoManager();
|
||||
var foldLines = null;
|
||||
|
||||
function insert(row, column, text) {
|
||||
session.insert({ row: row, column: column }, text);
|
||||
}
|
||||
|
||||
var foldLine, fold, folds;
|
||||
// First line.
|
||||
foldLine = null;
|
||||
fold = foldLine.folds[0];
|
||||
|
||||
insert(0, 0, "0");
|
||||
assert.range(foldLine.range, 0, 14, 0, 19);
|
||||
assert.range(fold.range, 0, 14, 0, 19);
|
||||
insert(0, 14, "1");
|
||||
assert.range(foldLine.range, 0, 15, 0, 20);
|
||||
assert.range(fold.range, 0, 15, 0, 20);
|
||||
insert(0, 20, "2");
|
||||
assert.range(foldLine.range, 0, 15, 0, 20);
|
||||
assert.range(fold.range, 0, 15, 0, 20);
|
||||
|
||||
// Second line.
|
||||
foldLine = null;
|
||||
folds = foldLine.folds;
|
||||
|
||||
insert(1, 0, "3");
|
||||
assert.range(foldLine.range, 1, 11, 2, 25);
|
||||
assert.range(folds[0].range, 1, 11, 2, 10);
|
||||
assert.range(folds[1].range, 2, 20, 2, 25);
|
||||
|
||||
insert(1, 11, "4");
|
||||
assert.range(foldLine.range, 1, 12, 2, 25);
|
||||
assert.range(folds[0].range, 1, 12, 2, 10);
|
||||
assert.range(folds[1].range, 2, 20, 2, 25);
|
||||
|
||||
insert(2, 10, "5");
|
||||
assert.range(foldLine.range, 1, 12, 2, 26);
|
||||
assert.range(folds[0].range, 1, 12, 2, 10);
|
||||
assert.range(folds[1].range, 2, 21, 2, 26);
|
||||
|
||||
insert(2, 21, "6");
|
||||
assert.range(foldLine.range, 1, 12, 2, 27);
|
||||
assert.range(folds[0].range, 1, 12, 2, 10);
|
||||
assert.range(folds[1].range, 2, 22, 2, 27);
|
||||
|
||||
insert(2, 27, "7");
|
||||
assert.range(foldLine.range, 1, 12, 2, 27);
|
||||
assert.range(folds[0].range, 1, 12, 2, 10);
|
||||
assert.range(folds[1].range, 2, 22, 2, 27);
|
||||
|
||||
// UNDO = REMOVE
|
||||
undoManager.undo(); // 6
|
||||
assert.range(foldLine.range, 1, 12, 2, 27);
|
||||
assert.range(folds[0].range, 1, 12, 2, 10);
|
||||
assert.range(folds[1].range, 2, 22, 2, 27);
|
||||
|
||||
undoManager.undo(); // 5
|
||||
assert.range(foldLine.range, 1, 12, 2, 26);
|
||||
assert.range(folds[0].range, 1, 12, 2, 10);
|
||||
assert.range(folds[1].range, 2, 21, 2, 26);
|
||||
|
||||
undoManager.undo(); // 4
|
||||
assert.range(foldLine.range, 1, 12, 2, 25);
|
||||
assert.range(folds[0].range, 1, 12, 2, 10);
|
||||
assert.range(folds[1].range, 2, 20, 2, 25);
|
||||
|
||||
undoManager.undo(); // 3
|
||||
assert.range(foldLine.range, 1, 11, 2, 25);
|
||||
assert.range(folds[0].range, 1, 11, 2, 10);
|
||||
assert.range(folds[1].range, 2, 20, 2, 25);
|
||||
|
||||
undoManager.undo(); // Beginning first line.
|
||||
assert.equal(foldLines.length, 2);
|
||||
assert.range(foldLines[0].range, 0, 15, 0, 20);
|
||||
assert.range(foldLines[1].range, 1, 10, 2, 25);
|
||||
|
||||
foldLine = null;
|
||||
fold = foldLine.folds[0];
|
||||
|
||||
undoManager.undo(); // 2
|
||||
assert.range(foldLine.range, 0, 15, 0, 20);
|
||||
assert.range(fold.range, 0, 15, 0, 20);
|
||||
|
||||
undoManager.undo(); // 1
|
||||
assert.range(foldLine.range, 0, 14, 0, 19);
|
||||
assert.range(fold.range, 0, 14, 0, 19);
|
||||
|
||||
undoManager.undo(); // 0
|
||||
assert.range(foldLine.range, 0, 13, 0, 18);
|
||||
assert.range(fold.range, 0, 13, 0, 18);
|
||||
} ,
|
||||
|
||||
"test fold multi-line insert/remove": function() {
|
||||
var session = createFoldTestSession(),
|
||||
undoManager = session.getUndoManager(),
|
||||
foldLines = null;
|
||||
function insert(row, column, text) {
|
||||
session.insert({ row: row, column: column }, text);
|
||||
}
|
||||
|
||||
var foldLines = null, foldLine, fold, folds;
|
||||
|
||||
insert(0, 0, "\nfo0");
|
||||
assert.equal(foldLines.length, 2);
|
||||
assert.range(foldLines[0].range, 1, 16, 1, 21);
|
||||
assert.range(foldLines[1].range, 2, 10, 3, 25);
|
||||
|
||||
insert(2, 0, "\nba1");
|
||||
assert.equal(foldLines.length, 2);
|
||||
assert.range(foldLines[0].range, 1, 16, 1, 21);
|
||||
assert.range(foldLines[1].range, 3, 13, 4, 25);
|
||||
|
||||
insert(3, 10, "\nfo2");
|
||||
assert.equal(foldLines.length, 2);
|
||||
assert.range(foldLines[0].range, 1, 16, 1, 21);
|
||||
assert.range(foldLines[1].range, 4, 6, 5, 25);
|
||||
|
||||
insert(5, 10, "\nba3");
|
||||
assert.equal(foldLines.length, 3);
|
||||
assert.range(foldLines[0].range, 1, 16, 1, 21);
|
||||
assert.range(foldLines[1].range, 4, 6, 5, 10);
|
||||
assert.range(foldLines[2].range, 6, 13, 6, 18);
|
||||
|
||||
insert(6, 18, "\nfo4");
|
||||
assert.equal(foldLines.length, 3);
|
||||
assert.range(foldLines[0].range, 1, 16, 1, 21);
|
||||
assert.range(foldLines[1].range, 4, 6, 5, 10);
|
||||
assert.range(foldLines[2].range, 6, 13, 6, 18);
|
||||
|
||||
undoManager.undo(); // 3
|
||||
assert.equal(foldLines.length, 3);
|
||||
assert.range(foldLines[0].range, 1, 16, 1, 21);
|
||||
assert.range(foldLines[1].range, 4, 6, 5, 10);
|
||||
assert.range(foldLines[2].range, 6, 13, 6, 18);
|
||||
|
||||
undoManager.undo(); // 2
|
||||
assert.equal(foldLines.length, 2);
|
||||
assert.range(foldLines[0].range, 1, 16, 1, 21);
|
||||
assert.range(foldLines[1].range, 4, 6, 5, 25);
|
||||
|
||||
undoManager.undo(); // 1
|
||||
assert.equal(foldLines.length, 2);
|
||||
assert.range(foldLines[0].range, 1, 16, 1, 21);
|
||||
assert.range(foldLines[1].range, 3, 13, 4, 25);
|
||||
|
||||
undoManager.undo(); // 0
|
||||
assert.equal(foldLines.length, 2);
|
||||
assert.range(foldLines[0].range, 1, 16, 1, 21);
|
||||
assert.range(foldLines[1].range, 2, 10, 3, 25);
|
||||
|
||||
undoManager.undo(); // Beginning
|
||||
assert.equal(foldLines.length, 2);
|
||||
assert.range(foldLines[0].range, 0, 13, 0, 18);
|
||||
assert.range(foldLines[1].range, 1, 10, 2, 25);
|
||||
// TODO: Add test for inseration inside of folds.
|
||||
} ,
|
||||
|
||||
"test fold wrap data compution": function() {
|
||||
function assertWrap(line0, line1, line2) {
|
||||
line0 && assertArray(wrapData[0], line0);
|
||||
line1 && assertArray(wrapData[1], line1);
|
||||
line2 && assertArray(wrapData[2], line2);
|
||||
}
|
||||
|
||||
function removeFoldAssertWrap(docRow, docColumn, line0, line1, line2) {
|
||||
session.removeFold(session.getFoldAt(docRow, docColumn));
|
||||
assertWrap(line0, line1, line2);
|
||||
}
|
||||
|
||||
var lines = [
|
||||
"foo bar foo bar",
|
||||
"foo bar foo bar",
|
||||
"foo bar foo bar"
|
||||
];
|
||||
|
||||
var session = new AceAjax.EditSession(lines.join("\n"));
|
||||
session.setUseWrapMode(true);
|
||||
var wrapData = null;
|
||||
|
||||
// Do a simple assertion without folds to check basic functionallity.
|
||||
assertWrap([8], [8], [8]);
|
||||
|
||||
// --- Do in line folding ---
|
||||
|
||||
// Adding a fold. The split position is inside of the fold. As placeholder
|
||||
// are not splitable, the split should be before the split.
|
||||
session.addFold("woot", new AceAjax.Range(0, 4, 0, 15));
|
||||
assertWrap([4], [8], [8]);
|
||||
|
||||
// Remove the fold again which should reset the wrapData.
|
||||
removeFoldAssertWrap(0, 4, [8], [8], [8]);
|
||||
|
||||
session.addFold("woot", new AceAjax.Range(0, 6, 0, 9));
|
||||
assertWrap([6, 13], [8], [8]);
|
||||
removeFoldAssertWrap(0, 6, [8], [8], [8]);
|
||||
|
||||
// The fold fits into the wrap limit - no split expected.
|
||||
session.addFold("woot", new AceAjax.Range(0, 3, 0, 15));
|
||||
assertWrap([], [8], [8]);
|
||||
removeFoldAssertWrap(0, 4, [8], [8], [8]);
|
||||
|
||||
// Fold after split position should be all fine.
|
||||
session.addFold("woot", new AceAjax.Range(0, 8, 0, 15));
|
||||
assertWrap([8], [8], [8]);
|
||||
removeFoldAssertWrap(0, 8, [8], [8], [8]);
|
||||
|
||||
// Fold's placeholder is far too long for wrapSplit.
|
||||
session.addFold("woot0123456789", new AceAjax.Range(0, 8, 0, 15));
|
||||
assertWrap([8], [8], [8]);
|
||||
removeFoldAssertWrap(0, 8, [8], [8], [8]);
|
||||
|
||||
// Fold's placeholder is far too long for wrapSplit
|
||||
// + content at the end of the line
|
||||
session.addFold("woot0123456789", new AceAjax.Range(0, 6, 0, 8));
|
||||
assertWrap([6, 20], [8], [8]);
|
||||
removeFoldAssertWrap(0, 8, [8], [8], [8]);
|
||||
|
||||
session.addFold("woot0123456789", new AceAjax.Range(0, 6, 0, 8));
|
||||
session.addFold("woot0123456789", new AceAjax.Range(0, 8, 0, 10));
|
||||
assertWrap([6, 20, 34], [8], [8]);
|
||||
session.removeFold(session.getFoldAt(0, 7));
|
||||
removeFoldAssertWrap(0, 8, [8], [8], [8]);
|
||||
|
||||
session.addFold("woot0123456789", new AceAjax.Range(0, 7, 0, 9));
|
||||
session.addFold("woot0123456789", new AceAjax.Range(0, 13, 0, 15));
|
||||
assertWrap([7, 21, 25], [8], [8]);
|
||||
session.removeFold(session.getFoldAt(0, 7));
|
||||
removeFoldAssertWrap(0, 14, [8], [8], [8]);
|
||||
|
||||
// --- Do some multiline folding ---
|
||||
|
||||
// Add a fold over two lines. Note, that the wrapData[1] stays the
|
||||
// same. This is an implementation detail and expected behavior.
|
||||
session.addFold("woot", new AceAjax.Range(0, 8, 1, 15));
|
||||
assertWrap([8], [8 /* See comments */], [8]);
|
||||
removeFoldAssertWrap(0, 8, [8], [8], [8]);
|
||||
|
||||
session.addFold("woot", new AceAjax.Range(0, 9, 1, 11));
|
||||
assertWrap([8, 14], [8 /* See comments */], [8]);
|
||||
removeFoldAssertWrap(0, 9, [8], [8], [8]);
|
||||
|
||||
session.addFold("woot", new AceAjax.Range(0, 9, 1, 15));
|
||||
assertWrap([8], [8 /* See comments */], [8]);
|
||||
removeFoldAssertWrap(0, 9, [8], [8], [8]);
|
||||
|
||||
return session;
|
||||
} ,
|
||||
|
||||
"test add fold": function() {
|
||||
var session = createFoldTestSession();
|
||||
var fold;
|
||||
|
||||
function tryAddFold(placeholder, range, shouldFail) {
|
||||
var fail = false;
|
||||
try {
|
||||
fold = session.addFold(placeholder, range);
|
||||
} catch (e) {
|
||||
fail = true;
|
||||
}
|
||||
if (fail != shouldFail) {
|
||||
throw "Expected to get an exception";
|
||||
}
|
||||
}
|
||||
|
||||
tryAddFold("foo", new AceAjax.Range(0, 13, 0, 17), false);
|
||||
tryAddFold("foo", new AceAjax.Range(0, 14, 0, 18), true);
|
||||
tryAddFold("foo", new AceAjax.Range(0, 13, 0, 18), false);
|
||||
|
||||
tryAddFold("f", new AceAjax.Range(0, 13, 0, 18), false);
|
||||
tryAddFold("foo", new AceAjax.Range(0, 18, 0, 21), false);
|
||||
session.removeFold(fold);
|
||||
|
||||
tryAddFold("foo", new AceAjax.Range(0, 18, 0, 22), false);
|
||||
tryAddFold("foo", new AceAjax.Range(0, 18, 0, 19), true);
|
||||
tryAddFold("foo", new AceAjax.Range(0, 22, 1, 10), false);
|
||||
} ,
|
||||
|
||||
"test add subfolds": function() {
|
||||
var session = createFoldTestSession();
|
||||
var fold, oldFold;
|
||||
var foldData = null;
|
||||
|
||||
oldFold = foldData[0].folds[0];
|
||||
|
||||
fold = session.addFold("fold0", new AceAjax.Range(0, 10, 0, 21));
|
||||
assert.equal(foldData[0].folds.length, 1);
|
||||
assert.equal(fold.subFolds.length, 1);
|
||||
assert.equal(fold.subFolds[0], oldFold);
|
||||
|
||||
session.expandFold(fold);
|
||||
assert.equal(foldData[0].folds.length, 1);
|
||||
assert.equal(foldData[0].folds[0], oldFold);
|
||||
assert.equal(fold.subFolds.length, 0);
|
||||
|
||||
fold = session.addFold("fold0", new AceAjax.Range(0, 13, 2, 10));
|
||||
assert.equal(foldData.length, 1);
|
||||
assert.equal(fold.subFolds.length, 2);
|
||||
assert.equal(fold.subFolds[0], oldFold);
|
||||
|
||||
session.expandFold(fold);
|
||||
assert.equal(foldData.length, 2);
|
||||
assert.equal(foldData[0].folds.length, 1);
|
||||
assert.equal(foldData[0].folds[0], oldFold);
|
||||
assert.equal(fold.subFolds.length, 0);
|
||||
|
||||
session.unfold(null, true);
|
||||
fold = session.addFold("fold0", new AceAjax.Range(0, 0, 0, 21));
|
||||
session.addFold("fold0", new AceAjax.Range(0, 1, 0, 5));
|
||||
session.addFold("fold0", new AceAjax.Range(0, 6, 0, 8));
|
||||
assert.equal(fold.subFolds.length, 2);
|
||||
} ,
|
||||
|
||||
"test row cache": function() {
|
||||
var session = createFoldTestSession();
|
||||
|
||||
session.screenToDocumentPosition(2, 3);
|
||||
|
||||
session.screenToDocumentPosition(5, 3);
|
||||
|
||||
session.screenToDocumentPosition(0, 3);
|
||||
|
||||
var pos = session.screenToDocumentPosition(0, 0);
|
||||
assert.equal(pos.row, 0);
|
||||
|
||||
session.screenToDocumentPosition(1, 0);
|
||||
|
||||
|
||||
session.screenToDocumentPosition(1, 3);
|
||||
|
||||
session.screenToDocumentPosition(5, 3);
|
||||
|
||||
session = new AceAjax.EditSession(new Array(30).join("\n"));
|
||||
session.documentToScreenPosition(2, 0);
|
||||
session.documentToScreenPosition(2, 0);
|
||||
}
|
||||
};
|
||||
@@ -1,154 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
|
||||
setUp: function(next) {
|
||||
this.session1 = new AceAjax.EditSession(["abc", "def"]);
|
||||
this.session2 = new AceAjax.EditSession(["ghi", "jkl"]);
|
||||
|
||||
|
||||
var editor = new AceAjax.Editor(null);
|
||||
next();
|
||||
} ,
|
||||
|
||||
"test: change document": function() {
|
||||
var editor = new AceAjax.Editor(null);
|
||||
|
||||
editor.setSession(this.session1);
|
||||
assert.equal(editor.getSession(), this.session1);
|
||||
|
||||
editor.setSession(this.session2);
|
||||
assert.equal(editor.getSession(), this.session2);
|
||||
} ,
|
||||
|
||||
"test: only changes to the new document should have effect": function () {
|
||||
var editor = new AceAjax.Editor(null);
|
||||
|
||||
var called = false;
|
||||
editor.onDocumentChange = function () {
|
||||
called = true;
|
||||
};
|
||||
|
||||
editor.setSession(this.session1);
|
||||
editor.setSession(this.session2);
|
||||
|
||||
this.session1.duplicateLines(0, 0);
|
||||
assert.notOk(called);
|
||||
|
||||
this.session2.duplicateLines(0, 0);
|
||||
assert.ok(called);
|
||||
} ,
|
||||
|
||||
"test: should use cursor of new document": function () {
|
||||
var editor = new AceAjax.Editor(null);
|
||||
|
||||
this.session1.getSelection().moveCursorTo(0, 1);
|
||||
this.session2.getSelection().moveCursorTo(1, 0);
|
||||
|
||||
editor.setSession(this.session1);
|
||||
assert.position(editor.getCursorPosition(), 0, 1);
|
||||
|
||||
editor.setSession(this.session2);
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
} ,
|
||||
|
||||
"test: only changing the cursor of the new doc should not have an effect": function () {
|
||||
var editor = new AceAjax.Editor(null);
|
||||
|
||||
editor.onCursorChange = function () {
|
||||
called = true;
|
||||
};
|
||||
|
||||
editor.setSession(this.session1);
|
||||
editor.setSession(this.session2);
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
|
||||
var called = false;
|
||||
this.session1.getSelection().moveCursorTo(0, 1);
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
assert.notOk(called);
|
||||
|
||||
this.session2.getSelection().moveCursorTo(1, 1);
|
||||
assert.position(editor.getCursorPosition(), 1, 1);
|
||||
assert.ok(called);
|
||||
} ,
|
||||
|
||||
"test: should use selection of new document": function () {
|
||||
var editor = new AceAjax.Editor(null);
|
||||
|
||||
this.session1.getSelection().selectTo(0, 1);
|
||||
this.session2.getSelection().selectTo(1, 0);
|
||||
|
||||
editor.setSession(this.session1);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 0, 1);
|
||||
|
||||
editor.setSession(this.session2);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||
} ,
|
||||
|
||||
"test: only changing the selection of the new doc should not have an effect": function () {
|
||||
var editor = new AceAjax.Editor(null);
|
||||
|
||||
editor.onSelectionChange = function () {
|
||||
called = true;
|
||||
};
|
||||
|
||||
editor.setSession(this.session1);
|
||||
editor.setSession(this.session2);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 0, 0);
|
||||
|
||||
var called = false;
|
||||
this.session1.getSelection().selectTo(0, 1);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 0, 0);
|
||||
assert.notOk(called);
|
||||
|
||||
this.session2.getSelection().selectTo(1, 1);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 1, 1);
|
||||
assert.ok(called);
|
||||
} ,
|
||||
|
||||
"test: should use mode of new document": function () {
|
||||
var editor = new AceAjax.Editor(null);
|
||||
|
||||
editor.onChangeMode = function () {
|
||||
called = true;
|
||||
};
|
||||
editor.setSession(this.session1);
|
||||
editor.setSession(this.session2);
|
||||
|
||||
var called = false;
|
||||
this.session1.setMode(new Text());
|
||||
assert.notOk(called);
|
||||
|
||||
this.session2.setMode(null);
|
||||
assert.ok(called);
|
||||
} ,
|
||||
|
||||
"test: should use stop worker of old document": function (next) {
|
||||
var editor = new AceAjax.Editor(null);
|
||||
|
||||
var self = this;
|
||||
|
||||
// 1. Open an editor and set the session to CssMode
|
||||
self.editor.setSession(self.session1);
|
||||
self.session1.setMode(null);
|
||||
|
||||
// 2. Add a line or two of valid CSS.
|
||||
self.session1.setValue("DIV { color: red; }");
|
||||
|
||||
// 3. Clear the session value.
|
||||
self.session1.setValue("");
|
||||
|
||||
// 4. Set the session to HtmlMode
|
||||
self.session1.setMode(null);
|
||||
|
||||
// 5. Try to type valid HTML
|
||||
self.session1.insert({ row: 0, column: 0 }, "<html></html>");
|
||||
|
||||
setTimeout(function () {
|
||||
assert.equal(Object.keys(self.session1.getAnnotations()).length, 0);
|
||||
next();
|
||||
}, 600);
|
||||
}
|
||||
};
|
||||
@@ -1,217 +0,0 @@
|
||||
|
||||
|
||||
var lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
|
||||
"Mauris at arcu mi, eu lobortis mauris. Quisque ut libero eget " +
|
||||
"diam congue vehicula. Quisque ut odio ut mi aliquam tincidunt. " +
|
||||
"Duis lacinia aliquam lorem eget eleifend. Morbi eget felis mi. " +
|
||||
"Duis quam ligula, consequat vitae convallis volutpat, blandit " +
|
||||
"nec neque. Nulla facilisi. Etiam suscipit lorem ac justo " +
|
||||
"sollicitudin tristique. Phasellus ut posuere nunc. Aliquam " +
|
||||
"scelerisque mollis felis non gravida. Vestibulum lacus sem, " +
|
||||
"posuere non bibendum id, luctus non dolor. Aenean id metus " +
|
||||
"lorem, vel dapibus est. Donec gravida feugiat augue nec " +
|
||||
"accumsan.Lorem ipsum dolor sit amet, consectetur adipiscing " +
|
||||
"elit. Nulla vulputate, velit vitae tincidunt congue, nunc " +
|
||||
"augue accumsan velit, eu consequat turpis lectus ac orci. " +
|
||||
"Pellentesque ornare dolor feugiat dui auctor eu varius nulla " +
|
||||
"fermentum. Sed aliquam odio at velit lacinia vel fermentum " +
|
||||
"felis sodales. In dignissim magna eget nunc lobortis non " +
|
||||
"fringilla nibh ullamcorper. Donec facilisis malesuada elit " +
|
||||
"at egestas. Etiam bibendum, diam vitae tempor aliquet, dui " +
|
||||
"libero vehicula odio, eget bibendum mauris velit eu lorem.\n" +
|
||||
"consectetur";
|
||||
|
||||
function callHighlighterUpdate(session: AceAjax.IEditSession, firstRow: number, lastRow: number) {
|
||||
var rangeCount = 0;
|
||||
var mockMarkerLayer = { drawSingleLineMarker: function () { rangeCount++; } }
|
||||
return rangeCount;
|
||||
}
|
||||
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
|
||||
var exports = {
|
||||
setUp: function(next) {
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
var selection = session.getSelection();
|
||||
next();
|
||||
} ,
|
||||
|
||||
"test: highlight selected words by default": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
assert.equal(editor.getHighlightSelectedWord(), true);
|
||||
} ,
|
||||
|
||||
"test: highlight a word": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 9);
|
||||
selection.selectWord();
|
||||
|
||||
var highlighter = null;
|
||||
assert.ok(highlighter != null);
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.equal(session.getTextRange(range), "ipsum");
|
||||
assert.equal(highlighter.cache.length, 0);
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 2);
|
||||
} ,
|
||||
|
||||
"test: highlight a word and clear highlight": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 8);
|
||||
selection.selectWord();
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.equal(session.getTextRange(range), "ipsum");
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 2);
|
||||
|
||||
session.highlight("");
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 0);
|
||||
} ,
|
||||
|
||||
"test: highlight another word": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 14);
|
||||
selection.selectWord();
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.equal(session.getTextRange(range), "dolor");
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 4);
|
||||
} ,
|
||||
|
||||
"test: no selection, no highlight": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.clearSelection();
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 0);
|
||||
} ,
|
||||
|
||||
"test: select a word, no highlight": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 14);
|
||||
selection.selectWord();
|
||||
|
||||
editor.setHighlightSelectedWord(false);
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.equal(session.getTextRange(range), "dolor");
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 0);
|
||||
} ,
|
||||
|
||||
"test: select a word with no matches": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.setHighlightSelectedWord(true);
|
||||
|
||||
var currentOptions = this.search.getOptions();
|
||||
var newOptions = {
|
||||
wrap: true,
|
||||
wholeWord: true,
|
||||
caseSensitive: true,
|
||||
needle: "Mauris"
|
||||
};
|
||||
this.search.set(newOptions);
|
||||
|
||||
var match = this.search.find(session);
|
||||
assert.notEqual(match, null, "found a match for 'Mauris'");
|
||||
|
||||
this.search.set(currentOptions);
|
||||
|
||||
selection.setSelectionRange(match);
|
||||
|
||||
assert.equal(session.getTextRange(match), "Mauris");
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 1);
|
||||
} ,
|
||||
|
||||
"test: partial word selection 1": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 14);
|
||||
selection.selectWord();
|
||||
selection.selectLeft();
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.equal(session.getTextRange(range), "dolo");
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 0);
|
||||
} ,
|
||||
|
||||
"test: partial word selection 2": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 13);
|
||||
selection.selectWord();
|
||||
selection.selectRight();
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.equal(session.getTextRange(range), "dolor ");
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 0);
|
||||
} ,
|
||||
|
||||
"test: partial word selection 3": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 14);
|
||||
selection.selectWord();
|
||||
selection.selectLeft();
|
||||
selection.shiftSelection(1);
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.equal(session.getTextRange(range), "olor");
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 0);
|
||||
} ,
|
||||
|
||||
"test: select last word": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 1);
|
||||
|
||||
var currentOptions = this.search.getOptions();
|
||||
var newOptions = {
|
||||
wrap: true,
|
||||
wholeWord: true,
|
||||
caseSensitive: true,
|
||||
backwards: true,
|
||||
needle: "consectetur"
|
||||
};
|
||||
this.search.set(newOptions);
|
||||
|
||||
var match = this.search.find(session);
|
||||
assert.notEqual(match, null, "found a match for 'consectetur'");
|
||||
assert.position(match.start, 1, 0);
|
||||
|
||||
this.search.set(currentOptions);
|
||||
|
||||
selection.setSelectionRange(match);
|
||||
|
||||
assert.equal(session.getTextRange(match), "consectetur");
|
||||
assert.equal(callHighlighterUpdate(session, 0, 1), 3);
|
||||
}
|
||||
};
|
||||
@@ -1,119 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
var exports = {
|
||||
createEditSession: function (rows, cols) {
|
||||
var line = new Array(cols + 1).join("a");
|
||||
var text = new Array(rows).join(line + "\n") + line;
|
||||
return new AceAjax.EditSession(text);
|
||||
},
|
||||
|
||||
"test: navigate to end of file should scroll the last line into view": function () {
|
||||
var doc = this.createEditSession(200, 10);
|
||||
var editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
editor.navigateFileEnd();
|
||||
var cursor = editor.getCursorPosition();
|
||||
|
||||
assert.ok(editor.getFirstVisibleRow() <= cursor.row);
|
||||
assert.ok(editor.getLastVisibleRow() >= cursor.row);
|
||||
},
|
||||
|
||||
"test: navigate to start of file should scroll the first row into view": function () {
|
||||
var doc = this.createEditSession(200, 10);
|
||||
var editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
editor.moveCursorTo(editor.getLastVisibleRow() + 20);
|
||||
editor.navigateFileStart();
|
||||
|
||||
assert.equal(editor.getFirstVisibleRow(), 0);
|
||||
},
|
||||
|
||||
"test: goto hidden line should scroll the line into the middle of the viewport": function () {
|
||||
var editor = new AceAjax.Editor(renderer, this.createEditSession(200, 5));
|
||||
|
||||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(101);
|
||||
assert.position(editor.getCursorPosition(), 100, 0);
|
||||
assert.equal(editor.getFirstVisibleRow(), 89);
|
||||
|
||||
editor.navigateTo(100, 0);
|
||||
editor.gotoLine(11);
|
||||
assert.position(editor.getCursorPosition(), 10, 0);
|
||||
assert.equal(editor.getFirstVisibleRow(), 0);
|
||||
|
||||
editor.navigateTo(100, 0);
|
||||
editor.gotoLine(6);
|
||||
assert.position(editor.getCursorPosition(), 5, 0);
|
||||
assert.equal(0, editor.getFirstVisibleRow(), 0);
|
||||
|
||||
editor.navigateTo(100, 0);
|
||||
editor.gotoLine(1);
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
assert.equal(editor.getFirstVisibleRow(), 0);
|
||||
|
||||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(191);
|
||||
assert.position(editor.getCursorPosition(), 190, 0);
|
||||
assert.equal(editor.getFirstVisibleRow(), 179);
|
||||
|
||||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(196);
|
||||
assert.position(editor.getCursorPosition(), 195, 0);
|
||||
assert.equal(editor.getFirstVisibleRow(), 180);
|
||||
},
|
||||
|
||||
"test: goto visible line should only move the cursor and not scroll": function () {
|
||||
var editor = new AceAjax.Editor(renderer, this.createEditSession(200, 5));
|
||||
|
||||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(12);
|
||||
assert.position(editor.getCursorPosition(), 11, 0);
|
||||
assert.equal(editor.getFirstVisibleRow(), 0);
|
||||
|
||||
editor.navigateTo(30, 0);
|
||||
editor.gotoLine(33);
|
||||
assert.position(editor.getCursorPosition(), 32, 0);
|
||||
assert.equal(editor.getFirstVisibleRow(), 30);
|
||||
},
|
||||
|
||||
"test: navigate from the end of a long line down to a short line and back should maintain the curser column": function () {
|
||||
var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["123456", "1"]));
|
||||
|
||||
editor.navigateTo(0, 6);
|
||||
assert.position(editor.getCursorPosition(), 0, 6);
|
||||
|
||||
editor.navigateDown();
|
||||
assert.position(editor.getCursorPosition(), 1, 1);
|
||||
|
||||
editor.navigateUp();
|
||||
assert.position(editor.getCursorPosition(), 0, 6);
|
||||
},
|
||||
|
||||
"test: reset desired column on navigate left or right": function () {
|
||||
var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["123456", "12"]));
|
||||
|
||||
editor.navigateTo(0, 6);
|
||||
assert.position(editor.getCursorPosition(), 0, 6);
|
||||
|
||||
editor.navigateDown();
|
||||
assert.position(editor.getCursorPosition(), 1, 2);
|
||||
|
||||
editor.navigateLeft();
|
||||
assert.position(editor.getCursorPosition(), 1, 1);
|
||||
|
||||
editor.navigateUp();
|
||||
assert.position(editor.getCursorPosition(), 0, 1);
|
||||
},
|
||||
|
||||
"test: typing text should update the desired column": function () {
|
||||
var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["1234", "1234567890"]));
|
||||
|
||||
editor.navigateTo(0, 3);
|
||||
editor.insert("juhu");
|
||||
|
||||
editor.navigateDown();
|
||||
assert.position(editor.getCursorPosition(), 1, 7);
|
||||
}
|
||||
};
|
||||
@@ -1,501 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
var mode: any;
|
||||
var exports = {
|
||||
"test: delete line from the middle": function () {
|
||||
var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(session.toString(), "a\nc\nd");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(session.toString(), "a\nd");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(session.toString(), "a");
|
||||
assert.position(editor.getCursorPosition(), 0, 1);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(session.toString(), "");
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
},
|
||||
|
||||
"test: delete multiple selected lines": function () {
|
||||
var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.removeLines();
|
||||
assert.equal(session.toString(), "a\nd");
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
},
|
||||
|
||||
"test: delete first line": function () {
|
||||
var session = new AceAjax.EditSession(["a", "b", "c"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
assert.equal(session.toString(), "b\nc");
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
},
|
||||
|
||||
"test: delete last should also delete the new line of the previous line": function () {
|
||||
var session = new AceAjax.EditSession(["a", "b", "c", ""].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(3, 0);
|
||||
|
||||
editor.removeLines();
|
||||
assert.equal(session.toString(), "a\nb\nc");
|
||||
assert.position(editor.getCursorPosition(), 2, 1);
|
||||
|
||||
editor.removeLines();
|
||||
assert.equal(session.toString(), "a\nb");
|
||||
assert.position(editor.getCursorPosition(), 1, 1);
|
||||
},
|
||||
|
||||
"test: indent block": function () {
|
||||
var session = new AceAjax.EditSession(["a12345", "b12345", "c12345"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 3);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.indent();
|
||||
|
||||
assert.equal(["a12345", " b12345", " c12345"].join("\n"), session.toString());
|
||||
|
||||
assert.position(editor.getCursorPosition(), 2, 7);
|
||||
|
||||
var range = editor.getSelectionRange();
|
||||
assert.position(range.start, 1, 7);
|
||||
assert.position(range.end, 2, 7);
|
||||
},
|
||||
|
||||
"test: indent selected lines": function () {
|
||||
var session = new AceAjax.EditSession(["a12345", "b12345", "c12345"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.indent();
|
||||
assert.equal(["a12345", " b12345", "c12345"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: no auto indent if cursor is before the {": function () {
|
||||
var session = new AceAjax.EditSession("{",mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.onTextInput("\n");
|
||||
assert.equal(["", "{"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
"test: outdent block": function () {
|
||||
var session = new AceAjax.EditSession([" a12345", " b12345", " c12345"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.getSelection().selectDown();
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.blockOutdent();
|
||||
assert.equal(session.toString(), [" a12345", "b12345", " c12345"].join("\n"));
|
||||
|
||||
assert.position(editor.getCursorPosition(), 2, 1);
|
||||
|
||||
var range = editor.getSelectionRange();
|
||||
assert.position(range.start, 0, 1);
|
||||
assert.position(range.end, 2, 1);
|
||||
|
||||
editor.blockOutdent();
|
||||
assert.equal(session.toString(), ["a12345", "b12345", "c12345"].join("\n"));
|
||||
|
||||
var range = editor.getSelectionRange();
|
||||
assert.position(range.start, 0, 0);
|
||||
assert.position(range.end, 2, 0);
|
||||
},
|
||||
|
||||
"test: outent without a selection should update cursor": function () {
|
||||
var session = new AceAjax.EditSession(" 12");
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 3);
|
||||
editor.blockOutdent(" ");
|
||||
|
||||
assert.equal(session.toString(), " 12");
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
},
|
||||
|
||||
"test: comment lines should perserve selection": function () {
|
||||
var session = new AceAjax.EditSession([" abc", "cde"].join("\n"),mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 2);
|
||||
editor.getSelection().selectDown();
|
||||
editor.toggleCommentLines();
|
||||
|
||||
assert.equal(["// abc", "//cde"].join("\n"), session.toString());
|
||||
|
||||
var selection = editor.getSelectionRange();
|
||||
assert.position(selection.start, 0, 4);
|
||||
assert.position(selection.end, 1, 4);
|
||||
},
|
||||
|
||||
"test: uncomment lines should perserve selection": function () {
|
||||
var session = new AceAjax.EditSession(["// abc", "//cde"].join("\n"),mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 1);
|
||||
editor.getSelection().selectDown();
|
||||
editor.getSelection().selectRight();
|
||||
editor.getSelection().selectRight();
|
||||
|
||||
editor.toggleCommentLines();
|
||||
|
||||
assert.equal([" abc", "cde"].join("\n"), session.toString());
|
||||
assert.range(editor.getSelectionRange(), 0, 0, 1, 1);
|
||||
},
|
||||
|
||||
"test: toggle comment lines twice should return the original text": function () {
|
||||
var session = new AceAjax.EditSession([" abc", "cde", "fg"], mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.getSelection().selectDown();
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.toggleCommentLines();
|
||||
editor.toggleCommentLines();
|
||||
|
||||
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
||||
|
||||
"test: comment lines - if the selection end is at the line start it should stay there": function () {
|
||||
//select down
|
||||
var session = new AceAjax.EditSession(["abc", "cde"].join("\n"),mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.toggleCommentLines();
|
||||
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
|
||||
|
||||
// select up
|
||||
var session = new AceAjax.EditSession(["abc", "cde"].join("\n"),mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectUp();
|
||||
|
||||
editor.toggleCommentLines();
|
||||
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
|
||||
},
|
||||
|
||||
"test: move lines down should select moved lines": function () {
|
||||
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["33", "11", "22", "44"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["33", "44", "11", "22"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 2, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 2);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 2, 0);
|
||||
|
||||
// moving again should have no effect
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["33", "44", "11", "22"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 2, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 2);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 2, 0);
|
||||
},
|
||||
|
||||
"test: move lines up should select moved lines": function () {
|
||||
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(2, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.moveLinesUp();
|
||||
assert.equal(session.toString(), ["11", "33", "44", "22"].join("\n"));
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||
|
||||
editor.moveLinesUp();
|
||||
assert.equal(session.toString(), ["33", "44", "11", "22"].join("\n"));
|
||||
assert.position(editor.getCursorPosition(), 0, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 2, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 0, 0);
|
||||
},
|
||||
|
||||
"test: move line without active selection should not move cursor relative to the moved line": function () {
|
||||
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.clearSelection();
|
||||
|
||||
editor.moveLinesDown();
|
||||
assert.equal(["11", "33", "22", "44"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 2, 1);
|
||||
|
||||
editor.clearSelection();
|
||||
|
||||
editor.moveLinesUp();
|
||||
assert.equal(["11", "22", "33", "44"].join("\n"), session.toString());
|
||||
assert.position(editor.getCursorPosition(), 1, 1);
|
||||
},
|
||||
|
||||
"test: copy lines down should select lines and place cursor at the selection start": function () {
|
||||
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.copyLinesDown();
|
||||
assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString());
|
||||
|
||||
assert.position(editor.getCursorPosition(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 5, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 3, 0);
|
||||
},
|
||||
|
||||
"test: copy lines up should select lines and place cursor at the selection start": function () {
|
||||
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
|
||||
editor.copyLinesUp();
|
||||
assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString());
|
||||
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||
},
|
||||
|
||||
"test: input a tab with soft tab should convert it to spaces": function () {
|
||||
var session = new AceAjax.EditSession("");
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
session.setTabSize(2);
|
||||
session.setUseSoftTabs(true);
|
||||
|
||||
editor.onTextInput("\t");
|
||||
assert.equal(session.toString(), " ");
|
||||
|
||||
session.setTabSize(5);
|
||||
editor.onTextInput("\t");
|
||||
assert.equal(session.toString(), " ");
|
||||
},
|
||||
|
||||
"test: input tab without soft tabs should keep the tab character": function () {
|
||||
var session = new AceAjax.EditSession("");
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
session.setUseSoftTabs(false);
|
||||
|
||||
editor.onTextInput("\t");
|
||||
assert.equal(session.toString(), "\t");
|
||||
},
|
||||
|
||||
"test: undo/redo for delete line": function () {
|
||||
var session = new AceAjax.EditSession(["111", "222", "333"]);
|
||||
var undoManager = new AceAjax.UndoManager();
|
||||
session.setUndoManager(undoManager);
|
||||
|
||||
var initialText = session.toString();
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.removeLines();
|
||||
var step1 = session.toString();
|
||||
assert.equal(step1, "222\n333");
|
||||
|
||||
editor.removeLines();
|
||||
var step2 = session.toString();
|
||||
assert.equal(step2, "333");
|
||||
|
||||
editor.removeLines();
|
||||
var step3 = session.toString();
|
||||
assert.equal(step3, "");
|
||||
|
||||
undoManager.undo();
|
||||
assert.equal(session.toString(), step2);
|
||||
|
||||
undoManager.undo();
|
||||
assert.equal(session.toString(), step1);
|
||||
|
||||
undoManager.undo();
|
||||
assert.equal(session.toString(), initialText);
|
||||
|
||||
undoManager.undo();
|
||||
assert.equal(session.toString(), initialText);
|
||||
},
|
||||
|
||||
"test: remove left should remove character left of the cursor": function () {
|
||||
var session = new AceAjax.EditSession(["123", "456"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.remove("left");
|
||||
assert.equal(session.toString(), "123\n56");
|
||||
},
|
||||
|
||||
"test: remove left should remove line break if cursor is at line start": function () {
|
||||
var session = new AceAjax.EditSession(["123", "456"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.remove("left");
|
||||
assert.equal(session.toString(), "123456");
|
||||
},
|
||||
|
||||
"test: remove left should remove tabsize spaces if cursor is on a tab stop and preceeded by spaces": function () {
|
||||
var session = new AceAjax.EditSession(["123", " 456"]);
|
||||
session.setUseSoftTabs(true);
|
||||
session.setTabSize(4);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 8);
|
||||
editor.remove("left");
|
||||
assert.equal(session.toString(), "123\n 456");
|
||||
},
|
||||
|
||||
"test: transpose at line start should be a noop": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.transposeLetters();
|
||||
|
||||
assert.equal(session.getValue(), ["123", "4567", "89"].join("\n"));
|
||||
},
|
||||
|
||||
"test: transpose in line should swap the charaters before and after the cursor": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 2);
|
||||
editor.transposeLetters();
|
||||
|
||||
assert.equal(session.getValue(), ["123", "4657", "89"].join("\n"));
|
||||
},
|
||||
|
||||
"test: transpose at line end should swap the last two characters": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 4);
|
||||
editor.transposeLetters();
|
||||
|
||||
assert.equal(session.getValue(), ["123", "4576", "89"].join("\n"));
|
||||
},
|
||||
|
||||
"test: transpose with non empty selection should be a noop": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectRight();
|
||||
editor.transposeLetters();
|
||||
|
||||
assert.equal(session.getValue(), ["123", "4567", "89"].join("\n"));
|
||||
},
|
||||
|
||||
"test: transpose should move the cursor behind the last swapped character": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 2);
|
||||
editor.transposeLetters();
|
||||
assert.position(editor.getCursorPosition(), 1, 3);
|
||||
},
|
||||
|
||||
"test: remove to line end": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 2);
|
||||
editor.removeToLineEnd();
|
||||
assert.equal(session.getValue(), ["123", "45", "89"].join("\n"));
|
||||
},
|
||||
|
||||
"test: remove to line end at line end should remove the new line": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 4);
|
||||
editor.removeToLineEnd();
|
||||
assert.position(editor.getCursorPosition(), 1, 4);
|
||||
assert.equal(session.getValue(), ["123", "456789"].join("\n"));
|
||||
},
|
||||
|
||||
"test: transform selection to uppercase": function () {
|
||||
var session = new AceAjax.EditSession(["ajax", "dot", "org"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectLineEnd();
|
||||
editor.toUpperCase()
|
||||
assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n"));
|
||||
},
|
||||
|
||||
"test: transform word to uppercase": function () {
|
||||
var session = new AceAjax.EditSession(["ajax", "dot", "org"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.toUpperCase()
|
||||
assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n"));
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
},
|
||||
|
||||
"test: transform selection to lowercase": function () {
|
||||
var session = new AceAjax.EditSession(["AJAX", "DOT", "ORG"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectLineEnd();
|
||||
editor.toLowerCase()
|
||||
assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n"));
|
||||
},
|
||||
|
||||
"test: transform word to lowercase": function () {
|
||||
var session = new AceAjax.EditSession(["AJAX", "DOT", "ORG"]);
|
||||
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.toLowerCase()
|
||||
assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n"));
|
||||
assert.position(editor.getCursorPosition(), 1, 0);
|
||||
}
|
||||
};
|
||||
@@ -1,114 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var editor: any;
|
||||
var renderer: any;
|
||||
var exec = function (name?, times?, args?) {
|
||||
do {
|
||||
editor.commands.exec(name, editor, args);
|
||||
} while (times-- > 1)
|
||||
};
|
||||
var testRanges = function (str) {
|
||||
assert.equal(editor.selection.getAllRanges() + "", str + "");
|
||||
}
|
||||
|
||||
var exports = {
|
||||
|
||||
name: "ACE multi_select.js",
|
||||
|
||||
"test: multiselect editing": function() {
|
||||
var doc = new AceAjax.EditSession([
|
||||
"w1.w2",
|
||||
" wtt.w",
|
||||
" wtt.w"
|
||||
]);
|
||||
editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
editor.navigateFileEnd();
|
||||
exec("selectMoreBefore", 3);
|
||||
assert.ok(editor.inMultiSelectMode);
|
||||
assert.equal(editor.selection.getAllRanges().length, 4);
|
||||
|
||||
var newLine = editor.session.getDocument().getNewLineCharacter();
|
||||
var copyText = "wwww".split("").join(newLine);
|
||||
assert.equal(editor.getCopyText(), copyText);
|
||||
exec("insertstring", 1, "a");
|
||||
exec("backspace", 2);
|
||||
assert.equal(editor.session.getValue(), "w1.w2\ntt\ntt");
|
||||
assert.equal(editor.selection.getAllRanges().length, 4);
|
||||
|
||||
exec("selectall");
|
||||
assert.ok(!editor.inMultiSelectMode);
|
||||
//assert.equal(editor.selection.getAllRanges().length, 1);
|
||||
} ,
|
||||
|
||||
"test: multiselect navigation": function() {
|
||||
var doc = new AceAjax.EditSession([
|
||||
"w1.w2",
|
||||
" wtt.w",
|
||||
" wtt.we"
|
||||
]);
|
||||
editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
editor.selectMoreLines(1);
|
||||
testRanges("Range: [0/0] -> [0/0],Range: [1/0] -> [1/0]");
|
||||
assert.ok(editor.inMultiSelectMode);
|
||||
|
||||
exec("golinedown");
|
||||
exec("gotolineend");
|
||||
testRanges("Range: [1/9] -> [1/9],Range: [2/10] -> [2/10]");
|
||||
exec("selectwordleft");
|
||||
|
||||
testRanges("Range: [1/8] -> [1/9],Range: [2/8] -> [2/10]");
|
||||
exec("golinedown", 2);
|
||||
assert.ok(!editor.inMultiSelectMode);
|
||||
} ,
|
||||
|
||||
"test: multiselect session change": function() {
|
||||
var doc = new AceAjax.EditSession([
|
||||
"w1.w2",
|
||||
" wtt.w",
|
||||
" wtt.w"
|
||||
]);
|
||||
editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
editor.selectMoreLines(1)
|
||||
testRanges("Range: [0/0] -> [0/0],Range: [1/0] -> [1/0]");
|
||||
assert.ok(editor.inMultiSelectMode);
|
||||
|
||||
var doc2 = new AceAjax.EditSession(["w1"]);
|
||||
editor.setSession(doc2);
|
||||
assert.ok(!editor.inMultiSelectMode);
|
||||
|
||||
editor.setSession(doc);
|
||||
assert.ok(editor.inMultiSelectMode);
|
||||
} ,
|
||||
|
||||
"test: multiselect addRange": function() {
|
||||
var doc = new AceAjax.EditSession([
|
||||
"w1.w2",
|
||||
" wtt.w",
|
||||
" wtt.w"
|
||||
]);
|
||||
editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
var selection = editor.selection;
|
||||
|
||||
var range1 = new AceAjax.Range(0, 2, 0, 4);
|
||||
editor.selection.fromOrientedRange(range1);
|
||||
|
||||
var range2 = new AceAjax.Range(0, 3, 0, 4);
|
||||
selection.addRange(range2);
|
||||
assert.ok(!editor.inMultiSelectMode);
|
||||
assert.ok(range2.isEqual(editor.selection.getRange()));
|
||||
|
||||
var range3 = new AceAjax.Range(0, 1, 0, 1);
|
||||
selection.addRange(range3);
|
||||
assert.ok(editor.inMultiSelectMode);
|
||||
testRanges([range3, range2]);
|
||||
|
||||
var range4 = new AceAjax.Range(0, 0, 4, 0);
|
||||
selection.addRange(range4);
|
||||
assert.ok(!editor.inMultiSelectMode);
|
||||
}
|
||||
};
|
||||
@@ -1,109 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
var mode: any;
|
||||
var exports = {
|
||||
|
||||
"test: simple at the end appending of text": function () {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.insert('b');
|
||||
assert.equal(session.doc.getValue(), "var ab = 10;\nconsole.log(ab, ab);");
|
||||
editor.insert('cd');
|
||||
assert.equal(session.doc.getValue(), "var abcd = 10;\nconsole.log(abcd, abcd);");
|
||||
editor.remove('left');
|
||||
editor.remove('left');
|
||||
editor.remove('left');
|
||||
assert.equal(session.doc.getValue(), "var a = 10;\nconsole.log(a, a);");
|
||||
},
|
||||
|
||||
"test: inserting text outside placeholder": function () {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);\n", mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
|
||||
editor.moveCursorTo(2, 0);
|
||||
editor.insert('b');
|
||||
assert.equal(session.doc.getValue(), "var a = 10;\nconsole.log(a, a);\nb");
|
||||
},
|
||||
|
||||
"test: insertion at the beginning": function (next) {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
|
||||
editor.moveCursorTo(0, 4);
|
||||
editor.insert('$');
|
||||
assert.equal(session.doc.getValue(), "var $a = 10;\nconsole.log($a, $a);");
|
||||
editor.moveCursorTo(0, 4);
|
||||
// Have to put this in a setTimeout because the anchor is only fixed later.
|
||||
setTimeout(function () {
|
||||
editor.insert('v');
|
||||
assert.equal(session.doc.getValue(), "var v$a = 10;\nconsole.log(v$a, v$a);");
|
||||
next();
|
||||
}, 10);
|
||||
},
|
||||
|
||||
"test: detaching placeholder": function () {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.insert('b');
|
||||
assert.equal(session.doc.getValue(), "var ab = 10;\nconsole.log(ab, ab);");
|
||||
p.detach();
|
||||
editor.insert('cd');
|
||||
assert.equal(session.doc.getValue(), "var abcd = 10;\nconsole.log(ab, ab);");
|
||||
},
|
||||
|
||||
"test: events": function () {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
var entered = false;
|
||||
var left = false;
|
||||
p.on("cursorEnter", function () {
|
||||
entered = true;
|
||||
});
|
||||
p.on("cursorLeave", function () {
|
||||
left = true;
|
||||
});
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.moveCursorTo(0, 4);
|
||||
p.onCursorChange(); // Have to do this by hand because moveCursorTo doesn't trigger the event
|
||||
assert.ok(entered);
|
||||
editor.moveCursorTo(1, 0);
|
||||
p.onCursorChange(); // Have to do this by hand because moveCursorTo doesn't trigger the event
|
||||
assert.ok(left);
|
||||
},
|
||||
|
||||
"test: cancel": function (next) {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
session.setUndoManager(new AceAjax.UndoManager());
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.insert('b');
|
||||
editor.insert('cd');
|
||||
editor.remove('left');
|
||||
assert.equal(session.doc.getValue(), "var abc = 10;\nconsole.log(abc, abc);");
|
||||
// Wait a little for the changes to enter the undo stack
|
||||
setTimeout(function () {
|
||||
p.cancel();
|
||||
assert.equal(session.doc.getValue(), "var a = 10;\nconsole.log(a, a);");
|
||||
next();
|
||||
}, 80);
|
||||
}
|
||||
};
|
||||
@@ -1,147 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
|
||||
name: "ACE range.js",
|
||||
|
||||
"test: create range": function () {
|
||||
var range = new AceAjax.Range(1, 2, 3, 4);
|
||||
|
||||
assert.equal(range.start.row, 1);
|
||||
assert.equal(range.start.column, 2);
|
||||
assert.equal(range.end.row, 3);
|
||||
assert.equal(range.end.column, 4);
|
||||
},
|
||||
|
||||
"test: create from points": function () {
|
||||
var range = AceAjax.Range.fromPoints({ row: 1, column: 2 }, { row: 3, column: 4 });
|
||||
|
||||
assert.equal(range.start.row, 1);
|
||||
assert.equal(range.start.column, 2);
|
||||
assert.equal(range.end.row, 3);
|
||||
assert.equal(range.end.column, 4);
|
||||
},
|
||||
|
||||
"test: clip to rows": function () {
|
||||
assert.range(new AceAjax.Range(0, 20, 100, 30).clipRows(10, 30), 10, 0, 31, 0);
|
||||
assert.range(new AceAjax.Range(0, 20, 30, 10).clipRows(10, 30), 10, 0, 30, 10);
|
||||
|
||||
var range = new AceAjax.Range(0, 20, 3, 10);
|
||||
var range = range.clipRows(10, 30);
|
||||
|
||||
assert.ok(range.isEmpty());
|
||||
assert.range(range, 10, 0, 10, 0);
|
||||
},
|
||||
|
||||
"test: isEmpty": function () {
|
||||
var range = new AceAjax.Range(1, 2, 1, 2);
|
||||
assert.ok(range.isEmpty());
|
||||
|
||||
var range = new AceAjax.Range(1, 2, 1, 6);
|
||||
assert.notOk(range.isEmpty());
|
||||
},
|
||||
|
||||
"test: is multi line": function () {
|
||||
var range = new AceAjax.Range(1, 2, 1, 6);
|
||||
assert.notOk(range.isMultiLine());
|
||||
|
||||
var range = new AceAjax.Range(1, 2, 2, 6);
|
||||
assert.ok(range.isMultiLine());
|
||||
},
|
||||
|
||||
"test: clone": function () {
|
||||
var range = new AceAjax.Range(1, 2, 3, 4);
|
||||
var clone = range.clone();
|
||||
|
||||
assert.position(clone.start, 1, 2);
|
||||
assert.position(clone.end, 3, 4);
|
||||
|
||||
clone.start.column = 20;
|
||||
assert.position(range.start, 1, 2);
|
||||
|
||||
clone.end.column = 20;
|
||||
assert.position(range.end, 3, 4);
|
||||
},
|
||||
|
||||
"test: contains for multi line ranges": function () {
|
||||
var range = new AceAjax.Range(1, 10, 5, 20);
|
||||
|
||||
assert.ok(range.contains(1, 10));
|
||||
assert.ok(range.contains(2, 0));
|
||||
assert.ok(range.contains(3, 100));
|
||||
assert.ok(range.contains(5, 19));
|
||||
assert.ok(range.contains(5, 20));
|
||||
|
||||
assert.notOk(range.contains(1, 9));
|
||||
assert.notOk(range.contains(0, 0));
|
||||
assert.notOk(range.contains(5, 21));
|
||||
},
|
||||
|
||||
"test: contains for single line ranges": function () {
|
||||
var range = new AceAjax.Range(1, 10, 1, 20);
|
||||
|
||||
assert.ok(range.contains(1, 10));
|
||||
assert.ok(range.contains(1, 15));
|
||||
assert.ok(range.contains(1, 20));
|
||||
|
||||
assert.notOk(range.contains(0, 9));
|
||||
assert.notOk(range.contains(2, 9));
|
||||
assert.notOk(range.contains(1, 9));
|
||||
assert.notOk(range.contains(1, 21));
|
||||
},
|
||||
|
||||
"test: extend range": function () {
|
||||
var range = new AceAjax.Range(2, 10, 2, 30);
|
||||
|
||||
var range = range.extend(2, 5);
|
||||
assert.range(range, 2, 5, 2, 30);
|
||||
|
||||
var range = range.extend(2, 35);
|
||||
assert.range(range, 2, 5, 2, 35);
|
||||
|
||||
var range = range.extend(2, 15);
|
||||
assert.range(range, 2, 5, 2, 35);
|
||||
|
||||
var range = range.extend(1, 4);
|
||||
assert.range(range, 1, 4, 2, 35);
|
||||
|
||||
var range = range.extend(6, 10);
|
||||
assert.range(range, 1, 4, 6, 10);
|
||||
},
|
||||
|
||||
"test: collapse rows": function () {
|
||||
var range = new AceAjax.Range(0, 2, 1, 2);
|
||||
assert.range(range.collapseRows(), 0, 0, 1, 0);
|
||||
|
||||
var range = new AceAjax.Range(2, 2, 3, 1);
|
||||
assert.range(range.collapseRows(), 2, 0, 3, 0);
|
||||
|
||||
var range = new AceAjax.Range(2, 2, 3, 0);
|
||||
assert.range(range.collapseRows(), 2, 0, 2, 0);
|
||||
|
||||
var range = new AceAjax.Range(2, 0, 2, 0);
|
||||
assert.range(range.collapseRows(), 2, 0, 2, 0);
|
||||
},
|
||||
|
||||
"test: to screen range": function () {
|
||||
var session = new AceAjax.EditSession([
|
||||
"juhu",
|
||||
"12\t\t34",
|
||||
"ぁぁa",
|
||||
"\t\t34",
|
||||
]);
|
||||
|
||||
var range = new AceAjax.Range(0, 0, 0, 3);
|
||||
assert.range(range.toScreenRange(session), 0, 0, 0, 3);
|
||||
|
||||
var range = new AceAjax.Range(1, 1, 1, 3);
|
||||
assert.range(range.toScreenRange(session), 1, 1, 1, 4);
|
||||
|
||||
var range = new AceAjax.Range(2, 1, 2, 2);
|
||||
assert.range(range.toScreenRange(session), 2, 2, 2, 4);
|
||||
|
||||
var range = new AceAjax.Range(3, 0, 3, 4);
|
||||
assert.range(range.toScreenRange(session), 3, 0, 3, 10);
|
||||
}
|
||||
};
|
||||
@@ -1,118 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
function flatten(rangeList) {
|
||||
var points = [];
|
||||
rangeList.ranges.forEach(function (r) {
|
||||
points.push(r.start.row, r.start.column, r.end.row, r.end.column)
|
||||
})
|
||||
return points;
|
||||
}
|
||||
function testRangeList(rangeList, points) {
|
||||
assert.equal("" + flatten(rangeList), "" + points);
|
||||
}
|
||||
|
||||
var exports = {
|
||||
|
||||
name: "ACE range_list.js",
|
||||
|
||||
"test: rangeList pointIndex": function() {
|
||||
var rangeList = new AceAjax.RangeList();
|
||||
rangeList.ranges = [
|
||||
new AceAjax.Range(1, 2, 3, 4),
|
||||
new AceAjax.Range(4, 2, 5, 4),
|
||||
new AceAjax.Range(8, 8, 9, 9)
|
||||
];
|
||||
|
||||
assert.equal(rangeList.pointIndex({ row: 0, column: 1 }), -1);
|
||||
assert.equal(rangeList.pointIndex({ row: 1, column: 2 }), 0);
|
||||
assert.equal(rangeList.pointIndex({ row: 1, column: 3 }), 0);
|
||||
assert.equal(rangeList.pointIndex({ row: 3, column: 4 }), 0);
|
||||
assert.equal(rangeList.pointIndex({ row: 4, column: 1 }), -2);
|
||||
assert.equal(rangeList.pointIndex({ row: 5, column: 1 }), 1);
|
||||
assert.equal(rangeList.pointIndex({ row: 8, column: 9 }), 2);
|
||||
assert.equal(rangeList.pointIndex({ row: 18, column: 9 }), -4);
|
||||
} ,
|
||||
|
||||
"test: rangeList add": function() {
|
||||
var rangeList = new AceAjax.RangeList();
|
||||
rangeList.addList([
|
||||
new AceAjax.Range(9, 0, 9, 1),
|
||||
new AceAjax.Range(1, 2, 3, 4),
|
||||
new AceAjax.Range(8, 8, 9, 9),
|
||||
new AceAjax.Range(4, 2, 5, 4),
|
||||
new AceAjax.Range(3, 20, 3, 24),
|
||||
new AceAjax.Range(6, 6, 7, 7)
|
||||
]);
|
||||
assert.equal(rangeList.ranges.length, 5);
|
||||
|
||||
rangeList.add(new AceAjax.Range(1, 2, 3, 5));
|
||||
assert.range(rangeList.ranges[0], 1, 2, 3, 5);
|
||||
assert.equal(rangeList.ranges.length, 5);
|
||||
|
||||
rangeList.add(new AceAjax.Range(7, 7, 7, 7));
|
||||
assert.range(rangeList.ranges[3], 7, 7, 7, 7);
|
||||
rangeList.add(new AceAjax.Range(7, 8, 7, 8));
|
||||
assert.range(rangeList.ranges[4], 7, 8, 7, 8);
|
||||
} ,
|
||||
|
||||
"test: rangeList add empty": function() {
|
||||
var rangeList = new AceAjax.RangeList();
|
||||
rangeList.addList([
|
||||
new AceAjax.Range(7, 10, 7, 10),
|
||||
new AceAjax.Range(9, 10, 9, 10),
|
||||
new AceAjax.Range(8, 10, 8, 10)
|
||||
]);
|
||||
assert.equal(rangeList.ranges.length, 3);
|
||||
|
||||
rangeList.add(new AceAjax.Range(9, 10, 9, 10));
|
||||
testRangeList(rangeList, [7, 10, 7, 10, 8, 10, 8, 10, 9, 10, 9, 10]);
|
||||
} ,
|
||||
|
||||
"test: rangeList merge": function() {
|
||||
var rangeList = new AceAjax.RangeList();
|
||||
rangeList.addList([
|
||||
new AceAjax.Range(1, 2, 3, 4),
|
||||
new AceAjax.Range(4, 2, 5, 4),
|
||||
new AceAjax.Range(6, 6, 7, 7),
|
||||
new AceAjax.Range(8, 8, 9, 9)
|
||||
]);
|
||||
var removed = [];
|
||||
|
||||
assert.equal(rangeList.ranges.length, 4);
|
||||
|
||||
rangeList.ranges[1].end.row = 7;
|
||||
removed = rangeList.merge();
|
||||
assert.equal(removed.length, 1);
|
||||
assert.range(rangeList.ranges[1], 4, 2, 7, 7);
|
||||
assert.equal(rangeList.ranges.length, 3);
|
||||
|
||||
rangeList.ranges[0].end.row = 10;
|
||||
removed = rangeList.merge();
|
||||
assert.range(rangeList.ranges[0], 1, 2, 10, 4);
|
||||
assert.equal(removed.length, 2);
|
||||
assert.equal(rangeList.ranges.length, 1);
|
||||
|
||||
rangeList.ranges.push(new AceAjax.Range(10, 10, 10, 10));
|
||||
rangeList.ranges.push(new AceAjax.Range(10, 10, 10, 10));
|
||||
removed = rangeList.merge();
|
||||
assert.equal(rangeList.ranges.length, 2);
|
||||
} ,
|
||||
|
||||
"test: rangeList remove": function() {
|
||||
var rangeList = new AceAjax.RangeList();
|
||||
var list = [
|
||||
new AceAjax.Range(1, 2, 3, 4),
|
||||
new AceAjax.Range(4, 2, 5, 4),
|
||||
new AceAjax.Range(6, 6, 7, 7),
|
||||
new AceAjax.Range(8, 8, 9, 9)
|
||||
];
|
||||
rangeList.addList(list);
|
||||
assert.equal(rangeList.ranges.length, 4);
|
||||
rangeList.substractPoint({ row: 1, column: 2 });
|
||||
assert.equal(rangeList.ranges.length, 3);
|
||||
rangeList.substractPoint({ row: 6, column: 7 });
|
||||
assert.equal(rangeList.ranges.length, 2);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,417 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
"test: configure the search object": function () {
|
||||
var search = new AceAjax.Search();
|
||||
search.set({
|
||||
needle: "juhu"
|
||||
});
|
||||
},
|
||||
|
||||
"test: find simple text in document": function () {
|
||||
var session = new AceAjax.EditSession(["juhu kinners 123", "456"]);
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "kinners"
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 0, 5);
|
||||
assert.position(range.end, 0, 12);
|
||||
},
|
||||
|
||||
"test: find simple text in next line": function () {
|
||||
var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "kinners"
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 5);
|
||||
assert.position(range.end, 1, 12);
|
||||
},
|
||||
|
||||
"test: find text starting at cursor position": function () {
|
||||
var session = new AceAjax.EditSession(["juhu kinners", "juhu kinners 123"]);
|
||||
session.getSelection().moveCursorTo(0, 6);
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "kinners"
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 5);
|
||||
assert.position(range.end, 1, 12);
|
||||
},
|
||||
|
||||
"test: wrap search is on by default": function () {
|
||||
var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
session.getSelection().moveCursorTo(2, 1);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "kinners"
|
||||
});
|
||||
|
||||
assert.notEqual(search.find(session), null);
|
||||
},
|
||||
|
||||
"test: wrap search should wrap at file end": function () {
|
||||
var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
session.getSelection().moveCursorTo(2, 1);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "kinners",
|
||||
wrap: true
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 5);
|
||||
assert.position(range.end, 1, 12);
|
||||
},
|
||||
|
||||
"test: wrap search should find needle even if it starts inside it": function () {
|
||||
var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
session.getSelection().moveCursorTo(6, 1);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "kinners",
|
||||
wrap: true
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 5);
|
||||
assert.position(range.end, 1, 12);
|
||||
},
|
||||
|
||||
"test: wrap search with no match should return 'null'": function () {
|
||||
var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
session.getSelection().moveCursorTo(2, 1);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "xyz",
|
||||
wrap: true
|
||||
});
|
||||
|
||||
assert.equal(search.find(session), null);
|
||||
},
|
||||
|
||||
"test: case sensitive is by default off": function () {
|
||||
var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "JUHU"
|
||||
});
|
||||
|
||||
assert.range(search.find(session), 1, 0, 1, 4);
|
||||
},
|
||||
|
||||
"test: case sensitive search": function () {
|
||||
var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "KINNERS",
|
||||
caseSensitive: true
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.equal(range, null);
|
||||
},
|
||||
|
||||
"test: whole word search should not match inside of words": function () {
|
||||
var session = new AceAjax.EditSession(["juhukinners", "juhu kinners 123", "456"]);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "kinners",
|
||||
wholeWord: true
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 5);
|
||||
assert.position(range.end, 1, 12);
|
||||
},
|
||||
|
||||
"test: find backwards": function () {
|
||||
var session = new AceAjax.EditSession(["juhu juhu juhu juhu"]);
|
||||
session.getSelection().moveCursorTo(0, 10);
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "juhu",
|
||||
backwards: true
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 0, 5);
|
||||
assert.position(range.end, 0, 9);
|
||||
},
|
||||
|
||||
"test: find in selection": function () {
|
||||
var session = new AceAjax.EditSession(["juhu", "juhu", "juhu", "juhu"]);
|
||||
session.getSelection().setSelectionAnchor(1, 0);
|
||||
session.getSelection().selectTo(3, 5);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "juhu",
|
||||
wrap: true,
|
||||
range: session.getSelection().getRange()
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 0);
|
||||
assert.position(range.end, 1, 4);
|
||||
|
||||
search = new AceAjax.Search().set({
|
||||
needle: "juhu",
|
||||
wrap: true,
|
||||
range: session.getSelection().getRange()
|
||||
});
|
||||
|
||||
session.getSelection().setSelectionAnchor(0, 2);
|
||||
session.getSelection().selectTo(3, 2);
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 0);
|
||||
assert.position(range.end, 1, 4);
|
||||
},
|
||||
|
||||
"test: find backwards in selection": function () {
|
||||
var session = new AceAjax.EditSession(["juhu", "juhu", "juhu", "juhu"]);
|
||||
|
||||
session.getSelection().setSelectionAnchor(0, 2);
|
||||
session.getSelection().selectTo(3, 2);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "juhu",
|
||||
wrap: true,
|
||||
backwards: true,
|
||||
range: session.getSelection().getRange()
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 2, 0);
|
||||
assert.position(range.end, 2, 4);
|
||||
|
||||
search = new AceAjax.Search().set({
|
||||
needle: "juhu",
|
||||
wrap: true,
|
||||
range: session.getSelection().getRange()
|
||||
});
|
||||
|
||||
session.getSelection().setSelectionAnchor(0, 2);
|
||||
session.getSelection().selectTo(1, 2);
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 1, 0);
|
||||
assert.position(range.end, 1, 4);
|
||||
},
|
||||
|
||||
"test: edge case - match directly before the cursor": function () {
|
||||
var session = new AceAjax.EditSession(["123", "123", "juhu"]);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "juhu",
|
||||
wrap: true
|
||||
});
|
||||
|
||||
session.getSelection().moveCursorTo(2, 5);
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 2, 0);
|
||||
assert.position(range.end, 2, 4);
|
||||
},
|
||||
|
||||
"test: edge case - match backwards directly after the cursor": function () {
|
||||
var session = new AceAjax.EditSession(["123", "123", "juhu"]);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "juhu",
|
||||
wrap: true,
|
||||
backwards: true
|
||||
});
|
||||
|
||||
session.getSelection().moveCursorTo(2, 0);
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 2, 0);
|
||||
assert.position(range.end, 2, 4);
|
||||
},
|
||||
|
||||
"test: find using a regular expression": function () {
|
||||
var session = new AceAjax.EditSession(["abc123 123 cd", "abc"]);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "\\d+",
|
||||
regExp: true
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 0, 3);
|
||||
assert.position(range.end, 0, 6);
|
||||
},
|
||||
|
||||
"test: find using a regular expression and whole word": function () {
|
||||
var session = new AceAjax.EditSession(["abc123 123 cd", "abc"]);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "\\d+\\b",
|
||||
regExp: true,
|
||||
wholeWord: true
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 0, 7);
|
||||
assert.position(range.end, 0, 10);
|
||||
},
|
||||
|
||||
"test: use regular expressions with capture groups": function () {
|
||||
var session = new AceAjax.EditSession([" ab: 12px", " <h1 abc"]);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "(\\d+)",
|
||||
regExp: true
|
||||
});
|
||||
|
||||
var range = search.find(session);
|
||||
assert.position(range.start, 0, 6);
|
||||
assert.position(range.end, 0, 8);
|
||||
},
|
||||
|
||||
"test: find all matches in selection": function () {
|
||||
var session = new AceAjax.EditSession(["juhu", "juhu", "juhu", "juhu"]);
|
||||
|
||||
session.getSelection().setSelectionAnchor(0, 2);
|
||||
session.getSelection().selectTo(3, 2);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "uh",
|
||||
wrap: true,
|
||||
range: session.getSelection().getRange()
|
||||
});
|
||||
|
||||
var ranges = search.findAll(session);
|
||||
|
||||
assert.equal(ranges.length, 2);
|
||||
assert.position(ranges[0].start, 1, 1);
|
||||
assert.position(ranges[0].end, 1, 3);
|
||||
assert.position(ranges[1].start, 2, 1);
|
||||
assert.position(ranges[1].end, 2, 3);
|
||||
},
|
||||
|
||||
|
||||
"test: find all multiline matches": function () {
|
||||
var session = new AceAjax.EditSession(["juhu", "juhu", "juhu", "juhu"]);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "hu\nju",
|
||||
wrap: true
|
||||
});
|
||||
|
||||
var ranges = search.findAll(session);
|
||||
|
||||
assert.equal(ranges.length, 3);
|
||||
assert.position(ranges[0].start, 0, 2);
|
||||
assert.position(ranges[0].end, 1, 2);
|
||||
assert.position(ranges[1].start, 1, 2);
|
||||
assert.position(ranges[1].end, 2, 2);
|
||||
},
|
||||
|
||||
"test: replace() should return the replacement if the input matches the needle": function () {
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "juhu"
|
||||
});
|
||||
|
||||
assert.equal(search.replace("juhu", "kinners"), "kinners");
|
||||
assert.equal(search.replace("", "kinners"), null);
|
||||
assert.equal(search.replace(" juhu", "kinners"), null);
|
||||
|
||||
// case sensitivity
|
||||
assert.equal(search.replace("Juhu", "kinners"), "kinners");
|
||||
search.set({ caseSensitive: true });
|
||||
assert.equal(search.replace("Juhu", "kinners"), null);
|
||||
|
||||
// regexp replacement
|
||||
},
|
||||
|
||||
"test: replace with a RegExp search": function () {
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "\\d+",
|
||||
regExp: true
|
||||
});
|
||||
|
||||
assert.equal(search.replace("123", "kinners"), "kinners");
|
||||
assert.equal(search.replace("01234", "kinners"), "kinners");
|
||||
assert.equal(search.replace("", "kinners"), null);
|
||||
assert.equal(search.replace("a12", "kinners"), null);
|
||||
assert.equal(search.replace("12a", "kinners"), null);
|
||||
},
|
||||
|
||||
"test: replace with RegExp match and capture groups": function () {
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "ab(\\d\\d)",
|
||||
regExp: true
|
||||
});
|
||||
|
||||
assert.equal(search.replace("ab12", "cd$1"), "cd12");
|
||||
assert.equal(search.replace("ab12", "-$&-"), "-ab12-");
|
||||
assert.equal(search.replace("ab12", "$$"), "$");
|
||||
},
|
||||
|
||||
"test: find all using regular expresion containing $": function () {
|
||||
var session = new AceAjax.EditSession(["a", " b", "c ", "d"]);
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "[ ]+$",
|
||||
regExp: true,
|
||||
wrap: true
|
||||
});
|
||||
|
||||
session.getSelection().moveCursorTo(1, 2);
|
||||
var ranges = search.findAll(session);
|
||||
|
||||
assert.equal(ranges.length, 1);
|
||||
assert.position(ranges[0].start, 2, 1);
|
||||
assert.position(ranges[0].end, 2, 2);
|
||||
},
|
||||
|
||||
"test: find all matches in a line": function () {
|
||||
var session = new AceAjax.EditSession("foo bar foo baz foobar foo");
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "foo",
|
||||
wrap: true,
|
||||
wholeWord: true
|
||||
});
|
||||
|
||||
session.getSelection().moveCursorTo(0, 4);
|
||||
|
||||
var ranges = search.findAll(session);
|
||||
|
||||
assert.equal(ranges.length, 3);
|
||||
assert.position(ranges[0].start, 0, 0);
|
||||
assert.position(ranges[0].end, 0, 3);
|
||||
assert.position(ranges[1].start, 0, 8);
|
||||
assert.position(ranges[1].end, 0, 11);
|
||||
assert.position(ranges[2].start, 0, 23);
|
||||
assert.position(ranges[2].end, 0, 26);
|
||||
},
|
||||
|
||||
"test: find all matches in a line backwards": function () {
|
||||
var session = new AceAjax.EditSession("foo bar foo baz foobar foo");
|
||||
|
||||
var search = new AceAjax.Search().set({
|
||||
needle: "foo",
|
||||
wrap: true,
|
||||
wholeWord: true,
|
||||
backwards: true
|
||||
});
|
||||
|
||||
session.getSelection().moveCursorTo(0, 13);
|
||||
|
||||
var ranges = search.findAll(session);
|
||||
|
||||
assert.equal(ranges.length, 3);
|
||||
assert.position(ranges[2].start, 0, 23);
|
||||
assert.position(ranges[2].end, 0, 26);
|
||||
assert.position(ranges[1].start, 0, 8);
|
||||
assert.position(ranges[1].end, 0, 11);
|
||||
assert.position(ranges[0].start, 0, 0);
|
||||
assert.position(ranges[0].end, 0, 3);
|
||||
},
|
||||
};
|
||||
@@ -1,412 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
createSession: function (rows, cols) {
|
||||
var line = new Array(cols + 1).join("a");
|
||||
var text = new Array(rows).join(line + "\n") + line;
|
||||
return new AceAjax.EditSession(text);
|
||||
},
|
||||
|
||||
"test: move cursor to end of file should place the cursor on last row and column": function () {
|
||||
var session = this.createSession(200, 10);
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorFileEnd();
|
||||
assert.position(selection.getCursor(), 199, 10);
|
||||
},
|
||||
|
||||
"test: moveCursor to start of file should place the cursor on the first row and column": function () {
|
||||
var session = this.createSession(200, 10);
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorFileStart();
|
||||
assert.position(selection.getCursor(), 0, 0);
|
||||
},
|
||||
|
||||
"test: move selection lead to end of file": function () {
|
||||
var session = this.createSession(200, 10);
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(100, 5);
|
||||
selection.selectFileEnd();
|
||||
|
||||
var range = selection.getRange();
|
||||
|
||||
assert.position(range.start, 100, 5);
|
||||
assert.position(range.end, 199, 10);
|
||||
},
|
||||
|
||||
"test: move selection lead to start of file": function () {
|
||||
var session = this.createSession(200, 10);
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(100, 5);
|
||||
selection.selectFileStart();
|
||||
|
||||
var range = selection.getRange();
|
||||
|
||||
assert.position(range.start, 0, 0);
|
||||
assert.position(range.end, 100, 5);
|
||||
},
|
||||
|
||||
"test: move cursor word right": function () {
|
||||
var session = new AceAjax.EditSession([
|
||||
"ab",
|
||||
" Juhu Kinners (abc, 12)",
|
||||
" cde"
|
||||
].join("\n"));
|
||||
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorDown();
|
||||
assert.position(selection.getCursor(), 1, 0);
|
||||
|
||||
selection.moveCursorWordRight();
|
||||
assert.position(selection.getCursor(), 1, 5);
|
||||
|
||||
selection.moveCursorWordRight();
|
||||
assert.position(selection.getCursor(), 1, 13);
|
||||
|
||||
selection.moveCursorWordRight();
|
||||
assert.position(selection.getCursor(), 1, 18);
|
||||
|
||||
selection.moveCursorWordRight();
|
||||
assert.position(selection.getCursor(), 1, 22);
|
||||
|
||||
// wrap line
|
||||
selection.moveCursorWordRight();
|
||||
assert.position(selection.getCursor(), 2, 4);
|
||||
|
||||
selection.moveCursorWordRight();
|
||||
assert.position(selection.getCursor(), 2, 4);
|
||||
},
|
||||
|
||||
"test: select word right if cursor in word": function () {
|
||||
var session = new AceAjax.EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 2);
|
||||
selection.moveCursorWordRight();
|
||||
|
||||
assert.position(selection.getCursor(), 0, 4);
|
||||
},
|
||||
|
||||
"test: moveCursor word left": function () {
|
||||
var session = new AceAjax.EditSession([
|
||||
"ab",
|
||||
" Juhu Kinners (abc, 12)",
|
||||
" cde"
|
||||
].join("\n"));
|
||||
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorDown();
|
||||
selection.moveCursorLineEnd();
|
||||
assert.position(selection.getCursor(), 1, 23);
|
||||
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 1, 20);
|
||||
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 1, 15);
|
||||
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 1, 6);
|
||||
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 1, 1);
|
||||
|
||||
// wrap line
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 0, 0);
|
||||
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 0, 0);
|
||||
},
|
||||
|
||||
"test: moveCursor word left with umlauts": function () {
|
||||
var session = new AceAjax.EditSession(" Fuß Füße");
|
||||
|
||||
var selection = session.getSelection();
|
||||
selection.moveCursorTo(0, 9)
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 0, 5);
|
||||
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 0, 1);
|
||||
},
|
||||
|
||||
"test: select word left if cursor in word": function () {
|
||||
var session = new AceAjax.EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 8);
|
||||
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 0, 5);
|
||||
},
|
||||
|
||||
"test: select word right and select": function () {
|
||||
var session = new AceAjax.EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 0);
|
||||
selection.selectWordRight();
|
||||
|
||||
var range = selection.getRange();
|
||||
|
||||
assert.position(range.start, 0, 0);
|
||||
assert.position(range.end, 0, 4);
|
||||
},
|
||||
|
||||
"test: select word left and select": function () {
|
||||
var session = new AceAjax.EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 3);
|
||||
selection.selectWordLeft();
|
||||
|
||||
var range = selection.getRange();
|
||||
|
||||
assert.position(range.start, 0, 0);
|
||||
assert.position(range.end, 0, 3);
|
||||
},
|
||||
|
||||
"test: select word with cursor in word should select the word": function () {
|
||||
var session = new AceAjax.EditSession("Juhu Kinners 123");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 8);
|
||||
selection.selectWord();
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.position(range.start, 0, 5);
|
||||
assert.position(range.end, 0, 12);
|
||||
},
|
||||
|
||||
"test: select word with cursor in word including right whitespace should select the word": function () {
|
||||
var session = new AceAjax.EditSession("Juhu Kinners 123");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 8);
|
||||
selection.selectAWord();
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.position(range.start, 0, 5);
|
||||
assert.position(range.end, 0, 18);
|
||||
},
|
||||
|
||||
"test: select word with cursor betwen white space and word should select the word": function () {
|
||||
var session = new AceAjax.EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 4);
|
||||
selection.selectWord();
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.position(range.start, 0, 0);
|
||||
assert.position(range.end, 0, 4);
|
||||
|
||||
selection.moveCursorTo(0, 5);
|
||||
selection.selectWord();
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.position(range.start, 0, 5);
|
||||
assert.position(range.end, 0, 12);
|
||||
},
|
||||
|
||||
"test: select word with cursor in white space should select white space": function () {
|
||||
var session = new AceAjax.EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 5);
|
||||
selection.selectWord();
|
||||
|
||||
var range = selection.getRange();
|
||||
assert.position(range.start, 0, 4);
|
||||
assert.position(range.end, 0, 6);
|
||||
},
|
||||
|
||||
"test: moving cursor should fire a 'changeCursor' event": function () {
|
||||
var session = new AceAjax.EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 5);
|
||||
|
||||
var called = false;
|
||||
selection.addEventListener("changeCursor", function () {
|
||||
called = true;
|
||||
});
|
||||
|
||||
selection.moveCursorTo(0, 6);
|
||||
assert.ok(called);
|
||||
},
|
||||
|
||||
"test: calling setCursor with the same position should not fire an event": function () {
|
||||
var session = new AceAjax.EditSession("Juhu Kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 5);
|
||||
|
||||
var called = false;
|
||||
selection.addEventListener("changeCursor", function () {
|
||||
called = true;
|
||||
});
|
||||
|
||||
selection.moveCursorTo(0, 5);
|
||||
assert.notOk(called);
|
||||
},
|
||||
|
||||
"test: moveWordright should move past || and [": function () {
|
||||
var session = new AceAjax.EditSession("||foo[");
|
||||
var selection = session.getSelection();
|
||||
|
||||
// Move behind ||foo
|
||||
selection.moveCursorWordRight();
|
||||
assert.position(selection.getCursor(), 0, 5);
|
||||
|
||||
// Move behind [
|
||||
selection.moveCursorWordRight();
|
||||
assert.position(selection.getCursor(), 0, 6);
|
||||
},
|
||||
|
||||
"test: moveWordLeft should move past || and [": function () {
|
||||
var session = new AceAjax.EditSession("||foo[");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 6);
|
||||
|
||||
// Move behind [foo
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 0, 2);
|
||||
|
||||
// Move behind ||
|
||||
selection.moveCursorWordLeft();
|
||||
assert.position(selection.getCursor(), 0, 0);
|
||||
},
|
||||
|
||||
"test: move cursor to line start should move cursor to end of the indentation first": function () {
|
||||
var session = new AceAjax.EditSession("12\n Juhu\n12");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(1, 6);
|
||||
selection.moveCursorLineStart();
|
||||
|
||||
assert.position(selection.getCursor(), 1, 4);
|
||||
},
|
||||
|
||||
"test: move cursor to line start when the cursor is at the end of the indentation should move cursor to column 0": function () {
|
||||
var session = new AceAjax.EditSession("12\n Juhu\n12");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(1, 4);
|
||||
selection.moveCursorLineStart();
|
||||
|
||||
assert.position(selection.getCursor(), 1, 0);
|
||||
},
|
||||
|
||||
"test: move cursor to line start when the cursor is at column 0 should move cursor to the end of the indentation": function () {
|
||||
var session = new AceAjax.EditSession("12\n Juhu\n12");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(1, 0);
|
||||
selection.moveCursorLineStart();
|
||||
|
||||
assert.position(selection.getCursor(), 1, 4);
|
||||
},
|
||||
|
||||
// Eclipse style
|
||||
"test: move cursor to line start when the cursor is before the initial indentation should move cursor to the end of the indentation": function () {
|
||||
var session = new AceAjax.EditSession("12\n Juhu\n12");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(1, 2);
|
||||
selection.moveCursorLineStart();
|
||||
|
||||
assert.position(selection.getCursor(), 1, 4);
|
||||
},
|
||||
|
||||
"test go line up when in the middle of the first line should go to document start": function () {
|
||||
var session = new AceAjax.EditSession("juhu kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 4);
|
||||
selection.moveCursorUp();
|
||||
|
||||
assert.position(selection.getCursor(), 0, 0);
|
||||
},
|
||||
|
||||
"test: (wrap) go line up when in the middle of the first line should go to document start": function () {
|
||||
var session = new AceAjax.EditSession("juhu kinners");
|
||||
session.setWrapLimitRange(5, 5);
|
||||
session.adjustWrapLimit(80);
|
||||
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 4);
|
||||
selection.moveCursorUp();
|
||||
|
||||
assert.position(selection.getCursor(), 0, 0);
|
||||
},
|
||||
|
||||
|
||||
"test go line down when in the middle of the last line should go to document end": function () {
|
||||
var session = new AceAjax.EditSession("juhu kinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 4);
|
||||
selection.moveCursorDown();
|
||||
|
||||
assert.position(selection.getCursor(), 0, 12);
|
||||
},
|
||||
|
||||
"test (wrap) go line down when in the middle of the last line should go to document end": function () {
|
||||
var session = new AceAjax.EditSession("juhu kinners");
|
||||
session.setWrapLimitRange(8, 8);
|
||||
session.adjustWrapLimit(80);
|
||||
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 10);
|
||||
selection.moveCursorDown();
|
||||
|
||||
assert.position(selection.getCursor(), 0, 12);
|
||||
},
|
||||
|
||||
"test go line up twice and then once down when in the second should go back to the previous column": function () {
|
||||
var session = new AceAjax.EditSession("juhu\nkinners");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(1, 4);
|
||||
selection.moveCursorUp();
|
||||
selection.moveCursorUp();
|
||||
selection.moveCursorDown();
|
||||
|
||||
assert.position(selection.getCursor(), 1, 4);
|
||||
},
|
||||
|
||||
"test (keyboard navigation) when curLine is not EOL and targetLine is all whitespace new column should be current column": function () {
|
||||
var session = new AceAjax.EditSession("function (a) {\n\
|
||||
\n\
|
||||
}");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(2, 0);
|
||||
selection.moveCursorUp();
|
||||
|
||||
assert.position(selection.getCursor(), 1, 0);
|
||||
},
|
||||
|
||||
"test (keyboard navigation) when curLine is EOL and targetLine is shorter dan current column, new column should be targetLine's EOL": function () {
|
||||
var session = new AceAjax.EditSession("function (a) {\n\
|
||||
\n\
|
||||
}");
|
||||
var selection = session.getSelection();
|
||||
|
||||
selection.moveCursorTo(0, 14);
|
||||
selection.moveCursorDown();
|
||||
|
||||
assert.position(selection.getCursor(), 1, 4);
|
||||
}
|
||||
};
|
||||
@@ -1,168 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var mode: any;
|
||||
var exports = {
|
||||
"test: token iterator initialization in JavaScript document": function () {
|
||||
var lines = [
|
||||
"function foo(items) {",
|
||||
" for (var i=0; i<items.length; i++) {",
|
||||
" alert(items[i] + \"juhu\");",
|
||||
" } // Real Tab.",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"),mode);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 0, 0);
|
||||
assert.equal(iterator.getCurrentToken().value, "function");
|
||||
assert.equal(iterator.getCurrentTokenRow(), 0);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 0);
|
||||
|
||||
iterator.stepForward();
|
||||
assert.equal(iterator.getCurrentToken().value, " ");
|
||||
assert.equal(iterator.getCurrentTokenRow(), 0);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 8);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 0, 4);
|
||||
assert.equal(iterator.getCurrentToken().value, "function");
|
||||
assert.equal(iterator.getCurrentTokenRow(), 0);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 0);
|
||||
|
||||
iterator.stepForward();
|
||||
assert.equal(iterator.getCurrentToken().value, " ");
|
||||
assert.equal(iterator.getCurrentTokenRow(), 0);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 8);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 2, 18);
|
||||
assert.equal(iterator.getCurrentToken().value, "items");
|
||||
assert.equal(iterator.getCurrentTokenRow(), 2);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 14);
|
||||
|
||||
iterator.stepForward();
|
||||
assert.equal(iterator.getCurrentToken().value, "[");
|
||||
assert.equal(iterator.getCurrentTokenRow(), 2);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 19);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 4, 0);
|
||||
assert.equal(iterator.getCurrentToken().value, "}");
|
||||
assert.equal(iterator.getCurrentTokenRow(), 4);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 0);
|
||||
|
||||
iterator.stepBackward();
|
||||
assert.equal(iterator.getCurrentToken().value, "// Real Tab.");
|
||||
assert.equal(iterator.getCurrentTokenRow(), 3);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 6);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 5, 0);
|
||||
assert.equal(iterator.getCurrentToken(), null);
|
||||
},
|
||||
|
||||
"test: token iterator initialization in text document": function () {
|
||||
var lines = [
|
||||
"Lorem ipsum dolor sit amet, consectetur adipisicing elit,",
|
||||
"sed do eiusmod tempor incididunt ut labore et dolore magna",
|
||||
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation",
|
||||
"ullamco laboris nisi ut aliquip ex ea commodo consequat."
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"));
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 0, 0);
|
||||
assert.equal(iterator.getCurrentToken().value, lines[0]);
|
||||
assert.equal(iterator.getCurrentTokenRow(), 0);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 0);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 0, 4);
|
||||
assert.equal(iterator.getCurrentToken().value, lines[0]);
|
||||
assert.equal(iterator.getCurrentTokenRow(), 0);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 0);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 2, 18);
|
||||
assert.equal(iterator.getCurrentToken().value, lines[2]);
|
||||
assert.equal(iterator.getCurrentTokenRow(), 2);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 0);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 3, lines[3].length - 1);
|
||||
assert.equal(iterator.getCurrentToken().value, lines[3]);
|
||||
assert.equal(iterator.getCurrentTokenRow(), 3);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 0);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 4, 0);
|
||||
assert.equal(iterator.getCurrentToken(), null);
|
||||
},
|
||||
|
||||
"test: token iterator step forward in JavaScript document": function () {
|
||||
var lines = [
|
||||
"function foo(items) {",
|
||||
" for (var i=0; i<items.length; i++) {",
|
||||
" alert(items[i] + \"juhu\");",
|
||||
" } // Real Tab.",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"),mode);
|
||||
|
||||
var tokens = [];
|
||||
var len = session.getLength();
|
||||
for (var i = 0; i < len; i++)
|
||||
tokens = tokens.concat(session.getTokens(i));
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 0, 0);
|
||||
for (var i = 1; i < tokens.length; i++)
|
||||
assert.equal(iterator.stepForward(), tokens[i]);
|
||||
assert.equal(iterator.stepForward(), null);
|
||||
assert.equal(iterator.getCurrentToken(), null);
|
||||
},
|
||||
|
||||
"test: token iterator step backward in JavaScript document": function () {
|
||||
var lines = [
|
||||
"function foo(items) {",
|
||||
" for (var i=0; i<items.length; i++) {",
|
||||
" alert(items[i] + \"juhu\");",
|
||||
" } // Real Tab.",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"),mode);
|
||||
|
||||
var tokens = [];
|
||||
var len = session.getLength();
|
||||
for (var i = 0; i < len; i++)
|
||||
tokens = tokens.concat(session.getTokens(i));
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 4, 0);
|
||||
for (var i = tokens.length - 2; i >= 0; i--)
|
||||
assert.equal(iterator.stepBackward(), tokens[i]);
|
||||
assert.equal(iterator.stepBackward(), null);
|
||||
assert.equal(iterator.getCurrentToken(), null);
|
||||
},
|
||||
|
||||
"test: token iterator reports correct row and column": function () {
|
||||
var lines = [
|
||||
"function foo(items) {",
|
||||
" for (var i=0; i<items.length; i++) {",
|
||||
" alert(items[i] + \"juhu\");",
|
||||
" } // Real Tab.",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"),mode);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 0, 0);
|
||||
|
||||
iterator.stepForward();
|
||||
iterator.stepForward();
|
||||
|
||||
assert.equal(iterator.getCurrentToken().value, "foo");
|
||||
assert.equal(iterator.getCurrentTokenRow(), 0);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 9);
|
||||
|
||||
iterator.stepForward();
|
||||
iterator.stepForward();
|
||||
iterator.stepForward();
|
||||
iterator.stepForward();
|
||||
iterator.stepForward();
|
||||
iterator.stepForward();
|
||||
iterator.stepForward();
|
||||
|
||||
assert.equal(iterator.getCurrentToken().value, "for");
|
||||
assert.equal(iterator.getCurrentTokenRow(), 1);
|
||||
assert.equal(iterator.getCurrentTokenColumn(), 4);
|
||||
}
|
||||
};
|
||||
@@ -1,41 +0,0 @@
|
||||
|
||||
|
||||
var assert: any;
|
||||
var exports = {
|
||||
"test: screen2text the column should be rounded to the next character edge": function () {
|
||||
var el = document.createElement("div");
|
||||
|
||||
if (!el.getBoundingClientRect) {
|
||||
console.log("Skipping test: This test only runs in the browser");
|
||||
return;
|
||||
}
|
||||
|
||||
el.style.left = "20px";
|
||||
el.style.top = "30px";
|
||||
el.style.width = "300px";
|
||||
el.style.height = "100px";
|
||||
document.body.appendChild(el);
|
||||
|
||||
var renderer = new AceAjax.VirtualRenderer(el);
|
||||
renderer.setPadding(0);
|
||||
renderer.setSession(new AceAjax.EditSession("1234"));
|
||||
|
||||
var r = renderer.scroller.getBoundingClientRect();
|
||||
function testPixelToText(x, y, row, column) {
|
||||
assert.position(renderer.screenToTextCoordinates(x + r.left, y + r.top), row, column);
|
||||
}
|
||||
|
||||
renderer.characterWidth = 10;
|
||||
renderer.lineHeight = 15;
|
||||
|
||||
testPixelToText(4, 0, 0, 0);
|
||||
testPixelToText(5, 0, 0, 1);
|
||||
testPixelToText(9, 0, 0, 1);
|
||||
testPixelToText(10, 0, 0, 1);
|
||||
testPixelToText(14, 0, 0, 1);
|
||||
testPixelToText(15, 0, 0, 2);
|
||||
document.body.removeChild(el);
|
||||
}
|
||||
|
||||
// change tab size after setDocument (for text layer)
|
||||
};
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"all-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
// Sample code from
|
||||
// https://github.com/OptimalBits/node_acl/blob/master/Readme.md
|
||||
import Acl = require('acl');
|
||||
|
||||
var report = <T>(err: Error, value: T) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
console.info(value);
|
||||
};
|
||||
|
||||
// Using the memory backend
|
||||
var acl = new Acl(new Acl.memoryBackend());
|
||||
|
||||
// guest is allowed to view blogs
|
||||
acl.allow('guest', 'blogs', 'view');
|
||||
|
||||
// allow function accepts arrays as any parameter
|
||||
acl.allow('member', 'blogs', ['edit','view', 'delete']);
|
||||
|
||||
acl.addUserRoles('joed', 'guest');
|
||||
|
||||
acl.addRoleParents('baz', ['foo','bar']);
|
||||
|
||||
acl.allow('foo', ['blogs','forums','news'], ['view', 'delete']);
|
||||
|
||||
acl.allow('admin', ['blogs','forums'], '*');
|
||||
|
||||
acl.allow([
|
||||
{
|
||||
roles:['guest','special-member'],
|
||||
allows:[
|
||||
{resources:'blogs', permissions:'get'},
|
||||
{resources:['forums','news'], permissions:['get','put','delete']}
|
||||
]
|
||||
},
|
||||
{
|
||||
roles:['gold','silver'],
|
||||
allows:[
|
||||
{resources:'cash', permissions:['sell','exchange']},
|
||||
{resources:['account','deposit'], permissions:['put','delete']}
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
acl.isAllowed('joed', 'blogs', 'view', (err, res) => {
|
||||
if (res) {
|
||||
console.log("User joed is allowed to view blogs");
|
||||
}
|
||||
});
|
||||
|
||||
acl.isAllowed('jsmith', 'blogs', ['edit','view','delete'])
|
||||
.then((result) => {
|
||||
console.dir('jsmith is allowed blogs ' + result);
|
||||
acl.addUserRoles('jsmith', 'member');
|
||||
}).then(() =>
|
||||
acl.isAllowed('jsmith', 'blogs', ['edit','view','delete'])
|
||||
).then((result) =>
|
||||
console.dir('jsmith is allowed blogs ' + result)
|
||||
).then(() => {
|
||||
acl.allowedPermissions('james', ['blogs','forums'], report);
|
||||
acl.allowedPermissions('jsmith', ['blogs','forums'], report);
|
||||
});
|
||||
Vendored
-145
@@ -1,145 +0,0 @@
|
||||
// Type definitions for node_acl 0.4.7
|
||||
// Project: https://github.com/optimalbits/node_acl
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="bluebird" />
|
||||
/// <reference types="node"/>
|
||||
|
||||
import http = require('http');
|
||||
import Promise = require("bluebird");
|
||||
|
||||
type strings = string|string[];
|
||||
type Value = string|number;
|
||||
type Values = Value|Value[];
|
||||
type Action = () => any;
|
||||
type Callback = (err: Error) => any;
|
||||
type AnyCallback = (err: Error, obj: any) => any;
|
||||
type AllowedCallback = (err: Error, allowed: boolean) => any;
|
||||
type GetUserId = (req: http.IncomingMessage, res: http.ServerResponse) => Value;
|
||||
|
||||
interface AclStatic {
|
||||
new (backend: Backend<any>, logger: Logger, options: Option): Acl;
|
||||
new (backend: Backend<any>, logger: Logger): Acl;
|
||||
new (backend: Backend<any>): Acl;
|
||||
memoryBackend: MemoryBackendStatic;
|
||||
}
|
||||
|
||||
interface Logger {
|
||||
debug: (msg: string) => any;
|
||||
}
|
||||
|
||||
interface Acl {
|
||||
addUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise<void>;
|
||||
removeUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise<void>;
|
||||
userRoles: (userId: Value, cb?: (err: Error, roles: string[]) => any) => Promise<string[]>;
|
||||
roleUsers: (role: Value, cb?: (err: Error, users: Values) => any) => Promise<any>;
|
||||
hasRole: (userId: Value, role: string, cb?: (err: Error, isInRole: boolean) => any) => Promise<boolean>;
|
||||
addRoleParents: (role: string, parents: Values, cb?: Callback) => Promise<void>;
|
||||
removeRole: (role: string, cb?: Callback) => Promise<void>;
|
||||
removeResource: (resource: string, cb?: Callback) => Promise<void>;
|
||||
allow: {
|
||||
(roles: Values, resources: strings, permissions: strings, cb?: Callback): Promise<void>;
|
||||
(aclSets: AclSet | AclSet[]): Promise<void>;
|
||||
}
|
||||
removeAllow: (role: string, resources: strings, permissions: strings, cb?: Callback) => Promise<void>;
|
||||
removePermissions: (role: string, resources: strings, permissions: strings, cb?: Function) => Promise<void>;
|
||||
allowedPermissions: (userId: Value, resources: strings, cb?: AnyCallback) => Promise<void>;
|
||||
isAllowed: (userId: Value, resources: strings, permissions: strings, cb?: AllowedCallback) => Promise<boolean>;
|
||||
areAnyRolesAllowed: (roles: strings, resource: strings, permissions: strings, cb?: AllowedCallback) => Promise<any>;
|
||||
whatResources: (roles: strings, permissions: strings, cb?: AnyCallback) => Promise<any>;
|
||||
permittedResources: (roles: strings, permissions: strings, cb?: Function) => Promise<void>;
|
||||
middleware: (numPathComponents: number, userId: Value | GetUserId, actions: strings) => Promise<any>;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
buckets?: BucketsOption;
|
||||
}
|
||||
|
||||
interface BucketsOption {
|
||||
meta?: string;
|
||||
parents?: string;
|
||||
permissions?: string;
|
||||
resources?: string;
|
||||
roles?: string;
|
||||
users?: string;
|
||||
}
|
||||
|
||||
interface AclSet {
|
||||
roles: strings;
|
||||
allows: AclAllow[];
|
||||
}
|
||||
|
||||
interface AclAllow {
|
||||
resources: strings;
|
||||
permissions: strings;
|
||||
}
|
||||
|
||||
interface MemoryBackend extends Backend<Action[]> { }
|
||||
interface MemoryBackendStatic {
|
||||
new (): MemoryBackend;
|
||||
}
|
||||
|
||||
//
|
||||
// For internal use
|
||||
//
|
||||
interface Backend<T> {
|
||||
begin: () => T;
|
||||
end: (transaction: T, cb?: Action) => void;
|
||||
clean: (cb?: Action) => void;
|
||||
get: (bucket: string, key: Value, cb?: Action) => void;
|
||||
union: (bucket: string, keys: Value[], cb?: Action) => void;
|
||||
add: (transaction: T, bucket: string, key: Value, values: Values) => void;
|
||||
del: (transaction: T, bucket: string, keys: Value[]) => void;
|
||||
remove: (transaction: T, bucket: string, key: Value, values: Values) => void;
|
||||
|
||||
endAsync: Function; //TODO: Give more specific function signature
|
||||
getAsync: Function;
|
||||
cleanAsync: Function;
|
||||
unionAsync: Function;
|
||||
}
|
||||
|
||||
interface Contract {
|
||||
(args: IArguments): Contract | NoOp;
|
||||
debug: boolean;
|
||||
fulfilled: boolean;
|
||||
args: any[];
|
||||
checkedParams: string[];
|
||||
params: (...types: string[]) => Contract | NoOp;
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
interface NoOp {
|
||||
params: (...types: string[]) => NoOp;
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
// for redis backend
|
||||
import redis = require('redis');
|
||||
|
||||
interface AclStatic {
|
||||
redisBackend: RedisBackendStatic;
|
||||
}
|
||||
|
||||
interface RedisBackend extends Backend<redis.RedisClient> { }
|
||||
interface RedisBackendStatic {
|
||||
new (redis: redis.RedisClient, prefix: string): RedisBackend;
|
||||
new (redis: redis.RedisClient): RedisBackend;
|
||||
}
|
||||
|
||||
// for mongodb backend
|
||||
import mongo = require('mongodb');
|
||||
|
||||
interface AclStatic {
|
||||
mongodbBackend: MongodbBackendStatic;
|
||||
}
|
||||
|
||||
interface MongodbBackend extends Backend<Callback> { }
|
||||
interface MongodbBackendStatic {
|
||||
new (db: mongo.Db, prefix: string, useSingle: boolean): MongodbBackend;
|
||||
new (db: mongo.Db, prefix: string): MongodbBackend;
|
||||
new (db: mongo.Db): MongodbBackend;
|
||||
}
|
||||
|
||||
declare var _: AclStatic;
|
||||
export = _;
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"acl-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-258
@@ -1,258 +0,0 @@
|
||||
// Type definitions for Acorn v4.0.3
|
||||
// Project: https://github.com/marijnh/acorn
|
||||
// Definitions by: RReverser <https://github.com/RReverser>, e-cloud <https://github.com/e-cloud>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="estree" />
|
||||
|
||||
export as namespace acorn;
|
||||
export = acorn;
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
declare namespace acorn {
|
||||
interface PlainObject {
|
||||
[name: string]: any;
|
||||
}
|
||||
|
||||
interface PluginsObject {
|
||||
[name: string]: (p: Parser, config: any) => void;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
ecmaVersion?: 3 | 5 | 6 | 7 | 8 | 2015 | 2016 | 2017;
|
||||
sourceType?: 'script' | 'module';
|
||||
onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: ESTree.Position) => void;
|
||||
onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: ESTree.Position) => void;
|
||||
allowReserved?: boolean;
|
||||
allowReturnOutsideFunction?: boolean;
|
||||
allowImportExportEverywhere?: boolean;
|
||||
allowHashBang?: boolean;
|
||||
locations?: boolean;
|
||||
onToken?: ((token: Token) => any) | Token[];
|
||||
onComment?: ((
|
||||
isBlock: boolean, text: string, start: number, end: number, startLoc?: ESTree.Position,
|
||||
endLoc?: ESTree.Position
|
||||
) => void) | Comment[];
|
||||
ranges?: boolean;
|
||||
program?: ESTree.Program;
|
||||
sourceFile?: string;
|
||||
directSourceFile?: string;
|
||||
preserveParens?: boolean;
|
||||
plugins?: PlainObject;
|
||||
}
|
||||
|
||||
class Parser {
|
||||
constructor(options: Options, input: string, startPos?: number);
|
||||
|
||||
parse(): ESTree.Program;
|
||||
}
|
||||
|
||||
const plugins: PluginsObject;
|
||||
|
||||
const defaultOptions: Options;
|
||||
|
||||
class Position implements ESTree.Position {
|
||||
line: number;
|
||||
column: number;
|
||||
|
||||
constructor(line: number, col: number);
|
||||
|
||||
offset(n: number): Position;
|
||||
}
|
||||
|
||||
class SourceLocation implements ESTree.SourceLocation {
|
||||
start: Position;
|
||||
end: Position;
|
||||
source?: string;
|
||||
|
||||
constructor(p: Parser, start: Position, end: Position);
|
||||
}
|
||||
|
||||
function getLineInfo(input: string, offset: number): ESTree.Position;
|
||||
|
||||
class Node {
|
||||
type: string;
|
||||
start: number;
|
||||
end: number;
|
||||
loc?: ESTree.SourceLocation;
|
||||
sourceFile?: string;
|
||||
range?: [number, number];
|
||||
|
||||
constructor(parser: Parser, pos: number, loc: number);
|
||||
}
|
||||
|
||||
interface TokeTypeConfig {
|
||||
keyword: string;
|
||||
beforeExpr?: boolean;
|
||||
startsExpr?: boolean;
|
||||
isLoop?: boolean;
|
||||
isAssign?: boolean;
|
||||
prefix?: boolean;
|
||||
postfix?: boolean;
|
||||
binop?: number;
|
||||
}
|
||||
|
||||
class TokenType {
|
||||
label: string;
|
||||
keyword: string;
|
||||
beforeExpr: boolean;
|
||||
startsExpr: boolean;
|
||||
isLoop: boolean;
|
||||
isAssign: boolean;
|
||||
prefix: boolean;
|
||||
postfix: boolean;
|
||||
binop: number;
|
||||
updateContext: (prevType: TokenType) => void;
|
||||
|
||||
constructor(label: string, conf?: TokeTypeConfig);
|
||||
}
|
||||
|
||||
const tokTypes: {
|
||||
num: TokenType;
|
||||
regexp: TokenType;
|
||||
string: TokenType;
|
||||
name: TokenType;
|
||||
eof: TokenType;
|
||||
bracketL: TokenType;
|
||||
bracketR: TokenType;
|
||||
braceL: TokenType;
|
||||
braceR: TokenType;
|
||||
parenL: TokenType;
|
||||
parenR: TokenType;
|
||||
comma: TokenType;
|
||||
semi: TokenType;
|
||||
colon: TokenType;
|
||||
dot: TokenType;
|
||||
question: TokenType;
|
||||
arrow: TokenType;
|
||||
template: TokenType;
|
||||
ellipsis: TokenType;
|
||||
backQuote: TokenType;
|
||||
dollarBraceL: TokenType;
|
||||
eq: TokenType;
|
||||
assign: TokenType;
|
||||
incDec: TokenType;
|
||||
prefix: TokenType;
|
||||
logicalOR: TokenType;
|
||||
logicalAND: TokenType;
|
||||
bitwiseOR: TokenType;
|
||||
bitwiseXOR: TokenType;
|
||||
bitwiseAND: TokenType;
|
||||
equality: TokenType;
|
||||
relational: TokenType;
|
||||
bitShift: TokenType;
|
||||
plusMin: TokenType;
|
||||
modulo: TokenType;
|
||||
star: TokenType;
|
||||
slash: TokenType;
|
||||
starstar: TokenType;
|
||||
_break: TokenType;
|
||||
_case: TokenType;
|
||||
_catch: TokenType;
|
||||
_continue: TokenType;
|
||||
_debugger: TokenType;
|
||||
_default: TokenType;
|
||||
_do: TokenType;
|
||||
_else: TokenType;
|
||||
_finally: TokenType;
|
||||
_for: TokenType;
|
||||
_function: TokenType;
|
||||
_if: TokenType;
|
||||
_return: TokenType;
|
||||
_switch: TokenType;
|
||||
_throw: TokenType;
|
||||
_try: TokenType;
|
||||
_var: TokenType;
|
||||
_const: TokenType;
|
||||
_while: TokenType;
|
||||
_with: TokenType;
|
||||
_new: TokenType;
|
||||
_this: TokenType;
|
||||
_super: TokenType;
|
||||
_class: TokenType;
|
||||
_extends: TokenType;
|
||||
_export: TokenType;
|
||||
_import: TokenType;
|
||||
_null: TokenType;
|
||||
_true: TokenType;
|
||||
_false: TokenType;
|
||||
_in: TokenType;
|
||||
_instanceof: TokenType;
|
||||
_typeof: TokenType;
|
||||
_void: TokenType;
|
||||
_delete: TokenType;
|
||||
}
|
||||
|
||||
class TokContext {
|
||||
constructor(token: string, isExpr: boolean, preserveSpace: boolean, override: (p: Parser) => void);
|
||||
}
|
||||
|
||||
const tokContexts: {
|
||||
b_stat: TokContext;
|
||||
b_expr: TokContext;
|
||||
b_tmpl: TokContext;
|
||||
p_stat: TokContext;
|
||||
p_expr: TokContext;
|
||||
q_tmpl: TokContext;
|
||||
f_expr: TokContext;
|
||||
};
|
||||
|
||||
function isIdentifierStart(code: number, astral?: boolean): boolean;
|
||||
|
||||
function isIdentifierChar(code: number, astral?: boolean): boolean;
|
||||
|
||||
interface AbstractToken {
|
||||
start: number;
|
||||
end: number;
|
||||
loc?: SourceLocation;
|
||||
range?: [number, number];
|
||||
}
|
||||
|
||||
interface Comment extends AbstractToken {
|
||||
type: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
class Token {
|
||||
constructor(p: Parser);
|
||||
}
|
||||
|
||||
interface Token extends AbstractToken {
|
||||
type: TokenType;
|
||||
value: any;
|
||||
}
|
||||
|
||||
function isNewLine(code: number): boolean;
|
||||
|
||||
const lineBreak: RegExp;
|
||||
|
||||
const lineBreakG: RegExp;
|
||||
|
||||
const version: string;
|
||||
|
||||
interface IParse {
|
||||
(input: string, options?: Options): ESTree.Program;
|
||||
}
|
||||
|
||||
const parse: IParse;
|
||||
|
||||
function parseExpressionAt(input: string, pos?: number, options?: Options): ESTree.Expression;
|
||||
|
||||
// todo: here the tokenizer function returns a Parser instance, that is targeting the detail of
|
||||
// Parser prototype. Someone need this please reade README.md first.
|
||||
// function tokenizer(options: Options, input: string): Parser;
|
||||
|
||||
let parse_dammit: IParse | undefined;
|
||||
let LooseParser: ILooseParserClass | undefined;
|
||||
let pluginsLoose: PluginsObject | undefined;
|
||||
|
||||
interface ILooseParserClass {
|
||||
new (input: string, options?: Options): ILooseParser
|
||||
}
|
||||
|
||||
interface ILooseParser {
|
||||
|
||||
}
|
||||
|
||||
function addLooseExports(parse: IParse, parser: ILooseParserClass, plugins: PluginsObject): void;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"acorn-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
interface HelloChannel extends ActionCable.Channel {
|
||||
hello(world: string, name?: string): void;
|
||||
}
|
||||
|
||||
App = {};
|
||||
App.cable = ActionCable.createConsumer();
|
||||
const helloChannel = App.cable.subscriptions.create('NetworkChannel', {
|
||||
connected(): void {
|
||||
console.log('connected');
|
||||
},
|
||||
disconnected(): void {
|
||||
console.log('disconnected');
|
||||
},
|
||||
received(obj: Object): void {
|
||||
console.log(obj);
|
||||
},
|
||||
hello(world: string, name: string = 'John Doe'): void {
|
||||
console.log(`Hello, ${world}! name[${name}]`);
|
||||
}
|
||||
}) as HelloChannel;
|
||||
|
||||
helloChannel.hello('World');
|
||||
Vendored
-40
@@ -1,40 +0,0 @@
|
||||
// Type definitions for ActionCable
|
||||
// Project: https://github.com/rails/rails/tree/master/actioncable
|
||||
// Definitions by: Vincent Zhu <https://github.com/zhu1230>
|
||||
// Definitions: https://github.com/zhu1230/DefinitelyTyped
|
||||
|
||||
declare module ActionCable {
|
||||
interface Channel {
|
||||
unsubscribe(): void;
|
||||
perform(action: string, data: {}): void;
|
||||
}
|
||||
|
||||
interface Subscriptions {
|
||||
create(chan_name: string, obj: CreateMixin): Channel;
|
||||
}
|
||||
|
||||
interface Cable {
|
||||
subscriptions: Subscriptions;
|
||||
}
|
||||
|
||||
interface CreateMixin {
|
||||
connected(): void;
|
||||
disconnected(): void;
|
||||
received(obj: Object): void;
|
||||
[key: string]: Function;
|
||||
}
|
||||
|
||||
function createConsumer(): Cable;
|
||||
function createConsumer(url: string): Cable;
|
||||
}
|
||||
|
||||
declare interface AppInterface {
|
||||
cable?: ActionCable.Cable;
|
||||
network?: ActionCable.Channel;
|
||||
}
|
||||
|
||||
declare var App: AppInterface;
|
||||
|
||||
declare module 'actioncable' {
|
||||
export = ActionCable;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"actioncable-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
//open connection to an Excel file
|
||||
var pathToExcelFile = 'C:\\path\\to\\excel\\file.xlsx';
|
||||
var conn = new ActiveXObject('ADODB.Connection');
|
||||
conn.Provider = 'Microsoft.ACE.OLEDB.12.0';
|
||||
conn.ConnectionString =
|
||||
'Data Source="' + pathToExcelFile + '";' +
|
||||
'Extended Properties="Excel 12.0;HDR=Yes"';
|
||||
conn.Open();
|
||||
|
||||
//create a Command to access the data
|
||||
var cmd = new ActiveXObject('ADODB.Command');
|
||||
cmd.CommandText = 'SELECT DISTINCT LastName, CityName FROM [Sheet1$]';
|
||||
//get a Recordset
|
||||
var rs = cmd.Execute();
|
||||
//build a string from the Recordset
|
||||
var s = rs.GetString(ADODB.StringFormatEnum.adClipString, -1, '\t', '\n', '(NULL)');
|
||||
rs.Close();
|
||||
WScript.Echo(s);
|
||||
Vendored
-834
@@ -1,834 +0,0 @@
|
||||
// Type definitions for Microsoft ActiveX Data Objects
|
||||
// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms675532(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace ADODB {
|
||||
|
||||
//Enums
|
||||
const enum ADCPROP_ASYNCTHREADPRIORITY_ENUM {
|
||||
adPriorityAboveNormal = 4,
|
||||
adPriorityBelowNormal = 2,
|
||||
adPriorityHighest = 5,
|
||||
adPriorityLowest = 1,
|
||||
adPriorityNormal = 3
|
||||
}
|
||||
|
||||
const enum ADCPROP_AUTORECALC_ENUM {
|
||||
adRecalcAlways = 1,
|
||||
adRecalcUpFront = 0
|
||||
}
|
||||
|
||||
const enum ADCPROP_UPDATECRITERIA_ENUM {
|
||||
adCriteriaAllCols = 1,
|
||||
adCriteriaKey = 0,
|
||||
adCriteriaTimeStamp = 3,
|
||||
adCriteriaUpdCols = 2
|
||||
}
|
||||
|
||||
const enum ADCPROP_UPDATERESYNC_ENUM {
|
||||
adResyncAll = 15,
|
||||
adResyncAutoIncrement = 1,
|
||||
adResyncConflicts = 2,
|
||||
adResyncInserts = 8,
|
||||
adResyncNone = 0,
|
||||
adResyncUpdates = 4
|
||||
}
|
||||
|
||||
const enum AffectEnum {
|
||||
adAffectAll = 3,
|
||||
adAffectAllChapters = 4,
|
||||
adAffectCurrent = 1,
|
||||
adAffectGroup = 2
|
||||
}
|
||||
|
||||
const enum BookmarkEnum {
|
||||
adBookmarkCurrent = 0,
|
||||
adBookmarkFirst = 1,
|
||||
adBookmarkLast = 2
|
||||
}
|
||||
|
||||
const enum CommandTypeEnum {
|
||||
adCmdFile = 256,
|
||||
adCmdStoredProc = 4,
|
||||
adCmdTable = 2,
|
||||
adCmdTableDirect = 512,
|
||||
adCmdText = 1,
|
||||
adCmdUnknown = 8,
|
||||
adCmdUnspecified = -1
|
||||
}
|
||||
|
||||
const enum CompareEnum {
|
||||
adCompareEqual = 1,
|
||||
adCompareGreaterThan = 2,
|
||||
adCompareLessThan = 0,
|
||||
adCompareNotComparable = 4,
|
||||
adCompareNotEqual = 3
|
||||
}
|
||||
|
||||
const enum ConnectModeEnum {
|
||||
adModeRead = 1,
|
||||
adModeReadWrite = 3,
|
||||
adModeRecursive = 4194304,
|
||||
adModeShareDenyNone = 16,
|
||||
adModeShareDenyRead = 4,
|
||||
adModeShareDenyWrite = 8,
|
||||
adModeShareExclusive = 12,
|
||||
adModeUnknown = 0,
|
||||
adModeWrite = 2
|
||||
}
|
||||
|
||||
const enum ConnectOptionEnum {
|
||||
adAsyncConnect = 16,
|
||||
adConnectUnspecified = -1
|
||||
}
|
||||
|
||||
const enum ConnectPromptEnum {
|
||||
adPromptAlways = 1,
|
||||
adPromptComplete = 2,
|
||||
adPromptCompleteRequired = 3,
|
||||
adPromptNever = 4
|
||||
}
|
||||
|
||||
const enum CopyRecordOptionsEnum {
|
||||
adCopyAllowEmulation = 4,
|
||||
adCopyNonRecursive = 2,
|
||||
adCopyOverWrite = 1,
|
||||
adCopyUnspecified = -1
|
||||
}
|
||||
|
||||
const enum CursorLocationEnum {
|
||||
adUseClient = 3,
|
||||
adUseClientBatch = 3,
|
||||
adUseNone = 1,
|
||||
adUseServer = 2
|
||||
}
|
||||
|
||||
const enum CursorOptionEnum {
|
||||
adAddNew = 16778240,
|
||||
adApproxPosition = 16384,
|
||||
adBookmark = 8192,
|
||||
adDelete = 16779264,
|
||||
adFind = 524288,
|
||||
adHoldRecords = 256,
|
||||
adIndex = 8388608,
|
||||
adMovePrevious = 512,
|
||||
adNotify = 262144,
|
||||
adResync = 131072,
|
||||
adSeek = 4194304,
|
||||
adUpdate = 16809984,
|
||||
adUpdateBatch = 65536
|
||||
}
|
||||
|
||||
const enum CursorTypeEnum {
|
||||
adOpenDynamic = 2,
|
||||
adOpenForwardOnly = 0,
|
||||
adOpenKeyset = 1,
|
||||
adOpenStatic = 3,
|
||||
adOpenUnspecified = -1
|
||||
}
|
||||
|
||||
const enum DataTypeEnum {
|
||||
adArray = 8192,
|
||||
adBigInt = 20,
|
||||
adBinary = 128,
|
||||
adBoolean = 11,
|
||||
adBSTR = 8,
|
||||
adChapter = 136,
|
||||
adChar = 129,
|
||||
adCurrency = 6,
|
||||
adDate = 7,
|
||||
adDBDate = 133,
|
||||
adDBTime = 134,
|
||||
adDBTimeStamp = 135,
|
||||
adDecimal = 14,
|
||||
adDouble = 5,
|
||||
adEmpty = 0,
|
||||
adError = 10,
|
||||
adFileTime = 64,
|
||||
adGUID = 72,
|
||||
adIDispatch = 9,
|
||||
adInteger = 3,
|
||||
adIUnknown = 13,
|
||||
adLongVarBinary = 205,
|
||||
adLongVarChar = 201,
|
||||
adLongVarWChar = 203,
|
||||
adNumeric = 131,
|
||||
adPropVariant = 138,
|
||||
adSingle = 4,
|
||||
adSmallInt = 2,
|
||||
adTinyInt = 16,
|
||||
adUnsignedBigInt = 21,
|
||||
adUnsignedInt = 19,
|
||||
adUnsignedSmallInt = 18,
|
||||
adUnsignedTinyInt = 17,
|
||||
adUserDefined = 132,
|
||||
adVarBinary = 204,
|
||||
adVarChar = 200,
|
||||
adVariant = 12,
|
||||
adVarNumeric = 139,
|
||||
adVarWChar = 202,
|
||||
adWChar = 130
|
||||
}
|
||||
|
||||
const enum EditModeEnum {
|
||||
adEditAdd = 2,
|
||||
adEditDelete = 4,
|
||||
adEditInProgress = 1,
|
||||
adEditNone = 0
|
||||
}
|
||||
|
||||
const enum ErrorValueEnum {
|
||||
adErrBoundToCommand = 3707,
|
||||
adErrCannotComplete = 3732,
|
||||
adErrCantChangeConnection = 3748,
|
||||
adErrCantChangeProvider = 3220,
|
||||
adErrCantConvertvalue = 3724,
|
||||
adErrCantCreate = 3725,
|
||||
adErrCatalogNotSet = 3747,
|
||||
adErrColumnNotOnThisRow = 3726,
|
||||
adErrConnectionStringTooLong = 3754,
|
||||
adErrDataConversion = 3421,
|
||||
adErrDataOverflow = 3721,
|
||||
adErrDelResOutOfScope = 3738,
|
||||
adErrDenyNotSupported = 3750,
|
||||
adErrDenyTypeNotSupported = 3751,
|
||||
adErrFeatureNotAvailable = 3251,
|
||||
adErrFieldsUpdateFailed = 3749,
|
||||
adErrIllegalOperation = 3219,
|
||||
adErrIntegrityViolation = 3719,
|
||||
adErrInTransaction = 3246,
|
||||
adErrInvalidArgument = 3001,
|
||||
adErrInvalidConnection = 3709,
|
||||
adErrInvalidParamInfo = 3708,
|
||||
adErrInvalidTransaction = 3714,
|
||||
adErrInvalidURL = 3729,
|
||||
adErrItemNotFound = 3265,
|
||||
adErrNoCurrentRecord = 3021,
|
||||
adErrNotExecuting = 3715,
|
||||
adErrNotReentrant = 3710,
|
||||
adErrObjectClosed = 3704,
|
||||
adErrObjectInCollection = 3367,
|
||||
adErrObjectNotSet = 3420,
|
||||
adErrObjectOpen = 3705,
|
||||
adErrOpeningFile = 3002,
|
||||
adErrOperationCancelled = 3712,
|
||||
adErrOutOfSpace = 3734,
|
||||
adErrPermissionDenied = 3720,
|
||||
adErrPropConflicting = 3742,
|
||||
adErrPropInvalidColumn = 3739,
|
||||
adErrPropInvalidOption = 3740,
|
||||
adErrPropInvalidValue = 3741,
|
||||
adErrPropNotAllSettable = 3743,
|
||||
adErrPropNotSet = 3744,
|
||||
adErrPropNotSettable = 3745,
|
||||
adErrPropNotSupported = 3746,
|
||||
adErrProviderFailed = 3000,
|
||||
adErrProviderNotFound = 3706,
|
||||
adErrProviderNotSpecified = 3753,
|
||||
adErrReadFile = 3003,
|
||||
adErrResourceExists = 3731,
|
||||
adErrResourceLocked = 3730,
|
||||
adErrResourceOutOfScope = 3735,
|
||||
adErrSchemaViolation = 3722,
|
||||
adErrSignMismatch = 3723,
|
||||
adErrStillConnecting = 3713,
|
||||
adErrStillExecuting = 3711,
|
||||
adErrTreePermissionDenied = 3728,
|
||||
adErrUnavailable = 3736,
|
||||
adErrUnsafeOperation = 3716,
|
||||
adErrURLDoesNotExist = 3727,
|
||||
adErrURLNamedRowDoesNotExist = 3737,
|
||||
adErrVolumeNotFound = 3733,
|
||||
adErrWriteFile = 3004,
|
||||
adwrnSecurityDialog = 3717,
|
||||
adwrnSecurityDialogHeader = 3718
|
||||
}
|
||||
|
||||
const enum EventReasonEnum {
|
||||
adRsnAddNew = 1,
|
||||
adRsnClose = 9,
|
||||
adRsnDelete = 2,
|
||||
adRsnFirstChange = 11,
|
||||
adRsnMove = 10,
|
||||
adRsnMoveFirst = 12,
|
||||
adRsnMoveLast = 15,
|
||||
adRsnMoveNext = 13,
|
||||
adRsnMovePrevious = 14,
|
||||
adRsnRequery = 7,
|
||||
adRsnResynch = 8,
|
||||
adRsnUndoAddNew = 5,
|
||||
adRsnUndoDelete = 6,
|
||||
adRsnUndoUpdate = 4,
|
||||
adRsnUpdate = 3
|
||||
}
|
||||
|
||||
const enum EventStatusEnum {
|
||||
adStatusCancel = 4,
|
||||
adStatusCantDeny = 3,
|
||||
adStatusErrorsOccurred = 2,
|
||||
adStatusOK = 1,
|
||||
adStatusUnwantedEvent = 5
|
||||
}
|
||||
|
||||
const enum ExecuteOptionEnum {
|
||||
adAsyncExecute = 16,
|
||||
adAsyncFetch = 32,
|
||||
adAsyncFetchNonBlocking = 64,
|
||||
adExecuteNoRecords = 128,
|
||||
adExecuteRecord = 2048,
|
||||
adExecuteStream = 1024,
|
||||
adOptionUnspecified = -1
|
||||
}
|
||||
|
||||
const enum FieldAttributeEnum {
|
||||
adFldCacheDeferred = 4096,
|
||||
adFldFixed = 16,
|
||||
adFldIsChapter = 8192,
|
||||
adFldIsCollection = 262144,
|
||||
adFldIsDefaultStream = 131072,
|
||||
adFldIsNullable = 32,
|
||||
adFldIsRowURL = 65536,
|
||||
adFldKeyColumn = 32768,
|
||||
adFldLong = 128,
|
||||
adFldMayBeNull = 64,
|
||||
adFldMayDefer = 2,
|
||||
adFldNegativeScale = 16384,
|
||||
adFldRowID = 256,
|
||||
adFldRowVersion = 512,
|
||||
adFldUnknownUpdatable = 8,
|
||||
adFldUnspecified = -1,
|
||||
adFldUpdatable = 4
|
||||
}
|
||||
|
||||
const enum FieldEnum {
|
||||
adDefaultStream = -1,
|
||||
adRecordURL = -2
|
||||
}
|
||||
|
||||
const enum FieldStatusEnum {
|
||||
adFieldAlreadyExists = 26,
|
||||
adFieldBadStatus = 12,
|
||||
adFieldCannotComplete = 20,
|
||||
adFieldCannotDeleteSource = 23,
|
||||
adFieldCantConvertValue = 2,
|
||||
adFieldCantCreate = 7,
|
||||
adFieldDataOverflow = 6,
|
||||
adFieldDefault = 13,
|
||||
adFieldDoesNotExist = 16,
|
||||
adFieldIgnore = 15,
|
||||
adFieldIntegrityViolation = 10,
|
||||
adFieldInvalidURL = 17,
|
||||
adFieldIsNull = 3,
|
||||
adFieldOK = 0,
|
||||
adFieldOutOfSpace = 22,
|
||||
adFieldPendingChange = 262144,
|
||||
adFieldPendingDelete = 131072,
|
||||
adFieldPendingInsert = 65536,
|
||||
adFieldPendingUnknown = 524288,
|
||||
adFieldPendingUnknownDelete = 1048576,
|
||||
adFieldPermissionDenied = 9,
|
||||
adFieldReadOnly = 24,
|
||||
adFieldResourceExists = 19,
|
||||
adFieldResourceLocked = 18,
|
||||
adFieldResourceOutOfScope = 25,
|
||||
adFieldSchemaViolation = 11,
|
||||
adFieldSignMismatch = 5,
|
||||
adFieldTruncated = 4,
|
||||
adFieldUnavailable = 8,
|
||||
adFieldVolumeNotFound = 21
|
||||
}
|
||||
|
||||
const enum FilterGroupEnum {
|
||||
adFilterAffectedRecords = 2,
|
||||
adFilterConflictingRecords = 5,
|
||||
adFilterFetchedRecords = 3,
|
||||
adFilterNone = 0,
|
||||
adFilterPendingRecords = 1,
|
||||
adFilterPredicate = 4
|
||||
}
|
||||
|
||||
const enum GetRowsOptionEnum {
|
||||
adGetRowsRest = -1
|
||||
}
|
||||
|
||||
const enum IsolationLevelEnum {
|
||||
adXactBrowse = 256,
|
||||
adXactChaos = 16,
|
||||
adXactCursorStability = 4096,
|
||||
adXactIsolated = 1048576,
|
||||
adXactReadCommitted = 4096,
|
||||
adXactReadUncommitted = 256,
|
||||
adXactRepeatableRead = 65536,
|
||||
adXactSerializable = 1048576,
|
||||
adXactUnspecified = -1
|
||||
}
|
||||
|
||||
const enum LineSeparatorEnum {
|
||||
adCR = 13,
|
||||
adCRLF = -1,
|
||||
adLF = 10
|
||||
}
|
||||
|
||||
const enum LockTypeEnum {
|
||||
adLockBatchOptimistic = 4,
|
||||
adLockOptimistic = 3,
|
||||
adLockPessimistic = 2,
|
||||
adLockReadOnly = 1,
|
||||
adLockUnspecified = -1
|
||||
}
|
||||
|
||||
const enum MarshalOptionsEnum {
|
||||
adMarshalAll = 0,
|
||||
adMarshalModifiedOnly = 1
|
||||
}
|
||||
|
||||
const enum MoveRecordOptionsEnum {
|
||||
adMoveAllowEmulation = 4,
|
||||
adMoveDontUpdateLinks = 2,
|
||||
adMoveOverWrite = 1,
|
||||
adMoveUnspecified = -1
|
||||
}
|
||||
|
||||
const enum ObjectStateEnum {
|
||||
adStateClosed = 0,
|
||||
adStateConnecting = 2,
|
||||
adStateExecuting = 4,
|
||||
adStateFetching = 8,
|
||||
adStateOpen = 1
|
||||
}
|
||||
|
||||
const enum ParameterAttributesEnum {
|
||||
adParamLong = 128,
|
||||
adParamNullable = 64,
|
||||
adParamSigned = 16
|
||||
}
|
||||
|
||||
const enum ParameterDirectionEnum {
|
||||
adParamInput = 1,
|
||||
adParamInputOutput = 3,
|
||||
adParamOutput = 2,
|
||||
adParamReturnValue = 4,
|
||||
adParamUnknown = 0
|
||||
}
|
||||
|
||||
const enum PersistFormatEnum {
|
||||
adPersistADTG = 0,
|
||||
adPersistXML = 1
|
||||
}
|
||||
|
||||
const enum PositionEnum {
|
||||
adPosBOF = -2,
|
||||
adPosEOF = -3,
|
||||
adPosUnknown = -1
|
||||
}
|
||||
|
||||
const enum PositionEnum_Param {
|
||||
adPosBOF = -2,
|
||||
adPosEOF = -3,
|
||||
adPosUnknown = -1
|
||||
}
|
||||
|
||||
const enum PropertyAttributesEnum {
|
||||
adPropNotSupported = 0,
|
||||
adPropOptional = 2,
|
||||
adPropRead = 512,
|
||||
adPropRequired = 1,
|
||||
adPropWrite = 1024
|
||||
}
|
||||
|
||||
const enum RecordCreateOptionsEnum {
|
||||
adCreateCollection = 8192,
|
||||
adCreateNonCollection = 0,
|
||||
adCreateOverwrite = 67108864,
|
||||
adCreateStructDoc = -2147483648,
|
||||
adFailIfNotExists = -1,
|
||||
adOpenIfExists = 33554432
|
||||
}
|
||||
|
||||
const enum RecordOpenOptionsEnum {
|
||||
adDelayFetchFields = 32768,
|
||||
adDelayFetchStream = 16384,
|
||||
adOpenAsync = 4096,
|
||||
adOpenExecuteCommand = 65536,
|
||||
adOpenOutput = 8388608,
|
||||
adOpenRecordUnspecified = -1,
|
||||
adOpenSource = 8388608
|
||||
}
|
||||
|
||||
const enum RecordStatusEnum {
|
||||
adRecCanceled = 256,
|
||||
adRecCantRelease = 1024,
|
||||
adRecConcurrencyViolation = 2048,
|
||||
adRecDBDeleted = 262144,
|
||||
adRecDeleted = 4,
|
||||
adRecIntegrityViolation = 4096,
|
||||
adRecInvalid = 16,
|
||||
adRecMaxChangesExceeded = 8192,
|
||||
adRecModified = 2,
|
||||
adRecMultipleChanges = 64,
|
||||
adRecNew = 1,
|
||||
adRecObjectOpen = 16384,
|
||||
adRecOK = 0,
|
||||
adRecOutOfMemory = 32768,
|
||||
adRecPendingChanges = 128,
|
||||
adRecPermissionDenied = 65536,
|
||||
adRecSchemaViolation = 131072,
|
||||
adRecUnmodified = 8
|
||||
}
|
||||
|
||||
const enum RecordTypeEnum {
|
||||
adCollectionRecord = 1,
|
||||
adSimpleRecord = 0,
|
||||
adStructDoc = 2
|
||||
}
|
||||
|
||||
const enum ResyncEnum {
|
||||
adResyncAllValues = 2,
|
||||
adResyncUnderlyingValues = 1
|
||||
}
|
||||
|
||||
const enum SaveOptionsEnum {
|
||||
adSaveCreateNotExist = 1,
|
||||
adSaveCreateOverWrite = 2
|
||||
}
|
||||
|
||||
const enum SchemaEnum {
|
||||
adSchemaActions = 41,
|
||||
adSchemaAsserts = 0,
|
||||
adSchemaCatalogs = 1,
|
||||
adSchemaCharacterSets = 2,
|
||||
adSchemaCheckConstraints = 5,
|
||||
adSchemaCollations = 3,
|
||||
adSchemaColumnPrivileges = 13,
|
||||
adSchemaColumns = 4,
|
||||
adSchemaColumnsDomainUsage = 11,
|
||||
adSchemaCommands = 42,
|
||||
adSchemaConstraintColumnUsage = 6,
|
||||
adSchemaConstraintTableUsage = 7,
|
||||
adSchemaCubes = 32,
|
||||
adSchemaDBInfoKeywords = 30,
|
||||
adSchemaDBInfoLiterals = 31,
|
||||
adSchemaDimensions = 33,
|
||||
adSchemaForeignKeys = 27,
|
||||
adSchemaFunctions = 40,
|
||||
adSchemaHierarchies = 34,
|
||||
adSchemaIndexes = 12,
|
||||
adSchemaKeyColumnUsage = 8,
|
||||
adSchemaLevels = 35,
|
||||
adSchemaMeasures = 36,
|
||||
adSchemaMembers = 38,
|
||||
adSchemaPrimaryKeys = 28,
|
||||
adSchemaProcedureColumns = 29,
|
||||
adSchemaProcedureParameters = 26,
|
||||
adSchemaProcedures = 16,
|
||||
adSchemaProperties = 37,
|
||||
adSchemaProviderSpecific = -1,
|
||||
adSchemaProviderTypes = 22,
|
||||
adSchemaReferentialConstraints = 9,
|
||||
adSchemaReferentialContraints = 9,
|
||||
adSchemaSchemata = 17,
|
||||
adSchemaSets = 43,
|
||||
adSchemaSQLLanguages = 18,
|
||||
adSchemaStatistics = 19,
|
||||
adSchemaTableConstraints = 10,
|
||||
adSchemaTablePrivileges = 14,
|
||||
adSchemaTables = 20,
|
||||
adSchemaTranslations = 21,
|
||||
adSchemaTrustees = 39,
|
||||
adSchemaUsagePrivileges = 15,
|
||||
adSchemaViewColumnUsage = 24,
|
||||
adSchemaViews = 23,
|
||||
adSchemaViewTableUsage = 25
|
||||
}
|
||||
|
||||
const enum SearchDirection {
|
||||
adSearchBackward = -1,
|
||||
adSearchForward = 1
|
||||
}
|
||||
|
||||
const enum SearchDirectionEnum {
|
||||
adSearchBackward = -1,
|
||||
adSearchForward = 1
|
||||
}
|
||||
|
||||
const enum SeekEnum {
|
||||
adSeekAfter = 8,
|
||||
adSeekAfterEQ = 4,
|
||||
adSeekBefore = 32,
|
||||
adSeekBeforeEQ = 16,
|
||||
adSeekFirstEQ = 1,
|
||||
adSeekLastEQ = 2
|
||||
}
|
||||
|
||||
const enum StreamOpenOptionsEnum {
|
||||
adOpenStreamAsync = 1,
|
||||
adOpenStreamFromRecord = 4,
|
||||
adOpenStreamUnspecified = -1
|
||||
}
|
||||
|
||||
const enum StreamReadEnum {
|
||||
adReadAll = -1,
|
||||
adReadLine = -2
|
||||
}
|
||||
|
||||
const enum StreamTypeEnum {
|
||||
adTypeBinary = 1,
|
||||
adTypeText = 2
|
||||
}
|
||||
|
||||
const enum StreamWriteEnum {
|
||||
adWriteChar = 0,
|
||||
adWriteLine = 1,
|
||||
stWriteChar = 0,
|
||||
stWriteLine = 1
|
||||
}
|
||||
|
||||
const enum StringFormatEnum {
|
||||
adClipString = 2
|
||||
}
|
||||
|
||||
const enum XactAttributeEnum {
|
||||
adXactAbortRetaining = 262144,
|
||||
adXactAsyncPhaseOne = 524288,
|
||||
adXactCommitRetaining = 131072,
|
||||
adXactSyncPhaseOne = 1048576
|
||||
}
|
||||
|
||||
//Interfaces
|
||||
interface Command {
|
||||
ActiveConnection: Connection;
|
||||
Cancel: () => void;
|
||||
CommandStream: any /*VT_UNKNOWN*/;
|
||||
CommandText: string;
|
||||
CommandTimeout: number;
|
||||
CommandType: CommandTypeEnum;
|
||||
CreateParameter: (Name?: string, Type?: DataTypeEnum, Direction?: ParameterDirectionEnum, Size?: number, Value?: any) => Parameter;
|
||||
Dialect: string;
|
||||
Execute: (RecordsAffected?: any, Parameters?: any, Options?: number) => Recordset;
|
||||
Name: string;
|
||||
NamedParameters: boolean;
|
||||
Parameters: Parameters;
|
||||
Prepared: boolean;
|
||||
Properties: Properties;
|
||||
State: number;
|
||||
}
|
||||
|
||||
interface Connection {
|
||||
Attributes: number;
|
||||
BeginTrans: () => number;
|
||||
Cancel: () => void;
|
||||
Close: () => void;
|
||||
CommandTimeout: number;
|
||||
CommitTrans: () => void;
|
||||
ConnectionString: string;
|
||||
ConnectionTimeout: number;
|
||||
CursorLocation: CursorLocationEnum;
|
||||
DefaultDatabase: string;
|
||||
Errors: Errors;
|
||||
Execute: (CommandText: string, RecordsAffected: any, Options?: number) => Recordset;
|
||||
IsolationLevel: IsolationLevelEnum;
|
||||
Mode: ConnectModeEnum;
|
||||
Open: (ConnectionString?: string, UserID?: string, Password?: string, Options?: number) => void;
|
||||
OpenSchema: (Schema: SchemaEnum, Restrictions?: any, SchemaID?: any) => Recordset;
|
||||
Properties: Properties;
|
||||
Provider: string;
|
||||
RollbackTrans: () => void;
|
||||
State: number;
|
||||
Version: string;
|
||||
}
|
||||
|
||||
interface Error {
|
||||
Description: string;
|
||||
HelpContext: number;
|
||||
HelpFile: string;
|
||||
NativeError: number;
|
||||
Number: number;
|
||||
Source: string;
|
||||
SQLState: string;
|
||||
}
|
||||
|
||||
interface Errors {
|
||||
Clear: () => void;
|
||||
Count: number;
|
||||
Item: (Index: any) => Error;
|
||||
Refresh: () => void;
|
||||
}
|
||||
|
||||
interface Field {
|
||||
ActualSize: number;
|
||||
AppendChunk: (Data: any) => void;
|
||||
Attributes: number;
|
||||
DataFormat: any /*VT_UNKNOWN*/;
|
||||
DefinedSize: number;
|
||||
GetChunk: (Length: number) => any;
|
||||
Name: string;
|
||||
NumericScale: number;
|
||||
OriginalValue: any;
|
||||
Precision: number;
|
||||
Properties: Properties;
|
||||
Status: number;
|
||||
Type: DataTypeEnum;
|
||||
UnderlyingValue: any;
|
||||
Value: any;
|
||||
}
|
||||
|
||||
interface Fields {
|
||||
_Append: (Name: string, Type: DataTypeEnum, DefinedSize?: number, Attrib?: FieldAttributeEnum) => void;
|
||||
Append: (Name: string, Type: DataTypeEnum, DefinedSize?: number, Attrib?: FieldAttributeEnum, FieldValue?: any) => void;
|
||||
CancelUpdate: () => void;
|
||||
Count: number;
|
||||
Delete: (Index: any) => void;
|
||||
Item: (Index: any) => Field;
|
||||
Refresh: () => void;
|
||||
Resync: (ResyncValues?: ResyncEnum) => void;
|
||||
Update: () => void;
|
||||
}
|
||||
|
||||
interface Parameter {
|
||||
AppendChunk: (Val: any) => void;
|
||||
Attributes: number;
|
||||
Direction: ParameterDirectionEnum;
|
||||
Name: string;
|
||||
NumericScale: number;
|
||||
Precision: number;
|
||||
Properties: Properties;
|
||||
Size: number;
|
||||
Type: DataTypeEnum;
|
||||
Value: any;
|
||||
}
|
||||
|
||||
interface Parameters {
|
||||
Append: (Object: any /*VT_DISPATCH*/) => void;
|
||||
Count: number;
|
||||
Delete: (Index: any) => void;
|
||||
Item: (Index: any) => Parameter;
|
||||
Refresh: () => void;
|
||||
}
|
||||
|
||||
interface Properties {
|
||||
Count: number;
|
||||
Item: (Index: any) => Property;
|
||||
Refresh: () => void;
|
||||
}
|
||||
|
||||
interface Property {
|
||||
Attributes: number;
|
||||
Name: string;
|
||||
Type: DataTypeEnum;
|
||||
Value: any;
|
||||
}
|
||||
|
||||
interface Record {
|
||||
ActiveConnection: any;
|
||||
Cancel: () => void;
|
||||
Close: () => void;
|
||||
CopyRecord: (Source?: string, Destination?: string, UserName?: string, Password?: string, Options?: CopyRecordOptionsEnum, Async?: boolean) => string;
|
||||
DeleteRecord: (Source?: string, Async?: boolean) => void;
|
||||
Fields: Fields;
|
||||
GetChildren: () => Recordset;
|
||||
Mode: ConnectModeEnum;
|
||||
MoveRecord: (Source?: string, Destination?: string, UserName?: string, Password?: string, Options?: MoveRecordOptionsEnum, Async?: boolean) => string;
|
||||
Open: (Source: any, ActiveConnection: any, Mode?: ConnectModeEnum, CreateOptions?: RecordCreateOptionsEnum, Options?: RecordOpenOptionsEnum, UserName?: string, Password?: string) => void;
|
||||
ParentURL: string;
|
||||
Properties: Properties;
|
||||
RecordType: RecordTypeEnum;
|
||||
Source: any;
|
||||
State: ObjectStateEnum;
|
||||
}
|
||||
|
||||
interface Recordset {
|
||||
_xClone: () => Recordset;
|
||||
_xResync: (AffectRecords?: AffectEnum) => void;
|
||||
_xSave: (FileName?: string, PersistFormat?: PersistFormatEnum) => void;
|
||||
AbsolutePage: PositionEnum;
|
||||
AbsolutePosition: PositionEnum;
|
||||
ActiveCommand: any /*VT_DISPATCH*/;
|
||||
ActiveConnection: any /*VT_DISPATCH*/;
|
||||
AddNew: (FieldList?: any, Values?: any) => void;
|
||||
BOF: boolean;
|
||||
Bookmark: any;
|
||||
CacheSize: number;
|
||||
Cancel: () => void;
|
||||
CancelBatch: (AffectRecords?: AffectEnum) => void;
|
||||
CancelUpdate: () => void;
|
||||
Clone: (LockType?: LockTypeEnum) => Recordset;
|
||||
Close: () => void;
|
||||
Collect: (Index: any) => any; //Also has setter with parameters
|
||||
CompareBookmarks: (Bookmark1: any, Bookmark2: any) => CompareEnum;
|
||||
CursorLocation: CursorLocationEnum;
|
||||
CursorType: CursorTypeEnum;
|
||||
DataMember: string;
|
||||
DataSource: any /*VT_UNKNOWN*/;
|
||||
Delete: (AffectRecords?: AffectEnum) => void;
|
||||
EditMode: EditModeEnum;
|
||||
EOF: boolean;
|
||||
Fields: Fields;
|
||||
Filter: any;
|
||||
Find: (Criteria: string, SkipRecords?: number, SearchDirection?: SearchDirectionEnum, Start?: any) => void;
|
||||
GetRows: (Rows?: number, Start?: any, Fields?: any) => any;
|
||||
GetString: (StringFormat?: StringFormatEnum, NumRows?: number, ColumnDelimeter?: string, RowDelimeter?: string, NullExpr?: string) => string;
|
||||
Index: string;
|
||||
LockType: LockTypeEnum;
|
||||
MarshalOptions: MarshalOptionsEnum;
|
||||
MaxRecords: number;
|
||||
Move: (NumRecords: number, Start?: any) => void;
|
||||
MoveFirst: () => void;
|
||||
MoveLast: () => void;
|
||||
MoveNext: () => void;
|
||||
MovePrevious: () => void;
|
||||
NextRecordset: (RecordsAffected?: any) => Recordset;
|
||||
Open: (Source: any, ActiveConnection: any, CursorType?: CursorTypeEnum, LockType?: LockTypeEnum, Options?: number) => void;
|
||||
PageCount: number;
|
||||
PageSize: number;
|
||||
Properties: Properties;
|
||||
RecordCount: number;
|
||||
Requery: (Options?: number) => void;
|
||||
Resync: (AffectRecords?: AffectEnum, ResyncValues?: ResyncEnum) => void;
|
||||
Save: (Destination: any, PersistFormat?: PersistFormatEnum) => void;
|
||||
Seek: (KeyValues: any, SeekOption?: SeekEnum) => void;
|
||||
Sort: string;
|
||||
Source: any /*VT_DISPATCH*/;
|
||||
State: number;
|
||||
Status: number;
|
||||
StayInSync: boolean;
|
||||
Supports: (CursorOptions: CursorOptionEnum) => boolean;
|
||||
Update: (Fields?: any, Values?: any) => void;
|
||||
UpdateBatch: (AffectRecords?: AffectEnum) => void;
|
||||
}
|
||||
|
||||
interface Stream {
|
||||
Cancel: () => void;
|
||||
Charset: string;
|
||||
Close: () => void;
|
||||
CopyTo: (DestStream: Stream, CharNumber?: number) => void;
|
||||
EOS: boolean;
|
||||
Flush: () => void;
|
||||
LineSeparator: LineSeparatorEnum;
|
||||
LoadFromFile: (FileName: string) => void;
|
||||
Mode: ConnectModeEnum;
|
||||
Open: (Source: any, Mode?: ConnectModeEnum, Options?: StreamOpenOptionsEnum, UserName?: string, Password?: string) => void;
|
||||
Position: number;
|
||||
Read: (NumBytes?: number) => any;
|
||||
ReadText: (NumChars?: number) => string;
|
||||
SaveToFile: (FileName: string, Options?: SaveOptionsEnum) => void;
|
||||
SetEOS: () => void;
|
||||
Size: number;
|
||||
SkipLine: () => void;
|
||||
State: ObjectStateEnum;
|
||||
Type: StreamTypeEnum;
|
||||
Write: (Buffer: any) => void;
|
||||
WriteText: (Data: string, Options?: StreamWriteEnum) => void;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
new (progID: 'ADODB.Connection'): ADODB.Connection;
|
||||
new (progID: 'ADODB.Record'): ADODB.Record;
|
||||
new (progID: 'ADODB.Stream'): ADODB.Stream;
|
||||
new (progID: 'ADODB.Command'): ADODB.Command;
|
||||
new (progID: 'ADODB.Recordset'): ADODB.Recordset;
|
||||
new (progID: 'ADODB.Parameter'): ADODB.Parameter;
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"activex-data-objects-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
//source -- https://msdn.microsoft.com/en-us/library/ebkhfaaz.aspx
|
||||
|
||||
|
||||
//Generates a string describing the drive type of a given Drive object.
|
||||
var showDriveType = (drive: Scripting.Drive) => {
|
||||
switch (drive.DriveType) {
|
||||
case Scripting.DriveTypeConst.Removable:
|
||||
return 'Removeable';
|
||||
case Scripting.DriveTypeConst.Fixed:
|
||||
return 'Fixecd';
|
||||
case Scripting.DriveTypeConst.Remote:
|
||||
return 'Network';
|
||||
case Scripting.DriveTypeConst.CDRom:
|
||||
return 'CD-ROM';
|
||||
case Scripting.DriveTypeConst.RamDisk:
|
||||
return 'RAM Disk';
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//Generates a string describing the attributes of a file or folder.
|
||||
var showFileAttributes = (file: Scripting.File) => {
|
||||
var attr = file.Attributes;
|
||||
if (attr === 0) {
|
||||
return 'Normal';
|
||||
}
|
||||
var attributeStrings: string[] = [];
|
||||
if (attr & Scripting.FileAttribute.Directory) { attributeStrings.push('Directory'); }
|
||||
if (attr & Scripting.FileAttribute.ReadOnly) { attributeStrings.push('Read-only'); }
|
||||
if (attr & Scripting.FileAttribute.Hidden) { attributeStrings.push('Hidden'); }
|
||||
if (attr & Scripting.FileAttribute.System) { attributeStrings.push('System'); }
|
||||
if (attr & Scripting.FileAttribute.Volume) { attributeStrings.push('Volume'); }
|
||||
if (attr & Scripting.FileAttribute.Archive) { attributeStrings.push('Archive'); }
|
||||
if (attr & Scripting.FileAttribute.Alias) { attributeStrings.push('Alias'); }
|
||||
if (attr & Scripting.FileAttribute.Compressed) { attributeStrings.push('Compressed'); }
|
||||
return attributeStrings.join(',');
|
||||
};
|
||||
|
||||
|
||||
//source --https://msdn.microsoft.com/en-us/library/ts2t8ybh(v=vs.84).aspx
|
||||
var showFreeSpace = (drvPath: string) => {
|
||||
var fso = new ActiveXObject('Scripting.FileSystemObject');
|
||||
var d = fso.GetDrive(fso.GetDriveName(drvPath));
|
||||
var s = 'Drive ' + drvPath + ' - ';
|
||||
s += d.VolumeName + '<br>';
|
||||
s += 'Free Space: ' + d.FreeSpace / 1024 + ' Kbytes';
|
||||
return (s);
|
||||
};
|
||||
|
||||
|
||||
//source -- https://msdn.microsoft.com/en-us/library/kaf6yaft(v=vs.84).aspx
|
||||
var getALine = (filespec: string) => {
|
||||
var fso = new ActiveXObject('Scripting.FileSystemObject');
|
||||
var file = fso.OpenTextFile(filespec, Scripting.IOMode.ForReading, false);
|
||||
|
||||
var s = '';
|
||||
while (!file.AtEndOfLine) {
|
||||
s += file.Read(1);
|
||||
}
|
||||
file.Close();
|
||||
return (s);
|
||||
};
|
||||
Vendored
-205
@@ -1,205 +0,0 @@
|
||||
// Type definitions for Microsoft Scripting Runtime
|
||||
// Project: https://msdn.microsoft.com/en-us/library/bstcxhf7.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace Scripting {
|
||||
|
||||
//Enums
|
||||
const enum CompareMethod {
|
||||
BinaryCompare = 0,
|
||||
DatabaseCompare = 2,
|
||||
TextCompare = 1
|
||||
}
|
||||
|
||||
const enum DriveTypeConst {
|
||||
CDRom = 4,
|
||||
Fixed = 2,
|
||||
RamDisk = 5,
|
||||
Remote = 3,
|
||||
Removable = 1,
|
||||
UnknownType = 0
|
||||
}
|
||||
|
||||
const enum FileAttribute {
|
||||
Alias = 1024,
|
||||
Archive = 32,
|
||||
Compressed = 2048,
|
||||
Directory = 16,
|
||||
Hidden = 2,
|
||||
Normal = 0,
|
||||
ReadOnly = 1,
|
||||
System = 4,
|
||||
Volume = 8
|
||||
}
|
||||
|
||||
const enum IOMode {
|
||||
ForAppending = 8,
|
||||
ForReading = 1,
|
||||
ForWriting = 2
|
||||
}
|
||||
|
||||
const enum SpecialFolderConst {
|
||||
SystemFolder = 1,
|
||||
TemporaryFolder = 2,
|
||||
WindowsFolder = 0
|
||||
}
|
||||
|
||||
const enum StandardStreamTypes {
|
||||
StdErr = 2,
|
||||
StdIn = 0,
|
||||
StdOut = 1
|
||||
}
|
||||
|
||||
const enum Tristate {
|
||||
TristateFalse = 0,
|
||||
TristateMixed = -2,
|
||||
TristateTrue = -1,
|
||||
TristateUseDefault = -2
|
||||
}
|
||||
|
||||
//Interfaces
|
||||
interface Dictionary {
|
||||
Add: (Key: any, Item: any) => void;
|
||||
CompareMode: CompareMethod;
|
||||
Count: number;
|
||||
Exists: (Key: any) => boolean;
|
||||
HashVal: (Key: any) => any;
|
||||
Item: (Key: any) => any; //Also has setter with parameters
|
||||
Items: () => any;
|
||||
Key: (Key: any) => any;
|
||||
Keys: () => any;
|
||||
Remove: (Key: any) => void;
|
||||
RemoveAll: () => void;
|
||||
}
|
||||
|
||||
interface Drive {
|
||||
AvailableSpace: any;
|
||||
DriveLetter: string;
|
||||
DriveType: DriveTypeConst;
|
||||
FileSystem: string;
|
||||
FreeSpace: any;
|
||||
IsReady: boolean;
|
||||
Path: string;
|
||||
RootFolder: Folder;
|
||||
SerialNumber: number;
|
||||
ShareName: string;
|
||||
TotalSize: any;
|
||||
VolumeName: string;
|
||||
}
|
||||
|
||||
interface Drives {
|
||||
Count: number;
|
||||
Item: (Key: any) => Drive;
|
||||
}
|
||||
|
||||
interface Encoder {
|
||||
EncodeScriptFile: (szExt: string, bstrStreamIn: string, cFlags: number, bstrDefaultLang: string) => string;
|
||||
}
|
||||
|
||||
interface File {
|
||||
Attributes: FileAttribute;
|
||||
Copy: (Destination: string, OverWriteFiles?: boolean) => void;
|
||||
DateCreated: VarDate;
|
||||
DateLastAccessed: VarDate;
|
||||
DateLastModified: VarDate;
|
||||
Delete: (Force?: boolean) => void;
|
||||
Drive: Drive;
|
||||
Move: (Destination: string) => void;
|
||||
Name: string;
|
||||
OpenAsTextStream: (IOMode?: IOMode, Format?: Tristate) => TextStream;
|
||||
ParentFolder: Folder;
|
||||
Path: string;
|
||||
ShortName: string;
|
||||
ShortPath: string;
|
||||
Size: any;
|
||||
Type: string;
|
||||
}
|
||||
|
||||
interface Files {
|
||||
Count: number;
|
||||
Item: (Key: any) => File;
|
||||
}
|
||||
|
||||
interface FileSystemObject {
|
||||
BuildPath: (Path: string, Name: string) => string;
|
||||
CopyFile: (Source: string, Destination: string, OverWriteFiles?: boolean) => void;
|
||||
CopyFolder: (Source: string, Destination: string, OverWriteFiles?: boolean) => void;
|
||||
CreateFolder: (Path: string) => Folder;
|
||||
CreateTextFile: (FileName: string, Overwrite?: boolean, Unicode?: boolean) => TextStream;
|
||||
DeleteFile: (FileSpec: string, Force?: boolean) => void;
|
||||
DeleteFolder: (FolderSpec: string, Force?: boolean) => void;
|
||||
DriveExists: (DriveSpec: string) => boolean;
|
||||
Drives: Drives;
|
||||
FileExists: (FileSpec: string) => boolean;
|
||||
FolderExists: (FolderSpec: string) => boolean;
|
||||
GetAbsolutePathName: (Path: string) => string;
|
||||
GetBaseName: (Path: string) => string;
|
||||
GetDrive: (DriveSpec: string) => Drive;
|
||||
GetDriveName: (Path: string) => string;
|
||||
GetExtensionName: (Path: string) => string;
|
||||
GetFile: (FilePath: string) => File;
|
||||
GetFileName: (Path: string) => string;
|
||||
GetFileVersion: (FileName: string) => string;
|
||||
GetFolder: (FolderPath: string) => Folder;
|
||||
GetParentFolderName: (Path: string) => string;
|
||||
GetSpecialFolder: (SpecialFolder: SpecialFolderConst) => Folder;
|
||||
GetStandardStream: (StandardStreamType: StandardStreamTypes, Unicode?: boolean) => TextStream;
|
||||
GetTempName: () => string;
|
||||
MoveFile: (Source: string, Destination: string) => void;
|
||||
MoveFolder: (Source: string, Destination: string) => void;
|
||||
OpenTextFile: (FileName: string, IOMode?: IOMode, Create?: boolean, Format?: Tristate) => TextStream;
|
||||
}
|
||||
|
||||
interface Folder {
|
||||
Attributes: FileAttribute;
|
||||
Copy: (Destination: string, OverWriteFiles?: boolean) => void;
|
||||
CreateTextFile: (FileName: string, Overwrite?: boolean, Unicode?: boolean) => TextStream;
|
||||
DateCreated: VarDate;
|
||||
DateLastAccessed: VarDate;
|
||||
DateLastModified: VarDate;
|
||||
Delete: (Force?: boolean) => void;
|
||||
Drive: Drive;
|
||||
Files: Files;
|
||||
IsRootFolder: boolean;
|
||||
Move: (Destination: string) => void;
|
||||
Name: string;
|
||||
ParentFolder: Folder;
|
||||
Path: string;
|
||||
ShortName: string;
|
||||
ShortPath: string;
|
||||
Size: any;
|
||||
SubFolders: Folders;
|
||||
Type: string;
|
||||
}
|
||||
|
||||
interface Folders {
|
||||
Add: (Name: string) => Folder;
|
||||
Count: number;
|
||||
Item: (Key: any) => Folder;
|
||||
}
|
||||
|
||||
interface TextStream {
|
||||
AtEndOfLine: boolean;
|
||||
AtEndOfStream: boolean;
|
||||
Close: () => void;
|
||||
Column: number;
|
||||
Line: number;
|
||||
Read: (Characters: number) => string;
|
||||
ReadAll: () => string;
|
||||
ReadLine: () => string;
|
||||
Skip: (Characters: number) => void;
|
||||
SkipLine: () => void;
|
||||
Write: (Text: string) => void;
|
||||
WriteBlankLines: (Lines: number) => void;
|
||||
WriteLine: (Text?: string) => void;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
new (progID: 'Scripting.Dictionary'): Scripting.Dictionary;
|
||||
new (progID: 'Scripting.FileSystemObject'): Scripting.FileSystemObject;
|
||||
new (progID: 'Scripting.Encoder'): Scripting.Encoder;
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"activex-scripting-runtime-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
//source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx
|
||||
|
||||
|
||||
//Convert a file
|
||||
var commonDialog = new ActiveXObject('WIA.CommonDialog');
|
||||
var img = commonDialog.ShowAcquireImage();
|
||||
if (img.FormatID !== WIA.FormatID.wiaFormatJPEG) {
|
||||
var ip = new ActiveXObject('WIA.ImageProcess');
|
||||
ip.Filters.Add(ip.FilterInfos.Item('Convert').FilterID);
|
||||
ip.Filters.Item(1).Properties.Item('FormatID').Value = WIA.FormatID.wiaFormatJPEG;
|
||||
img = ip.Apply(img);
|
||||
}
|
||||
|
||||
|
||||
//Take a picture
|
||||
var dev = commonDialog.ShowSelectDevice();
|
||||
if (dev.Type === WIA.WiaDeviceType.CameraDeviceType) {
|
||||
var itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture);
|
||||
}
|
||||
|
||||
|
||||
//Display detailed property information
|
||||
dev = commonDialog.ShowSelectDevice();
|
||||
var e = new Enumerator<WIA.Property>(dev.Properties); //no foreach over ActiveX collections
|
||||
e.moveFirst();
|
||||
while (!e.atEnd()) {
|
||||
var p = e.item();
|
||||
var s = p.Name + ' (' + p.PropertyID + ') = ';
|
||||
if (p.IsVector) {
|
||||
s += '[vector of data]';
|
||||
} else {
|
||||
s += p.Value;
|
||||
if (p.SubType !== WIA.WiaSubType.UnspecifiedSubType) {
|
||||
if (p.Value !== p.SubTypeDefault) {
|
||||
s += ' (Default = ' + p.SubTypeDefault + ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p.IsReadOnly) {
|
||||
s += ' [READ ONLY]';
|
||||
} else {
|
||||
switch (p.SubType) {
|
||||
case WIA.WiaSubType.FlagSubType:
|
||||
case WIA.WiaSubType.ListSubType:
|
||||
if (p.SubType === WIA.WiaSubType.FlagSubType) {
|
||||
s += ' [valid flags include: ';
|
||||
} else {
|
||||
s += ' [valid values include: ';
|
||||
}
|
||||
var count = p.SubTypeValues.Count;
|
||||
for (var i = 1; i <= count; i++) {
|
||||
s += p.SubTypeValues.Item(i);
|
||||
if (i < count) {
|
||||
s += ', ';
|
||||
}
|
||||
}
|
||||
s += ']';
|
||||
break;
|
||||
case WIA.WiaSubType.RangeSubType:
|
||||
s += ' [valid values in the range from ' + p.SubTypeMin + ' to ' + p.SubTypeMax + ' in increments of ' + p.SubTypeStep + ']';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (WScript) {
|
||||
WScript.Echo(s);
|
||||
} else if (window) {
|
||||
window.alert(s);
|
||||
}
|
||||
}
|
||||
-379
@@ -1,379 +0,0 @@
|
||||
// Type definitions for Microsoft Windows Image Acquisition Library v2.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms630827(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace WIA {
|
||||
|
||||
//Enums
|
||||
type CommandID =
|
||||
"'{04E725B0-ACAE-11D2-A093-00C04F72DC3C}'" //wiaCommandChangeDocument
|
||||
| "'{E208C170-ACAD-11D2-A093-00C04F72DC3C}'" //wiaCommandDeleteAllItems
|
||||
| "'{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}'" //wiaCommandSynchronize
|
||||
| "'{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}'" //wiaCommandTakePicture
|
||||
| "'{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}'"; //wiaCommandUnloadDocument
|
||||
const CommandID: {
|
||||
wiaCommandChangeDocument: CommandID,
|
||||
wiaCommandDeleteAllItems: CommandID,
|
||||
wiaCommandSynchronize: CommandID,
|
||||
wiaCommandTakePicture: CommandID,
|
||||
wiaCommandUnloadDocument: CommandID
|
||||
};
|
||||
|
||||
type EventID =
|
||||
"'{A28BBADE-64B6-11D2-A231-00C04FA31809}'" //wiaEventDeviceConnected
|
||||
| "'{143E4E83-6497-11D2-A231-00C04FA31809}'" //wiaEventDeviceDisconnected
|
||||
| "'{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}'" //wiaEventItemCreated
|
||||
| "'{1D22A559-E14F-11D2-B326-00C04F68CE61}'" //wiaEventItemDeleted
|
||||
| "'{C686DCEE-54F2-419E-9A27-2FC7F2E98F9E}'" //wiaEventScanEmailImage
|
||||
| "'{C00EB793-8C6E-11D2-977A-0000F87A926F}'" //wiaEventScanFaxImage
|
||||
| "'{9B2B662C-6185-438C-B68B-E39EE25E71CB}'" //wiaEventScanFilmImage
|
||||
| "'{A6C5A715-8C6E-11D2-977A-0000F87A926F}'" //wiaEventScanImage
|
||||
| "'{FC4767C1-C8B3-48A2-9CFA-2E90CB3D3590}'" //wiaEventScanImage2
|
||||
| "'{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}'" //wiaEventScanImage3
|
||||
| "'{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}'" //wiaEventScanImage4
|
||||
| "'{9D095B89-37D6-4877-AFED-62A297DC6DBE}'" //wiaEventScanOCRImage
|
||||
| "'{B441F425-8C6E-11D2-977A-0000F87A926F}'"; //wiaEventScanPrintImage
|
||||
const EventID: {
|
||||
wiaEventDeviceConnected: EventID,
|
||||
wiaEventDeviceDisconnected: EventID,
|
||||
wiaEventItemCreated: EventID,
|
||||
wiaEventItemDeleted: EventID,
|
||||
wiaEventScanEmailImage: EventID,
|
||||
wiaEventScanFaxImage: EventID,
|
||||
wiaEventScanFilmImage: EventID,
|
||||
wiaEventScanImage: EventID,
|
||||
wiaEventScanImage2: EventID,
|
||||
wiaEventScanImage3: EventID,
|
||||
wiaEventScanImage4: EventID,
|
||||
wiaEventScanOCRImage: EventID,
|
||||
wiaEventScanPrintImage: EventID
|
||||
};
|
||||
|
||||
type FormatID =
|
||||
"'{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}'" //wiaFormatBMP
|
||||
| "'{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}'" //wiaFormatGIF
|
||||
| "'{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}'" //wiaFormatJPEG
|
||||
| "'{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}'" //wiaFormatPNG
|
||||
| "'{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}'"; //wiaFormatTIFF
|
||||
const FormatID: {
|
||||
wiaFormatBMP: FormatID,
|
||||
wiaFormatGIF: FormatID,
|
||||
wiaFormatJPEG: FormatID,
|
||||
wiaFormatPNG: FormatID,
|
||||
wiaFormatTIFF: FormatID
|
||||
};
|
||||
|
||||
type Miscellaneous =
|
||||
"'*'" //wiaAnyDeviceID
|
||||
| "'{00000000-0000-0000-0000-000000000000}'"; //wiaIDUnknown
|
||||
const Miscellaneous: {
|
||||
wiaAnyDeviceID: Miscellaneous,
|
||||
wiaIDUnknown: Miscellaneous
|
||||
};
|
||||
|
||||
const enum WiaDeviceType {
|
||||
CameraDeviceType = 2,
|
||||
ScannerDeviceType = 1,
|
||||
UnspecifiedDeviceType = 0,
|
||||
VideoDeviceType = 3
|
||||
}
|
||||
|
||||
const enum WiaEventFlag {
|
||||
ActionEvent = 2,
|
||||
NotificationEvent = 1
|
||||
}
|
||||
|
||||
const enum WiaImageBias {
|
||||
MaximizeQuality = 131072,
|
||||
MinimizeSize = 65536
|
||||
}
|
||||
|
||||
const enum WiaImageIntent {
|
||||
ColorIntent = 1,
|
||||
GrayscaleIntent = 2,
|
||||
TextIntent = 4,
|
||||
UnspecifiedIntent = 0
|
||||
}
|
||||
|
||||
const enum WiaImagePropertyType {
|
||||
ByteImagePropertyType = 1001,
|
||||
LongImagePropertyType = 1004,
|
||||
RationalImagePropertyType = 1006,
|
||||
StringImagePropertyType = 1002,
|
||||
UndefinedImagePropertyType = 1000,
|
||||
UnsignedIntegerImagePropertyType = 1003,
|
||||
UnsignedLongImagePropertyType = 1005,
|
||||
UnsignedRationalImagePropertyType = 1007,
|
||||
VectorOfBytesImagePropertyType = 1101,
|
||||
VectorOfLongsImagePropertyType = 1103,
|
||||
VectorOfRationalsImagePropertyType = 1105,
|
||||
VectorOfUndefinedImagePropertyType = 1100,
|
||||
VectorOfUnsignedIntegersImagePropertyType = 1102,
|
||||
VectorOfUnsignedLongsImagePropertyType = 1104,
|
||||
VectorOfUnsignedRationalsImagePropertyType = 1106
|
||||
}
|
||||
|
||||
const enum WiaItemFlag {
|
||||
AnalyzeItemFlag = 16,
|
||||
AudioItemFlag = 32,
|
||||
BurstItemFlag = 2048,
|
||||
DeletedItemFlag = 128,
|
||||
DeviceItemFlag = 64,
|
||||
DisconnectedItemFlag = 256,
|
||||
FileItemFlag = 2,
|
||||
FolderItemFlag = 4,
|
||||
FreeItemFlag = 0,
|
||||
GeneratedItemFlag = 16384,
|
||||
HasAttachmentsItemFlag = 32768,
|
||||
HPanoramaItemFlag = 512,
|
||||
ImageItemFlag = 1,
|
||||
RemovedItemFlag = -2147483648,
|
||||
RootItemFlag = 8,
|
||||
StorageItemFlag = 4096,
|
||||
TransferItemFlag = 8192,
|
||||
VideoItemFlag = 65536,
|
||||
VPanoramaItemFlag = 1024
|
||||
}
|
||||
|
||||
const enum WiaPropertyType {
|
||||
BooleanPropertyType = 1,
|
||||
BytePropertyType = 2,
|
||||
ClassIDPropertyType = 15,
|
||||
CurrencyPropertyType = 12,
|
||||
DatePropertyType = 13,
|
||||
DoublePropertyType = 11,
|
||||
ErrorCodePropertyType = 7,
|
||||
FileTimePropertyType = 14,
|
||||
HandlePropertyType = 18,
|
||||
IntegerPropertyType = 3,
|
||||
LargeIntegerPropertyType = 8,
|
||||
LongPropertyType = 5,
|
||||
ObjectPropertyType = 17,
|
||||
SinglePropertyType = 10,
|
||||
StringPropertyType = 16,
|
||||
UnsignedIntegerPropertyType = 4,
|
||||
UnsignedLargeIntegerPropertyType = 9,
|
||||
UnsignedLongPropertyType = 6,
|
||||
UnsupportedPropertyType = 0,
|
||||
VariantPropertyType = 19,
|
||||
VectorOfBooleansPropertyType = 101,
|
||||
VectorOfBytesPropertyType = 102,
|
||||
VectorOfClassIDsPropertyType = 115,
|
||||
VectorOfCurrenciesPropertyType = 112,
|
||||
VectorOfDatesPropertyType = 113,
|
||||
VectorOfDoublesPropertyType = 111,
|
||||
VectorOfErrorCodesPropertyType = 107,
|
||||
VectorOfFileTimesPropertyType = 114,
|
||||
VectorOfIntegersPropertyType = 103,
|
||||
VectorOfLargeIntegersPropertyType = 108,
|
||||
VectorOfLongsPropertyType = 105,
|
||||
VectorOfSinglesPropertyType = 110,
|
||||
VectorOfStringsPropertyType = 116,
|
||||
VectorOfUnsignedIntegersPropertyType = 104,
|
||||
VectorOfUnsignedLargeIntegersPropertyType = 109,
|
||||
VectorOfUnsignedLongsPropertyType = 106,
|
||||
VectorOfVariantsPropertyType = 119
|
||||
}
|
||||
|
||||
const enum WiaSubType {
|
||||
FlagSubType = 3,
|
||||
ListSubType = 2,
|
||||
RangeSubType = 1,
|
||||
UnspecifiedSubType = 0
|
||||
}
|
||||
|
||||
//Interfaces
|
||||
interface CommonDialog {
|
||||
ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile;
|
||||
ShowAcquisitionWizard: (Device: Device) => any;
|
||||
ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void;
|
||||
ShowItemProperties: (Item: Item, CancelError?: boolean) => void;
|
||||
ShowPhotoPrintingWizard: (Files: any) => void;
|
||||
ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device;
|
||||
ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items;
|
||||
ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any;
|
||||
}
|
||||
|
||||
interface Device {
|
||||
Commands: DeviceCommands;
|
||||
DeviceID: string;
|
||||
Events: DeviceEvents;
|
||||
ExecuteCommand: (CommandID: string) => Item;
|
||||
GetItem: (ItemID: string) => Item;
|
||||
Items: Items;
|
||||
Properties: Properties;
|
||||
Type: WiaDeviceType;
|
||||
WiaItem: any /*VT_UNKNOWN*/;
|
||||
}
|
||||
|
||||
interface DeviceCommand {
|
||||
CommandID: string;
|
||||
Description: string;
|
||||
Name: string;
|
||||
}
|
||||
|
||||
interface DeviceCommands {
|
||||
Count: number;
|
||||
Item: (Index: number) => DeviceCommand;
|
||||
}
|
||||
|
||||
interface DeviceEvent {
|
||||
Description: string;
|
||||
EventID: string;
|
||||
Name: string;
|
||||
Type: WiaEventFlag;
|
||||
}
|
||||
|
||||
interface DeviceEvents {
|
||||
Count: number;
|
||||
Item: (Index: number) => DeviceEvent;
|
||||
}
|
||||
|
||||
interface DeviceInfo {
|
||||
Connect: () => Device;
|
||||
DeviceID: string;
|
||||
Properties: Properties;
|
||||
Type: WiaDeviceType;
|
||||
}
|
||||
|
||||
interface DeviceInfos {
|
||||
Count: number;
|
||||
Item: (Index: any) => DeviceInfo;
|
||||
}
|
||||
|
||||
interface DeviceManager {
|
||||
DeviceInfos: DeviceInfos;
|
||||
RegisterEvent: (EventID: string, DeviceID?: string) => void;
|
||||
RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void;
|
||||
UnregisterEvent: (EventID: string, DeviceID?: string) => void;
|
||||
UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void;
|
||||
}
|
||||
|
||||
interface Filter {
|
||||
Description: string;
|
||||
FilterID: string;
|
||||
Name: string;
|
||||
Properties: Properties;
|
||||
}
|
||||
|
||||
interface FilterInfo {
|
||||
Description: string;
|
||||
FilterID: string;
|
||||
Name: string;
|
||||
}
|
||||
|
||||
interface FilterInfos {
|
||||
Count: number;
|
||||
Item: (Index: any) => FilterInfo;
|
||||
}
|
||||
|
||||
interface Filters {
|
||||
Add: (FilterID: string, Index?: number) => void;
|
||||
Count: number;
|
||||
Item: (Index: number) => Filter;
|
||||
Remove: (Index: number) => void;
|
||||
}
|
||||
|
||||
interface Formats {
|
||||
Count: number;
|
||||
Item: (Index: number) => string;
|
||||
}
|
||||
|
||||
interface ImageFile {
|
||||
ActiveFrame: number;
|
||||
ARGBData: Vector;
|
||||
FileData: Vector;
|
||||
FileExtension: string;
|
||||
FormatID: string;
|
||||
FrameCount: number;
|
||||
Height: number;
|
||||
HorizontalResolution: number;
|
||||
IsAlphaPixelFormat: boolean;
|
||||
IsAnimated: boolean;
|
||||
IsExtendedPixelFormat: boolean;
|
||||
IsIndexedPixelFormat: boolean;
|
||||
LoadFile: (Filename: string) => void;
|
||||
PixelDepth: number;
|
||||
Properties: Properties;
|
||||
SaveFile: (Filename: string) => void;
|
||||
VerticalResolution: number;
|
||||
Width: number;
|
||||
}
|
||||
|
||||
interface ImageProcess {
|
||||
Apply: (Source: ImageFile) => ImageFile;
|
||||
FilterInfos: FilterInfos;
|
||||
Filters: Filters;
|
||||
}
|
||||
|
||||
interface Item {
|
||||
Commands: DeviceCommands;
|
||||
ExecuteCommand: (CommandID: string) => Item;
|
||||
Formats: Formats;
|
||||
ItemID: string;
|
||||
Items: Items;
|
||||
Properties: Properties;
|
||||
Transfer: (FormatID?: string) => any;
|
||||
WiaItem: any /*VT_UNKNOWN*/;
|
||||
}
|
||||
|
||||
interface Items {
|
||||
Add: (Name: string, Flags: number) => void;
|
||||
Count: number;
|
||||
Item: (Index: number) => Item;
|
||||
Remove: (Index: number) => void;
|
||||
}
|
||||
|
||||
interface Properties {
|
||||
Count: number;
|
||||
Exists: (Index: any) => boolean;
|
||||
Item: (Index: any) => Property;
|
||||
}
|
||||
|
||||
interface Property {
|
||||
IsReadOnly: boolean;
|
||||
IsVector: boolean;
|
||||
Name: string;
|
||||
PropertyID: number;
|
||||
SubType: WiaSubType;
|
||||
SubTypeDefault: any;
|
||||
SubTypeMax: number;
|
||||
SubTypeMin: number;
|
||||
SubTypeStep: number;
|
||||
SubTypeValues: Vector;
|
||||
Type: number;
|
||||
Value: any;
|
||||
}
|
||||
|
||||
interface Rational {
|
||||
Denominator: number;
|
||||
Numerator: number;
|
||||
Value: number;
|
||||
}
|
||||
|
||||
interface Vector {
|
||||
Add: (Value: any, Index?: number) => void;
|
||||
BinaryData: any;
|
||||
Clear: () => void;
|
||||
Count: number;
|
||||
Date: VarDate;
|
||||
ImageFile: (Width?: number, Height?: number) => ImageFile;
|
||||
Item: (Index: number) => any; //Also has setter with parameters
|
||||
Picture: (Width?: number, Height?: number) => any;
|
||||
Remove: (Index: number) => any;
|
||||
SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void;
|
||||
String: (Unicode?: boolean) => string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
new (progID: 'WIA.Rational'): WIA.Rational;
|
||||
new (progID: 'WIA.Vector'): WIA.Vector;
|
||||
new (progID: 'WIA.ImageFile'): WIA.ImageFile;
|
||||
new (progID: 'WIA.ImageProcess'): WIA.ImageProcess;
|
||||
new (progID: 'WIA.CommonDialog'): WIA.CommonDialog;
|
||||
new (progID: 'WIA.DeviceManager'): WIA.DeviceManager;
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"activex-windows-image-acquisition-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-169
@@ -1,169 +0,0 @@
|
||||
// Type definitions for ADAL.JS 1.0.8
|
||||
// Project: https://github.com/AzureAD/azure-activedirectory-library-for-js
|
||||
// Definitions by: mmaitre314 <https://github.com/mmaitre314>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var AuthenticationContext: adal.AuthenticationContextStatic;
|
||||
declare var Logging: adal.Logging;
|
||||
|
||||
declare module 'adal' {
|
||||
export = { AuthenticationContext, Logging };
|
||||
}
|
||||
|
||||
declare namespace adal {
|
||||
|
||||
interface Config {
|
||||
tenant?: string;
|
||||
clientId: string;
|
||||
redirectUri?: string;
|
||||
cacheLocation?: string;
|
||||
displayCall?: (urlNavigate: string) => any;
|
||||
correlationId?: string;
|
||||
loginResource?: string;
|
||||
resource?: string;
|
||||
endpoints?: any; // If you need to send CORS api requests.
|
||||
extraQueryParameter?: string;
|
||||
postLogoutRedirectUri?: string; // redirect url after succesful logout operation
|
||||
}
|
||||
|
||||
interface User {
|
||||
userName: string;
|
||||
profile: any;
|
||||
}
|
||||
|
||||
interface RequestInfo {
|
||||
valid: boolean;
|
||||
parameters: any;
|
||||
stateMatch: boolean;
|
||||
stateResponse: string;
|
||||
requestType: string;
|
||||
}
|
||||
|
||||
interface Logging {
|
||||
log: (message: string) => void;
|
||||
level: LoggingLevel;
|
||||
}
|
||||
|
||||
enum LoggingLevel {
|
||||
ERROR = 0,
|
||||
WARNING = 1,
|
||||
INFO = 2,
|
||||
VERBOSE = 3
|
||||
}
|
||||
|
||||
interface AuthenticationContextStatic {
|
||||
new (config: Config): AuthenticationContext;
|
||||
}
|
||||
|
||||
interface AuthenticationContext {
|
||||
|
||||
instance: string;
|
||||
config: Config;
|
||||
|
||||
/**
|
||||
* Gets initial Idtoken for the app backend
|
||||
* Saves the resulting Idtoken in localStorage.
|
||||
*/
|
||||
login(): void;
|
||||
|
||||
/**
|
||||
* Indicates whether login is in progress now or not.
|
||||
*/
|
||||
loginInProgress(): boolean;
|
||||
|
||||
/**
|
||||
* Gets token for the specified resource from local storage cache
|
||||
* @param {string} resource A URI that identifies the resource for which the token is valid.
|
||||
* @returns {string} token if exists and not expired or null
|
||||
*/
|
||||
getCachedToken(resource: string): string;
|
||||
|
||||
/**
|
||||
* Retrieves and parse idToken from localstorage
|
||||
* @returns {User} user object
|
||||
*/
|
||||
getCachedUser(): User;
|
||||
|
||||
registerCallback(expectedState: string, resource: string, callback: (message: string, token: string) => any): void;
|
||||
|
||||
/**
|
||||
* Acquire token from cache if not expired and available. Acquires token from iframe if expired.
|
||||
* @param {string} resource ResourceUri identifying the target resource
|
||||
* @param {requestCallback} callback
|
||||
*/
|
||||
acquireToken(resource: string, callback: (message: string, token: string) => any): void;
|
||||
|
||||
/**
|
||||
* Redirect the Browser to Azure AD Authorization endpoint
|
||||
* @param {string} urlNavigate The authorization request url
|
||||
*/
|
||||
promptUser(urlNavigate: string): void;
|
||||
|
||||
/**
|
||||
* Clear cache items.
|
||||
*/
|
||||
clearCache(): void;
|
||||
|
||||
/**
|
||||
* Clear cache items for a resource.
|
||||
*/
|
||||
clearCacheForResource(resource: string): void;
|
||||
|
||||
/**
|
||||
* Logout user will redirect page to logout endpoint.
|
||||
* After logout, it will redirect to post_logout page if provided.
|
||||
*/
|
||||
logOut(): void;
|
||||
|
||||
/**
|
||||
* Gets a user profile
|
||||
* @param {requestCallback} callback - The callback that handles the response.
|
||||
*/
|
||||
getUser(callback: (message: string, user?: User) => any): void;
|
||||
|
||||
/**
|
||||
* Checks if hash contains access token or id token or error_description
|
||||
* @param {string} hash - Hash passed from redirect page
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
isCallback(hash: string): boolean;
|
||||
|
||||
/**
|
||||
* Gets login error
|
||||
* @returns {string} error message related to login
|
||||
*/
|
||||
getLoginError(): string;
|
||||
|
||||
/**
|
||||
* Gets requestInfo from given hash.
|
||||
* @returns {RequestInfo} for appropriate hash.
|
||||
*/
|
||||
getRequestInfo(hash: string): RequestInfo;
|
||||
|
||||
/**
|
||||
* Saves token from hash that is received from redirect.
|
||||
*/
|
||||
saveTokenFromHash(requestInfo: RequestInfo): void;
|
||||
|
||||
/**
|
||||
* Gets resource for given endpoint if mapping is provided with config.
|
||||
* @param {string} endpoint - API endpoint
|
||||
* @returns {string} resource for this API endpoint
|
||||
*/
|
||||
getResourceForEndpoint(endpoint: string): string;
|
||||
|
||||
/**
|
||||
* Handles redirection after login operation.
|
||||
* Gets access token from url and saves token to the (local/session) storage
|
||||
* or saves error in case unsuccessful login.
|
||||
*/
|
||||
handleWindowCallback(): void;
|
||||
|
||||
log(level: number, message: string, error: any): void;
|
||||
error(message: string, error: any): void;
|
||||
warn(message: string): void;
|
||||
info(message: string): void;
|
||||
verbose(message: string): void;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"adal-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"add2home-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-306
@@ -1,306 +0,0 @@
|
||||
// Type definitions for adm-zip v0.4.4
|
||||
// Project: https://github.com/cthackers/adm-zip
|
||||
// Definitions by: John Vilk <https://github.com/jvilk>, Abner Oliveira <https://github.com/abner>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
declare class AdmZip {
|
||||
/**
|
||||
* Create a new, empty archive.
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Read an existing archive.
|
||||
*/
|
||||
constructor(fileName: string);
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as a
|
||||
* Buffer object.
|
||||
* @param entry String with the full path of the entry
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFile(entry: string): Buffer;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as a
|
||||
* Buffer object.
|
||||
* @param entry ZipEntry object
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFile(entry: AdmZip.IZipEntry): Buffer;
|
||||
/**
|
||||
* Asynchronous readFile
|
||||
* @param entry String with the full path of the entry
|
||||
* @param callback Called with a Buffer or Null in case of error
|
||||
*/
|
||||
readFileAsync(entry: string, callback: (data: Buffer, err: string) => any): void;
|
||||
/**
|
||||
* Asynchronous readFile
|
||||
* @param entry ZipEntry object
|
||||
* @param callback Called with a Buffer or Null in case of error
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFileAsync(entry: AdmZip.IZipEntry, callback: (data: Buffer, err: string) => any): void;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as
|
||||
* plain text in the given encoding
|
||||
* @param entry String with the full path of the entry
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @return String
|
||||
*/
|
||||
readAsText(fileName: string, encoding?: string): string;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as
|
||||
* plain text in the given encoding
|
||||
* @param entry ZipEntry object
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @return String
|
||||
*/
|
||||
readAsText(fileName: AdmZip.IZipEntry, encoding?: string): string;
|
||||
/**
|
||||
* Asynchronous readAsText
|
||||
* @param entry String with the full path of the entry
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
*/
|
||||
readAsTextAsync(fileName: string, callback: (data: string) => any, encoding?: string): void;
|
||||
/**
|
||||
* Asynchronous readAsText
|
||||
* @param entry ZipEntry object
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
*/
|
||||
readAsTextAsync(fileName: AdmZip.IZipEntry, callback: (data: string) => any, encoding?: string): void;
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all its nested directories
|
||||
* and files if the given entry is a directory
|
||||
* @param entry String with the full path of the entry
|
||||
*/
|
||||
deleteFile(entry: string): void;
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all its nested directories
|
||||
* and files if the given entry is a directory
|
||||
* @param entry A ZipEntry object.
|
||||
*/
|
||||
deleteFile(entry: AdmZip.IZipEntry): void;
|
||||
/**
|
||||
* Adds a comment to the zip. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* @param comment Content of the comment.
|
||||
*/
|
||||
addZipComment(comment: string): void;
|
||||
/**
|
||||
* Returns the zip comment
|
||||
* @return The zip comment.
|
||||
*/
|
||||
getZipComment(): string;
|
||||
/**
|
||||
* Adds a comment to a specified zipEntry. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* The comment cannot exceed 65535 characters in length.
|
||||
* @param entry String with the full path of the entry
|
||||
* @param comment The comment to add to the entry.
|
||||
*/
|
||||
addZipEntryComment(entry: string, comment: string): void;
|
||||
/**
|
||||
* Adds a comment to a specified zipEntry. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* The comment cannot exceed 65535 characters in length.
|
||||
* @param entry ZipEntry object.
|
||||
* @param comment The comment to add to the entry.
|
||||
*/
|
||||
addZipEntryComment(entry: AdmZip.IZipEntry, comment: string): void;
|
||||
/**
|
||||
* Returns the comment of the specified entry.
|
||||
* @param entry String with the full path of the entry.
|
||||
* @return String The comment of the specified entry.
|
||||
*/
|
||||
getZipEntryComment(entry: string): string;
|
||||
/**
|
||||
* Returns the comment of the specified entry
|
||||
* @param entry ZipEntry object.
|
||||
* @return String The comment of the specified entry.
|
||||
*/
|
||||
getZipEntryComment(entry: AdmZip.IZipEntry): string;
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip
|
||||
* must be rewritten after updating the content
|
||||
* @param entry String with the full path of the entry.
|
||||
* @param content The entry's new contents.
|
||||
*/
|
||||
updateFile(entry: string, content: Buffer): void;
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip
|
||||
* must be rewritten after updating the content
|
||||
* @param entry ZipEntry object.
|
||||
* @param content The entry's new contents.
|
||||
*/
|
||||
updateFile(entry: AdmZip.IZipEntry, content: Buffer): void;
|
||||
/**
|
||||
* Adds a file from the disk to the archive.
|
||||
* @param localPath Path to a file on disk.
|
||||
* @param zipPath Path to a directory in the archive. Defaults to the empty
|
||||
* string.
|
||||
*/
|
||||
addLocalFile(localPath: string, zipPath?: string): void;
|
||||
/**
|
||||
* Adds a local directory and all its nested files and directories to the
|
||||
* archive.
|
||||
* @param localPath Path to a folder on disk.
|
||||
* @param zipPath Path to a folder in the archive. Defaults to an empty
|
||||
* string.
|
||||
*/
|
||||
addLocalFolder(localPath: string, zipPath?: string): void;
|
||||
/**
|
||||
* Allows you to create a entry (file or directory) in the zip file.
|
||||
* If you want to create a directory the entryName must end in / and a null
|
||||
* buffer should be provided.
|
||||
* @param entryName Entry path
|
||||
* @param content Content to add to the entry; must be a 0-length buffer
|
||||
* for a directory.
|
||||
* @param comment Comment to add to the entry.
|
||||
* @param attr Attribute to add to the entry.
|
||||
*/
|
||||
addFile(entryName: string, data: Buffer, comment?: string, attr?: number): void;
|
||||
/**
|
||||
* Returns an array of ZipEntry objects representing the files and folders
|
||||
* inside the archive
|
||||
*/
|
||||
getEntries(): AdmZip.IZipEntry[];
|
||||
/**
|
||||
* Returns a ZipEntry object representing the file or folder specified by
|
||||
* ``name``.
|
||||
* @param name Name of the file or folder to retrieve.
|
||||
* @return ZipEntry The entry corresponding to the name.
|
||||
*/
|
||||
getEntry(name: string): AdmZip.IZipEntry;
|
||||
/**
|
||||
* Extracts the given entry to the given targetPath.
|
||||
* If the entry is a directory inside the archive, the entire directory and
|
||||
* its subdirectories will be extracted.
|
||||
* @param entry String with the full path of the entry
|
||||
* @param targetPath Target folder where to write the file
|
||||
* @param maintainEntryPath If maintainEntryPath is true and the entry is
|
||||
* inside a folder, the entry folder will be created in targetPath as
|
||||
* well. Default is TRUE
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
extractEntryTo(entryPath: string, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
|
||||
/**
|
||||
* Extracts the given entry to the given targetPath.
|
||||
* If the entry is a directory inside the archive, the entire directory and
|
||||
* its subdirectories will be extracted.
|
||||
* @param entry ZipEntry object
|
||||
* @param targetPath Target folder where to write the file
|
||||
* @param maintainEntryPath If maintainEntryPath is true and the entry is
|
||||
* inside a folder, the entry folder will be created in targetPath as
|
||||
* well. Default is TRUE
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
* @return Boolean
|
||||
*/
|
||||
extractEntryTo(entryPath: AdmZip.IZipEntry, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
|
||||
/**
|
||||
* Extracts the entire archive to the given location
|
||||
* @param targetPath Target location
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
*/
|
||||
extractAllTo(targetPath: string, overwrite?: boolean): void;
|
||||
/**
|
||||
* Extracts the entire archive to the given location
|
||||
* @param targetPath Target location
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
* @param callback The callback function will be called afeter extraction
|
||||
*/
|
||||
extractAllToAsync(targetPath: string, overwrite: boolean, callback: (error: Error) => void): void;
|
||||
/**
|
||||
* Writes the newly created zip file to disk at the specified location or
|
||||
* if a zip was opened and no ``targetFileName`` is provided, it will
|
||||
* overwrite the opened zip
|
||||
* @param targetFileName
|
||||
*/
|
||||
writeZip(targetPath?: string): void;
|
||||
/**
|
||||
* Returns the content of the entire zip file as a Buffer object
|
||||
* @return Buffer
|
||||
*/
|
||||
toBuffer(): Buffer;
|
||||
}
|
||||
|
||||
declare namespace AdmZip {
|
||||
/**
|
||||
* The ZipEntry is more than a structure representing the entry inside the
|
||||
* zip file. Beside the normal attributes and headers a entry can have, the
|
||||
* class contains a reference to the part of the file where the compressed
|
||||
* data resides and decompresses it when requested. It also compresses the
|
||||
* data and creates the headers required to write in the zip file.
|
||||
*/
|
||||
interface IZipEntry {
|
||||
/**
|
||||
* Represents the full name and path of the file
|
||||
*/
|
||||
entryName: string;
|
||||
rawEntryName: Buffer;
|
||||
/**
|
||||
* Extra data associated with this entry.
|
||||
*/
|
||||
extra: Buffer;
|
||||
/**
|
||||
* Entry comment.
|
||||
*/
|
||||
comment: string;
|
||||
name: string;
|
||||
/**
|
||||
* Read-Only property that indicates the type of the entry.
|
||||
*/
|
||||
isDirectory: boolean;
|
||||
/**
|
||||
* Get the header associated with this ZipEntry.
|
||||
*/
|
||||
header: Buffer;
|
||||
/**
|
||||
* Retrieve the compressed data for this entry. Note that this may trigger
|
||||
* compression if any properties were modified.
|
||||
*/
|
||||
getCompressedData(): Buffer;
|
||||
/**
|
||||
* Asynchronously retrieve the compressed data for this entry. Note that
|
||||
* this may trigger compression if any properties were modified.
|
||||
*/
|
||||
getCompressedDataAsync(callback: (data: Buffer) => void): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: string): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: Buffer): void;
|
||||
/**
|
||||
* Get the decompressed data associated with this entry.
|
||||
*/
|
||||
getData(): Buffer;
|
||||
/**
|
||||
* Asynchronously get the decompressed data associated with this entry.
|
||||
*/
|
||||
getDataAsync(callback: (data: Buffer) => void): void;
|
||||
/**
|
||||
* Returns the CEN Entry Header to be written to the output zip file, plus
|
||||
* the extra data and the entry comment.
|
||||
*/
|
||||
packHeader(): Buffer;
|
||||
/**
|
||||
* Returns a nicely formatted string with the most important properties of
|
||||
* the ZipEntry.
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
}
|
||||
|
||||
export = AdmZip;
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"adm-zip-tests.ts"
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ag-grid-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
Vendored
-448
@@ -1,448 +0,0 @@
|
||||
// Type definitions for Agenda v0.8.9
|
||||
// Project: https://github.com/rschmukler/agenda
|
||||
// Definitions by: Meir Gottlieb <https://github.com/meirgottlieb>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { EventEmitter } from "events";
|
||||
import { Db, Collection, ObjectID } from "mongodb";
|
||||
|
||||
export = Agenda;
|
||||
|
||||
interface Callback {
|
||||
(err?: Error): void;
|
||||
}
|
||||
|
||||
interface ResultCallback<T> {
|
||||
(err?: Error, result?: T): void;
|
||||
}
|
||||
|
||||
|
||||
declare class Agenda extends EventEmitter {
|
||||
/**
|
||||
* Constructs a new Agenda object.
|
||||
* @param config Optional configuration to initialize the Agenda.
|
||||
* @param cb Optional callback called with the MongoDB colleciton.
|
||||
*/
|
||||
constructor(config?: Agenda.AgendaConfiguration, cb?: ResultCallback<Collection>);
|
||||
|
||||
/**
|
||||
* Connect to the specified MongoDB server and database.
|
||||
*/
|
||||
database(url: string, collection?: string, options?: any, cb?: ResultCallback<Collection>): Agenda;
|
||||
|
||||
/**
|
||||
* Initialize agenda with an existing MongoDB connection.
|
||||
*/
|
||||
mongo(db: Db, collection?: string, cb?: ResultCallback<Collection>): Agenda;
|
||||
|
||||
/**
|
||||
* Sets the agenda name.
|
||||
*/
|
||||
name(value: string): Agenda;
|
||||
|
||||
/**
|
||||
* Sets the interval with which the queue is checked. A number in milliseconds or a frequency string.
|
||||
*/
|
||||
processEvery(interval: string | number): Agenda;
|
||||
|
||||
/**
|
||||
* Takes a number which specifies the max number of jobs that can be running at any given moment. By default it
|
||||
* is 20.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
maxConcurrency(value: number): Agenda;
|
||||
|
||||
/**
|
||||
* Takes a number which specifies the default number of a specific job that can be running at any given moment.
|
||||
* By default it is 5.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
defaultConcurrency(value: number): Agenda;
|
||||
|
||||
/**
|
||||
* Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is
|
||||
* 0 for no max.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
lockLimit(value: number): Agenda;
|
||||
|
||||
/**
|
||||
* Takes a number which specifies the default number of a specific job that can be locked at any given moment.
|
||||
* By default it is 0 for no max.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
defaultLockLimit(value: number): Agenda;
|
||||
|
||||
/**
|
||||
* Takes a number which specifies the default lock lifetime in milliseconds. By default it is 10 minutes. This
|
||||
* can be overridden by specifying the lockLifetime option to a defined job.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
defaultLockLifetime(value: number): Agenda;
|
||||
|
||||
/**
|
||||
* Returns an instance of a jobName with data. This does NOT save the job in the database. See below to learn
|
||||
* how to manually work with jobs.
|
||||
* @param name The name of the job.
|
||||
* @param data Data to associated with the job.
|
||||
*/
|
||||
create(name: string, data?: any): Agenda.Job;
|
||||
|
||||
/**
|
||||
* Find all Jobs matching `query` and pass same back in cb().
|
||||
* @param query
|
||||
* @param cb
|
||||
*/
|
||||
jobs(query: any, cb: ResultCallback<Agenda.Job[]>): void;
|
||||
|
||||
/**
|
||||
* Removes all jobs in the database without defined behaviors. Useful if you change a definition name and want
|
||||
* to remove old jobs.
|
||||
* @param cb Called with the number of jobs removed.
|
||||
*/
|
||||
purge(cb?: ResultCallback<number>): void;
|
||||
|
||||
/**
|
||||
* Defines a job with the name of jobName. When a job of job name gets run, it will be passed to fn(job, done).
|
||||
* To maintain asynchronous behavior, you must call done() when you are processing the job. If your function is
|
||||
* synchronous, you may omit done from the signature.
|
||||
* @param name The name of the jobs.
|
||||
* @param options The options for the job.
|
||||
* @param handler The handler to execute.
|
||||
*/
|
||||
define(name: string, handler: (job?: Agenda.Job, done?: (err?: Error) => void) => void): void;
|
||||
define(name: string, options: Agenda.JobOptions, handler: (job?: Agenda.Job, done?: (err?: Error) => void) => void): void;
|
||||
|
||||
/**
|
||||
* Runs job name at the given interval. Optionally, data and options can be passed in.
|
||||
* @param interval Can be a human-readable format String, a cron format String, or a Number.
|
||||
* @param names The name or names of the job(s) to run.
|
||||
* @param data An optional argument that will be passed to the processing function under job.attrs.data.
|
||||
* @param options An optional argument that will be passed to job.repeatEvery.
|
||||
* @param cb An optional callback function which will be called when the job has been persisted in the database.
|
||||
*/
|
||||
every(interval: number | string, names: string, data?: any, options?: any, cb?: ResultCallback<Agenda.Job>): Agenda.Job;
|
||||
every(interval: number | string, names: string[], data?: any, options?: any, cb?: ResultCallback<Agenda.Job[]>): Agenda.Job[];
|
||||
|
||||
/**
|
||||
* Schedules a job to run name once at a given time.
|
||||
* @param when A Date or a String such as tomorrow at 5pm.
|
||||
* @param names The name or names of the job(s) to run.
|
||||
* @param data An optional argument that will be passed to the processing function under job.attrs.data.
|
||||
* @param cb An optional callback function which will be called when the job has been persisted in the database.
|
||||
*/
|
||||
schedule(when: Date | string, names: string, data?: any, cb?: ResultCallback<Agenda.Job>): Agenda.Job;
|
||||
schedule(when: Date | string, names: string[], data?: any, cb?: ResultCallback<Agenda.Job[]>): Agenda.Job[];
|
||||
|
||||
/**
|
||||
* Schedules a job to run name once immediately.
|
||||
* @param name The name of the job to run.
|
||||
* @param data An optional argument that will be passed to the processing function under job.attrs.data.
|
||||
* @param cb An optional callback function which will be called when the job has been persisted in the database.
|
||||
*/
|
||||
now(name: string, data?: any, cb?: ResultCallback<Agenda.Job>): Agenda.Job;
|
||||
|
||||
/**
|
||||
* Cancels any jobs matching the passed mongodb-native query, and removes them from the database.
|
||||
* @param query Mongodb native query.
|
||||
* @param cb Called with the number of jobs removed.
|
||||
*/
|
||||
cancel(query: any, cb?: ResultCallback<number>): void;
|
||||
|
||||
/**
|
||||
* Starts the job queue processing, checking processEvery time to see if there are new jobs.
|
||||
*/
|
||||
start(): void;
|
||||
|
||||
/**
|
||||
* Stops the job queue processing. Unlocks currently running jobs.
|
||||
* @param cb Called after the job processing queue shuts down and unlocks all jobs.
|
||||
*/
|
||||
stop(cb: Callback): void;
|
||||
}
|
||||
|
||||
declare namespace Agenda {
|
||||
|
||||
/**
|
||||
* Agenda Configuration.
|
||||
*/
|
||||
interface AgendaConfiguration {
|
||||
|
||||
/**
|
||||
* Sets the interval with which the queue is checked. A number in milliseconds or a frequency string.
|
||||
*/
|
||||
processEvery?: string | number;
|
||||
|
||||
/**
|
||||
* Takes a number which specifies the default number of a specific job that can be running at any given moment.
|
||||
* By default it is 5.
|
||||
*/
|
||||
defaultConcurrency?: number;
|
||||
|
||||
/**
|
||||
* Takes a number which specifies the max number of jobs that can be running at any given moment. By default it
|
||||
* is 20.
|
||||
*/
|
||||
maxConcurrency?: number;
|
||||
|
||||
/**
|
||||
* Takes a number which specifies the default number of a specific job that can be locked at any given moment.
|
||||
* By default it is 0 for no max.
|
||||
*/
|
||||
defaultLockLimit?: number;
|
||||
|
||||
/**
|
||||
* Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is
|
||||
* 0 for no max.
|
||||
*/
|
||||
lockLimit?: number;
|
||||
|
||||
/**
|
||||
* Takes a number which specifies the default lock lifetime in milliseconds. By default it is 10 minutes. This
|
||||
* can be overridden by specifying the lockLifetime option to a defined job.
|
||||
*/
|
||||
defaultLockLifetime?: number;
|
||||
|
||||
/**
|
||||
* Specifies that Agenda should be initialized using and existing MongoDB connection.
|
||||
*/
|
||||
mongo?: {
|
||||
/**
|
||||
* The MongoDB database connection to use.
|
||||
*/
|
||||
db: Db;
|
||||
|
||||
/**
|
||||
* The name of the collection to use.
|
||||
*/
|
||||
collection?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies that Agenda should connect to MongoDB.
|
||||
*/
|
||||
db?: {
|
||||
/**
|
||||
* The connection URL.
|
||||
*/
|
||||
address: string;
|
||||
|
||||
/**
|
||||
* The name of the collection to use.
|
||||
*/
|
||||
collection?: string;
|
||||
|
||||
/**
|
||||
* Connection options to pass to MongoDB.
|
||||
*/
|
||||
options?: any;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The database record associated with a job.
|
||||
*/
|
||||
interface JobAttributes {
|
||||
/**
|
||||
* The record identity.
|
||||
*/
|
||||
_id: ObjectID;
|
||||
|
||||
/**
|
||||
* The name of the job.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The type of the job (single|normal).
|
||||
*/
|
||||
type: string;
|
||||
|
||||
/**
|
||||
* The job details.
|
||||
*/
|
||||
data: { [name: string]: any };
|
||||
|
||||
/**
|
||||
* The priority of the job.
|
||||
*/
|
||||
priority: number;
|
||||
|
||||
/**
|
||||
* How often the job is repeated using a human-readable or cron format.
|
||||
*/
|
||||
repeatInterval: string | number;
|
||||
|
||||
/**
|
||||
* The timezone that conforms to [moment-timezone](http://momentjs.com/timezone/).
|
||||
*/
|
||||
repeatTimezone: string;
|
||||
|
||||
/**
|
||||
* Date/time the job was las modified.
|
||||
*/
|
||||
lastModifiedBy: string;
|
||||
|
||||
/**
|
||||
* Date/time the job will run next.
|
||||
*/
|
||||
nextRunAt: Date;
|
||||
|
||||
/**
|
||||
* Date/time the job was locked.
|
||||
*/
|
||||
lockedAt: Date;
|
||||
|
||||
/**
|
||||
* Date/time the job was last run.
|
||||
*/
|
||||
lastRunAt: Date;
|
||||
|
||||
/**
|
||||
* Date/time the job last finished running.
|
||||
*/
|
||||
lastFinishedAt: Date;
|
||||
|
||||
/**
|
||||
* The reason the job failed.
|
||||
*/
|
||||
failReason: string;
|
||||
|
||||
/**
|
||||
* The number of times the job has failed.
|
||||
*/
|
||||
failCount: number;
|
||||
|
||||
/**
|
||||
* The date/time the job last failed.
|
||||
*/
|
||||
failedAt: Date;
|
||||
|
||||
/**
|
||||
* Job's state
|
||||
*/
|
||||
disabled: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* A scheduled job.
|
||||
*/
|
||||
interface Job {
|
||||
|
||||
/**
|
||||
* The database record associated with the job.
|
||||
*/
|
||||
attrs: JobAttributes;
|
||||
|
||||
/**
|
||||
* Specifies an interval on which the job should repeat.
|
||||
* @param interval A human-readable format String, a cron format String, or a Number.
|
||||
* @param options An optional argument that can include a timezone field. The timezone should be a string as
|
||||
* accepted by moment-timezone and is considered when using an interval in the cron string format.
|
||||
*/
|
||||
repeatEvery(interval: string | number, options?: { timezone?: string }): Job
|
||||
|
||||
/**
|
||||
* Specifies a time when the job should repeat. [Possible values](https://github.com/matthewmueller/date#examples).
|
||||
* @param time
|
||||
*/
|
||||
repeatAt(time: string): Job
|
||||
|
||||
/**
|
||||
* Disables the job.
|
||||
*/
|
||||
disable(): Job;
|
||||
|
||||
/**
|
||||
* Enables the job.
|
||||
*/
|
||||
enable(): Job;
|
||||
|
||||
/**
|
||||
* Ensure that only one instance of this job exists with the specified properties
|
||||
* @param value The properties associated with the job that must be unqiue.
|
||||
* @param opts
|
||||
*/
|
||||
unique(value: any, opts?: { insertOnly?: boolean }): Job;
|
||||
|
||||
/**
|
||||
* Specifies the next time at which the job should run.
|
||||
* @param time The next time at which the job should run.
|
||||
*/
|
||||
schedule(time: string | Date): Job;
|
||||
|
||||
/**
|
||||
* Specifies the priority weighting of the job.
|
||||
* @param value The priority of the job (lowest|low|normal|high|highest|number).
|
||||
*/
|
||||
priority(value: string | number): Job;
|
||||
|
||||
/**
|
||||
* Sets job.attrs.failedAt to now, and sets job.attrs.failReason to reason.
|
||||
* @param reason A message or Error object that indicates why the job failed.
|
||||
*/
|
||||
fail(reason: string | Error): Job;
|
||||
|
||||
/**
|
||||
* Runs the given job and calls callback(err, job) upon completion. Normally you never need to call this manually
|
||||
* @param cb Called when the job is completed.
|
||||
*/
|
||||
run(cb?: ResultCallback<Job>): Job;
|
||||
|
||||
/**
|
||||
* Returns true if the job is running; otherwise, returns false.
|
||||
*/
|
||||
isRunning(): boolean;
|
||||
|
||||
/**
|
||||
* Saves the job into the database.
|
||||
* @param cb Called when the job is saved.
|
||||
*/
|
||||
save(cb?: ResultCallback<Job>): Job;
|
||||
|
||||
/**
|
||||
* Removes the job from the database and cancels the job.
|
||||
* @param cb Called after the job has beeb removed from the database.
|
||||
*/
|
||||
remove(cb?: Callback): void;
|
||||
|
||||
/**
|
||||
* Resets the lock on the job. Useful to indicate that the job hasn't timed out when you have very long running
|
||||
* jobs.
|
||||
* @param cb Called after the job has been saved to the database.
|
||||
*/
|
||||
touch(cb?: Callback): void;
|
||||
|
||||
/**
|
||||
* Calculates next time the job should run
|
||||
*/
|
||||
computeNextRunAt(): Job;
|
||||
}
|
||||
|
||||
interface JobOptions {
|
||||
|
||||
/**
|
||||
* Maximum number of that job that can be running at once (per instance of agenda)
|
||||
*/
|
||||
concurrency?: number;
|
||||
|
||||
/**
|
||||
* Maximum number of that job that can be locked at once (per instance of agenda)
|
||||
*/
|
||||
lockLimit?: number;
|
||||
|
||||
/**
|
||||
* Interval in ms of how long the job stays locked for (see multiple job processors for more info). A job will
|
||||
* automatically unlock if done() is called.
|
||||
*/
|
||||
lockLifetime?: number;
|
||||
|
||||
/**
|
||||
* (lowest|low|normal|high|highest|number) specifies the priority of the job. Higher priority jobs will run
|
||||
* first.
|
||||
*/
|
||||
priority?: string | number;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"agenda-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"alertify-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/// <reference types="node"/>
|
||||
|
||||
import * as Alexa from "alexa-sdk";
|
||||
|
||||
exports.handler = function(event: Alexa.RequestBody, context: Alexa.Context, callback: Function) {
|
||||
let alexa = Alexa.handler(event, context);
|
||||
alexa.registerHandlers(handlers);
|
||||
alexa.execute();
|
||||
};
|
||||
|
||||
let handlers: Alexa.Handlers = {
|
||||
'LaunchRequest': function () {
|
||||
this.emit('SayHello');
|
||||
},
|
||||
'HelloWorldIntent': function () {
|
||||
this.emit('SayHello');
|
||||
},
|
||||
'SayHello': function () {
|
||||
this.emit(':tell', 'Hello World!');
|
||||
}
|
||||
};
|
||||
Vendored
-131
@@ -1,131 +0,0 @@
|
||||
// Type definitions for Alexa SDK for Node.js v1.0.3
|
||||
// Project: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs
|
||||
// Definitions by: Pete Beegle <https://github.com/petebeegle>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function handler(event: RequestBody, context: Context, callback?: Function): AlexaObject;
|
||||
export function CreateStateHandler(state: string, obj: any): any;
|
||||
export var StateString: string;
|
||||
|
||||
interface AlexaObject {
|
||||
_event: any;
|
||||
_context: any;
|
||||
_callback: any;
|
||||
state: any;
|
||||
appId: any;
|
||||
response: any;
|
||||
dynamoDBTableName: any;
|
||||
saveBeforeResponse: boolean;
|
||||
registerHandlers: (...handlers: Handlers[]) => any;
|
||||
execute: () => void;
|
||||
}
|
||||
|
||||
interface Handlers {
|
||||
[intent: string]: (this: Handler) => void;
|
||||
}
|
||||
|
||||
interface Handler {
|
||||
on: any;
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emitWithState: any;
|
||||
state: any;
|
||||
handler: any;
|
||||
event: RequestBody;
|
||||
attributes: any;
|
||||
context: any;
|
||||
name: any;
|
||||
isOverriden: any;
|
||||
}
|
||||
|
||||
interface Context {
|
||||
callbackWaitsForEmptyEventLoop: boolean;
|
||||
logGroupName: string;
|
||||
logStreamName: string;
|
||||
functionName: string;
|
||||
memoryLimitInMB: string;
|
||||
functionVersion: string;
|
||||
invokeid: string;
|
||||
awsRequestId: string;
|
||||
}
|
||||
|
||||
interface RequestBody {
|
||||
version: string;
|
||||
session: Session;
|
||||
request: LaunchRequest | IntentRequest | SessionEndedRequest;
|
||||
}
|
||||
|
||||
interface Session {
|
||||
new: boolean;
|
||||
sessionId: string;
|
||||
attributes: any;
|
||||
application: SessionApplication;
|
||||
user: SessionUser;
|
||||
}
|
||||
|
||||
interface SessionApplication {
|
||||
applicationId: string;
|
||||
}
|
||||
|
||||
interface SessionUser {
|
||||
userId: string;
|
||||
accessToken: string;
|
||||
}
|
||||
|
||||
interface LaunchRequest extends IRequest { }
|
||||
|
||||
interface IntentRequest extends IRequest {
|
||||
intent: Intent;
|
||||
}
|
||||
|
||||
interface Intent {
|
||||
name: string;
|
||||
slots: any;
|
||||
}
|
||||
|
||||
interface SessionEndedRequest extends IRequest {
|
||||
reason: string;
|
||||
}
|
||||
|
||||
interface IRequest {
|
||||
type: "LaunchRequest" | "IntentRequest" | "SessionEndedRequest";
|
||||
requestId: string;
|
||||
timeStamp: string;
|
||||
}
|
||||
|
||||
interface ResponseBody {
|
||||
version: string;
|
||||
sessionAttributes?: any;
|
||||
response: Response;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
outputSpeech?: OutputSpeech;
|
||||
card?: Card;
|
||||
reprompt?: Reprompt;
|
||||
shouldEndSession: boolean;
|
||||
}
|
||||
|
||||
interface OutputSpeech {
|
||||
type: "PlainText" | "SSML";
|
||||
text?: string;
|
||||
ssml?: string;
|
||||
}
|
||||
|
||||
interface Card {
|
||||
type: "Simple" | "Standard" | "LinkAccount";
|
||||
title?: string;
|
||||
content?: string;
|
||||
text?: string;
|
||||
image?: Image;
|
||||
}
|
||||
|
||||
interface Image {
|
||||
smallImageUrl: string;
|
||||
largeImageUrl: string;
|
||||
}
|
||||
|
||||
interface Reprompt {
|
||||
outputSpeech: OutputSpeech;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"alexa-sdk-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
import algoliasearch = require('algoliasearch');
|
||||
import { ClientOptions, SynonymOption, AlgoliaUserKeyOptions, SearchSynonymOptions,
|
||||
AlgoliaSecuredApiOptions, AlgoliaIndexSettings, AlgoliaQueryParameters, AlgoliaIndex } from "algoliasearch";
|
||||
|
||||
var _clientOptions: ClientOptions = {
|
||||
timeout : 12,
|
||||
protocol: "",
|
||||
httpAgent: ""
|
||||
};
|
||||
|
||||
var _synonymOption: SynonymOption = {
|
||||
forwardToSlaves: false,
|
||||
replaceExistingSynonyms: false
|
||||
};
|
||||
|
||||
var _algoliaUserKeyOptions : AlgoliaUserKeyOptions = {
|
||||
validity: 0,
|
||||
maxQueriesPerIPPerHour: 0,
|
||||
indexes: [""],
|
||||
queryParameters: { attributesToRetrieve: ["algolia"] },
|
||||
description: ""
|
||||
};
|
||||
|
||||
var _searchSynonymOptions : SearchSynonymOptions = {
|
||||
query: "",
|
||||
page: 0,
|
||||
type: "",
|
||||
hitsPerPage: 0
|
||||
};
|
||||
|
||||
var _algoliaSecuredApiOptions: AlgoliaSecuredApiOptions = {
|
||||
filters: "",
|
||||
validUntil: 0,
|
||||
restrictIndices: "",
|
||||
userToken: ""
|
||||
};
|
||||
|
||||
var _algoliaIndexSettings : AlgoliaIndexSettings = {
|
||||
attributesToIndex: [""],
|
||||
attributesforFaceting: [""],
|
||||
unretrievableAttributes: [""],
|
||||
attributesToRetrieve: [""],
|
||||
ranking: [""],
|
||||
customRanking: [""],
|
||||
slaves: [""],
|
||||
maxValuesPerFacet: '',
|
||||
attributesToHighlight: [""],
|
||||
attributesToSnippet: [""],
|
||||
highlightPreTag: '',
|
||||
highlightPostTag: '',
|
||||
snippetEllipsisText: '',
|
||||
restrictHighlightAndSnippetArrays: false,
|
||||
hitsPerPage: 0,
|
||||
minWordSizefor1Typo: 0,
|
||||
minWordSizefor2Typos: 0,
|
||||
typoTolerance: false,
|
||||
allowTyposOnNumericTokens: false,
|
||||
ignorePlurals: false,
|
||||
disableTypoToleranceOnAttributes: '',
|
||||
separatorsToIndex: '',
|
||||
queryType: '',
|
||||
removeWordsIfNoResults: '',
|
||||
advancedSyntax: false,
|
||||
optionalWords: [""],
|
||||
removeStopWords: [""],
|
||||
disablePrefixOnAttributes: [""],
|
||||
disableExactOnAttributes: [""],
|
||||
exactOnSingleWordQuery: '',
|
||||
alternativesAsExact: false,
|
||||
attributeForDistinct: "",
|
||||
distinct: false,
|
||||
numericAttributesToIndex: [""],
|
||||
allowCompressionOfIntegerArray: false,
|
||||
altCorrections: [{}],
|
||||
minProximity: 0,
|
||||
placeholders: ''
|
||||
};
|
||||
|
||||
var _algoliaQueryParameters : AlgoliaQueryParameters = {
|
||||
query: '',
|
||||
filters: '',
|
||||
attributesToRetrieve: [""],
|
||||
restrictSearchableAttributes: [""],
|
||||
facets: '',
|
||||
maxValuesPerFacet: '',
|
||||
attributesToHighlight: [''],
|
||||
attributesToSnippet: [''],
|
||||
highlightPreTag: '',
|
||||
highlightPostTag: '',
|
||||
snippetEllipsisText: '',
|
||||
restrictHighlightAndSnippetArrays: false,
|
||||
hitsPerPage: 0,
|
||||
page: 0,
|
||||
offset: 0,
|
||||
length: 0,
|
||||
minWordSizefor1Typo: 0,
|
||||
minWordSizefor2Typos: 0,
|
||||
typoTolerance: false,
|
||||
allowTyposOnNumericTokens: false,
|
||||
ignorePlurals: false,
|
||||
disableTypoToleranceOnAttributes: '',
|
||||
aroundLatLng: '',
|
||||
aroundLatLngViaIP: '',
|
||||
aroundRadius: '',
|
||||
aroundPrecision: 0,
|
||||
minimumAroundRadius: 0,
|
||||
insideBoundingBox: '',
|
||||
queryType: '',
|
||||
insidePolygon: '',
|
||||
removeWordsIfNoResults: '',
|
||||
advancedSyntax: false,
|
||||
optionalWords: [''],
|
||||
removeStopWords: [''],
|
||||
disableExactOnAttributes: [''],
|
||||
exactOnSingleWordQuery: '',
|
||||
alternativesAsExact: true,
|
||||
distinct: 0,
|
||||
getRankingInfo: false,
|
||||
numericAttributesToIndex: [''],
|
||||
numericFilters: [''],
|
||||
tagFilters: '',
|
||||
facetFilters: '',
|
||||
analytics: false,
|
||||
analyticsTags: [''],
|
||||
synonyms: true,
|
||||
replaceSynonymsInHighlight: false,
|
||||
minProximity: 0
|
||||
};
|
||||
|
||||
var index: AlgoliaIndex = algoliasearch('', '').initIndex('');
|
||||
|
||||
var search = index.search({query: ""});
|
||||
index.search({query: ""}, function(err, res){});
|
||||
|
||||
|
||||
Vendored
-1528
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"algoliasearch-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-166
@@ -1,166 +0,0 @@
|
||||
// Type definitions for Alt 0.16.10
|
||||
// Project: https://github.com/goatslacker/alt
|
||||
// Definitions by: Michael Shearer <https://github.com/Shearerbeard>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference types="react"/>
|
||||
|
||||
declare namespace AltJS {
|
||||
|
||||
interface StoreReduce {
|
||||
action:any;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export interface StoreModel<S> {
|
||||
//Actions
|
||||
bindAction?( action:Action<any>, handler:ActionHandler):void;
|
||||
bindActions?(actions:ActionsClass):void;
|
||||
|
||||
//Methods/Listeners
|
||||
exportPublicMethods?(exportConfig:any):void;
|
||||
bindListeners?(config:{[methodName:string]:Action<any> | Actions}):void;
|
||||
exportAsync?(source:Source):void;
|
||||
registerAsync?(datasource:Source):void;
|
||||
|
||||
//state
|
||||
setState?(state:S):void;
|
||||
setState?(stateFn:(currentState:S, nextState:S) => S):void;
|
||||
getState?():S;
|
||||
waitFor?(store:AltStore<any>):void;
|
||||
|
||||
//events
|
||||
onSerialize?(fn:(data:any) => any):void;
|
||||
onDeserialize?(fn:(data:any) => any):void;
|
||||
on?(event:AltJS.lifeCycleEvents, callback:() => any):void;
|
||||
emitChange?():void;
|
||||
waitFor?(storeOrStores:AltStore<any> | Array<AltStore<any>>):void;
|
||||
otherwise?(data:any, action:AltJS.Action<any>):void;
|
||||
observe?(alt:Alt):any;
|
||||
reduce?(state:any, config:StoreReduce):Object;
|
||||
preventDefault?():void;
|
||||
afterEach?(payload:Object, state:Object):void;
|
||||
beforeEach?(payload:Object, state:Object):void;
|
||||
// TODO: Embed dispatcher interface in def
|
||||
dispatcher?:any;
|
||||
|
||||
//instance
|
||||
getInstance?():AltJS.AltStore<S>;
|
||||
alt?:Alt;
|
||||
displayName?:string;
|
||||
}
|
||||
|
||||
export type Source = {[name:string]: () => SourceModel<any>};
|
||||
|
||||
export interface SourceModel<S> {
|
||||
local(state:any, ...args: any[]):any;
|
||||
remote(state:any, ...args: any[]):Promise<S>;
|
||||
shouldFetch?(fetchFn:(...args:Array<any>) => boolean):void;
|
||||
loading?:(args:any) => void;
|
||||
success?:(state:S) => void;
|
||||
error?:(args:any) => void;
|
||||
interceptResponse?(response:any, action:Action<any>, ...args:Array<any>):any;
|
||||
}
|
||||
|
||||
export interface AltStore<S> {
|
||||
getState():S;
|
||||
listen(handler:(state:S) => any):() => void;
|
||||
unlisten(handler:(state:S) => any):void;
|
||||
emitChange():void;
|
||||
}
|
||||
|
||||
export enum lifeCycleEvents {
|
||||
bootstrap,
|
||||
snapshot,
|
||||
init,
|
||||
rollback,
|
||||
error
|
||||
}
|
||||
|
||||
export type Actions = {[action:string]:Action<any>};
|
||||
|
||||
export interface Action<T> {
|
||||
( args:T):void;
|
||||
defer(data:any):void;
|
||||
}
|
||||
|
||||
export interface ActionsClass {
|
||||
generateActions?( ...action:Array<string>):void;
|
||||
dispatch( ...payload:Array<any>):void;
|
||||
actions?:Actions;
|
||||
}
|
||||
|
||||
type StateTransform = (store:StoreModel<any>) => AltJS.AltStore<any>;
|
||||
|
||||
interface AltConfig {
|
||||
dispatcher?:any;
|
||||
serialize?:(serializeFn:(data:Object) => string) => void;
|
||||
deserialize?:(deserializeFn:(serialData:string) => Object) => void;
|
||||
storeTransforms?:Array<StateTransform>;
|
||||
batchingFunction?:(callback:( ...data:Array<any>) => any) => void;
|
||||
}
|
||||
|
||||
class Alt {
|
||||
constructor(config?:AltConfig);
|
||||
actions:Actions;
|
||||
bootstrap(jsonData:string):void;
|
||||
takeSnapshot( ...storeNames:Array<string>):string;
|
||||
flush():Object;
|
||||
recycle( ...stores:Array<AltJS.AltStore<any>>):void;
|
||||
rollback():void;
|
||||
dispatch(action?:AltJS.Action<any>, data?:Object, details?:any):void;
|
||||
|
||||
//Actions methods
|
||||
addActions(actionsName:string, ActionsClass: ActionsClassConstructor):void;
|
||||
createActions<T>(ActionsClass: ActionsClassConstructor, exportObj?: Object):T;
|
||||
createActions<T>(ActionsClass: ActionsClassConstructor, exportObj?: Object, ...constructorArgs:Array<any>):T;
|
||||
generateActions<T>( ...actions:Array<string>):T;
|
||||
getActions(actionsName:string):AltJS.Actions;
|
||||
|
||||
//Stores methods
|
||||
addStore(name:string, store:StoreModel<any>, saveStore?:boolean):void;
|
||||
createStore<S>(store:StoreModel<S>, name?:string):AltJS.AltStore<S>;
|
||||
getStore(name:string):AltJS.AltStore<any>;
|
||||
}
|
||||
|
||||
export interface AltFactory {
|
||||
new(config?:AltConfig):Alt;
|
||||
}
|
||||
|
||||
type ActionsClassConstructor = new (alt:Alt) => AltJS.ActionsClass;
|
||||
|
||||
type ActionHandler = ( ...data:Array<any>) => any;
|
||||
type ExportConfig = {[key:string]:(...args:Array<any>) => any};
|
||||
}
|
||||
|
||||
declare module "alt/utils/chromeDebug" {
|
||||
function chromeDebug(alt:AltJS.Alt):void;
|
||||
export = chromeDebug;
|
||||
}
|
||||
|
||||
declare module "alt/AltContainer" {
|
||||
|
||||
import React = require("react");
|
||||
|
||||
interface ContainerProps {
|
||||
store?:AltJS.AltStore<any>;
|
||||
stores?:Array<AltJS.AltStore<any>>;
|
||||
inject?:{[key:string]:any};
|
||||
actions?:{[key:string]:Object};
|
||||
render?:(...props:Array<any>) => React.ReactElement<any>;
|
||||
flux?:AltJS.Alt;
|
||||
transform?:(store:AltJS.AltStore<any>, actions:any) => any;
|
||||
shouldComponentUpdate?:(props:any) => boolean;
|
||||
component?:React.Component<any, any>;
|
||||
}
|
||||
|
||||
type AltContainer = React.ReactElement<ContainerProps>;
|
||||
var AltContainer:React.ComponentClass<ContainerProps>;
|
||||
|
||||
export = AltContainer;
|
||||
}
|
||||
|
||||
declare module "alt" {
|
||||
var alt:AltJS.AltFactory;
|
||||
export = alt;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"alt-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amazon-product-api-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-2603
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": false,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
amplify.request({
|
||||
resourceId: "statusExample1"
|
||||
}).done(function (data, status) {
|
||||
}).fail(function (data, status) {
|
||||
}).always(function (data, status) { });
|
||||
Vendored
-30
@@ -1,30 +0,0 @@
|
||||
// Type definitions for AmplifyJs (using JQuery Deferred) 1.1
|
||||
// Project: http://amplifyjs.com/
|
||||
// Definitions by: Jonas Eriksson <https://github.com/joeriks/>, Laurentiu Stamate <https://github.com/laurentiustamate94>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
import * as amplify from "amplify";
|
||||
|
||||
declare module "amplify" {
|
||||
interface Request {
|
||||
/***
|
||||
* Request a resource.
|
||||
* resourceId: Identifier string for the resource.
|
||||
* data: A set of key/value pairs of data to be sent to the resource.
|
||||
* callback: A function to invoke if the resource is retrieved successfully.
|
||||
*/
|
||||
(resourceId: string, hash?: any, callback?: Function): JQueryPromise<any>;
|
||||
|
||||
/***
|
||||
* Request a resource.
|
||||
* settings: A set of key/value pairs of settings for the request.
|
||||
* resourceId: Identifier string for the resource.
|
||||
* data (optional): Data associated with the request.
|
||||
* success (optional): Function to invoke on success.
|
||||
* error (optional): Function to invoke on error.
|
||||
*/
|
||||
(settings: RequestSettings): JQueryPromise<any>;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": false,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amplify-deferred-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
}
|
||||
}
|
||||
@@ -1,263 +0,0 @@
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
import amplify = require("amplify");
|
||||
|
||||
// Copied examples directly from AmplifyJs site
|
||||
|
||||
// Subscribe and publish with no data
|
||||
|
||||
amplify.subscribe("nodataexample", function () {
|
||||
alert("nodataexample topic published!");
|
||||
});
|
||||
|
||||
// Subscribe and publish with data
|
||||
|
||||
amplify.publish("nodataexample");
|
||||
|
||||
amplify.subscribe("dataexample", function (data) {
|
||||
alert(data.foo); // bar
|
||||
});
|
||||
|
||||
|
||||
amplify.publish("dataexample", { foo: "bar" });
|
||||
|
||||
amplify.subscribe("dataexample2", function (param1, param2) {
|
||||
alert(param1 + param2); // barbaz
|
||||
});
|
||||
|
||||
//...
|
||||
|
||||
amplify.publish("dataexample2", "bar", "baz");
|
||||
|
||||
// Subscribe and publish with context and data
|
||||
|
||||
amplify.subscribe("datacontextexample", $("p:first"), function (data) {
|
||||
this.text(data.exampleText); // first p element would have "foo bar baz" as text
|
||||
});
|
||||
|
||||
amplify.publish("datacontextexample", { exampleText: "foo bar baz" });
|
||||
|
||||
// Subscribe to a topic with high priority
|
||||
|
||||
amplify.subscribe("priorityexample", function (data) {
|
||||
alert(data.foo);
|
||||
});
|
||||
|
||||
amplify.subscribe("priorityexample", function (data) {
|
||||
if (data.foo === "oops") {
|
||||
return false;
|
||||
}
|
||||
}, 1);
|
||||
|
||||
|
||||
// Store data with amplify storage picking the default storage technology:
|
||||
|
||||
amplify.publish("priorityexample", { foo: "bar" });
|
||||
amplify.publish("priorityexample", { foo: "oops" });
|
||||
|
||||
amplify.store("storeExample1", { foo: "bar" });
|
||||
amplify.store("storeExample2", "baz");
|
||||
// retrieve the data later via the key
|
||||
var myStoredValue = amplify.store("storeExample1"),
|
||||
myStoredValue2 = amplify.store("storeExample2"),
|
||||
myStoredValues = amplify.store();
|
||||
myStoredValue.foo; // bar
|
||||
myStoredValue2; // baz
|
||||
myStoredValues.storeExample1.foo; // bar
|
||||
myStoredValues.storeExample2; // baz
|
||||
|
||||
// Store data explicitly with session storage
|
||||
|
||||
amplify.store.sessionStorage("explicitExample", { foo2: "baz" });
|
||||
// retrieve the data later via the key
|
||||
var myStoredValue2 = amplify.store.sessionStorage("explicitExample");
|
||||
myStoredValue2.foo2; // baz
|
||||
|
||||
|
||||
// REQUEST
|
||||
|
||||
// Set up and use a request utilizing Ajax
|
||||
|
||||
|
||||
amplify.request.define("ajaxExample1", "ajax", {
|
||||
url: "/myApiUrl",
|
||||
dataType: "json",
|
||||
type: "GET"
|
||||
});
|
||||
|
||||
// later in code
|
||||
amplify.request("ajaxExample1", function (data) {
|
||||
data.foo; // bar
|
||||
});
|
||||
|
||||
// Set up and use a request utilizing Ajax and Caching
|
||||
|
||||
amplify.request.define("ajaxExample2", "ajax", {
|
||||
url: "/myApiUrl",
|
||||
dataType: "json",
|
||||
type: "GET",
|
||||
cache: "persist"
|
||||
});
|
||||
|
||||
// later in code
|
||||
amplify.request("ajaxExample2", function (data) {
|
||||
data.foo; // bar
|
||||
});
|
||||
|
||||
// a second call will result in pulling from the cache
|
||||
amplify.request("ajaxExample2", function (data) {
|
||||
data.baz; // qux
|
||||
})
|
||||
|
||||
// Set up and use a RESTful request utilizing Ajax
|
||||
|
||||
amplify.request.define("ajaxRESTFulExample", "ajax", {
|
||||
url: "/myRestFulApi/{type}/{id}",
|
||||
type: "GET"
|
||||
})
|
||||
|
||||
// later in code
|
||||
amplify.request("ajaxRESTFulExample",
|
||||
{
|
||||
type: "foo",
|
||||
id: "bar"
|
||||
},
|
||||
function (data) {
|
||||
// /myRESTFulApi/foo/bar was the URL used
|
||||
data.foo; // bar
|
||||
}
|
||||
);
|
||||
|
||||
// POST data with Ajax
|
||||
|
||||
amplify.request.define("ajaxPostExample", "ajax", {
|
||||
url: "/myRestFulApi",
|
||||
type: "POST"
|
||||
})
|
||||
|
||||
// later in code
|
||||
amplify.request("ajaxPostExample",
|
||||
{
|
||||
type: "foo",
|
||||
id: "bar"
|
||||
},
|
||||
function (data) {
|
||||
data.foo; // bar
|
||||
}
|
||||
);
|
||||
// Using data maps
|
||||
|
||||
// When searching Twitter, the key for the search phrase is q.If we want a more descriptive name, such as term, we can use a data map:
|
||||
|
||||
amplify.request.define("twitter-search", "ajax", {
|
||||
url: "http://search.twitter.com/search.json",
|
||||
dataType: "jsonp",
|
||||
dataMap: {
|
||||
term: "q"
|
||||
}
|
||||
});
|
||||
|
||||
amplify.request("twitter-search", { term: "amplifyjs" } );
|
||||
|
||||
// Similarly, we can create a request that searches for mentions, by accepting a username:
|
||||
|
||||
amplify.request.define("twitter-mentions", "ajax", {
|
||||
url: "http://search.twitter.com/search.json",
|
||||
dataType: "jsonp",
|
||||
dataMap: function (data) {
|
||||
return {
|
||||
q: "@" + data.user
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
amplify.request("twitter-mentions", { user: "amplifyjs" });
|
||||
|
||||
// Setting up and using decoders
|
||||
|
||||
//Example:
|
||||
|
||||
var appEnvelopeDecoder: amplify.Decoder = function (data, status, xhr, success, error) {
|
||||
if (data.status === "success") {
|
||||
success(data.data);
|
||||
} else if (data.status === "fail" || data.status === "error") {
|
||||
error(data.message, data.status);
|
||||
} else {
|
||||
error(data.message, "fatal");
|
||||
}
|
||||
};
|
||||
|
||||
//a new decoder can be added to the amplifyDecoders interface
|
||||
declare module "amplify" {
|
||||
interface Decoders {
|
||||
appEnvelope: amplify.Decoder;
|
||||
}
|
||||
}
|
||||
|
||||
amplify.request.decoders.appEnvelope = appEnvelopeDecoder;
|
||||
|
||||
//but you can also just add it via an index
|
||||
amplify.request.decoders['appEnvelopeStr'] = appEnvelopeDecoder;
|
||||
|
||||
|
||||
amplify.request.define("decoderExample", "ajax", {
|
||||
url: "/myAjaxUrl",
|
||||
type: "POST",
|
||||
decoder: "appEnvelope"
|
||||
});
|
||||
|
||||
amplify.request({
|
||||
resourceId: "decoderExample",
|
||||
success: function (data) {
|
||||
data.foo; // bar
|
||||
},
|
||||
error: function (message, level) {
|
||||
alert("always handle errors with alerts.");
|
||||
}
|
||||
});
|
||||
|
||||
// POST with caching and single - use decoder
|
||||
|
||||
// Example:
|
||||
|
||||
amplify.request.define("decoderSingleExample", "ajax", {
|
||||
url: "/myAjaxUrl",
|
||||
type: "POST",
|
||||
decoder: function (data, status, xhr, success, error) {
|
||||
if (data.status === "success") {
|
||||
success(data.data);
|
||||
} else if (data.status === "fail" || data.status === "error") {
|
||||
error(data.message, data.status);
|
||||
} else {
|
||||
error(data.message, "fatal");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
amplify.request({
|
||||
resourceId: "decoderSingleExample",
|
||||
success: function (data) {
|
||||
data.foo; // bar
|
||||
},
|
||||
error: function (message, level) {
|
||||
alert("always handle errors with alerts.");
|
||||
}
|
||||
});
|
||||
// Handling Status
|
||||
// Status in Success and Error Callbacks
|
||||
|
||||
// amplify.request comes with built in support for status.The status parameter appears in the default success or error callbacks when using an ajax definition.
|
||||
|
||||
amplify.request.define("statusExample1", "ajax", {
|
||||
//...
|
||||
});
|
||||
|
||||
amplify.request({
|
||||
resourceId: "statusExample1",
|
||||
success: function (data, status) {
|
||||
},
|
||||
error: function (data, status) {
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
-177
@@ -1,177 +0,0 @@
|
||||
// Type definitions for AmplifyJs 1.1
|
||||
// Project: http://amplifyjs.com/
|
||||
// Definitions by: Jonas Eriksson <https://github.com/joeriks/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
declare namespace amplify {
|
||||
interface RequestSettings {
|
||||
resourceId: string;
|
||||
data?: any;
|
||||
success?: (...args: any[]) => void;
|
||||
error?: (...args: any[]) => void;
|
||||
}
|
||||
|
||||
type Decoder =
|
||||
(
|
||||
data?: any,
|
||||
status?: string,
|
||||
xhr?: JQueryXHR,
|
||||
success?: (...args: any[]) => void,
|
||||
error?: (...args: any[]) => void
|
||||
) => void;
|
||||
|
||||
interface Decoders {
|
||||
[decoderName: string]: Decoder;
|
||||
jsSend: Decoder;
|
||||
}
|
||||
|
||||
interface AjaxSettings extends JQueryAjaxSettings {
|
||||
cache?: any;
|
||||
dataMap?: {} | ((data: any) => {});
|
||||
decoder?: any /* string or amplifyDecoder */;
|
||||
}
|
||||
|
||||
interface Request {
|
||||
|
||||
/***
|
||||
* Request a resource.
|
||||
* resourceId: Identifier string for the resource.
|
||||
* data: A set of key/value pairs of data to be sent to the resource.
|
||||
* callback: A function to invoke if the resource is retrieved successfully.
|
||||
*/
|
||||
(resourceId: string, hash?: any, callback?: Function): void;
|
||||
|
||||
/***
|
||||
* Request a resource.
|
||||
* settings: A set of key/value pairs of settings for the request.
|
||||
* resourceId: Identifier string for the resource.
|
||||
* data (optional): Data associated with the request.
|
||||
* success (optional): Function to invoke on success.
|
||||
* error (optional): Function to invoke on error.
|
||||
*/
|
||||
(settings: RequestSettings): any;
|
||||
|
||||
/***
|
||||
* Define a resource.
|
||||
* resourceId: Identifier string for the resource.
|
||||
* requestType: The type of data retrieval method from the server. See the request types sections for more information.
|
||||
* settings: A set of key/value pairs that relate to the server communication technology. The following settings are available:
|
||||
* Any settings found in jQuery.ajax().
|
||||
* cache: See the cache section for more details.
|
||||
* decoder: See the decoder section for more details.
|
||||
*/
|
||||
define(resourceId: string, requestType: string, settings?: AjaxSettings): void;
|
||||
|
||||
/***
|
||||
* Define a custom request.
|
||||
* resourceId: Identifier string for the resource.
|
||||
* resource: Function to handle requests. Receives a hash with the following properties:
|
||||
* resourceId: Identifier string for the resource.
|
||||
* data: Data provided by the user.
|
||||
* success: Callback to invoke on success.
|
||||
* error: Callback to invoke on error.
|
||||
*/
|
||||
define(resourceId: string, resource: (settings: RequestSettings) => void): void;
|
||||
|
||||
decoders: Decoders;
|
||||
cache: any;
|
||||
}
|
||||
|
||||
interface Subscribe {
|
||||
/***
|
||||
* Subscribe to a message.
|
||||
* topic: Name of the message to subscribe to.
|
||||
* callback: Function to invoke when the message is published.
|
||||
* [priority]: Priority relative to other subscriptions for the same message. Lower values have higher priority. Default is 10.
|
||||
*/
|
||||
(topic: string, callback: Function, priority?: number): void;
|
||||
/***
|
||||
* Subscribe to a message.
|
||||
* topic: Name of the message to subscribe to.
|
||||
* context: What this will be when the callback is invoked.
|
||||
* callback: Function to invoke when the message is published.
|
||||
* [priority]: Priority relative to other subscriptions for the same message. Lower values have higher priority. Default is 10.
|
||||
*/
|
||||
(topic: string, context: any, callback: Function, priority?: number): void;
|
||||
}
|
||||
interface StorageTypeStore {
|
||||
/***
|
||||
* Stores a value for a given key using the default storage type.
|
||||
*
|
||||
* key: Identifier for the value being stored.
|
||||
* value: The value to store. The value can be anything that can be serialized as JSON.
|
||||
* [options]: A set of key/value pairs that relate to settings for storing the value.
|
||||
*/
|
||||
(key: string, value: any, options?: any): void;
|
||||
|
||||
/***
|
||||
* Gets a stored value based on the key.
|
||||
*/
|
||||
(key: string): any;
|
||||
|
||||
/***
|
||||
* Gets a hash of all stored values.
|
||||
*/
|
||||
(): any;
|
||||
}
|
||||
|
||||
interface Store extends StorageTypeStore {
|
||||
|
||||
/***
|
||||
* IE 8+, Firefox 3.5+, Safari 4+, Chrome, Opera 10.5+, iPhone 2+, Android 2+
|
||||
*/
|
||||
localStorage: StorageTypeStore;
|
||||
|
||||
/***
|
||||
* IE 8+, Firefox 2+, Safari 4+, Chrome, Opera 10.5+, iPhone 2+, Android 2+
|
||||
*/
|
||||
sessionStorage: StorageTypeStore;
|
||||
|
||||
/***
|
||||
* Firefox 2+
|
||||
*/
|
||||
globalStorage: StorageTypeStore;
|
||||
|
||||
/***
|
||||
* IE 5 - 7
|
||||
*/
|
||||
userData: StorageTypeStore;
|
||||
|
||||
/***
|
||||
* An in-memory store is provided as a fallback if none of the other storage types are available.
|
||||
*/
|
||||
memory: StorageTypeStore;
|
||||
|
||||
|
||||
}
|
||||
|
||||
interface Static {
|
||||
|
||||
subscribe: Subscribe;
|
||||
|
||||
/***
|
||||
* Remove a subscription.
|
||||
* topic: The topic being unsubscribed from.
|
||||
* callback: The callback that was originally subscribed.
|
||||
*/
|
||||
unsubscribe(topic: string, callback: Function): void;
|
||||
|
||||
/***
|
||||
* Publish a message.
|
||||
* topic: The name of the message to publish.
|
||||
* Any additional parameters will be passed to the subscriptions.
|
||||
* amplify.publish returns a boolean indicating whether any subscriptions returned false. The return value is true if none of the subscriptions returned false, and false otherwise. Note that only one subscription can return false because doing so will prevent additional subscriptions from being invoked.
|
||||
*/
|
||||
publish(topic: string, ...args: any[]): boolean;
|
||||
|
||||
store: Store;
|
||||
|
||||
request: Request;
|
||||
}
|
||||
}
|
||||
|
||||
declare var amplify: amplify.Static;
|
||||
export = amplify;
|
||||
export as namespace amplify;
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": false,
|
||||
"noImplicitThis": false,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amplifyjs-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amplitude-js-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amqp-rpc-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-219
@@ -1,219 +0,0 @@
|
||||
// Type definitions for amqplib 0.3.x
|
||||
// Project: https://github.com/squaremo/amqp.node
|
||||
// Definitions by: Michael Nahkies <https://github.com/mnahkies>, Ab Reitsma <https://github.com/abreits>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="when" />
|
||||
/// <reference types="node" />
|
||||
|
||||
declare module "amqplib/properties" {
|
||||
namespace Replies {
|
||||
interface Empty {
|
||||
}
|
||||
interface AssertQueue {
|
||||
queue: string;
|
||||
messageCount: number;
|
||||
consumerCount: number;
|
||||
}
|
||||
interface PurgeQueue {
|
||||
messageCount: number;
|
||||
}
|
||||
interface DeleteQueue {
|
||||
messageCount: number;
|
||||
}
|
||||
interface AssertExchange {
|
||||
exchange: string;
|
||||
}
|
||||
interface Consume {
|
||||
consumerTag: string;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Options {
|
||||
interface AssertQueue {
|
||||
exclusive?: boolean;
|
||||
durable?: boolean;
|
||||
autoDelete?: boolean;
|
||||
arguments?: any;
|
||||
messageTtl?: number;
|
||||
expires?: number;
|
||||
deadLetterExchange?: string;
|
||||
deadLetterRoutingKey?: string;
|
||||
maxLength?: number;
|
||||
}
|
||||
interface DeleteQueue {
|
||||
ifUnused?: boolean;
|
||||
ifEmpty?: boolean;
|
||||
}
|
||||
interface AssertExchange {
|
||||
durable?: boolean;
|
||||
internal?: boolean;
|
||||
autoDelete?: boolean;
|
||||
alternateExchange?: string;
|
||||
arguments?: any;
|
||||
}
|
||||
interface DeleteExchange {
|
||||
ifUnused?: boolean;
|
||||
}
|
||||
interface Publish {
|
||||
expiration?: string;
|
||||
userId?: string;
|
||||
CC?: string | string[];
|
||||
|
||||
mandatory?: boolean;
|
||||
persistent?: boolean;
|
||||
deliveryMode?: boolean | number;
|
||||
BCC?: string | string[];
|
||||
|
||||
contentType?: string;
|
||||
contentEncoding?: string;
|
||||
headers?: any;
|
||||
priority?: number;
|
||||
correlationId?: string;
|
||||
replyTo?: string;
|
||||
messageId?: string;
|
||||
timestamp?: number;
|
||||
type?: string;
|
||||
appId?: string;
|
||||
}
|
||||
interface Consume {
|
||||
consumerTag?: string;
|
||||
noLocal?: boolean;
|
||||
noAck?: boolean;
|
||||
exclusive?: boolean;
|
||||
priority?: number;
|
||||
arguments?: any;
|
||||
}
|
||||
interface Get {
|
||||
noAck?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
interface Message {
|
||||
content: Buffer;
|
||||
fields: any;
|
||||
properties: any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "amqplib" {
|
||||
|
||||
import events = require("events");
|
||||
import when = require("when");
|
||||
import shared = require("amqplib/properties")
|
||||
export import Replies = shared.Replies;
|
||||
export import Options = shared.Options;
|
||||
export import Message = shared.Message;
|
||||
|
||||
interface Connection extends events.EventEmitter {
|
||||
close(): when.Promise<void>;
|
||||
createChannel(): when.Promise<Channel>;
|
||||
createConfirmChannel(): when.Promise<Channel>;
|
||||
}
|
||||
|
||||
interface Channel extends events.EventEmitter {
|
||||
close(): when.Promise<void>;
|
||||
|
||||
assertQueue(queue: string, options?: Options.AssertQueue): when.Promise<Replies.AssertQueue>;
|
||||
checkQueue(queue: string): when.Promise<Replies.AssertQueue>;
|
||||
|
||||
deleteQueue(queue: string, options?: Options.DeleteQueue): when.Promise<Replies.DeleteQueue>;
|
||||
purgeQueue(queue: string): when.Promise<Replies.PurgeQueue>;
|
||||
|
||||
bindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
unbindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
|
||||
assertExchange(exchange: string, type: string, options?: Options.AssertExchange): when.Promise<Replies.AssertExchange>;
|
||||
checkExchange(exchange: string): when.Promise<Replies.Empty>;
|
||||
|
||||
deleteExchange(exchange: string, options?: Options.DeleteExchange): when.Promise<Replies.Empty>;
|
||||
|
||||
bindExchange(destination: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
unbindExchange(destination: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
|
||||
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume): when.Promise<Replies.Consume>;
|
||||
|
||||
cancel(consumerTag: string): when.Promise<Replies.Empty>;
|
||||
get(queue: string, options?: Options.Get): when.Promise<Message | boolean>;
|
||||
|
||||
ack(message: Message, allUpTo?: boolean): void;
|
||||
ackAll(): void;
|
||||
|
||||
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
|
||||
nackAll(requeue?: boolean): void;
|
||||
reject(message: Message, requeue?: boolean): void;
|
||||
|
||||
prefetch(count: number, global?: boolean): when.Promise<Replies.Empty>;
|
||||
recover(): when.Promise<Replies.Empty>;
|
||||
}
|
||||
|
||||
function connect(url: string, socketOptions?: any): when.Promise<Connection>;
|
||||
}
|
||||
|
||||
declare module "amqplib/callback_api" {
|
||||
|
||||
import events = require("events");
|
||||
import shared = require("amqplib/properties")
|
||||
export import Replies = shared.Replies;
|
||||
export import Options = shared.Options;
|
||||
export import Message = shared.Message;
|
||||
|
||||
interface Connection extends events.EventEmitter {
|
||||
close(callback?: (err: any) => void): void;
|
||||
createChannel(callback: (err: any, channel: Channel) => void): void;
|
||||
createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void;
|
||||
}
|
||||
|
||||
interface Channel extends events.EventEmitter {
|
||||
close(callback: (err: any) => void): void;
|
||||
|
||||
assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void): void;
|
||||
checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
|
||||
|
||||
deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void): void;
|
||||
purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void): void;
|
||||
|
||||
bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void): void;
|
||||
checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
|
||||
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void;
|
||||
|
||||
cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void): void;
|
||||
|
||||
ack(message: Message, allUpTo?: boolean): void;
|
||||
ackAll(): void;
|
||||
|
||||
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
|
||||
nackAll(requeue?: boolean): void;
|
||||
reject(message: Message, requeue?: boolean): void;
|
||||
|
||||
prefetch(count: number, global?: boolean): void;
|
||||
recover(callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
}
|
||||
|
||||
interface ConfirmChannel extends Channel {
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
|
||||
|
||||
waitForConfirms(callback?: (err: any) => void): void;
|
||||
}
|
||||
|
||||
function connect(callback: (err: any, connection: Connection) => void): void;
|
||||
function connect(url: string, callback: (err: any, connection: Connection) => void): void;
|
||||
function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void): void;
|
||||
}
|
||||
Vendored
-226
@@ -1,226 +0,0 @@
|
||||
// Type definitions for amqplib 0.5.x
|
||||
// Project: https://github.com/squaremo/amqp.node
|
||||
// Definitions by: Michael Nahkies <https://github.com/mnahkies>, Ab Reitsma <https://github.com/abreits>, Nicolás Fantone <https://github.com/nfantone>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare module 'amqplib' {
|
||||
import * as Promise from 'bluebird';
|
||||
import * as events from 'events';
|
||||
import shared = require('amqplib/properties');
|
||||
|
||||
export import Replies = shared.Replies;
|
||||
export import Options = shared.Options;
|
||||
export import Message = shared.Message;
|
||||
|
||||
export interface Connection extends events.EventEmitter {
|
||||
close(): Promise<void>;
|
||||
createChannel(): Promise<Channel>;
|
||||
createConfirmChannel(): Promise<ConfirmChannel>;
|
||||
}
|
||||
|
||||
export interface Channel extends events.EventEmitter {
|
||||
close(): Promise<void>;
|
||||
|
||||
assertQueue(queue: string, options?: Options.AssertQueue): Promise<Replies.AssertQueue>;
|
||||
checkQueue(queue: string): Promise<Replies.AssertQueue>;
|
||||
|
||||
deleteQueue(queue: string, options?: Options.DeleteQueue): Promise<Replies.DeleteQueue>;
|
||||
purgeQueue(queue: string): Promise<Replies.PurgeQueue>;
|
||||
|
||||
bindQueue(queue: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
|
||||
unbindQueue(queue: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
|
||||
|
||||
assertExchange(exchange: string, type: string, options?: Options.AssertExchange): Promise<Replies.AssertExchange>;
|
||||
checkExchange(exchange: string): Promise<Replies.Empty>;
|
||||
|
||||
deleteExchange(exchange: string, options?: Options.DeleteExchange): Promise<Replies.Empty>;
|
||||
|
||||
bindExchange(destination: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
|
||||
unbindExchange(destination: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
|
||||
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
|
||||
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume): Promise<Replies.Consume>;
|
||||
|
||||
cancel(consumerTag: string): Promise<Replies.Empty>;
|
||||
get(queue: string, options?: Options.Get): Promise<Message | boolean>;
|
||||
|
||||
ack(message: Message, allUpTo?: boolean): void;
|
||||
ackAll(): void;
|
||||
|
||||
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
|
||||
nackAll(requeue?: boolean): void;
|
||||
reject(message: Message, requeue?: boolean): void;
|
||||
|
||||
prefetch(count: number, global?: boolean): Promise<Replies.Empty>;
|
||||
recover(): Promise<Replies.Empty>;
|
||||
}
|
||||
|
||||
export interface ConfirmChannel extends Channel {
|
||||
publish(exchange:string, routingKey:string, content:Buffer, options?:Options.Publish, callback?:(err:any, ok:Replies.Empty) => void):boolean;
|
||||
sendToQueue(queue:string, content:Buffer, options?:Options.Publish, callback?:(err:any, ok:Replies.Empty) => void):boolean;
|
||||
|
||||
waitForConfirms(): Promise<void>;
|
||||
}
|
||||
|
||||
export function connect(url: string, socketOptions?: any): Promise<Connection>;
|
||||
}
|
||||
|
||||
declare module 'amqplib/properties' {
|
||||
export namespace Replies {
|
||||
interface Empty {
|
||||
}
|
||||
interface AssertQueue {
|
||||
queue: string;
|
||||
messageCount: number;
|
||||
consumerCount: number;
|
||||
}
|
||||
interface PurgeQueue {
|
||||
messageCount: number;
|
||||
}
|
||||
interface DeleteQueue {
|
||||
messageCount: number;
|
||||
}
|
||||
interface AssertExchange {
|
||||
exchange: string;
|
||||
}
|
||||
interface Consume {
|
||||
consumerTag: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Options {
|
||||
interface AssertQueue {
|
||||
exclusive?: boolean;
|
||||
durable?: boolean;
|
||||
autoDelete?: boolean;
|
||||
arguments?: any;
|
||||
messageTtl?: number;
|
||||
expires?: number;
|
||||
deadLetterExchange?: string;
|
||||
deadLetterRoutingKey?: string;
|
||||
maxLength?: number;
|
||||
maxPriority?: number;
|
||||
}
|
||||
interface DeleteQueue {
|
||||
ifUnused?: boolean;
|
||||
ifEmpty?: boolean;
|
||||
}
|
||||
interface AssertExchange {
|
||||
durable?: boolean;
|
||||
internal?: boolean;
|
||||
autoDelete?: boolean;
|
||||
alternateExchange?: string;
|
||||
arguments?: any;
|
||||
}
|
||||
interface DeleteExchange {
|
||||
ifUnused?: boolean;
|
||||
}
|
||||
interface Publish {
|
||||
expiration?: string | number;
|
||||
userId?: string;
|
||||
CC?: string | string[];
|
||||
|
||||
mandatory?: boolean;
|
||||
persistent?: boolean;
|
||||
deliveryMode?: boolean | number;
|
||||
BCC?: string | string[];
|
||||
|
||||
contentType?: string;
|
||||
contentEncoding?: string;
|
||||
headers?: any;
|
||||
priority?: number;
|
||||
correlationId?: string;
|
||||
replyTo?: string;
|
||||
messageId?: string;
|
||||
timestamp?: number;
|
||||
type?: string;
|
||||
appId?: string;
|
||||
}
|
||||
interface Consume {
|
||||
consumerTag?: string;
|
||||
noLocal?: boolean;
|
||||
noAck?: boolean;
|
||||
exclusive?: boolean;
|
||||
priority?: number;
|
||||
arguments?: any;
|
||||
}
|
||||
interface Get {
|
||||
noAck?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
content: Buffer;
|
||||
fields: any;
|
||||
properties: any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'amqplib/callback_api' {
|
||||
import events = require('events');
|
||||
import shared = require('amqplib/properties')
|
||||
|
||||
export import Replies = shared.Replies;
|
||||
export import Options = shared.Options;
|
||||
export import Message = shared.Message;
|
||||
|
||||
export interface Connection extends events.EventEmitter {
|
||||
close(callback?: (err: any) => void): void;
|
||||
createChannel(callback: (err: any, channel: Channel) => void): void;
|
||||
createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void;
|
||||
}
|
||||
|
||||
export interface Channel extends events.EventEmitter {
|
||||
close(callback: (err: any) => void): void;
|
||||
|
||||
assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
|
||||
checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
|
||||
|
||||
deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err: any, ok: Replies.DeleteQueue) => void): void;
|
||||
purgeQueue(queue: string, callback?: (err: any, ok: Replies.PurgeQueue) => void): void;
|
||||
|
||||
bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void): void;
|
||||
checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
|
||||
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void;
|
||||
|
||||
cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void): void;
|
||||
|
||||
ack(message: Message, allUpTo?: boolean): void;
|
||||
ackAll(): void;
|
||||
|
||||
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
|
||||
nackAll(requeue?: boolean): void;
|
||||
reject(message: Message, requeue?: boolean): void;
|
||||
|
||||
prefetch(count: number, global?: boolean): void;
|
||||
recover(callback?: (err: any, ok: Replies.Empty) => void): void;
|
||||
}
|
||||
|
||||
export interface ConfirmChannel extends Channel {
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
|
||||
|
||||
waitForConfirms(callback?: (err: any) => void): void;
|
||||
}
|
||||
|
||||
export function connect(callback: (err: any, connection: Connection) => void): void;
|
||||
export function connect(url: string, callback: (err: any, connection: Connection) => void): void;
|
||||
export function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void): void;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amqplib-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"analytics-node-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-106
@@ -1,106 +0,0 @@
|
||||
// Type definitions for AngularAgility
|
||||
// Project: https://github.com/AngularAgility/AngularAgility
|
||||
// Definitions by: Roland Zwaga <https://github.com/rolandzwaga>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="angular" />
|
||||
|
||||
declare namespace aa {
|
||||
|
||||
export interface ILabelStrategies {
|
||||
[strategyName: string]: (element:ng.IAugmentedJQueryStatic, labelText:string, isRequired:boolean)=>void;
|
||||
}
|
||||
|
||||
export interface IFieldGroupStrategies {
|
||||
[strategyName: string]: (element:ng.IAugmentedJQueryStatic)=>void;
|
||||
}
|
||||
|
||||
export interface IValMsgPlacementStrategies {
|
||||
[strategyName: string]: (formFieldElement:ng.IAugmentedJQueryStatic, formName:string, formFieldName:string)=>void;
|
||||
}
|
||||
|
||||
export interface IValidIconStrategy {
|
||||
validIcon:string;
|
||||
invalidIcon:string;
|
||||
getContainer(element:ng.IAugmentedJQueryStatic):void;
|
||||
}
|
||||
|
||||
export interface ISpinnerClickStrategies {
|
||||
[strategyName: string]: (element:ng.IAugmentedJQueryStatic)=>void;
|
||||
}
|
||||
|
||||
export interface IOnNavigateAwayStrategies {
|
||||
[strategyName: string]: (rootFormScope:ng.IScope, rootForm:ng.IAugmentedJQueryStatic, $injector:ng.auto.IInjectorService)=>void;
|
||||
}
|
||||
|
||||
export interface IValidationMessages {
|
||||
[validationKey: string]: string;
|
||||
}
|
||||
|
||||
export interface IGlobalSettings {
|
||||
[settingName: string]: any;
|
||||
}
|
||||
|
||||
export interface IFormExtensionsProvider extends ng.IServiceProvider {
|
||||
defaultLabelStrategy:string;
|
||||
defaultFieldGroupStrategy:string;
|
||||
defaultValMsgPlacementStrategy:string;
|
||||
validIconStrategy:IValidIconStrategy;
|
||||
defaultSpinnerClickStrategy:string;
|
||||
defaultNotifyTarget:string;
|
||||
defaultOnNavigateAwayStrategy:string;
|
||||
validationMessages:IValidationMessages;
|
||||
valMsgForTemplate:string;
|
||||
confirmResetStrategy:()=>boolean;
|
||||
globalSettings:IGlobalSettings;
|
||||
|
||||
labelStrategies:ILabelStrategies;
|
||||
fieldGroupStrategies:IFieldGroupStrategies;
|
||||
valMsgPlacementStrategies:IValMsgPlacementStrategies;
|
||||
spinnerClickStrategies:ISpinnerClickStrategies;
|
||||
onNavigateAwayStrategies:IOnNavigateAwayStrategies;
|
||||
}
|
||||
|
||||
export interface INotifyPredicate {
|
||||
(message:string, options:any, notifier:any):any;
|
||||
}
|
||||
|
||||
export interface INotifyDefaults {
|
||||
success: INotifyPredicate;
|
||||
info: INotifyPredicate;
|
||||
warning: INotifyPredicate;
|
||||
danger: INotifyPredicate;
|
||||
error: INotifyPredicate;
|
||||
}
|
||||
|
||||
export interface INotifyConfig {
|
||||
name:string;
|
||||
template?:string;
|
||||
templateName?:string;
|
||||
options:INotifyOptions;
|
||||
namedDefaults:INotifyDefaults;
|
||||
}
|
||||
|
||||
export interface INotifyOptions {
|
||||
cssClasses?:string;
|
||||
messageType:string;
|
||||
allowHtml:boolean;
|
||||
message:string;
|
||||
}
|
||||
|
||||
export interface INotifyConfigProvider extends ng.IServiceProvider {
|
||||
notifyConfigs:any;
|
||||
defaultTargetContainerName:string;
|
||||
defaultNotifyConfig:string;
|
||||
addOrUpdateNotifyConfig(name:string, opts:INotifyConfig):void;
|
||||
optionsTransformer(options:INotifyOptions, $sce:ng.ISCEService):void;
|
||||
}
|
||||
|
||||
export interface IExternalFormValidationConfig {
|
||||
validations:any;
|
||||
ignore?:any;
|
||||
globals?:any;
|
||||
resolve?:any;
|
||||
resolveFn?:(modelValue:string)=>string;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"angular-agility-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
-309
@@ -1,309 +0,0 @@
|
||||
// Type definitions for Angular JS (ngAnimate module) 1.5
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>, Raphael Schweizer <https://github.com/rasch>, Cody Schaaf <https://github.com/codyschaaf>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
declare var _: string;
|
||||
export = _;
|
||||
|
||||
import * as angular from 'angular';
|
||||
|
||||
declare module 'angular' {
|
||||
/**
|
||||
* ngAnimate module (angular-animate.js)
|
||||
*/
|
||||
namespace animate {
|
||||
interface IAnimateFactory {
|
||||
(...args: any[]): IAnimateCallbackObject;
|
||||
}
|
||||
|
||||
interface IAnimateCallbackObject {
|
||||
eventFn?: (element: JQuery, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
setClass?: (element: JQuery, addedClasses: string, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
addClass?: (element: JQuery, addedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
removeClass?: (element: JQuery, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
enter?: (element: JQuery, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
leave?: (element: JQuery, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
move?: (element: JQuery, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
animate?: (element: JQuery, fromStyles: string, toStyles: string, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
}
|
||||
|
||||
interface IAnimationPromise extends IPromise<void> { }
|
||||
|
||||
/**
|
||||
* AnimateService
|
||||
* see http://docs.angularjs.org/api/ngAnimate/service/$animate
|
||||
*/
|
||||
interface IAnimateService {
|
||||
/**
|
||||
* Sets up an event listener to fire whenever the animation event has fired on the given element or among any of its children.
|
||||
*
|
||||
* @param event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...)
|
||||
* @param container the container element that will capture each of the animation events that are fired on itself as well as among its children
|
||||
* @param callback the callback function that will be fired when the listener is triggered
|
||||
*/
|
||||
on(event: string, container: JQuery, callback: (element?: JQuery, phase?: string) => any): void;
|
||||
|
||||
/**
|
||||
* Deregisters an event listener based on the event which has been associated with the provided element.
|
||||
*
|
||||
* @param event the animation event (e.g. enter, leave, move, addClass, removeClass, etc...)
|
||||
* @param container the container element the event listener was placed on
|
||||
* @param callback the callback function that was registered as the listener
|
||||
*/
|
||||
off(event: string, container?: JQuery, callback?: (element?: JQuery, phase?: string) => any): void;
|
||||
|
||||
/**
|
||||
* Associates the provided element with a host parent element to allow the element to be animated even if it exists outside of the DOM structure of the Angular application.
|
||||
*
|
||||
* @param element the external element that will be pinned
|
||||
* @param parentElement the host parent element that will be associated with the external element
|
||||
*/
|
||||
pin(element: JQuery, parentElement: JQuery): void;
|
||||
|
||||
/**
|
||||
* Globally enables / disables animations.
|
||||
*
|
||||
* @param element If provided then the element will be used to represent the enable/disable operation.
|
||||
* @param value If provided then set the animation on or off.
|
||||
* @returns current animation state
|
||||
*/
|
||||
enabled(element: JQuery, value?: boolean): boolean;
|
||||
enabled(value?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Cancels the provided animation.
|
||||
*/
|
||||
cancel(animationPromise: IAnimationPromise): void;
|
||||
|
||||
/**
|
||||
* Performs an inline animation on the element.
|
||||
*
|
||||
* @param element the element that will be the focus of the animation
|
||||
* @param from a collection of CSS styles that will be applied to the element at the start of the animation
|
||||
* @param to a collection of CSS styles that the element will animate towards
|
||||
* @param className an optional CSS class that will be added to the element for the duration of the animation (the default class is 'ng-inline-animate')
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
animate(element: JQuery, from: any, to: any, className?: string, options?: IAnimationOptions): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Appends the element to the parentElement element that resides in the document and then runs the enter animation.
|
||||
*
|
||||
* @param element the element that will be the focus of the enter animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the enter animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, options?: IAnimationOptions): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Runs the leave animation operation and, upon completion, removes the element from the DOM.
|
||||
*
|
||||
* @param element the element that will be the focus of the leave animation
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
leave(element: JQuery, options?: IAnimationOptions): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Fires the move DOM operation. Just before the animation starts, the animate service will either append
|
||||
* it into the parentElement container or add the element directly after the afterElement element if present.
|
||||
* Then the move animation will be run.
|
||||
*
|
||||
* @param element the element that will be the focus of the move animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the move animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then attaches the className
|
||||
* value to the element as a CSS class.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be added to the element and then animated
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
addClass(element: JQuery, className: string, options?: IAnimationOptions): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then removes the CSS class
|
||||
* provided by the className value from the element.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be animated and then removed from the element
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
removeClass(element: JQuery, className: string, options?: IAnimationOptions): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
|
||||
* will be fired (if provided).
|
||||
*
|
||||
* @param element the element which will have its CSS classes changed removed from it
|
||||
* @param add the CSS classes which will be added to the element
|
||||
* @param remove the CSS class which will be removed from the element CSS classes have been set on the element
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
setClass(element: JQuery, add: string, remove: string, options?: IAnimationOptions): IAnimationPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* AnimateProvider
|
||||
* see http://docs.angularjs.org/api/ngAnimate/provider/$animateProvider
|
||||
*/
|
||||
interface IAnimateProvider {
|
||||
/**
|
||||
* Registers a new injectable animation factory function.
|
||||
*
|
||||
* @param name The name of the animation.
|
||||
* @param factory The factory function that will be executed to return the animation object.
|
||||
*/
|
||||
register(name: string, factory: IAnimateFactory): void;
|
||||
|
||||
/**
|
||||
* Gets and/or sets the CSS class expression that is checked when performing an animation.
|
||||
*
|
||||
* @param expression The className expression which will be checked against all animations.
|
||||
* @returns The current CSS className expression value. If null then there is no expression value.
|
||||
*/
|
||||
classNameFilter(expression?: RegExp): RegExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Angular Animation Options
|
||||
* see https://docs.angularjs.org/api/ngAnimate/#applying-directive-specific-styles-to-an-animation
|
||||
*/
|
||||
interface IAnimationOptions {
|
||||
/**
|
||||
* The DOM event (e.g. enter, leave, move). When used, a generated CSS class of ng-EVENT and
|
||||
* ng-EVENT-active will be applied to the element during the animation. Multiple events can be provided when
|
||||
* spaces are used as a separator. (Note that this will not perform any DOM operation.)
|
||||
*/
|
||||
event?: string;
|
||||
|
||||
/**
|
||||
* Indicates that the ng-prefix will be added to the event class. Setting to false or
|
||||
* omitting will turn ng-EVENT and ng-EVENT-active in EVENT and EVENT-active. Unused if event is omitted.
|
||||
*/
|
||||
structural?: boolean;
|
||||
|
||||
/**
|
||||
* The CSS easing value that will be applied to the transition or keyframe animation (or both).
|
||||
*/
|
||||
easing?: string;
|
||||
|
||||
/**
|
||||
* The raw CSS transition style that will be used (e.g. 1s linear all).
|
||||
*/
|
||||
transitionStyle?: string;
|
||||
|
||||
/**
|
||||
* The raw CSS keyframe animation style that will be used (e.g. 1s my_animation linear).
|
||||
*/
|
||||
keyframeStyle?: string;
|
||||
|
||||
/**
|
||||
* The starting CSS styles (a key/value object) that will be applied at the start of the animation.
|
||||
*/
|
||||
from?: Object;
|
||||
|
||||
/**
|
||||
* The ending CSS styles (a key/value object) that will be applied across the animation via a CSS transition.
|
||||
*/
|
||||
to?: Object;
|
||||
|
||||
/**
|
||||
* A space separated list of CSS classes that will be added to the element and spread across the animation.
|
||||
*/
|
||||
addClass?: string;
|
||||
|
||||
/**
|
||||
* A space separated list of CSS classes that will be removed from the element and spread across
|
||||
* the animation.
|
||||
*/
|
||||
removeClass?: string;
|
||||
|
||||
/**
|
||||
* A number value representing the total duration of the transition and/or keyframe (note that a value
|
||||
* of 1 is 1000ms). If a value of 0 is provided then the animation will be skipped entirely.
|
||||
*/
|
||||
duration?: number;
|
||||
|
||||
/**
|
||||
* A number value representing the total delay of the transition and/or keyframe (note that a value of
|
||||
* 1 is 1000ms). If a value of true is used then whatever delay value is detected from the CSS classes will be
|
||||
* mirrored on the elements styles (e.g. by setting delay true then the style value of the element will be
|
||||
* transition-delay: DETECTED_VALUE). Using true is useful when you want the CSS classes and inline styles to
|
||||
* all share the same CSS delay value.
|
||||
*/
|
||||
delay?: number;
|
||||
|
||||
/**
|
||||
* A numeric time value representing the delay between successively animated elements (Click here to
|
||||
* learn how CSS-based staggering works in ngAnimate.)
|
||||
*/
|
||||
stagger?: number;
|
||||
|
||||
/**
|
||||
* The numeric index representing the stagger item (e.g. a value of 5 is equal to the sixth item
|
||||
* in the stagger; therefore when a stagger option value of 0.1 is used then there will be a stagger delay of 600ms)
|
||||
*
|
||||
*/
|
||||
staggerIndex?: number;
|
||||
|
||||
/**
|
||||
* Whether or not the provided from and to styles will be removed once the animation is closed. This is useful for
|
||||
* when the styles are used purely for the sake of the animation and do not have a lasting visual effect on the element
|
||||
* (e.g. a colapse and open animation). By default this value is set to false.
|
||||
*/
|
||||
cleanupStyles?: boolean;
|
||||
}
|
||||
|
||||
interface IAnimateCssRunner {
|
||||
/**
|
||||
* Starts the animation
|
||||
*
|
||||
* @returns The animation runner with a done function for supplying a callback.
|
||||
*/
|
||||
start(): IAnimateCssRunnerStart;
|
||||
|
||||
/**
|
||||
* Ends (aborts) the animation
|
||||
*/
|
||||
end(): void;
|
||||
}
|
||||
|
||||
interface IAnimateCssRunnerStart extends IPromise<void> {
|
||||
/**
|
||||
* Allows you to add done callbacks to the running animation
|
||||
*
|
||||
* @param callbackFn: the callback function to be run
|
||||
*/
|
||||
done(callbackFn: (animationFinished: boolean) => void): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* AnimateCssService
|
||||
* see http://docs.angularjs.org/api/ngAnimate/service/$animateCss
|
||||
*/
|
||||
interface IAnimateCssService {
|
||||
(element: JQuery, animateCssOptions: IAnimationOptions): IAnimateCssRunner;
|
||||
}
|
||||
}
|
||||
|
||||
interface IModule {
|
||||
animation(name: string, animationFactory: angular.animate.IAnimateFactory): IModule;
|
||||
animation(name: string, inlineAnnotatedFunction: any[]): IModule;
|
||||
animation(object: Object): IModule;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
-181
@@ -1,181 +0,0 @@
|
||||
// Type definitions for angular-bootstrap-calendar
|
||||
// Project: https://github.com/mattlewis92/angular-bootstrap-calendar
|
||||
// Definitions by: Egor Komarov <https://github.com/Odrin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as moment from 'moment';
|
||||
import * as angular from 'angular';
|
||||
|
||||
declare module 'angular' {
|
||||
export namespace bootstrap.calendar {
|
||||
interface IEventAction {
|
||||
/**
|
||||
* The label of the action
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* CSS class to be added to the action element
|
||||
*/
|
||||
cssClass?: string;
|
||||
/**
|
||||
* The action that occurs when it's clicked
|
||||
* @param args - the IEvent whose action was clicked
|
||||
*/
|
||||
onClick: (args: any) => void;
|
||||
}
|
||||
|
||||
interface IEventColor {
|
||||
/**
|
||||
* The primary color of the event, should be darker than secondary
|
||||
*/
|
||||
primary: string;
|
||||
|
||||
/**
|
||||
* The secondary color of the event, should be lighter than primary
|
||||
*/
|
||||
secondary: string;
|
||||
}
|
||||
|
||||
interface IEvent {
|
||||
/**
|
||||
* The title of the event
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* The type of the event (determines its color). Can be important, warning, info, inverse, success or special
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* A javascript date object for when the event starts
|
||||
*/
|
||||
startsAt: Date;
|
||||
/**
|
||||
* Optional - a javascript date object for when the event ends
|
||||
*/
|
||||
endsAt?: Date;
|
||||
/**
|
||||
* Color of the Event
|
||||
*/
|
||||
color?: IEventColor;
|
||||
/**
|
||||
* Actions of the Event
|
||||
*/
|
||||
actions?: Array<IEventAction>;
|
||||
/**
|
||||
* If edit-event-html is set and this field is explicitly set to false then dont make it editable.
|
||||
*/
|
||||
editable?: boolean;
|
||||
/**
|
||||
* If delete-event-html is set and this field is explicitly set to false then dont make it deleteable
|
||||
*/
|
||||
deletable?: boolean;
|
||||
/**
|
||||
* Allow an event to be dragged and dropped
|
||||
*/
|
||||
draggable?: boolean;
|
||||
/**
|
||||
* Allow an event to be resizable
|
||||
*/
|
||||
resizable?: boolean;
|
||||
/**
|
||||
* If set to false then will not count towards the badge total amount on the month and year view
|
||||
*/
|
||||
incrementsBadgeTotal?: boolean;
|
||||
/**
|
||||
* If set the event will recur on the given period. Valid values are year or month
|
||||
*/
|
||||
recursOn?: string;
|
||||
/**
|
||||
* A CSS class (or more, just separate with spaces) that will be added to the event when it is displayed on each view. Useful for marking an event as selected / active etc
|
||||
*/
|
||||
cssClass?: string;
|
||||
/**
|
||||
* If set the event will display as all-day event
|
||||
*/
|
||||
allDay?: boolean;
|
||||
}
|
||||
|
||||
interface ICalendarConfig {
|
||||
allDateFormats: {
|
||||
angular: IFormats;
|
||||
moment: IFormats;
|
||||
};
|
||||
dateFormats: IDateFormats;
|
||||
titleFormats: ITitleFormats;
|
||||
dateFormatter: string;
|
||||
displayEventEndTimes: boolean;
|
||||
showTimesOnWeekView: boolean;
|
||||
displayAllMonthEvents: boolean;
|
||||
i18nStrings: { weekNumber: string; };
|
||||
templates: {
|
||||
calendarDayView: string;
|
||||
calendarHourList: string;
|
||||
calendarMonthCell: string;
|
||||
calendarMonthCellEvents: string;
|
||||
calendarMonthView: string;
|
||||
calendarSlideBox: string;
|
||||
calendarWeekView: string;
|
||||
calendarYearView: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface IFormats {
|
||||
date: IDateFormats;
|
||||
title: ITitleFormats;
|
||||
}
|
||||
|
||||
interface IDateFormats {
|
||||
hour: string;
|
||||
day: string;
|
||||
month: string;
|
||||
weekDay: string;
|
||||
time: string;
|
||||
datetime: string;
|
||||
}
|
||||
|
||||
interface ITitleFormats {
|
||||
day: string;
|
||||
week: string;
|
||||
month: string;
|
||||
year: string;
|
||||
}
|
||||
|
||||
interface ICalendarCell {
|
||||
label: number;
|
||||
date: moment.Moment;
|
||||
inMonth: boolean;
|
||||
isPast: boolean;
|
||||
isToday: boolean;
|
||||
isFuture: boolean;
|
||||
isWeekend: boolean;
|
||||
events: IEvent[];
|
||||
badgeTotal: number;
|
||||
}
|
||||
|
||||
namespace events {
|
||||
interface IOnEventClick {
|
||||
(calendarEvent: IEvent): void;
|
||||
}
|
||||
|
||||
interface IOnEventTimesChanged {
|
||||
(calendarEvent: IEvent, calendarNewEventStart: Date, calendarNewEventEnd: Date): void;
|
||||
}
|
||||
|
||||
interface IOnEditEventClick {
|
||||
(calendarEvent: IEvent): void;
|
||||
}
|
||||
|
||||
interface IOnDeleteEventClick {
|
||||
(calendarEvent: IEvent): void;
|
||||
}
|
||||
|
||||
interface IOnTimespanClick {
|
||||
(calendarDate: Date, calendarCell: ICalendarCell): void;
|
||||
}
|
||||
|
||||
interface IOnViewChangeClick {
|
||||
(calendarDate: Date, calendarNextView: string): boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user