diff --git a/README.md b/README.md index 8e582f05b4..34eae06069 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Before you share your improvement with the world, use it yourself. #### Test editing an existing package -To add new features you can use [module augmentation](http://www.typescriptlang.org/docs/handbook/declaration-merging.html). +To add new features you can use [module augmentation](http://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation). You can also directly edit the types in `node_modules/@types/foo/index.d.ts`, or copy them from there and follow the steps below. diff --git a/types/buffer-from/buffer-from-tests.ts b/types/buffer-from/buffer-from-tests.ts new file mode 100644 index 0000000000..8fdd4fa811 --- /dev/null +++ b/types/buffer-from/buffer-from-tests.ts @@ -0,0 +1,6 @@ +import bufferFrom = require('buffer-from'); + +bufferFrom([1, 2, 3, 4]); // $ExpectType Buffer +bufferFrom(new Uint8Array([1, 2, 3, 4]).buffer, 1, 2); // $ExpectType Buffer +bufferFrom('test', 'utf8'); // $ExpectType Buffer +bufferFrom(bufferFrom('test')); // $ExpectType Buffer diff --git a/types/buffer-from/index.d.ts b/types/buffer-from/index.d.ts new file mode 100644 index 0000000000..412056ed8a --- /dev/null +++ b/types/buffer-from/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for buffer-from 1.1 +// Project: https://github.com/LinusU/buffer-from#readme +// Definitions by: Nat Burns +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function bufferFrom(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; +declare function bufferFrom(str: string, encoding?: string): Buffer; +declare function bufferFrom(data: ReadonlyArray | Buffer): Buffer; + +export = bufferFrom; diff --git a/types/buffer-from/tsconfig.json b/types/buffer-from/tsconfig.json new file mode 100644 index 0000000000..195d0a78b6 --- /dev/null +++ b/types/buffer-from/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "buffer-from-tests.ts" + ] +} diff --git a/types/buffer-from/tslint.json b/types/buffer-from/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/buffer-from/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/config-yaml/config-yaml-tests.ts b/types/config-yaml/config-yaml-tests.ts new file mode 100644 index 0000000000..4ddf61e69f --- /dev/null +++ b/types/config-yaml/config-yaml-tests.ts @@ -0,0 +1,5 @@ +import yaml = require('config-yaml'); + +yaml('./simple.yaml'); +yaml('./simple.yaml', { encoding: 'gbk' }); +yaml('./simple.yaml', { encoding: 'utf-8' }); diff --git a/types/config-yaml/index.d.ts b/types/config-yaml/index.d.ts new file mode 100644 index 0000000000..6f2be7957b --- /dev/null +++ b/types/config-yaml/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for config-yaml 1.1 +// Project: https://github.com/neolao/config-yaml#readme +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// TypeScript Version: 2.1 + +/// +import * as fs from 'fs'; + +export = Yaml; + +declare namespace Yaml { + interface Options { + encoding: string; + } +} + +declare function Yaml(path: fs.PathLike, options?: Partial): any; diff --git a/types/config-yaml/tsconfig.json b/types/config-yaml/tsconfig.json new file mode 100644 index 0000000000..fa349a2f41 --- /dev/null +++ b/types/config-yaml/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "config-yaml-tests.ts" + ] +} diff --git a/types/config-yaml/tslint.json b/types/config-yaml/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/config-yaml/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ex-react-native-i18n/ex-react-native-i18n-tests.ts b/types/ex-react-native-i18n/ex-react-native-i18n-tests.ts new file mode 100644 index 0000000000..c83c4b60d3 --- /dev/null +++ b/types/ex-react-native-i18n/ex-react-native-i18n-tests.ts @@ -0,0 +1,8 @@ +import I18n from 'ex-react-native-i18n'; + +I18n.defaultLocale = 'en'; +I18n.fallbacks = true; +I18n.translations = {}; +I18n.locale = 'zh'; + +const deviceLocale: string = I18n.locale; diff --git a/types/ex-react-native-i18n/index.d.ts b/types/ex-react-native-i18n/index.d.ts new file mode 100644 index 0000000000..0b83b06a68 --- /dev/null +++ b/types/ex-react-native-i18n/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for ex-react-native-i18n 0.0 +// Project: https://github.com/xcarpentier/ex-react-native-i18n/ +// Definitions by: LikKee Richie +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +// Actual version for ex-react-native-i18n is 0.0.4 but 'npm run lint' doesn't allow patch version to pass +import I18n = require("i18n-js"); +// import I18n from 'ex-react-native-i18n'; + +export default I18n; diff --git a/types/ex-react-native-i18n/tsconfig.json b/types/ex-react-native-i18n/tsconfig.json new file mode 100644 index 0000000000..8e6dd691bf --- /dev/null +++ b/types/ex-react-native-i18n/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ex-react-native-i18n-tests.ts" + ] +} diff --git a/types/ex-react-native-i18n/tslint.json b/types/ex-react-native-i18n/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ex-react-native-i18n/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/expo__status-bar-height/expo__status-bar-height-tests.ts b/types/expo__status-bar-height/expo__status-bar-height-tests.ts new file mode 100644 index 0000000000..84dd284d12 --- /dev/null +++ b/types/expo__status-bar-height/expo__status-bar-height-tests.ts @@ -0,0 +1,11 @@ +import StatusBarHeight from '@expo/status-bar-height'; + +const onChangeHeight = (height: number) => console.log(`New height: ${height}`); + +StatusBarHeight.addEventListener(onChangeHeight); + +StatusBarHeight.getAsync() + .then((height: number) => console.log(`Current height: ${height}`)) + .catch((error: Error) => console.error('Threw an error in StatusBarHeight.getAsync():', error)); + +StatusBarHeight.removeEventListener(onChangeHeight); diff --git a/types/expo__status-bar-height/index.d.ts b/types/expo__status-bar-height/index.d.ts new file mode 100644 index 0000000000..24331721da --- /dev/null +++ b/types/expo__status-bar-height/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for @expo/status-bar-height 0.0 +// Project: https://github.com/expo/status-bar-height +// Definitions by: Janeene Beeforth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export type StatusBarHeightHandler = (height: number) => void; + +export class StatusBarHeight { + /** + * Get the current status bar height + */ + getAsync(): Promise; + /** + * Add 'willChange' event listener + */ + addEventListener(handler: StatusBarHeightHandler): void; + /** + * Remove 'willChange' event listener + */ + removeEventListener(handler: StatusBarHeightHandler): void; +} + +declare const StatusBarHeightStatic: StatusBarHeight; +export default StatusBarHeightStatic; diff --git a/types/expo__status-bar-height/tsconfig.json b/types/expo__status-bar-height/tsconfig.json new file mode 100644 index 0000000000..88649150a0 --- /dev/null +++ b/types/expo__status-bar-height/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@expo/status-bar-height": [ + "expo__status-bar-height" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "expo__status-bar-height-tests.ts" + ] +} diff --git a/types/expo__status-bar-height/tslint.json b/types/expo__status-bar-height/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/expo__status-bar-height/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/fibjs/UNUSED_FILES.txt b/types/fibjs/UNUSED_FILES.txt new file mode 100644 index 0000000000..2a6c4b5a1c --- /dev/null +++ b/types/fibjs/UNUSED_FILES.txt @@ -0,0 +1 @@ +declare/_test_env.d.ts \ No newline at end of file diff --git a/types/fibjs/declare/Buffer.d.ts b/types/fibjs/declare/Buffer.d.ts new file mode 100644 index 0000000000..1d51d44ab6 --- /dev/null +++ b/types/fibjs/declare/Buffer.d.ts @@ -0,0 +1,1131 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 二进制数据缓存对象,用于 io 读写的数据处理 + * @detail Buffer 对象为全局基础类,在任何时候都可以直接以 new Buffer(...) 创建:,```JavaScript,var buf = new Buffer();,``` + */ + +declare class Class_Buffer extends Class__object { + + /** + * class prop + * + * + * @brief 获取缓存对象的尺寸 + * + * @readonly + * @type Integer + */ + + length: number + + + + /** + * + * @brief 缓存对象构造函数 + * @param datas 初始化数据数组 + * + * + * + */ + constructor(datas: any[]); + + /** + * + * @brief 缓存对象构造函数 + * @param datas 初始化数据数组 + * + * + * + */ + constructor(datas: ArrayBuffer); + + /** + * + * @brief 缓存对象构造函数 + * @param datas 初始化数据数组 + * + * + * + */ + constructor(datas: TypedArray); + + /** + * + * @brief 缓存对象构造函数 + * @param datas 初始化数据数组 + * + * + * + */ + constructor(datas: ArrayBufferView); + + /** + * + * @brief 缓存对象构造函数 + * @param buffer 初始化Buffer对象 + * + * + * + */ + constructor(buffer: Class_Buffer); + + /** + * + * @brief 缓存对象构造函数 + * @param str 初始化字符串,字符串将以 utf-8 格式写入,缺省则创建一个空对象 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * + * + * + */ + constructor(str: string, codec?: string/** = "utf8"*/); + + /** + * + * @brief 缓存对象构造函数 + * @param size 初始化缓冲区大小 + * + * + * + */ + constructor(size?: number/** = 0*/); + + /** + * + * @brief 检测给定的变量是否是 Buffer 对象 + * @param v 给定需要检测的变量 + * @return 传入对象是否 Buffer 对象 + * + * + * + */ + static isBuffer(v: any): boolean; + + /** + * + * @brief 通过其他 Buffer 创建 Buffer 对象 + * @param buffer 给定 Buffer 类型变量用于创建 Buffer 对象 + * @param byteOffset 指定数据起始位置,起始为 0 + * @param length 指定数据长度,起始位 -1,表示剩余所有数据 + * @return 返回 Buffer 实例 + * + * + * + */ + static from(buffer: Class_Buffer, byteOffset?: number/** = 0*/, length?: number/** = -1*/): Class_Buffer; + + /** + * + * @brief 通过字符串创建 Buffer 对象 + * @param str 初始化字符串,字符串将以 utf-8 格式写入 + * @param byteOffset 指定数据起始位置,起始为 0 + * @param length 指定数据长度,起始位 -1,表示剩余所有数据 + * @return 返回 Buffer 实例 + * + * + * + */ + static from(str: string, byteOffset?: number/** = 0*/, length?: number/** = -1*/): Class_Buffer; + + /** + * + * @brief 通过字符串创建 Buffer 对象 + * @param str 初始化字符串,字符串将以 utf-8 格式写入,缺省则创建一个空对象 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 返回 Buffer 实例 + * + * + * + */ + static from(str: string, codec?: string/** = "utf8"*/): Class_Buffer; + + /** + * + * @brief 拼接多个缓存区中的数据 + * @param buflist 待拼接的Buffer数组 + * @param cutLength 截取多少个Buffer对象 + * @return 拼接后产生的新 Buffer 对象 + * + * + * + */ + static concat(buflist: any[], cutLength?: number/** = -1*/): Class_Buffer; + + /** + * + * @brief 分配一个指定长度的新缓存区。如果大小为0,将创建一个零长度的缓存区。 + * @param size 缓冲区的所需长度 + * @param fill 预先填充新缓冲区的值,可使用 string/buffer/integer 值类型。 默认值:0 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 填充好的新 Buffer 对象 + * + * + * + */ + static alloc(size: number, fill?: number/** = 0*/, codec?: string/** = "utf8"*/): Class_Buffer; + + /** + * + * @brief 分配一个指定长度的新缓存区。如果大小为0,将创建一个零长度的缓存区。 + * @param size 缓冲区的所需长度 + * @param fill 预先填充新缓冲区的值,可使用 string/buffer/integer 值类型。 默认值:0 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 填充好的新 Buffer 对象 + * + * + * + */ + static alloc(size: number, fill?: string/** = ""*/, codec?: string/** = "utf8"*/): Class_Buffer; + + /** + * + * @brief 分配一个指定长度的新缓存区。如果大小为0,将创建一个零长度的缓存区。 + * @param size 缓冲区的所需长度 + * @param fill 预先填充新缓冲区的值,可使用 string/buffer/integer 值类型。 默认值:0 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 填充好的新 Buffer 对象 + * + * + * + */ + static alloc(size: number, fill: Class_Buffer, codec?: string/** = "utf8"*/): Class_Buffer; + + /** + * + * @brief 分配一个指定长度的新缓存区。如果大小为0,将创建一个零长度的缓存区。 + * @param size 缓冲区的所需长度 + * @return 指定尺寸的新 Buffer 对象 + * + * + * + */ + static allocUnsafe(size: number): Class_Buffer; + + /** + * + * @brief 分配一个指定长度的新缓存区。如果大小为0,将创建一个零长度的缓存区。 + * @param size 缓冲区的所需长度 + * @return 指定尺寸的新 Buffer 对象 + * + * + * + */ + static allocUnsafeSlow(size: number): Class_Buffer; + + /** + * + * @brief 返回字符串的实际字节长度 + * @param str 待取字节的字符串,如果str为 ArrayBuffer/TypedArray/DataView/Buffer 对象,则返回它们的实际长度 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 返回实际字节长度 + * + * + * + */ + static byteLength(str: string, codec?: string/** = "utf8"*/): number; + + /** + * + * @brief 返回字符串的实际字节长度 + * @param str 待取字节的字符串,如果str为 ArrayBuffer/TypedArray/DataView/Buffer 对象,则返回它们的实际长度 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 返回实际字节长度 + * + * + * + */ + static byteLength(str: ArrayBuffer, codec?: string/** = "utf8"*/): number; + + /** + * + * @brief 返回字符串的实际字节长度 + * @param str 待取字节的字符串,如果 str 为 ArrayBuffer/TypedArray/DataView/Buffer 对象,则返回它们的实际长度 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 返回实际字节长度 + * + * + * + */ + static byteLength(str: ArrayBufferView, codec?: string/** = "utf8"*/): number; + + /** + * + * @brief 返回字符串的实际字节长度 + * @param str 待取字节的字符串,如果str为 ArrayBuffer/TypedArray/DataView/Buffer 对象,则返回它们的实际长度 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 返回实际字节长度 + * + * + * + */ + static byteLength(str: Class_Buffer, codec?: string/** = "utf8"*/): number; + + /** + * + * @brief 检测编码格式是否被支持 + * @param codec 待检测的编码格式 + * @return 是否支持 + * + * + * + */ + static isEncoding(codec: string): boolean; + + /** + * + * @brief 修改缓存对象尺寸 + * @param sz 指定新尺寸 + * + * + * + */ + resize(sz: number): void; + + /** + * + * @brief 在缓存对象尾部写入一组二进制数据 + * @param data 初始化二进制数据 + * + * + * + */ + append(data: Class_Buffer): void; + + /** + * + * @brief 在缓存对象尾部写入字符串,字符串将以 utf-8 格式写入 + * @param str 要写入的字符串 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * + * + * + */ + append(str: string, codec?: string/** = "utf8"*/): void; + + /** + * + * @brief 向缓存对象写入指定字符串,字符串默认为utf-8,越界时只写入部分数据 + * @param str 待写入的字符串 + * @param offset 写入起始位置 + * @param length 写入长度(单位字节,默认值-1),未指定时为待写入字符串的长度 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 写入的数据字节长度 + * + * + * + */ + write(str: string, offset?: number/** = 0*/, length?: number/** = -1*/, codec?: string/** = "utf8"*/): number; + + /** + * + * @brief 向缓存对象写入指定字符串,字符串默认为utf-8,越界时只写入部分数据 + * @param str 待写入的字符串 + * @param offset 写入起始位置 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 写入的数据字节长度 + * + * + * + */ + write(str: string, offset?: number/** = 0*/, codec?: string/** = "utf8"*/): number; + + /** + * + * @brief 向缓存对象写入指定字符串,字符串默认为utf-8,越界时只写入部分数据 + * @param str 待写入的字符串 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @return 写入的数据字节长度 + * + * + * + */ + write(str: string, codec?: string/** = "utf8"*/): number; + + /** + * + * @brief 为 Buffer 对象填充指定内容数据 + * @param v 需要填充的数据,如果未指定 offset 和 end,将填充满整个 buffer + * @param offset 填充起始位置 + * @param end 填充终止位置 + * @return 返回当前 Buffer 对象 + * + * + * + */ + fill(v: number, offset?: number/** = 0*/, end?: number/** = -1*/): Class_Buffer; + + /** + * + * @brief 为 Buffer 对象填充指定内容数据 + * @param v 需要填充的数据,如果未指定 offset 和 end,将填充满整个 buffer + * @param offset 填充起始位置 + * @param end 填充终止位置 + * @return 返回当前 Buffer 对象 + * + * + * + */ + fill(v: Class_Buffer, offset?: number/** = 0*/, end?: number/** = -1*/): Class_Buffer; + + /** + * + * @brief 为 Buffer 对象填充指定内容数据 + * @param v 需要填充的数据,如果未指定 offset 和 end,将填充满整个 buffer + * @param offset 填充起始位置 + * @param end 填充终止位置 + * @return 返回当前 Buffer 对象 + * + * + * + */ + fill(v: string, offset?: number/** = 0*/, end?: number/** = -1*/): Class_Buffer; + + /** + * + * @brief 返回某个指定数据在 Buffer 中首次出现的位置 + * @param v 待查找数据,如果未指定 offset,默认从起始位开始 + * @param offset 起始查找位置 + * @return 返回查找到的位置,未找到返回 -1 + * + * + * + */ + indexOf(v: number, offset?: number/** = 0*/): number; + + /** + * + * @brief 返回某个指定数据在 Buffer 中首次出现的位置 + * @param v 待查找数据,如果未指定 offset,默认从起始位开始 + * @param offset 起始查找位置 + * @return 返回查找到的位置,未找到返回 -1 + * + * + * + */ + indexOf(v: Class_Buffer, offset?: number/** = 0*/): number; + + /** + * + * @brief 返回某个指定数据在 Buffer 中首次出现的位置 + * @param v 待查找数据,如果未指定 offset,默认从起始位开始 + * @param offset 起始查找位置 + * @return 返回查找到的位置,未找到返回 -1 + * + * + * + */ + indexOf(v: string, offset?: number/** = 0*/): number; + + /** + * + * @brief 比较缓存区的内容 + * @param buf 待比较缓存对象 + * @return 内容比较结果 + * + * + * + */ + compare(buf: Class_Buffer): number; + + /** + * + * @brief 从源缓存对象区域拷贝数据到目标缓存对象区域 + * @param targetBuffer 目标缓存对象 + * @param targetStart 目标缓存对象开始拷贝字节位置,缺省为 0 + * @param sourceStart 源缓存对象开始字节位置, 缺省为 0 + * @param sourceEnd 源缓存对象结束字节位置, 缺省为 -1,表示源数据长度 + * @return 拷贝的数据字节长度 + * + * + * + */ + copy(targetBuffer: Class_Buffer, targetStart?: number/** = 0*/, sourceStart?: number/** = 0*/, sourceEnd?: number/** = -1*/): number; + + /** + * + * @brief 从缓存对象读取一个 8 位无符号整型数值 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readUInt8(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个 16 位无符号整型数值,以低字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readUInt16LE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个 16 位无符号整型数值,以高字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readUInt16BE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个 32 位无符号整型数值,以低字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readUInt32LE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个 32 位无符号整型数值,以高字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readUInt32BE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个无符号整型数值,最大支持 48 位,以低字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readUIntLE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个无符号整型数值,最大支持 48 位,以高字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readUIntBE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个 8 位整型数值 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readInt8(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个 16 位整型数值,以低字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readInt16LE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个 16 位整型数值,以高字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readInt16BE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个 32 位整型数值,以低字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readInt32LE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个 32 位整型数值,以高字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readInt32BE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个整型数值,最大支持 48 位,以低字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readIntLE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个整型数值,最大支持 48 位,以高字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readIntBE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个 64 位整型数值,以低字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readInt64LE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): Class_Int64; + + /** + * + * @brief 从缓存对象读取一个 64 位整型数值,以高字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的整型数值 + * + * + * + */ + readInt64BE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): Class_Int64; + + /** + * + * @brief 从缓存对象读取一个浮点数,以低字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的浮点数 + * + * + * + */ + readFloatLE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个浮点数,以高字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的浮点数 + * + * + * + */ + readFloatBE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个双精度浮点数,以低字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的双精度浮点数 + * + * + * + */ + readDoubleLE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 从缓存对象读取一个双精度浮点数,以高字节序的存储方式 + * @param offset 指定读取的起始位置,缺省为 0 + * @param noAssert 指定读取越界时不抛出错误,缺省为 flase,抛出 + * @return 返回读取的双精度浮点数 + * + * + * + */ + readDoubleBE(offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 8 位无符号整型数值 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeUInt8(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 16 位无符号整型数值,以低字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeUInt16LE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 16 位无符号整型数值,以高字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeUInt16BE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 32 位无符号整型数值,以低字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeUInt32LE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 32 位无符号整型数值,以高字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeUInt32BE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个无符号整型数值,最大支持 48 位,以低字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeUIntLE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个无符号整型数值,最大支持 48 位,以高字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeUIntBE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 8 位整型数值 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeInt8(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 16 位整型数值,以低字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeInt16LE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 16 位整型数值,以高字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeInt16BE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 32 位整型数值,以低字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeInt32LE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 32 位整型数值,以高字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeInt32BE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个整型数值,最大支持 48 位,以低字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeIntLE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个整型数值,最大支持 48 位,以高字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeIntBE(value: number, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 64 位整型数值,以低字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeInt64LE(value: Class_Int64, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个 64 位整型数值,以高字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeInt64BE(value: Class_Int64, offset?: number/** = 0*/, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个浮点数,以低字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeFloatLE(value: number, offset: number, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个浮点数,以高字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeFloatBE(value: number, offset: number, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个双精度浮点数,以低字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeDoubleLE(value: number, offset: number, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 向缓存对象写入一个双精度浮点数,以高字节序的存储方式 + * @param value 指定写入的数值 + * @param offset 指定写入的起始位置 + * @param noAssert 指定写入越界时不抛出错误,缺省为 flase,抛出 + * @return offset 加上写入的字节数 + * + * + * + */ + writeDoubleBE(value: number, offset: number, noAssert?: boolean/** = false*/): number; + + /** + * + * @brief 返回一个新缓存对象,包含指定起始到缓存结尾的数据 + * @param start 指定范围的起始,缺省从头开始 + * @return 返回新的缓存对象 + * + * + * + */ + slice(start?: number/** = 0*/): Class_Buffer; + + /** + * + * @brief 返回一个新缓存对象,包含指定范围的数据,若范围超出缓存,则只返回有效部分数据 + * @param start 指定范围的起始 + * @param end 指定范围的结束 + * @return 返回新的缓存对象 + * + * + * + */ + slice(start: number, end: number): Class_Buffer; + + /** + * + * @brief 把当前对象中的所有元素放入一个字符串 + * @param separator 分割字符,缺省为 "," + * @return 返回生成的字符串 + * + * + * + */ + join(separator?: string/** = ","*/): string; + + /** + * + * @brief 返回一个新缓存对象,包含当前对象数据的倒序 + * @return 返回新的缓存对象 + * + * + * + */ + reverse(): Class_Buffer; + + /** + * + * @brief 比较当前对象与给定的对象是否相等 + * @param expected 制定比较的目标对象 + * @return 返回对象比较的结果 + * + * + * + */ + equals(expected: Class__object): boolean; + + /** + * + * @brief 使用 16 进制编码缓存对象内容 + * @return 返回编码字符串 + * + * + * + */ + hex(): string; + + /** + * + * @brief 使用 base64 编码缓存对象内容 + * @return 返回编码字符串 + * + * + * + */ + base64(): string; + + /** + * + * @brief 返回全部二进制数据的数组 + * @return 返回包含对象数据索引的迭代器 + * + * + * + */ + keys(): Object; + + /** + * + * @brief 返回全部二进制数据的数组 + * @return 返回包含对象数据值的迭代器 + * + * + * + */ + values(): Object; + + /** + * + * @brief 返回包含对象数据 [index, byte] 对的迭代器 + * @return [index, byte] 对的迭代器 + * ```JavaScript + * const buf = Buffer.from('buffer'); + * + * // Prints: + * // [0, 98] + * // [1, 117] + * // [2, 102] + * // [3, 102] + * // [4, 101] + * // [5, 114] + * for (const pair of buf.entries()) { + * console.log(pair); + * } + * ``` + * + * + * + */ + entries(): Object; + + /** + * + * @brief 返回全部二进制数据的数组 + * @return 返回包含对象数据的数组 + * + * + * + */ + toArray(): any[]; + + /** + * + * @brief 返回二进制数据的编码字符串 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @param offset 读取起始位置 + * @param end 读取终止位置 + * @return 返回对象的字符串表示 + * + * + * + */ + toString(codec: string, offset?: number/** = 0*/, end?: number): string; + + /** + * + * @brief 返回二进制数据的编码字符串 + * @param codec 指定编码格式,允许值为:"hex", "base64", "utf8", 或者系统支持的字符集 + * @param offset 读取起始位置 + * @return 返回对象的字符串表示 + * + * + * + */ + toString(codec: string, offset?: number/** = 0*/): string; + + /** + * + * @brief 返回二进制数据的 utf8 编码字符串 + * @return 返回对象的字符串表示 + * + * + * + */ + toString(): string; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/BufferedStream.d.ts b/types/fibjs/declare/BufferedStream.d.ts new file mode 100644 index 0000000000..f0f1ef74ba --- /dev/null +++ b/types/fibjs/declare/BufferedStream.d.ts @@ -0,0 +1,144 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 缓存读取对象 + * @detail BufferedReader 对象用于对二进制流对象数据进行缓存,并提供文本读取能力,仅支持 utf-8 格式转换。创建方法:,```JavaScript,var reader = new io.BufferedStream(stream);,``` + */ +/// +declare class Class_BufferedStream extends Class_Stream { + + /** + * class prop + * + * + * @brief 查询创建缓存对象时的流对象 + * + * @readonly + * @type Stream + */ + + stream: Class_Stream + + /** + * class prop + * + * + * @brief 查询和设置当前对象处理文本时的字符集,缺省为 utf-8 + * + * + * @type String + */ + + charset: string + + /** + * class prop + * + * + * @brief 查询和设置行结尾标识,缺省时,posix:\"\\n\";windows:\"\\r\\n\" + * + * + * @type String + */ + + EOL: string + + + + /** + * + * @brief BufferedStream 构造函数 + * @param stm BufferedStream 的二进制基础流对象 + * + * + * + */ + constructor(stm: Class_Stream); + + /** + * + * @brief 读取指定字符的文本 + * @param size 指定读取的文本字符个数,以 utf8 或者指定的编码字节数为准 + * @return 返回读取的文本字符串,若无数据可读,或者连接中断,则返回 null + * + * + * @async + */ + readText(size: number): string; + + /** + * + * @brief 读取一行文本,行结尾标识基于 EOL 属性的设置,缺省时,posix:\"\\n\";windows:\"\\r\\n\" + * @param maxlen 指定此次读取的最大字符串,以 utf8 编码字节数为准,缺省不限制字符数 + * @return 返回读取的文本字符串,若无数据可读,或者连接中断,则返回 null + * + * + * @async + */ + readLine(maxlen?: number/** = -1*/): string; + + /** + * + * @brief 以数组方式读取一组文本行,行结尾标识基于 EOL 属性的设置,缺省时,posix:\"\\n\";windows:\"\\r\\n\" + * @param maxlines 指定此次读取的最大行数,缺省读取全部文本行 + * @return 返回读取的文本行数组,若无数据可读,或者连接中断,空数组 + * + * + * + */ + readLines(maxlines?: number/** = -1*/): any[]; + + /** + * + * @brief 读取一个文本字符串,以指定的字节为结尾 + * @param mk 指定结尾的字符串 + * @param maxlen 指定此次读取的最大字符串,以 utf8 编码字节数为准,缺省不限制字符数 + * @return 返回读取的文本字符串,若无数据可读,或者连接中断,则返回 null + * + * + * @async + */ + readUntil(mk: string, maxlen?: number/** = -1*/): string; + + /** + * + * @brief 写入一个字符串 + * @param txt 指定写入的字符串 + * + * + * @async + */ + writeText(txt: string): void; + + /** + * + * @brief 写入一个字符串,并写入换行符 + * @param txt 指定写入的字符串 + * + * + * @async + */ + writeLine(txt: string): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Chain.d.ts b/types/fibjs/declare/Chain.d.ts new file mode 100644 index 0000000000..9d980757af --- /dev/null +++ b/types/fibjs/declare/Chain.d.ts @@ -0,0 +1,63 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 消息处理器链处理对象 + * @detail 消息处理器链处理对象用于链接一系列消息处理器,按照指定的顺序链式处理。创建方法:,```JavaScript,var chain = new mq.Chain([, func1, func2,]);,``` + */ +/// +declare class Class_Chain extends Class_Handler { + + + + /** + * + * @brief 构造一个消息处理器链处理对象 + * @param hdlrs 处理器数组 + * + * + * + */ + constructor(hdlrs: any[]); + + /** + * + * @brief 添加处理器数组 + * @param hdlrs 处理器数组 + * + * + * + */ + append(hdlrs: any[]): void; + + /** + * + * @brief 添加处理器 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + append(hdlr: Class_Handler): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Cipher.d.ts b/types/fibjs/declare/Cipher.d.ts new file mode 100644 index 0000000000..cbae22fc3f --- /dev/null +++ b/types/fibjs/declare/Cipher.d.ts @@ -0,0 +1,149 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 对称加密算法对象 + * @detail Cipher 对象属于 crypto 模块,创建:,```JavaScript,var c = new crypto.Cipher(crypto.AES, crypto.ECB, ...);,``` + */ + +declare class Class_Cipher extends Class__object { + + /** + * class prop + * + * + * @brief 返回当前算法名称 + * + * @readonly + * @type String + */ + + name: string + + /** + * class prop + * + * + * @brief 返回当前算法密码长度,以位为单位 + * + * @readonly + * @type Integer + */ + + keySize: number + + /** + * class prop + * + * + * @brief 返回当前算法初始向量长度,以字节为单位 + * + * @readonly + * @type Integer + */ + + ivSize: number + + /** + * class prop + * + * + * @brief 返回当前算法数据块长度,以字节为单位 + * + * @readonly + * @type Integer + */ + + blockSize: number + + + + /** + * + * @brief Cipher 构造函数,仅用于 ARC4 初始化 + * @param provider 指定加密算法 + * @param key 指定加密解密密码 + * + * + * + */ + constructor(provider: number, key: Class_Buffer); + + /** + * + * @brief Cipher 构造函数 + * @param provider 指定加密算法 + * @param mode 指定分组密码工作模式 + * @param key 指定加密解密密码 + * + * + * + */ + constructor(provider: number, mode: number, key: Class_Buffer); + + /** + * + * @brief Cipher 构造函数 + * @param provider 指定加密算法 + * @param mode 指定分组密码工作模式 + * @param key 指定加密解密密码 + * @param iv 指定初始向量 + * + * + * + */ + constructor(provider: number, mode: number, key: Class_Buffer, iv: Class_Buffer); + + /** + * + * @brief 使用填充模式 + * @param mode 指定填充模式,缺省为 PADDING_PKCS7 + * + * + * + */ + paddingMode(mode: number): void; + + /** + * + * @brief 使用当前算法密码加密数据 + * @param data 指定要加密的数据 + * @return 返回加密后的数据 + * + * + * @async + */ + encrypt(data: Class_Buffer): Class_Buffer; + + /** + * + * @brief 使用当前算法密码解密数据 + * @param data 指定要解密的数据 + * @return 返回解密后的数据 + * + * + * @async + */ + decrypt(data: Class_Buffer): Class_Buffer; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Condition.d.ts b/types/fibjs/declare/Condition.d.ts new file mode 100644 index 0000000000..47b5e086fa --- /dev/null +++ b/types/fibjs/declare/Condition.d.ts @@ -0,0 +1,75 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 条件变量对象 + * @detail 条件变量是利用纤程间共享的全局变量来进行同步的一种机制,主要包括两个动作:,1)一个线程等待某个条件成立,而将自己挂起;,2)另一个线程使条件成立,并通知等待的纤程向下执行。,,为了防止竞争,每个条件变量都需要一个Lock的配合(Lock可自行显式创建并传递进来,也可交由fibjs为您创建),,通过使用条件变量,可以利用一个条件变量控制一批纤程的开关;,,以下是两个纤程调度的实例:,```JavaScript,var coroutine = require("coroutine");,var cond = new coroutine.Condition();,var ready = false;,var state = "ready";,,function funcwait() {, cond.acquire();, while (!ready), cond.wait();, state = "go", cond.release();,},,coroutine.start(funcwait);,,cond.acquire();,console.log(state),ready = true;,cond.notify();,coroutine.sleep();,console.log(state);,```,will output:,```sh,ready,go,``` + */ +/// +declare class Class_Condition extends Class_Lock { + + + + /** + * + * @brief 条件变量构造函数(条件变量所需的锁由fibjs内部构造) + * + * + */ + constructor(); + + /** + * + * @brief 条件变量构造函数 + * @param lock 使用自行构造的锁 + * + * + * + */ + constructor(lock: Class_Lock); + + /** + * + * @brief 使纤程进入阻塞状态 + * + * + */ + wait(): void; + + /** + * + * @brief 通知一个被阻塞的纤程(最后加入纤程池的)向下继续执行 + * + * + */ + notify(): void; + + /** + * + * @brief 通知所有被阻塞的纤程向下继续执行 + * + * + */ + notifyAll(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/DbConnection.d.ts b/types/fibjs/declare/DbConnection.d.ts new file mode 100644 index 0000000000..221db6a185 --- /dev/null +++ b/types/fibjs/declare/DbConnection.d.ts @@ -0,0 +1,119 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 数据库连接对象,用于建立和维护一个数据库连接会话。 + * @detail + */ + +declare class Class_DbConnection extends Class__object { + + /** + * class prop + * + * + * @brief 查询当前连接数据库类型 + * + * @readonly + * @type String + */ + + type: string + + + + /** + * + * @brief 关闭当前数据库连接 + * + * @async + */ + close(): void; + + /** + * + * @brief 在当前数据库连接上启动一个事务 + * + * @async + */ + begin(): void; + + /** + * + * @brief 提交当前数据库连接上的事务 + * + * @async + */ + commit(): void; + + /** + * + * @brief 回滚当前数据库连接上的事务 + * + * @async + */ + rollback(): void; + + /** + * + * @brief 进入事务执行一个函数,并根据函数执行情况提交或者回滚 + * func 执行有三种结果: + * * 函数正常返回,包括运行结束和主动 return,此时事务将自动提交 + * * 函数返回 false,此时事务将回滚 + * * 函数运行错误,事务自动回滚 + * + * @param func 以事务方式执行的函数 + * @return 返回事务是否提交,正常 commit 时返回 true, rollback 时返回 false,如果事务出错则抛出错误 + * + * + * + */ + trans(func: Function): boolean; + + /** + * + * @brief 执行一个 sql 命令,并返回执行结果,可根据参数格式化字符串 + * + * @param sql 格式化字符串,可选参数用 ? 指定。例如:'SELECT FROM TEST WHERE [id]=?' + * @param args 可选参数列表 + * @return 返回包含结果记录的数组,如果请求是 UPDATE 或者 INSERT,返回结果还会包含 affected 和 insertId,mssql 不支持 insertId。 + * + * + * @async + */ + execute(sql: string, ...args: any[]): any[]; + + /** + * + * @brief 格式化一个 sql 命令,并返回格式化结果 + * + * @param sql 格式化字符串,可选参数用 ? 指定。例如:'SELECT FROM TEST WHERE [id]=?' + * @param args 可选参数列表 + * @return 返回格式化之后的 sql 命令 + * + * + * + */ + format(sql: string, ...args: any[]): string; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/DgramSocket.d.ts b/types/fibjs/declare/DgramSocket.d.ts new file mode 100644 index 0000000000..58ec61209f --- /dev/null +++ b/types/fibjs/declare/DgramSocket.d.ts @@ -0,0 +1,180 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief dgram.Socket 对象是一个封装了数据包函数功能的 EventEmitter。 + * @detail DgramSocket 实例是由 dgram.createSocket() 创建的。创建 dgram.Socket 实例不需要使用 new 关键字。,,创建方法:,```JavaScript,var dgram = require('dgram');,var sock = dgram.createSocket('udp4');,```,,## 事件,DgramSocket 继承于 EventEmitter,对象的状态变化,以及数据接受,都是以事件的方式实现。,,### close 事件,** `close` 事件将在使用 `close()` 关闭一个 `socket` 之后触发。该事件一旦触发,这个 `socket` 上将不会触发新的 `message` 事件。**,,### error 事件,** 当有任何错误发生时,`error` 事件将被触发。 **,,### listening 事件,** 当一个 `socket` 开始监听数据包信息时,`listening` 事件将被触发。该事件会在创建 UDP socket 之后被立即触发。 **,,### message 事件,** 当有新的数据包被 `socket` 接收时,`message` 事件会被触发。`msg` 和 `rinfo` 会作为参数传递到该事件的处理函数中。 **,- msg: Buffer,消息,- rinfo: Object,远程地址信息, - address: string,发送方地址, - family: string,地址类型 ('IPv4' or 'IPv6'), - port: number,发送者端口, - size: number,消息大小 + */ +/// +declare class Class_DgramSocket extends Class_EventEmitter { + + + + /** + * + * @brief 该方法会令 dgram.Socket 在指定的 `port` 和 `addr` 上监听数据包信息。绑定完成时会触发一个 `listening` 事件。 + * @param port 指定绑定端口,若 `port` 未指定或为 0,操作系统会尝试绑定一个随机的端口 + * @param addr 指定绑定地址,若 address 未指定,操作系统会尝试在所有地址上监听。 + * + * + * @async + */ + bind(port?: number/** = 0*/, addr?: string/** = ""*/): void; + + /** + * + * @brief 该方法会令 dgram.Socket 在 `opts` 指定的 `port` 和 `address` 上监听数据包信息。绑定完成时会触发一个 `listening` 事件。 + * @param opts 指定绑定参数 + * + * + * @async + */ + bind(opts: Object): void; + + /** + * + * @brief 在 socket 上发送一个数据包 + * @param msg 指定发送的数据 + * @param port 指定发送的目的端口 + * @param address 指定发送的目的地址 + * @return 返回发送尺寸 + * + * + * @async + */ + send(msg: Class_Buffer, port: number, address?: string/** = ""*/): number; + + /** + * + * @brief 在 socket 上发送一个数据包 + * @param msg 指定发送的数据 + * @param offset 从指定偏移开始发送 + * @param length 之发送指定长度 + * @param port 指定发送的目的端口 + * @param address 指定发送的目的地址 + * @return 返回发送尺寸 + * + * + * @async + */ + send(msg: Class_Buffer, offset: number, length: number, port: number, address?: string/** = ""*/): number; + + /** + * + * @brief 返回一个包含 socket 地址信息的对象。对于 UDP socket,该对象将包含 address、family 和 port 属性。 + * @return 返回对象绑定地址 + * + * + * + */ + address(): any; + + /** + * + * @brief 关闭当前 socket + * + * + */ + close(): void; + + /** + * + * @brief 关闭当前 socket + * @param callback 关闭完成后的回调函数,它相当于为 `close` 事件添加了一个监听器 + * + * + * + */ + close(callback: Function): void; + + /** + * + * @brief 查询 socket 接收缓冲区大小 + * @return 返回查询结果 + * + * + * + */ + getRecvBufferSize(): number; + + /** + * + * @brief 查询 socket 发送缓冲区大小 + * @return 返回查询结果 + * + * + * + */ + getSendBufferSize(): number; + + /** + * + * @brief 设置 socket 接收缓冲区大小 + * @param size 指定要设置的尺寸 + * + * + * + */ + setRecvBufferSize(size: number): void; + + /** + * + * @brief 设置 socket 发送缓冲区大小 + * @param size 指定要设置的尺寸 + * + * + * + */ + setSendBufferSize(size: number): void; + + /** + * + * @brief 设置或清除 SO_BROADCAST socket 选项 + * @param flag 当设置为 true, UDP包会被发送到一个本地接口的广播地址 + * + * + * + */ + setBroadcast(flag: boolean): void; + + /** + * + * @brief 维持 fibjs 进程不退出,在对象绑定期间阻止 fibjs 进程退出 + * @return 返回当前对象 + * + * + * + */ + ref(): Class_DgramSocket; + + /** + * + * @brief 允许 fibjs 进程退出,在对象绑定期间允许 fibjs 进程退出 + * @return 返回当前对象 + * + * + * + */ + unref(): Class_DgramSocket; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Digest.d.ts b/types/fibjs/declare/Digest.d.ts new file mode 100644 index 0000000000..5486759cf1 --- /dev/null +++ b/types/fibjs/declare/Digest.d.ts @@ -0,0 +1,77 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 信息摘要对象 + * @detail + */ + +declare class Class_Digest extends Class__object { + + /** + * class prop + * + * + * @brief 查询当前信息摘要算法的摘要字节数 + * + * @readonly + * @type Integer + */ + + size: number + + + + /** + * + * @brief 更新二进制摘要信息 + * @param data 二进制数据块 + * @return 返回信息摘要对象本身 + * + * + * + */ + update(data: Class_Buffer): Class_Digest; + + /** + * + * @brief 计算并返回摘要 + * @param data 二进制数据块,此数据块将在计算前更新进摘要 + * @return 返回摘要的二进制数据 + * + * + * + */ + digest(data: Class_Buffer): Class_Buffer; + + /** + * + * @brief 计算并返回摘要 + * @return 返回摘要的二进制数据 + * + * + * + */ + digest(): Class_Buffer; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Event.d.ts b/types/fibjs/declare/Event.d.ts new file mode 100644 index 0000000000..00c6daa247 --- /dev/null +++ b/types/fibjs/declare/Event.d.ts @@ -0,0 +1,85 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 事件对象 + * @detail 通过一个事件达到对一组纤程进行控制的目的(事件对象的状态为bool类型) + */ +/// +declare class Class_Event extends Class_Lock { + + + + /** + * + * @brief 事件对象构造函数 + * @param value 指定是否等待,为 true 时等待,缺省为 false + * + * + * + */ + constructor(value?: boolean/** = false*/); + + /** + * + * @brief 判断事件对象是否为真 + * @return 如果事件为真,返回 true + * + * + * + */ + isSet(): boolean; + + /** + * + * @brief 激活事件(将事件状态改为true),并调用pulse() + * + * + */ + set(): void; + + /** + * + * @brief 激活等待该事件的所有纤程 + * + * + */ + pulse(): void; + + /** + * + * @brief 重置事件(将事件状态改为false) + * + * + */ + clear(): void; + + /** + * + * @brief 等待一个事件 + * + * + */ + wait(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/EventEmitter.d.ts b/types/fibjs/declare/EventEmitter.d.ts new file mode 100644 index 0000000000..afa0b3f4ac --- /dev/null +++ b/types/fibjs/declare/EventEmitter.d.ts @@ -0,0 +1,311 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 事件触发对象,可用于建立观察者模式,支持事件触发的对象均继承于此,同一事件的同一函数只会产生一次回调 + * @detail Event 对象可独立创建,以用于组建自定义的事件系统:,```JavaScript,var EventEmitter = require('events');,,var e = new EventEmitter();,``` + */ + +declare class Class_EventEmitter extends Class__object { + + /** + * class prop + * + * + * @brief 默认全局最大监听器数 + * @static + * + * @type Integer + */ + + defaultMaxListeners: number + + + + /** + * + * @brief 构造函数 + * + * + */ + constructor(); + + /** + * + * @brief 绑定一个事件处理函数到对象 + * @param ev 指定事件的名称 + * @param func 指定事件处理函数 + * @return 返回成功绑定的数量,如果函数已绑定则返回 0 + * + * + * + */ + on(ev: string, func: Function): Object; + + /** + * + * @brief 绑定一个事件处理函数到对象 + * @param map 指定事件映射关系,对象属性名称将作为事件名称,属性的值将作为事件处理函数 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + on(map: Object): Object; + + /** + * + * @brief 绑定一个事件处理函数到对象 + * @param ev 指定事件的名称 + * @param func 指定事件处理函数 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + addListener(ev: string, func: Function): Object; + + /** + * + * @brief 绑定一个事件处理函数到对象 + * @param map 指定事件映射关系,对象属性名称将作为事件名称,属性的值将作为事件处理函数 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + addListener(map: Object): Object; + + /** + * + * @brief 绑定一个事件处理函数到对象起始 + * @param ev 指定事件的名称 + * @param func 指定事件处理函数 + * @return 返回成功绑定的数量,如果函数已绑定则返回 0 + * + * + * + */ + prependListener(ev: string, func: Function): Object; + + /** + * + * @brief 绑定一个事件处理函数到对象起始 + * @param map 指定事件映射关系,对象属性名称将作为事件名称,属性的值将作为事件处理函数 + * @return 返回成功绑定的数量,如果函数已绑定则返回 0 + * + * + * + */ + prependListener(map: Object): Object; + + /** + * + * @brief 绑定一个一次性事件处理函数到对象,一次性处理函数只会触发一次 + * @param ev 指定事件的名称 + * @param func 指定事件处理函数 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + once(ev: string, func: Function): Object; + + /** + * + * @brief 绑定一个一次性事件处理函数到对象,一次性处理函数只会触发一次 + * @param map 指定事件映射关系,对象属性名称将作为事件名称,属性的值将作为事件处理函数 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + once(map: Object): Object; + + /** + * + * @brief 绑定一个事件处理函数到对象起始 + * @param ev 指定事件的名称 + * @param func 指定事件处理函数 + * @return 返回成功绑定的数量,如果函数已绑定则返回 0 + * + * + * + */ + prependOnceListener(ev: string, func: Function): Object; + + /** + * + * @brief 绑定一个事件处理函数到对象起始 + * @param map 指定事件映射关系,对象属性名称将作为事件名称,属性的值将作为事件处理函数 + * @return 返回成功绑定的数量,如果函数已绑定则返回 0 + * + * + * + */ + prependOnceListener(map: Object): Object; + + /** + * + * @brief 从对象处理队列中取消指定函数 + * @param ev 指定事件的名称 + * @param func 指定事件处理函数 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + off(ev: string, func: Function): Object; + + /** + * + * @brief 取消对象处理队列中的全部函数 + * @param ev 指定事件的名称 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + off(ev: string): Object; + + /** + * + * @brief 从对象处理队列中取消指定函数 + * @param map 指定事件映射关系,对象属性名称作为事件名称,属性的值作为事件处理函数 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + off(map: Object): Object; + + /** + * + * @brief 从对象处理队列中取消指定函数 + * @param ev 指定事件的名称 + * @param func 指定事件处理函数 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + removeListener(ev: string, func: Function): Object; + + /** + * + * @brief 取消对象处理队列中的全部函数 + * @param ev 指定事件的名称 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + removeListener(ev: string): Object; + + /** + * + * @brief 从对象处理队列中取消指定函数 + * @param map 指定事件映射关系,对象属性名称作为事件名称,属性的值作为事件处理函数 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + removeListener(map: Object): Object; + + /** + * + * @brief 从对象处理队列中取消所有事件的所有监听器, 如果指定事件,则移除指定事件的所有监听器。 + * @param evs 指定事件的名称 + * @return 返回事件对象本身,便于链式调用 + * + * + * + */ + removeAllListeners(evs?: any[]/** = v8::Array::New(isolate)*/): Object; + + /** + * + * 监听器的默认限制的数量,仅用于兼容 + * @param n 指定事件的数量 + * + * + * + */ + setMaxListeners(n: number): void; + + /** + * + * 获取监听器的默认限制的数量,仅用于兼容 + * @return 返回默认限制数量 + * + * + * + */ + getMaxListeners(): number; + + /** + * + * @brief 查询对象指定事件的监听器数组 + * @param ev 指定事件的名称 + * @return 返回指定事件的监听器数组 + * + * + * + */ + listeners(ev: string): any[]; + + /** + * + * @brief 查询对象指定事件的监听器数量 + * @param ev 指定事件的名称 + * @return 返回指定事件的监听器数量 + * + * + * + */ + listenerCount(ev: string): number; + + /** + * + * @brief 查询监听器事件名称 + * @return 返回事件名称数组 + * + * + * + */ + eventNames(): any[]; + + /** + * + * @brief 主动触发一个事件 + * @param ev 事件名称 + * @param args 事件参数,将会传递给事件处理函数 + * @return 返回事件触发状态,有响应事件返回 true,否则返回 false + * + * + * + */ + emit(ev: string, ...args: any[]): boolean; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/EventInfo.d.ts b/types/fibjs/declare/EventInfo.d.ts new file mode 100644 index 0000000000..f108f8e7bd --- /dev/null +++ b/types/fibjs/declare/EventInfo.d.ts @@ -0,0 +1,81 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 事件信息对象,用于在事件中传递信息 + * @detail + */ + +declare class Class_EventInfo extends Class__object { + + /** + * class prop + * + * + * 查询事件错误编码 + * + * @readonly + * @type Integer + */ + + code: number + + /** + * class prop + * + * + * 查询事件错误信息 + * + * @readonly + * @type String + */ + + reason: string + + /** + * class prop + * + * + * 查询事件类型 + * + * @readonly + * @type String + */ + + type: string + + /** + * class prop + * + * + * 查询触发事件的对象 + * + * @readonly + * @type Object + */ + + target: Object + + + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Fiber.d.ts b/types/fibjs/declare/Fiber.d.ts new file mode 100644 index 0000000000..546e099e5d --- /dev/null +++ b/types/fibjs/declare/Fiber.d.ts @@ -0,0 +1,77 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 纤程操作对象,此对象不可直接创建 + * @detail 使用 coroutine.start 创建纤程后,将返回此对象,用于纤程处理和纤程间通信。,纤程主函数可以通过 this 访问本纤程对象,也可通过 coroutine.current 获取当前纤程。,```JavaScript,function func(v1),{, console.log(v1 + this.v);,},,var fb = coroutine.start(func,100);,,fb.v = 123;,,fb.join();,```,,纤程局部存储通过共享的 Fiber 对象完成,通过 coroutine.current 获取当前纤程,通过修改和查询其变量达到共享数据的目的。,,```JavaScript,function func(),{, console.log(coroutine.current().v);,},,coroutine.current().v = 100;,,func();,```,,纤程在创建时,会自动复制当前纤程的局部变量到新的纤程,之后,各自的局部变量的修改不会相互影响,除非变量本身为对象引用。,,```JavaScript,function func(),{, console.log(coroutine.current().v);,},,coroutine.current().v = 100;,,var fb = coroutine.start(func);,,coroutine.current().v = 200;,,fb.join();,``` + */ + +declare class Class_Fiber extends Class__object { + + /** + * class prop + * + * + * @brief 查询纤程的唯一 id + * + * @readonly + * @type Long + */ + + id: number + + /** + * class prop + * + * + * @brief 查询纤程的调用纤程 + * + * @readonly + * @type Fiber + */ + + caller: Class_Fiber + + /** + * class prop + * + * + * @brief 查询纤程的调用堆栈 + * + * @readonly + * @type String + */ + + stack: string + + + + /** + * + * @brief 等待纤程结束 + * + * + */ + join(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/File.d.ts b/types/fibjs/declare/File.d.ts new file mode 100644 index 0000000000..bf42f7f8b0 --- /dev/null +++ b/types/fibjs/declare/File.d.ts @@ -0,0 +1,67 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 文件操作对象,用于二进制文件读写 + * @detail 文件操作对象用于对二进制文件进行操作,可使用 fs 模块打开和创建文件:,```JavaScript,var f = fs.openFile('test.txt');,``` + */ +/// +declare class Class_File extends Class_SeekableStream { + + /** + * class prop + * + * + * @brief 查询当前文件名 + * + * @readonly + * @type String + */ + + name: string + + /** + * class prop + * + * + * @brief 查询当前文件描述符 + * + * @readonly + * @type Integer + */ + + fd: number + + + + /** + * + * @brief 查询当前文件的访问权限,Windows 不支持此方法 + * @param mode 指定设定的访问权限 + * + * + * @async + */ + chmod(mode: number): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Handler.d.ts b/types/fibjs/declare/Handler.d.ts new file mode 100644 index 0000000000..1dcae285f5 --- /dev/null +++ b/types/fibjs/declare/Handler.d.ts @@ -0,0 +1,74 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 消息处理器接口 + * @detail + */ + +declare class Class_Handler extends Class__object { + + + + /** + * + * @brief 构造一个消息处理器链处理对象 + * @param hdlrs 处理器数组 + * + * + * + */ + constructor(hdlrs: any[]); + + /** + * + * @brief 创建一个消息处理器路由对象 + * @param map 初始化路由参数 + * + * + * + */ + constructor(map: Object); + + /** + * + * @brief 创建一个 JavaSvript 消息处理器 + * @param hdlr JavaScript 处理器函数 + * + * + * + */ + constructor(hdlr: Function); + + /** + * + * @brief 处理一个消息或对象 + * @param v 指定处理的消息或对象 + * @return 返回下一步的处理器 + * + * + * @async + */ + invoke(v: Class__object): Class_Handler; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HandlerEx.d.ts b/types/fibjs/declare/HandlerEx.d.ts new file mode 100644 index 0000000000..1e95e65335 --- /dev/null +++ b/types/fibjs/declare/HandlerEx.d.ts @@ -0,0 +1,90 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 扩展消息处理器接口 + * @detail + */ +/// +declare class Class_HandlerEx extends Class_Handler { + + /** + * class prop + * + * + * @brief WebSocket 协议转换处理器当前事件处理接口对象 + * + * + * @type Handler + */ + + handler: Class_Handler + + /** + * class prop + * + * + * @brief 查询 WebSocket 包协议转换处理器的工作状态 + * + * 返回的结果为一个 Stats 对象,结构如下: + * ```JavaScript + * { + * total : 1000, // 总计处理的请求 + * pendding : 100, // 当前正在处理的请求 + * request : 10, // 新建的请求 + * response : 10, // 发送的响应 + * error : 100 // 发生的错误 + * } + * ``` + * + * + * @readonly + * @type Stats + */ + + stats: Class_Stats + + + + /** + * + * @brief 设置错误处理器 + * + * 使用方式: + * ```JavaScript + * hdlr.onerror({ + * "404": function(v) + * { + * ... + * }, + * "500": new mq.Routing(...) + * }) + * ``` + * @param hdlrs 指定不同的错误的处理器,key 是错误号,value 是处理器,可以是内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + onerror(hdlrs: Object): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HeapGraphEdge.d.ts b/types/fibjs/declare/HeapGraphEdge.d.ts new file mode 100644 index 0000000000..55f301ba0d --- /dev/null +++ b/types/fibjs/declare/HeapGraphEdge.d.ts @@ -0,0 +1,97 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief HeapGraphEdge表示两个HeapGraphNode节点间的关联,从上游节点到下游节点 + * @detail + */ + +declare class Class_HeapGraphEdge extends Class__object { + + /** + * class prop + * + * + * @brief 下游节点的链接方式,可能的值: + * - profiler.Edge_ContextVariable, 函数中的变量 + * - profiler.Edge_Element, 数组中的元素 + * - profiler.Edge_Property, 有名对象的属性 + * - profiler.Edge_Internal, JS无法进入的链接 + * - profiler.Edge_Hidden, 指向需要事先计算出空间大小的节点 + * - profiler.Edge_Shortcut, 指向无法事先计算出空间大小的节点 + * - profiler.Edge_Weak, 一个弱引用(被GC忽视) + * + * + * @readonly + * @type Integer + */ + + type: number + + /** + * class prop + * + * + * @brief 链接名称 + * + * @readonly + * @type String + */ + + name: string + + /** + * class prop + * + * + * @brief 链接的描述 + * + * @readonly + * @type String + */ + + description: string + + + + /** + * + * @brief 获取HeapGraphEdge的上游HeapGraphNode节点 + * @return 返回源HeapGraphNode节点 + * + * + * + */ + getFromNode(): Class_HeapGraphNode; + + /** + * + * @brief 获取HeapGraphEdge的下游HeapGraphNode节点 + * @return 返回目的HeapGraphNode节点 + * + * + * + */ + getToNode(): Class_HeapGraphNode; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HeapGraphNode.d.ts b/types/fibjs/declare/HeapGraphNode.d.ts new file mode 100644 index 0000000000..bdecf5b967 --- /dev/null +++ b/types/fibjs/declare/HeapGraphNode.d.ts @@ -0,0 +1,120 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief HeapGraphNode表示堆视图中的一个节点 + * @detail + */ + +declare class Class_HeapGraphNode extends Class__object { + + /** + * class prop + * + * + * @brief 节点类型,可能的值: + * - profiler.Node_Hidden, 隐藏节点,当显示给用户时可以被过滤掉 + * - profiler.Node_Array, 数组 + * - profiler.Node_String, 字符串 + * - profiler.Node_Object, JS对象(字符串和数组除外) + * - profiler.Node_Code, 编译后的代码 + * - profiler.Node_Closure, 函数闭包 + * - profiler.Node_RegExp, 正则表达式 + * - profiler.Node_HeapNumber, 堆中排好序的数字 + * - profiler.Node_Native, Native对象(非v8堆上的) + * - profiler.Node_Synthetic, Synthetic对象 + * - profiler.Node_ConsString, 拼接的字符串 + * - profiler.Node_SlicedString, 分割的字符串 + * - profiler.Node_Symbol, 符号(ES6) + * - profiler.Node_SimdValue, 堆中排好序的SIMD值(ES7) + * + * + * @readonly + * @type Integer + */ + + type: number + + /** + * class prop + * + * + * @brief 节点名称 + * + * @readonly + * @type String + */ + + name: string + + /** + * class prop + * + * + * @brief 节点的描述 + * + * @readonly + * @type String + */ + + description: string + + /** + * class prop + * + * + * @brief 节点ID + * + * @readonly + * @type Integer + */ + + id: number + + /** + * class prop + * + * + * @brief 节点大小,单位为字节 + * + * @readonly + * @type Integer + */ + + shallowSize: number + + /** + * class prop + * + * + * @brief 子节点列表,由HeapGraphEdge类型对象组成 + * + * @readonly + * @type NArray + */ + + childs: any[] + + + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HeapSnapshot.d.ts b/types/fibjs/declare/HeapSnapshot.d.ts new file mode 100644 index 0000000000..8b2e797206 --- /dev/null +++ b/types/fibjs/declare/HeapSnapshot.d.ts @@ -0,0 +1,101 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief HeapSnapshots记录JS堆在某个时刻的状态 + * @detail + */ + +declare class Class_HeapSnapshot extends Class__object { + + /** + * class prop + * + * + * @brief 时间信息 + * + * @readonly + * @type Date + */ + + time: Date + + /** + * class prop + * + * + * @brief 堆视图的根节点 + * + * @readonly + * @type HeapGraphNode + */ + + root: Class_HeapGraphNode + + /** + * class prop + * + * + * @brief 堆视图节点组成的列表 + * + * @readonly + * @type NArray + */ + + nodes: any[] + + + + /** + * + * @brief 和指定的堆快照进行比较 + * @param before 待比较的堆快照 + * @return 返回堆快照的比较结果 + * + * + * + */ + diff(before: Class_HeapSnapshot): Object; + + /** + * + * @brief 根据ID获取堆视图节点 + * @param id 数字类型的节点ID + * @return 返回获取到的堆视图节点 + * + * + * + */ + getNodeById(id: number): Class_HeapGraphNode; + + /** + * + * @brief 根据指定名称保存HeapSnapshot + * @param fname 快照名称 + * + * + * @async + */ + save(fname: string): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HttpClient.d.ts b/types/fibjs/declare/HttpClient.d.ts new file mode 100644 index 0000000000..17520b37f0 --- /dev/null +++ b/types/fibjs/declare/HttpClient.d.ts @@ -0,0 +1,258 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief http客户端对象 + * @detail http客户端对象模拟浏览器环境缓存cookie,并在访问url的时候携带对应的cookie,不同的http客户端对象是相互隔离的,提供http的request、get、post等方法。,用法如下:,,```JavaScript,var http = require('http');,var httpClient = new http.Client();,httpClient.request('GET', 'http://fibjs.org');,``` + */ + +declare class Class_HttpClient extends Class__object { + + /** + * class prop + * + * + * @brief 返回http客户端的 HttpCookie 对象列表 + * + * @readonly + * @type NArray + */ + + cookies: any[] + + /** + * class prop + * + * + * @brief 查询和设置超时时间 单位毫秒 + * + * + * @type Integer + */ + + timeout: number + + /** + * class prop + * + * + * @brief 查询和设置 body 最大尺寸,以 MB 为单位,缺省为 -1,不限制尺寸 + * + * + * @type Integer + */ + + maxBodySize: number + + /** + * class prop + * + * + * @brief cookie功能开关,默认开启 + * + * + * @type Boolean + */ + + enableCookie: boolean + + /** + * class prop + * + * + * @brief 自动redirect功能开关,默认开启 + * + * + * @type Boolean + */ + + autoRedirect: boolean + + /** + * class prop + * + * + * @brief 查询和设置 http 请求中的浏览器标识 + * + * + * @type String + */ + + userAgent: string + + + + /** + * + * @brief HttpClient 构造函数,创建一个新的HttpClient对象 + * + * + */ + constructor(); + + /** + * + * @brief 发送 http 请求到指定的流对象,并返回结果 + * @param conn 指定处理请求的流对象 + * @param req 要发送的 HttpRequest 对象 + * @return 返回服务器响应 + * + * + * @async + */ + request(conn: Class_Stream, req: Class_HttpRequest): Class_HttpResponse; + + /** + * + * @brief 请求指定的 url,并返回结果 + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param method 指定 http 请求方法:GET, POST 等 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + request(method: string, url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + /** + * + * @brief 用 GET 方法请求指定的 url,并返回结果,等同于 request("GET", ...) + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + get(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + /** + * + * @brief 用 POST 方法请求指定的 url,并返回结果,等同于 request("POST", ...) + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + post(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + /** + * + * @brief 用 DELETE 方法请求指定的 url,并返回结果,等同于 request("DELETE", ...) + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + del(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + /** + * + * @brief 用 PUT 方法请求指定的 url,并返回结果,等同于 request("PUT", ...) + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + put(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + /** + * + * @brief 用 PATCH 方法请求指定的 url,并返回结果,等同于 request("PATCH", ...) + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + patch(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HttpCollection.d.ts b/types/fibjs/declare/HttpCollection.d.ts new file mode 100644 index 0000000000..631e9a3717 --- /dev/null +++ b/types/fibjs/declare/HttpCollection.d.ts @@ -0,0 +1,126 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief http 容器对象,用于 http header,cookie,query,form,等数据的存储与组织 + * @detail + */ + +declare class Class_HttpCollection extends Class__object { + + + + /** + * + * @brief 清除容器数据 + * + * + */ + clear(): void; + + /** + * + * @brief 检查容器内是否存在指定键值的数据 + * @param name 指定要检查的键值 + * @return 返回键值是否存在 + * + * + * + */ + has(name: string): boolean; + + /** + * + * @brief 查询指定键值的第一个值 + * @param name 指定要查询的键值 + * @return 返回键值所对应的值,若不存在,则返回 undefined + * + * + * + */ + first(name: string): any; + + /** + * + * @brief 查询指定键值的全部值 + * @param name 指定要查询的键值 + * @return 返回键值所对应全部值的数组,若数据不存在,则返回 null + * + * + * + */ + all(name: string): any[]; + + /** + * + * @brief 添加一个键值数据,添加数据并不修改已存在的键值的数据 + * @param map 指定要添加的键值数据字典 + * + * + * + */ + add(map: Object): void; + + /** + * + * @brief 添加一个键值数据,添加数据并不修改已存在的键值的数据 + * @param name 指定要添加的键值 + * @param value 指定要添加的数据 + * + * + * + */ + add(name: string, value: any): void; + + /** + * + * @brief 设定一个键值数据,设定数据将修改键值所对应的第一个数值,并清除相同键值的其余数据 + * @param map 指定要设定的键值数据字典 + * + * + * + */ + set(map: Object): void; + + /** + * + * @brief 设定一个键值数据,设定数据将修改键值所对应的第一个数值,并清除相同键值的其余数据 + * @param name 指定要设定的键值 + * @param value 指定要设定的数据 + * + * + * + */ + set(name: string, value: any): void; + + /** + * + * @brief 删除指定键值的全部值 + * @param name 指定要删除的键值 + * + * + * + */ + remove(name: string): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HttpCookie.d.ts b/types/fibjs/declare/HttpCookie.d.ts new file mode 100644 index 0000000000..7c3827de68 --- /dev/null +++ b/types/fibjs/declare/HttpCookie.d.ts @@ -0,0 +1,160 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief http Cookie 对象,用于添加和处理 cookie + * @detail + */ + +declare class Class_HttpCookie extends Class__object { + + /** + * class prop + * + * + * @brief 查询和设置 cookie 名称 + * + * + * @type String + */ + + name: string + + /** + * class prop + * + * + * @brief 查询和设置 cookie 的值 + * + * + * @type String + */ + + value: string + + /** + * class prop + * + * + * @brief 查询和设置 cookie 的域名范围 + * + * + * @type String + */ + + domain: string + + /** + * class prop + * + * + * @brief 查询和设置 cookie 的路径范围 + * + * + * @type String + */ + + path: string + + /** + * class prop + * + * + * @brief 查询和设置 cookie 的过期时间 + * + * + * @type Date + */ + + expires: Date + + /** + * class prop + * + * + * @brief 查询和设置 cookie 是否仅允许 http 请求,缺省 false + * + * + * @type Boolean + */ + + httpOnly: boolean + + /** + * class prop + * + * + * @brief 查询和设置 cookie 是否仅通过 https 传递,缺省 false + * + * + * @type Boolean + */ + + secure: boolean + + + + /** + * + * @brief HttpCookie 构造函数,创建一个新的 HttpCookie 对象 + * @param opts 指定创建的 cookie 的属性 + * + * + * + */ + constructor(opts?: Object/** = v8::Object::New(isolate)*/); + + /** + * + * @brief HttpCookie 构造函数,创建一个新的 HttpCookie 对象 + * @param name 指定创建的 cookie 名称 + * @param value 指定创建的 cookie 值 + * @param opts 指定创建的 cookie 的其它属性 + * + * + * + */ + constructor(name: string, value: string, opts?: Object/** = v8::Object::New(isolate)*/); + + /** + * + * @brief 解析给定的字符串,填充 cookie 对象 + * @param header 指定需要解析的 header 字符串 + * + * + * + */ + parse(header: string): void; + + /** + * + * @brief 检测给定的 url 是否匹配当前设置 + * @param url 指定测试的 url + * @return 匹配成功返回 true + * + * + * + */ + match(url: string): boolean; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HttpHandler.d.ts b/types/fibjs/declare/HttpHandler.d.ts new file mode 100644 index 0000000000..6ab5067b29 --- /dev/null +++ b/types/fibjs/declare/HttpHandler.d.ts @@ -0,0 +1,101 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief http 协议转换处理器 + * @detail 用以将数据流转换为 http 协议消息,创建方式:,```JavaScript,var hdlr = new mq.HttpHandler(...);,```,或者:,```JavaScript,var hdlr = new http.Handler(...);,``` + */ +/// +declare class Class_HttpHandler extends Class_HandlerEx { + + /** + * class prop + * + * + * @brief 查询和设置是否允强制使用 gzip 压缩输出,缺省为 false + * + * + * @type Boolean + */ + + forceGZIP: boolean + + /** + * class prop + * + * + * @brief 查询和设置最大请求头个数,缺省为 128 + * + * + * @type Integer + */ + + maxHeadersCount: number + + /** + * class prop + * + * + * @brief 查询和设置 body 最大尺寸,以 MB 为单位,缺省为 64 + * + * + * @type Integer + */ + + maxBodySize: number + + /** + * class prop + * + * + * @brief 查询和设置服务器名称,缺省为:fibjs/0.x.0 + * + * + * @type String + */ + + serverName: string + + + + /** + * + * @brief 创建一个 http 协议处理器对象,将流对象的数据转变为 http 消息对象 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(hdlr: Class_Handler); + + /** + * + * @brief 允许跨域请求 + * @param allowHeaders 指定接受的 http 头字段 + * + * + * + */ + enableCrossOrigin(allowHeaders?: string/** = "Content-Type"*/): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HttpMessage.d.ts b/types/fibjs/declare/HttpMessage.d.ts new file mode 100644 index 0000000000..1e745b0529 --- /dev/null +++ b/types/fibjs/declare/HttpMessage.d.ts @@ -0,0 +1,202 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief http 基础消息对象 + * @detail + */ +/// +declare class Class_HttpMessage extends Class_Message { + + /** + * class prop + * + * + * @brief 协议版本信息,允许的格式为:HTTP/#.# + * + * + * @type String + */ + + protocol: string + + /** + * class prop + * + * + * @brief 包含消息中 http 消息头的容器,只读属性 + * + * @readonly + * @type HttpCollection + */ + + headers: Class_HttpCollection + + /** + * class prop + * + * + * @brief 查询和设定是否保持连接 + * + * + * @type Boolean + */ + + keepAlive: boolean + + /** + * class prop + * + * + * @brief 查询和设定是否是升级协议 + * + * + * @type Boolean + */ + + upgrade: boolean + + /** + * class prop + * + * + * @brief 查询和设置最大请求头个数,缺省为 128 + * + * + * @type Integer + */ + + maxHeadersCount: number + + /** + * class prop + * + * + * @brief 查询和设置 body 最大尺寸,以 MB 为单位,缺省为 64 + * + * + * @type Integer + */ + + maxBodySize: number + + /** + * class prop + * + * + * @brief 查询当前对象的来源 socket + * + * @readonly + * @type Stream + */ + + socket: Class_Stream + + + + /** + * + * @brief 检查是否存在指定键值的消息头 + * @param name 指定要检查的键值 + * @return 返回键值是否存在 + * + * + * + */ + hasHeader(name: string): boolean; + + /** + * + * @brief 查询指定键值的第一个消息头 + * @param name 指定要查询的键值 + * @return 返回键值所对应的值,若不存在,则返回 undefined + * + * + * + */ + firstHeader(name: string): any; + + /** + * + * @brief 查询指定键值的全部消息头 + * @param name 指定要查询的键值 + * @return 返回键值所对应全部值的数组,若数据不存在,则返回 null + * + * + * + */ + allHeader(name: string): any[]; + + /** + * + * @brief 添加一个消息头,添加数据并不修改已存在的键值的消息头 + * @param map 指定要添加的键值数据字典 + * + * + * + */ + addHeader(map: Object): void; + + /** + * + * @brief 添加一个消息头,添加数据并不修改已存在的键值的消息头 + * @param name 指定要添加的键值 + * @param value 指定要添加的数据 + * + * + * + */ + addHeader(name: string, value: any): void; + + /** + * + * @brief 设定一个消息头,设定数据将修改键值所对应的第一个数值,并清除相同键值的其余消息头 + * @param map 指定要设定的键值数据字典 + * + * + * + */ + setHeader(map: Object): void; + + /** + * + * @brief 设定一个消息头,设定数据将修改键值所对应的第一个数值,并清除相同键值的其余消息头 + * @param name 指定要设定的键值 + * @param value 指定要设定的数据 + * + * + * + */ + setHeader(name: string, value: any): void; + + /** + * + * @brief 删除指定键值的全部消息头 + * @param name 指定要删除的键值 + * + * + * + */ + removeHeader(name: string): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HttpRequest.d.ts b/types/fibjs/declare/HttpRequest.d.ts new file mode 100644 index 0000000000..20a129129e --- /dev/null +++ b/types/fibjs/declare/HttpRequest.d.ts @@ -0,0 +1,125 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief http 请求消息对象 + * @detail + */ +/// +declare class Class_HttpRequest extends Class_HttpMessage { + + /** + * class prop + * + * + * @brief 获取响应消息对象 + * + * @readonly + * @type HttpResponse + */ + + response: Class_HttpResponse + + /** + * class prop + * + * + * @brief 查询和设置请求方法 + * + * + * @type String + */ + + method: string + + /** + * class prop + * + * + * @brief 查询和设置请求地址 + * + * + * @type String + */ + + address: string + + /** + * class prop + * + * + * @brief 查询和设置请求查询字符串 + * + * + * @type String + */ + + queryString: string + + /** + * class prop + * + * + * @brief 获取包含消息 cookies 的容器 + * + * @readonly + * @type HttpCollection + */ + + cookies: Class_HttpCollection + + /** + * class prop + * + * + * @brief 获取包含消息 form 的容器 + * + * @readonly + * @type HttpCollection + */ + + form: Class_HttpCollection + + /** + * class prop + * + * + * @brief 获取包含消息 query 的容器 + * + * @readonly + * @type HttpCollection + */ + + query: Class_HttpCollection + + + + /** + * + * @brief HttpRequest 构造函数,创建一个新的 HttpRequest 对象 + * + * + */ + constructor(); + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HttpResponse.d.ts b/types/fibjs/declare/HttpResponse.d.ts new file mode 100644 index 0000000000..b7a3ac4aaa --- /dev/null +++ b/types/fibjs/declare/HttpResponse.d.ts @@ -0,0 +1,130 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief http 响应消息对象 + * @detail + */ +/// +declare class Class_HttpResponse extends Class_HttpMessage { + + /** + * class prop + * + * + * @brief 查询和设置响应消息的返回状态 + * + * + * @type Integer + */ + + statusCode: number + + /** + * class prop + * + * + * @brief 查询和设置响应消息的返回消息 + * + * + * @type String + */ + + statusMessage: string + + /** + * class prop + * + * + * @brief 返回当前消息的 HttpCookie 对象列表 + * + * @readonly + * @type NArray + */ + + cookies: any[] + + + + /** + * + * @brief HttpResponse 构造函数,创建一个新的 HttpResponse 对象 + * + * + */ + constructor(); + + /** + * + * @brief 设置响应消息的返回状态,返回消息,并添加响应头 + * @param statusCode 指定响应消息的返回状态 + * @param statusMessage 指定响应消息的返回消息 + * @param headers 指定响应消息添加的响应头 + * + * + * + */ + writeHead(statusCode: number, statusMessage: string, headers?: Object/** = v8::Object::New(isolate)*/): void; + + /** + * + * @brief 设置响应消息的返回状态,返回消息,并添加响应头 + * @param statusCode 指定响应消息的返回状态 + * @param headers 指定响应消息添加的响应头 + * + * + * + */ + writeHead(statusCode: number, headers?: Object/** = v8::Object::New(isolate)*/): void; + + /** + * + * @brief 向 cookies 添加一个 HttpCookie 对象 + * @param cookie 指定要添加的 HttpCookie 对象 + * + * + * + */ + addCookie(cookie: Class_HttpCookie): void; + + /** + * + * @brief 发送重定向到客户端 + * @param url 重定向的地址 + * + * + * + */ + redirect(url: string): void; + + /** + * + * @brief 仅发送格式化 http 头到给定的流对象 + * @param stm 指定接收格式化消息的流对象 + * + * + * @async + */ + sendHeader(stm: Class_Stream): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HttpServer.d.ts b/types/fibjs/declare/HttpServer.d.ts new file mode 100644 index 0000000000..1ef964bb09 --- /dev/null +++ b/types/fibjs/declare/HttpServer.d.ts @@ -0,0 +1,162 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief http 服务器对象 + * @detail http 服务器对象是将 TcpServer 和 HttpHandler 组合封装的对象,方便快速搭建服务器,逻辑上相当于:,```JavaScript,var svr = new net.TcpServer(addr, port, new http.Handler(function(req){, ...,}));,```,,创建方法:,```JavaScript,var http = require("http");,var svr = new http.Server(80, function(req){, ...,});,``` + */ +/// +declare class Class_HttpServer extends Class_TcpServer { + + /** + * class prop + * + * + * @brief 查询和设置是否允强制使用 gzip 压缩输出,缺省为 false + * + * + * @type Boolean + */ + + forceGZIP: boolean + + /** + * class prop + * + * + * @brief 查询和设置最大请求头个数,缺省为 128 + * + * + * @type Integer + */ + + maxHeadersCount: number + + /** + * class prop + * + * + * @brief 查询和设置 body 最大尺寸,以 MB 为单位,缺省为 64 + * + * + * @type Integer + */ + + maxBodySize: number + + /** + * class prop + * + * + * @brief 查询和设置服务器名称,缺省为:fibjs/0.x.0 + * + * + * @type String + */ + + serverName: string + + /** + * class prop + * + * + * @brief 查询 http 协议转换处理器的工作状态 + * + * 返回的结果为一个 Stats 对象,结构如下: + * ```JavaScript + * { + * total : 1000, // 总计处理的请求 + * pendding : 100, // 当前正在处理的请求 + * request : 10, // 新建的请求 + * response : 10, // 发送的响应 + * error : 100, // 发生的错误(不计入 404) + * error_400 : 10, // 发生的请求错误 + * error_404 : 12, // 文件未找到的数量 + * error_500 : 2 // 内部处理错误 + * } + * ``` + * + * + * @readonly + * @type Stats + */ + + httpStats: Class_Stats + + + + /** + * + * @brief HttpServer 构造函数,在所有本机地址侦听 + * @param port 指定 http 服务器侦听端口 + * @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(port: number, hdlr: Class_Handler); + + /** + * + * @brief HttpServer 构造函数 + * @param addr 指定 http 服务器侦听地址,为 "" 则在本机所有地址侦听 + * @param port 指定 http 服务器侦听端口 + * @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(addr: string, port: number, hdlr: Class_Handler); + + /** + * + * @brief 设置错误处理器 + * + * 使用方式: + * ```JavaScript + * hdlr.onerror({ + * "404": function(v) + * { + * ... + * }, + * "500": new mq.Routing(...) + * }) + * ``` + * @param hdlrs 指定不同的错误的处理器,key 是错误号,value 是处理器,可以是内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + onerror(hdlrs: Object): void; + + /** + * + * @brief 允许跨域请求 + * @param allowHeaders 指定接受的 http 头字段 + * + * + * + */ + enableCrossOrigin(allowHeaders?: string/** = "Content-Type"*/): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HttpUploadData.d.ts b/types/fibjs/declare/HttpUploadData.d.ts new file mode 100644 index 0000000000..8d88b2b125 --- /dev/null +++ b/types/fibjs/declare/HttpUploadData.d.ts @@ -0,0 +1,81 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 包含 multipart 的一个条目数据 + * @detail + */ + +declare class Class_HttpUploadData extends Class__object { + + /** + * class prop + * + * + * @brief 包含本条目数据的文件名 + * + * @readonly + * @type String + */ + + fileName: string + + /** + * class prop + * + * + * @brief 包含本条目数据的类型 + * + * @readonly + * @type String + */ + + contentType: string + + /** + * class prop + * + * + * @brief 包含本条目数据的传输编码类型 + * + * @readonly + * @type String + */ + + contentTransferEncoding: string + + /** + * class prop + * + * + * @brief 包含本条目数据部分的流对象 + * + * @readonly + * @type SeekableStream + */ + + body: Class_SeekableStream + + + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/HttpsServer.d.ts b/types/fibjs/declare/HttpsServer.d.ts new file mode 100644 index 0000000000..2213c7c4c6 --- /dev/null +++ b/types/fibjs/declare/HttpsServer.d.ts @@ -0,0 +1,137 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief https 服务器对象 + * @detail https 服务器对象是将 SslServer 和 HttpHandler 组合封装的对象,方便快速搭建服务器,逻辑上相当于:,```JavaScript,var svr = new net.SslServer(crt, key, addr, port, new http.Handler(function(req){, ...,}));,```,,创建方法:,```JavaScript,var http = require("http");,var svr = new http.HttpsServer(crt, key, 443, function(req){, ...,});,``` + */ +/// +declare class Class_HttpsServer extends Class_HttpServer { + + /** + * class prop + * + * + * @brief 设定证书验证模式,缺省为 VERIFY_NONE + * + * + * @type Integer + */ + + verification: number + + /** + * class prop + * + * + * @brief 客户端证书验证 ca + * + * @readonly + * @type X509Cert + */ + + ca: Class_X509Cert + + + + /** + * + * @brief HttpsServer 构造函数,在所有本机地址侦听 + * + * certs 格式为: + * ```JavaScript + * [ + * { + * crt: [X509Cert object], + * key: [PKey object] + * }, + * { + * crt: [X509Cert object], + * key: [PKey object] + * } + * ] + * ``` + * @param certs 服务器证书列表 + * @param port 指定 http 服务器侦听端口 + * @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见 + * + * + * + */ + constructor(certs: any[], port: number, hdlr: Class_Handler); + + /** + * + * @brief HttpsServer 构造函数 + * + * certs 格式为: + * ```JavaScript + * [ + * { + * crt: [X509Cert object], + * key: [PKey object] + * }, + * { + * crt: [X509Cert object], + * key: [PKey object] + * } + * ] + * ``` + * @param certs 服务器证书列表 + * @param addr 指定 http 服务器侦听地址,为 "" 则在本机所有地址侦听 + * @param port 指定 http 服务器侦听端口 + * @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见 + * + * + * + */ + constructor(certs: any[], addr: string, port: number, hdlr: Class_Handler); + + /** + * + * @brief HttpsServer 构造函数,在所有本机地址侦听 + * @param crt X509Cert 证书,用于客户端验证服务器 + * @param key PKey 私钥,用于与客户端会话 + * @param port 指定 http 服务器侦听端口 + * @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见 + * + * + * + */ + constructor(crt: Class_X509Cert, key: Class_PKey, port: number, hdlr: Class_Handler); + + /** + * + * @brief HttpsServer 构造函数 + * @param crt X509Cert 证书,用于客户端验证服务器 + * @param key PKey 私钥,用于与客户端会话 + * @param addr 指定 http 服务器侦听地址,为 "" 则在本机所有地址侦听 + * @param port 指定 http 服务器侦听端口 + * @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见 + * + * + * + */ + constructor(crt: Class_X509Cert, key: Class_PKey, addr: string, port: number, hdlr: Class_Handler); + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Image.d.ts b/types/fibjs/declare/Image.d.ts new file mode 100644 index 0000000000..ff88443b70 --- /dev/null +++ b/types/fibjs/declare/Image.d.ts @@ -0,0 +1,856 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + + + +/** module Or Internal Object */ +/** + * @brief 图像处理对象,用以对图像进行转换,绘制,存储等操作 + * @detail Image 对象属于 gd 模块,创建:,```JavaScript,var img = gd.create(640, 480);,var img1 = gd.load(data);,``` + */ + +declare class Class_Image extends Class__object { + + /** + * class prop + * + * + * @brief 查询图像宽度 + * + * @readonly + * @type Integer + */ + + width: number + + /** + * class prop + * + * + * @brief 查询图像高度 + * + * @readonly + * @type Integer + */ + + height: number + + /** + * class prop + * + * + * @brief 查询图像来源格式,结果为 gd.PNG, gd.JPEG, gd.GIF, gd.BMP, gd.WEBP + * + * @readonly + * @type Integer + */ + + format: number + + /** + * class prop + * + * + * @brief 查询图像类型,结果为 gd.TRUECOLOR, gd.PALETTE + * + * @readonly + * @type Integer + */ + + type: number + + /** + * class prop + * + * + * @brief 查询图像颜色表内的颜色总数 + * + * @readonly + * @type Integer + */ + + colorsTotal: number + + /** + * class prop + * + * + * @brief 查询和设定指定的颜色为透明色 + * + * + * @type Integer + */ + + transparent: number + + /** + * class prop + * + * + * @brief 查询和设定图像是否渐进式,仅支持 jpeg 格式时 + * + * + * @type Boolean + */ + + progressive: boolean + + /** + * class prop + * + * + * @brief查询和设定绘图时是否计算 alpha 层,缺省为 true + * + * + * @type Boolean + */ + + alphaBlending: boolean + + + + /** + * + * @brief 按照指定的格式返回图像数据 + * @param format 指定返回数据的格式,允许值为 gd.PNG, gd.JPEG, gd.GIF, gd.BMP, gd.WEBP, 缺省为 gd.PNG + * @param quality 当格式为 gd.JPEG 或 gd.WEBP 时用于指定压缩质量,缺省为 85,其他格式忽略此参数 + * @return 返回格式化的数据 + * + * + * @async + */ + getData(format?: number/** = undefined*/, quality?: number/** = 85*/): Class_Buffer; + + /** + * + * @brief 按照指定的格式将图像数据存入流对象 + * @param stm 指定要存入的流对象 + * @param format 指定返回数据的格式,允许值为 gd.PNG, gd.JPEG, gd.GIF, gd.BMP, gd.WEBP, 缺省为 gd.PNG + * @param quality 当格式为 gd.JPEG 或 gd.WEBP 时用于指定压缩质量,缺省为 85,其他格式忽略此参数 + * + * + * @async + */ + save(stm: Class_Stream, format?: number/** = undefined*/, quality?: number/** = 85*/): void; + + /** + * + * @brief 按照指定的格式将图像数据存入指定文件,文件将被强制覆盖 + * @param fname 指定文件名 + * @param format 指定返回数据的格式,允许值为 gd.PNG, gd.JPEG, gd.GIF, gd.BMP, gd.WEBP, 缺省为 gd.PNG + * @param quality 当格式为 gd.JPEG 时用于指定压缩质量,缺省为 85,其他格式忽略此参数 + * + * + * @async + */ + save(fname: string, format?: number/** = undefined*/, quality?: number/** = 85*/): void; + + /** + * + * @brief 为指定的颜色申请一个颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorAllocate(red: number, green: number, blue: number): number; + + /** + * + * @brief 为指定的颜色申请一个颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值 + * @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorAllocate(color: number): number; + + /** + * + * @brief 为指定的颜色及透明申请一个颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @param alpha 透明分量,范围为 0-1.0 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorAllocateAlpha(red: number, green: number, blue: number, alpha: number): number; + + /** + * + * @brief 为指定的颜色及透明申请一个颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值 + * @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorAllocateAlpha(color: number): number; + + /** + * + * @brief 为指定的颜色查找一个最接近的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorClosest(red: number, green: number, blue: number): number; + + /** + * + * @brief 为指定的颜色查找一个最接近的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值 + * @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorClosest(color: number): number; + + /** + * + * @brief 为指定的颜色查找一个最接近的颜色号,此方法使用 Hue/White/Black 计算查找最接近颜色,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorClosestHWB(red: number, green: number, blue: number): number; + + /** + * + * @brief 为指定的颜色查找一个最接近的颜色号,此方法使用 Hue/White/Black 计算查找最接近颜色,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值 + * @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorClosestHWB(color: number): number; + + /** + * + * @brief 为指定的颜色及透明查找一个最接近的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @param alpha 透明分量,范围为 0-1.0 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorClosestAlpha(red: number, green: number, blue: number, alpha: number): number; + + /** + * + * @brief 为指定的颜色及透明查找一个最接近的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值 + * @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorClosestAlpha(color: number): number; + + /** + * + * @brief 查找指定的颜色对应的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorExact(red: number, green: number, blue: number): number; + + /** + * + * @brief 查找指定的颜色对应的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值 + * @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorExact(color: number): number; + + /** + * + * @brief 查找指定的颜色及透明对应的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @param alpha 透明分量,范围为 0-1.0 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorExactAlpha(red: number, green: number, blue: number, alpha: number): number; + + /** + * + * @brief 查找指定的颜色及透明对应的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值 + * @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorExactAlpha(color: number): number; + + /** + * + * @brief 查找指定的颜色对应的颜色号,如果颜色不存在,则为其申请一个新颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorResolve(red: number, green: number, blue: number): number; + + /** + * + * @brief 查找指定的颜色对应的颜色号,如果颜色不存在,则为其申请一个新颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值 + * @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorResolve(color: number): number; + + /** + * + * @brief 查找指定的颜色及透明对应的颜色号,如果颜色不存在,则为其申请一个新颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @param alpha 透明分量,范围为 0-1.0 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorResolveAlpha(red: number, green: number, blue: number, alpha: number): number; + + /** + * + * @brief 查找指定的颜色及透明对应的颜色号,如果颜色不存在,则为其申请一个新颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值 + * @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成 + * @return 返回颜色号,不成功返回 -1 + * + * + * + */ + colorResolveAlpha(color: number): number; + + /** + * + * @brief 释放指定的颜色号,释放的颜色号将会被再次申请后替换 + * @param color 指定要释放的颜色号 + * + * + * + */ + colorDeallocate(color: number): void; + + /** + * + * @brief 设定绘图的剪切窗口,设定后,所有的绘制将被剪切在窗口内部 + * @param x1 剪切窗口的左上 x 坐标 + * @param y1 剪切窗口的左上 y 坐标 + * @param x2 剪切窗口的右下 x 坐标 + * @param y2 剪切窗口的右下 y 坐标 + * + * + * + */ + clip(x1: number, y1: number, x2: number, y2: number): void; + + /** + * + * @brief 查询指定位置点的颜色 + * @param x 指定查询的 x 坐标 + * @param y 指定查询的 y 坐标 + * @return 返回指定点的颜色号 + * + * + * + */ + getPixel(x: number, y: number): number; + + /** + * + * @brief 查询指定位置点的真彩色颜色 + * @param x 指定查询的 x 坐标 + * @param y 指定查询的 y 坐标 + * @return 返回指定点的颜色号 + * + * + * + */ + getTrueColorPixel(x: number, y: number): number; + + /** + * + * @brief 在指定位置画一个点 + * @param x 指定画点的 x 坐标 + * @param y 指定画点的 y 坐标 + * @param color 指定画点的颜色号 + * + * + * + */ + setPixel(x: number, y: number, color: number): void; + + /** + * + * @brief 设定画线的宽度,line, rectangle, arc 等方法画线时缺省宽度为一个像素,可使用此方法改变线的宽度 + * @param thickness 画线的宽度 + * + * + * + */ + setThickness(thickness: number): void; + + /** + * + * @brief 在指定的位置画一条线 + * @param x1 指定画线的起始 x 坐标 + * @param y1 指定画线的起始 y 坐标 + * @param x2 指定画线的结束 x 坐标 + * @param y2 指定画线的结束 y 坐标 + * @param color 指定画线的颜色号 + * + * + * + */ + line(x1: number, y1: number, x2: number, y2: number, color: number): void; + + /** + * + * @brief 在指定的位置画一个矩形 + * @param x1 指定左上角 x 坐标 + * @param y1 指定左上角 y 坐标 + * @param x2 指定右下角 x 坐标 + * @param y2 指定右下角 y 坐标 + * @param color 指定矩形的颜色号 + * + * + * + */ + rectangle(x1: number, y1: number, x2: number, y2: number, color: number): void; + + /** + * + * @brief 在指定的位置画一个填充的矩形 + * @param x1 指定左上角 x 坐标 + * @param y1 指定左上角 y 坐标 + * @param x2 指定右下角 x 坐标 + * @param y2 指定右下角 y 坐标 + * @param color 指定矩形的颜色号 + * + * + * + */ + filledRectangle(x1: number, y1: number, x2: number, y2: number, color: number): void; + + /** + * + * @brief 根据给定的点绘制一个多边形 + * @param points 包含多边形点的数组,如 [[1, 1], [1, 10], [10, 15], [10, 20]] + * @param color 指定矩形的颜色号 + * + * + * + */ + polygon(points: any[], color: number): void; + + /** + * + * @brief 根据给定的点绘制一个开放多边形 + * @param points 包含多边形点的数组,如 [[1, 1], [1, 10], [10, 15], [10, 20]] + * @param color 指定矩形的颜色号 + * + * + * + */ + openPolygon(points: any[], color: number): void; + + /** + * + * @brief 根据给定的点绘制一个填充多边形 + * @param points 包含多边形点的数组,如 [[1, 1], [1, 10], [10, 15], [10, 20]] + * @param color 指定矩形的颜色号 + * + * + * + */ + filledPolygon(points: any[], color: number): void; + + /** + * + * @brief 画一个椭圆 + * @param x 椭圆中心的 x 坐标 + * @param y 椭圆中心的 y 坐标 + * @param width 椭圆的宽度 + * @param height 椭圆的高度 + * @param color 指定矩形的颜色号 + * + * + * + */ + ellipse(x: number, y: number, width: number, height: number, color: number): void; + + /** + * + * @brief 画一个填充的椭圆 + * @param x 椭圆中心的 x 坐标 + * @param y 椭圆中心的 y 坐标 + * @param width 椭圆的宽度 + * @param height 椭圆的高度 + * @param color 指定矩形的颜色号 + * + * + * + */ + filledEllipse(x: number, y: number, width: number, height: number, color: number): void; + + /** + * + * @brief 画一个扇形 + * @param x 扇形中心的 x 坐标 + * @param y 扇形中心的 y 坐标 + * @param width 扇形所在椭圆的宽度 + * @param height 扇形所在椭圆的高度 + * @param start 扇形开始的角度,范围为 0-360 + * @param end 扇形结束的角度,范围为 0-360 + * @param color 指定矩形的颜色号 + * + * + * + */ + arc(x: number, y: number, width: number, height: number, start: number, end: number, color: number): void; + + /** + * + * @brief 画一个填充扇形 + * @param x 扇形中心的 x 坐标 + * @param y 扇形中心的 y 坐标 + * @param width 扇形所在椭圆的宽度 + * @param height 扇形所在椭圆的高度 + * @param start 扇形开始的角度,范围为 0-360 + * @param end 扇形结束的角度,范围为 0-360 + * @param color 指定矩形的颜色号 + * @param style 指定扇形的样式,允许的值有 gd.ARC, gd.CHORD, gd.NOFILL, gd.EDGED 及其组合 + * + * + * + */ + filledArc(x: number, y: number, width: number, height: number, start: number, end: number, color: number, style?: number/** = undefined*/): void; + + /** + * + * @brief 从指定的点开始填充封闭区域 + * @param x 开始填充的 x 坐标 + * @param y 开始填充的 y 坐标 + * @param color 指定填充的颜色号 + * + * + * + */ + fill(x: number, y: number, color: number): void; + + /** + * + * @brief 从指定的点开始在指定颜色的边框内填充封闭区域 + * @param x 开始填充的 x 坐标 + * @param y 开始填充的 y 坐标 + * @param borderColor 指定边框的颜色号 + * @param color 指定填充的颜色号 + * + * + * + */ + fillToBorder(x: number, y: number, borderColor: number, color: number): void; + + /** + * + * @brief 替换图像中指定的颜色为新颜色 + * @param src 指定要替换的颜色 + * @param dst 指定新颜色 + * + * + * @async + */ + colorReplace(src: number, dst: number): void; + + /** + * + * @brief 复制当前图像为一个新图像 + * @return 返回复制的新图像对象 + * + * + * @async + */ + clone(): Class_Image; + + /** + * + * @brief 根据图像拉伸生成一个新尺寸的图像 + * @param width 指定拉伸的宽度 + * @param height 指定拉伸的高度 + * @return 返回新图像对象 + * + * + * @async + */ + resample(width: number, height: number): Class_Image; + + /** + * + * @brief 剪切图像的一部分为一个新的图像 + * @param x 剪切窗口的左上 x 坐标 + * @param y 剪切窗口的左上 y 坐标 + * @param width 剪切窗口的宽度 + * @param height 剪切窗口的高度 + * @return 返回剪切出的图像 + * + * + * @async + */ + crop(x: number, y: number, width: number, height: number): Class_Image; + + /** + * + * @brief 镜像当前图像 + * @param dir 镜像方向,允许值为 gd.BOTH,gd.HORIZONTAL, gd.VERTICAL, 缺省为 gd.HORIZONTAL + * + * + * @async + */ + flip(dir?: number/** = undefined*/): void; + + /** + * + * @brief 旋转当前图像 + * @param dir 旋转方向,允许值为 gd.LEFT, gd.RIGHT + * + * + * @async + */ + rotate(dir: number): void; + + /** + * + * @brief 转换当前图像类型 + * @param color 指定图像类型,允许值为 gd.TRUECOLOR 或 gd.PALETTE + * + * + * @async + */ + convert(color?: number/** = undefined*/): void; + + /** + * + * @brief 从一个图像中复制一个区域到指定的位置 + * @param source 源图像对象 + * @param dstX 指定复制目标的 x 坐标 + * @param dstY 指定复制目标的 y 坐标 + * @param srcX 指定复制源左上角的 x 坐标 + * @param srcY 指定复制源左上角的 y 坐标 + * @param width 指定复制的宽度 + * @param height 指定复制的高度 + * + * + * @async + */ + copy(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, width: number, height: number): void; + + /** + * + * @brief 从一个图像中复制一个区域覆盖到指定的位置 + * @param source 源图像对象 + * @param dstX 指定复制目标的 x 坐标 + * @param dstY 指定复制目标的 y 坐标 + * @param srcX 指定复制源左上角的 x 坐标 + * @param srcY 指定复制源左上角的 y 坐标 + * @param width 指定复制的宽度 + * @param height 指定复制的高度 + * @param percent 指定覆盖的透明度 + * + * + * @async + */ + copyMerge(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, width: number, height: number, percent: number): void; + + /** + * + * @brief 从一个图像中复制一个区域的灰度覆盖到指定的位置 + * @param source 源图像对象 + * @param dstX 指定复制目标的 x 坐标 + * @param dstY 指定复制目标的 y 坐标 + * @param srcX 指定复制源左上角的 x 坐标 + * @param srcY 指定复制源左上角的 y 坐标 + * @param width 指定复制的宽度 + * @param height 指定复制的高度 + * @param percent 指定覆盖的透明度 + * + * + * @async + */ + copyMergeGray(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, width: number, height: number, percent: number): void; + + /** + * + * @brief 将一个图像中的一个区域拉伸后复制到指定的位置 + * @param source 源图像对象 + * @param dstX 指定复制目标的 x 坐标 + * @param dstY 指定复制目标的 y 坐标 + * @param srcX 指定复制源左上角的 x 坐标 + * @param srcY 指定复制源左上角的 y 坐标 + * @param dstW 指定复制的拉伸宽度 + * @param dstH 指定复制的拉伸高度 + * @param srcW 指定复制的源宽度 + * @param srcH 指定复制的源高度 + * + * + * @async + */ + copyResized(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, dstW: number, dstH: number, srcW: number, srcH: number): void; + + /** + * + * @brief 将一个图像中的一个区域拉伸后复制到指定的位置,不同与 copyResized,此方法拉伸时会对图像进行抖动 + * @param source 源图像对象 + * @param dstX 指定复制目标的 x 坐标 + * @param dstY 指定复制目标的 y 坐标 + * @param srcX 指定复制源左上角的 x 坐标 + * @param srcY 指定复制源左上角的 y 坐标 + * @param dstW 指定复制的拉伸宽度 + * @param dstH 指定复制的拉伸高度 + * @param srcW 指定复制的源宽度 + * @param srcH 指定复制的源高度 + * + * + * @async + */ + copyResampled(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, dstW: number, dstH: number, srcW: number, srcH: number): void; + + /** + * + * @brief 将一个图像中的一个区域旋转后复制到指定的位置 + * @param source 源图像对象 + * @param dstX 指定复制目标的 x 坐标 + * @param dstY 指定复制目标的 y 坐标 + * @param srcX 指定复制源左上角的 x 坐标 + * @param srcY 指定复制源左上角的 y 坐标 + * @param width 指定复制的宽度 + * @param height 指定复制的高度 + * @param angle 指定旋转的角度 + * + * + * @async + */ + copyRotated(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, width: number, height: number, angle: number): void; + + /** + * + * @brief 把过滤器 filterType应用到图像上,根据过滤器类型传入所需参数 + * + * 参数 filterType 可以为以下数值: + * - MEAN_REMOVAL, 用平均移除法来达到轮廓效果 + * - EDGEDETECT, 用边缘检测来突出图像的边缘 + * - EMBOSS, 使图像浮雕化 + * - SELECTIVE_BLUR, 模糊图像 + * - GAUSSIAN_BLUR, 用高斯算法模糊图像 + * - NEGATE, 将图像中所有颜色反转 + * - GRAYSCALE, 将图像转换为灰度图 + * - SMOOTH, 使图像更柔滑,用arg1设定柔滑级别 + * - BRIGHTNESS, 改变图像的亮度,用arg1设定亮度级别,取值范围是-255~255 + * - CONTRAST, 改变图像的对比度,用arg1设定对比度级别,取值范围是0~100 + * - COLORIZE, 改变图像的色调,用arg1、arg2、arg3分别指定red、blue、green分值,每种颜色范围是0~255,arg4为透明度,取值返回是0~127 + * @param filterType 过滤器类型 + * @param arg1 过滤器所需参数: SMOOTH 的平滑级别、BRIGHTNESS 的亮度级别、CONTRAST 的对比度级别、COLORIZE 的 red 分值 + * @param arg2 过滤器所需参数: COLORIZE 的 green 分值 + * @param arg3 过滤器所需参数: COLORIZE 的 blue 分值 + * @param arg4 过滤器所需参数: COLORIZE 的透明度 alpha 分值 + * + * + * @async + */ + filter(filterType: number, arg1?: number/** = 0*/, arg2?: number/** = 0*/, arg3?: number/** = 0*/, arg4?: number/** = 0*/): void; + + /** + * + * @brief 根据给定的矩阵,对当前图像进行仿射 + * + * 参数 affine 是一个数组: + * ```JavaScript + * affine = [ a0, a1, b0, b1, a2, b2 ]; + * x' = a0x + a1y + a2; + * y' = b0x + b1y + b2; + * ``` + * @param affine 仿射矩阵,由 6 个 double 类型的数字组成 + * @param x 可选剪切区域的原点 x 坐标 + * @param y 可选剪切区域的原点 y 坐标 + * @param width 可选剪切区域的的宽度 + * @param height 可选剪切区域的的高度 + * @return 返回仿射后的图像 + * + * + * @async + */ + affine(affine: any[], x?: number/** = -1*/, y?: number/** = -1*/, width?: number/** = -1*/, height?: number/** = -1*/): Class_Image; + + /** + * + * @brief 对当前图像进行高斯模糊处理 + * @param radius 模糊半径 + * + * + * @async + */ + gaussianBlur(radius: number): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Int64.d.ts b/types/fibjs/declare/Int64.d.ts new file mode 100644 index 0000000000..3bba627aed --- /dev/null +++ b/types/fibjs/declare/Int64.d.ts @@ -0,0 +1,241 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 64位整数对象 + * @detail 创建方法:,```JavaScript,var n = new Int64(123);,``` + */ + +declare class Class_Int64 extends Class__object { + + /** + * class prop + * + * + * @brief 高 32 位数值 + * + * + * @type Long + */ + + hi: number + + /** + * class prop + * + * + * @brief 低 32 位数值 + * + * + * @type Long + */ + + lo: number + + + + /** + * + * @brief Int64 构造函数 + * @param num 初始化的值 + * + * + * + */ + constructor(num?: number/** = 0*/); + + /** + * + * @brief Int64 构造函数 + * @param hi 高32位数 + * @param lo 低32位数 + * + * + * + */ + constructor(hi: number, lo: number); + + /** + * + * @brief Int64 构造函数 + * @param num 初始化的值 + * + * + * + */ + constructor(num: Class_Int64); + + /** + * + * @brief Int64 构造函数 + * @param num 数字字符串 + * @param base 数字字符串的编码方式,可以接受 2-16, 32, 64,默认为 10,为 10 时自动识别 0x 编码 + * + * + * + */ + constructor(num: string, base?: number/** = 10*/); + + /** + * + * @brief 将 Int64 内的数值与给定数值比较大小 + * @param num 指定比较的数值 + * @return 返回 1 表示 Int64 内的数值比指定数值更大,0 表示相等,-1 表示更小 + * + * + * + */ + compare(num: Class_Int64): number; + + /** + * + * @brief 将 Int64 内的数值左移相应的位数,此操作不影响 Int64 原有数值 + * @param bits 指定移动的位数 + * @return 返回包含移位以后数值的对象 + * + * + * + */ + shiftLeft(bits: number): Class_Int64; + + /** + * + * @brief 将 Int64 内的数值右移相应的位数,此操作不影响 Int64 原有数值 + * @param bits 指定移动的位数 + * @return 返回包含移位以后数值的对象 + * + * + * + */ + shiftRight(bits: number): Class_Int64; + + /** + * + * @brief 将 Int64 内的数值与给定的数值进行按位 and 操作,此操作不影响 Int64 原有数值 + * @param num 指定运算的数值 + * @return 返回包含预算以后数值的对象 + * + * + * + */ + and(num: Class_Int64): Class_Int64; + + /** + * + * @brief 将 Int64 内的数值与给定的数值进行按位 or 操作,此操作不影响 Int64 原有数值 + * @param num 指定运算的数值 + * @return 返回包含预算以后数值的对象 + * + * + * + */ + or(num: Class_Int64): Class_Int64; + + /** + * + * @brief 将 Int64 内的数值与给定的数值进行按位 xor 操作,此操作不影响 Int64 原有数值 + * @param num 指定运算的数值 + * @return 返回包含预算以后数值的对象 + * + * + * + */ + xor(num: Class_Int64): Class_Int64; + + /** + * + * @brief 将 Int64 内的数值与给定的数值进行加操作,此操作不影响 Int64 原有数值 + * @param num 指定运算的数值 + * @return 返回包含预算以后数值的对象 + * + * + * + */ + add(num: Class_Int64): Class_Int64; + + /** + * + * @brief 将 Int64 内的数值与给定的数值进行减操作,此操作不影响 Int64 原有数值 + * @param num 指定运算的数值 + * @return 返回包含预算以后数值的对象 + * + * + * + */ + sub(num: Class_Int64): Class_Int64; + + /** + * + * @brief 将 Int64 内的数值与给定的数值进行乘操作,此操作不影响 Int64 原有数值 + * @param num 指定运算的数值 + * @return 返回包含预算以后数值的对象 + * + * + * + */ + multi(num: Class_Int64): Class_Int64; + + /** + * + * @brief 将 Int64 内的数值与给定的数值进行除操作,此操作不影响 Int64 原有数值 + * @param num 指定运算的数值 + * @return 返回包含预算以后数值的对象 + * + * + * + */ + div(num: Class_Int64): Class_Int64; + + /** + * + * @brief 比较当前对象与给定的对象是否相等 + * @param expected 制定比较的目标对象 + * @return 返回对象比较的结果 + * + * + * + */ + equals(expected: Class__object): boolean; + + /** + * + * @brief 转换成数字类型 + * @return 返回转换后的数字 + * + * + * + */ + toNumber(): number; + + /** + * + * @brief 转换成字符串类型 + * @param base 字符串进制数,可以接受 2-16, 32, 64,默认为 10 + * @return 返回转换后的字符串 + * + * + * + */ + toString(base?: number/** = 10*/): string; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/LevelDB.d.ts b/types/fibjs/declare/LevelDB.d.ts new file mode 100644 index 0000000000..67e4ced5c2 --- /dev/null +++ b/types/fibjs/declare/LevelDB.d.ts @@ -0,0 +1,176 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief LevelDB 数据库对象 + * @detail 用以创建和管理字典对象,创建方法:,```JavaScript,var db = require("db");,var test = new db.openLevelDB("test.db");,``` + */ + +declare class Class_LevelDB extends Class__object { + + + + /** + * + * @brief 检查数据库内是否存在指定键值的数据 + * @param key 指定要检查的键值 + * @return 返回键值是否存在 + * + * + * @async + */ + has(key: Class_Buffer): boolean; + + /** + * + * @brief 查询指定键值的值 + * @param key 指定要查询的键值 + * @return 返回键值所对应的值,若不存在,则返回 null + * + * + * @async + */ + get(key: Class_Buffer): Class_Buffer; + + /** + * + * @brief 查询一组指定键值的值 + * @param keys 指定要查询的键值数组 + * @return 返回包含键值得数组 + * + * + * + */ + mget(keys: any[]): any[]; + + /** + * + * @brief 设定一个键值数据,键值不存在则插入新数据 + * @param key 指定要设定的键值 + * @param value 指定要设定的数据 + * + * + * @async + */ + set(key: Class_Buffer, value: Class_Buffer): void; + + /** + * + * @brief 设定一组键值数据,键值不存在则插入新数据 + * @param map 指定要设定的键值数据字典 + * + * + * + */ + mset(map: Object): void; + + /** + * + * @brief 删除一组指定键值的值 + * @param keys 指定要删除的键值数组 + * + * + * + */ + mremove(keys: any[]): void; + + /** + * + * @brief 删除指定键值的全部值 + * @param key 指定要删除的键值 + * + * + * @async + */ + remove(key: Class_Buffer): void; + + /** + * + * @brief 枚举数据库中所有的键值对 + * + * 回调函数有两个参数,(value, key) + * + * ```JavaScript + * var db = require("db"); + * var test = new db.openLevelDB("test.db"); + * + * test.forEach(function(value, key){ + * ... + * }); + * ``` + * @param func 枚举回调函数 + * + * + * + */ + forEach(func: Function): void; + + /** + * + * @brief 枚举数据库中键值在 from 和 to 之间的键值对 + * + * 回调函数有两个参数,(value, key) + * + * ```JavaScript + * var db = require("db"); + * var test = new db.openLevelDB("test.db"); + * + * test.between("aaa", "bbb", function(value, key){ + * ... + * }); + * ``` + * @param from 枚举的最小键值,枚举时包含此键值 + * @param to 枚举的最大键值,枚举时不包含此键值 + * @param func 枚举回调函数 + * + * + * + */ + between(from: Class_Buffer, to: Class_Buffer, func: Function): void; + + /** + * + * @brief 在当前数据库上开启一个事务 + * @return 返回一个开启的事务对象 + * + * + */ + begin(): Class_LevelDB; + + /** + * + * @brief 提交当前事务 + * + * + */ + commit(): void; + + /** + * + * @brief 关闭当前数据库连接或事务 + * + * @async + */ + close(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Lock.d.ts b/types/fibjs/declare/Lock.d.ts new file mode 100644 index 0000000000..7f6f1ab13d --- /dev/null +++ b/types/fibjs/declare/Lock.d.ts @@ -0,0 +1,79 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 纤程锁对象 + * @detail 不同于操作系统的锁,纤程锁是纯逻辑实现,加锁与解锁负荷很小,```JavaScript,var l = new coroutine.Lock();,l.acquire();,.....,l.release();,``` + */ + +declare class Class_Lock extends Class__object { + + + + /** + * + * @brief 构造函数 + * + * + */ + constructor(); + + /** + * + * @brief 获取锁的拥有权 + * + * acquire 方法用于获取锁的拥有权,当锁处于可获取状态时,此方法立即返回 true。 + * + * 当锁不可获取,且 blocking 为 true,则当前纤程进入休眠,当其他纤程释放锁后,此方法返回 true。 + * + * 当锁不可获取,且 blocking 为 false,则方法返回 false。 + * @param blocking 指定是否等待,为 true 时等待,缺省为真 + * @return 返回是否成功获取锁,为 true 表示成功获取 + * + * + * + */ + acquire(blocking?: boolean/** = true*/): boolean; + + /** + * + * @brief 释放锁的拥有权 + * + * 此方法将释放对锁的拥有权,如果当前纤程未拥有锁,此方法将抛出错误。 + * + * + * + */ + release(): void; + + /** + * + * @brief 查询当前等待任务数 + * @return 返回任务数 + * + * + * + */ + count(): number; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/LruCache.d.ts b/types/fibjs/declare/LruCache.d.ts new file mode 100644 index 0000000000..2ca05b4d6c --- /dev/null +++ b/types/fibjs/declare/LruCache.d.ts @@ -0,0 +1,163 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief LRU(least recently used) 缓存对象 + * @detail LruCache 用以维护一个 LRU 缓存,创建方法:,```JavaScript,var util = require("util");,var c = new util.LruCache(10, 100);,``` + */ +/// +declare class Class_LruCache extends Class_EventEmitter { + + /** + * class prop + * + * + * @brief 查询容器内数值个数 + * + * @readonly + * @type Integer + */ + + size: number + + /** + * class prop + * + * + * @brief 查询和设置容器内元素失效时间,单位是 ms,小于等于 0 不失效 + * + * + * @type Integer + */ + + timeout: number + + /** + * class prop + * + * + * @brief 查询和绑定数据超时事件,相当于 on("expire", func); + * + * + * @type Function + */ + + onexpire: Function + + + + /** + * + * @brief LruCache 对象构造函数 + * @param size 缓存最大尺寸 + * @param timeout 元素失效时间,单位是 ms,小于等于 0 不失效,缺省为 0 + * + * + * + */ + constructor(size: number, timeout?: number/** = 0*/); + + /** + * + * @brief 清除容器数据 + * + * + */ + clear(): void; + + /** + * + * @brief 检查容器内是否存在指定键值的数据 + * @param name 指定要检查的键值 + * @return 返回键值是否存在 + * + * + * + */ + has(name: string): boolean; + + /** + * + * @brief 查询指定键值的值 + * @param name 指定要查询的键值 + * @return 返回键值所对应的值,若不存在,则返回 undefined + * + * + * + */ + get(name: string): any; + + /** + * + * @brief 查询指定键值的值,若不存在或过期,则调用回调函数更新数据 + * @param name 指定要查询的键值 + * @param updater 指定更新函数 + * @return 返回键值所对应的值 + * + * + * + */ + get(name: string, updater: Function): any; + + /** + * + * @brief 设定一个键值数据,键值不存在则插入一条新数据 + * @param name 指定要设定的键值 + * @param value 指定要设定的数据 + * + * + * + */ + set(name: string, value: any): void; + + /** + * + * @brief 设定一个键值数据,键值不存在则插入新数据 + * @param map 指定要设定的键值数据字典 + * + * + * + */ + set(map: Object): void; + + /** + * + * @brief 删除指定键值的全部值 + * @param name 指定要删除的键值 + * + * + * + */ + remove(name: string): void; + + /** + * + * @brief 检查容器是否为空 + * @return 容器内无数值则返回 true + * + * + * + */ + isEmpty(): boolean; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/MSSQL.d.ts b/types/fibjs/declare/MSSQL.d.ts new file mode 100644 index 0000000000..c38cff27cb --- /dev/null +++ b/types/fibjs/declare/MSSQL.d.ts @@ -0,0 +1,43 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief SQL Server 数据库连接对象 + * @detail 使用 db.open 或 db.openMySQL 创建,创建方式:,```JavaScript,var sql = db.openMSSQL("mssql://user:pass@host/db");,``` + */ +/// +declare class Class_MSSQL extends Class_DbConnection { + + + + /** + * + * @brief 选择当前数据库连接的缺省数据库 + * @param dbName 指定数据库名 + * + * + * @async + */ + use(dbName: string): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/MemoryStream.d.ts b/types/fibjs/declare/MemoryStream.d.ts new file mode 100644 index 0000000000..1c0b050134 --- /dev/null +++ b/types/fibjs/declare/MemoryStream.d.ts @@ -0,0 +1,69 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 内存流对象 + * @detail MemoryStream 对象创建一个基于内存的流对象,创建方法:,```JavaScript,var ms = new io.MemoryStream();,``` + */ +/// +declare class Class_MemoryStream extends Class_SeekableStream { + + + + /** + * + * @brief MemoryStream 构造函数 + * + * + */ + constructor(); + + /** + * + * @brief 强制设定内存流对象的最后更新时间 + * @param d 指定要设定的时间 + * + * + * + */ + setTime(d: Date): void; + + /** + * + * @brief 创建当前内存流的一个只读副本 + * @return 返回只读的内存流对象 + * + * + * + */ + clone(): Class_MemoryStream; + + /** + * + * @brief 清空内存文件数据,复位指针 + * + * + */ + clear(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Message.d.ts b/types/fibjs/declare/Message.d.ts new file mode 100644 index 0000000000..523c9c4ef5 --- /dev/null +++ b/types/fibjs/declare/Message.d.ts @@ -0,0 +1,235 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 基础消息对象 + * @detail Message 对象兼容于 mq 各个模块,可用于构建自定义消息处理系统,创建方法:,```JavaScript,var mq = require("mq");,var m = new mq.Message();,``` + */ + +declare class Class_Message extends Class__object { + + /** + * class prop + * + * + * @brief 消息的基本内容 + * + * + * @type String + */ + + value: string + + /** + * class prop + * + * + * @brief 消息的基本参数 + * + * @readonly + * @type NArray + */ + + params: any[] + + /** + * class prop + * + * + * @brief 消息类型 + * + * + * @type Integer + */ + + type: number + + /** + * class prop + * + * + * @brief 查询消息的数据 + * + * @readonly + * @type Value + */ + + data: any + + /** + * class prop + * + * + * @brief 包含消息数据部分的流对象 + * + * + * @type SeekableStream + */ + + body: Class_SeekableStream + + /** + * class prop + * + * + * @brief 消息数据部分的长度 + * + * @readonly + * @type Long + */ + + length: number + + /** + * class prop + * + * + * @brief 查询消息 readFrom 时的流对象 + * + * @readonly + * @type Stream + */ + + stream: Class_Stream + + /** + * class prop + * + * + * @brief 查询和设置消息处理的最后错误 + * + * + * @type String + */ + + lastError: string + + + + /** + * + * @brief 消息对象构造函数 + * + * + */ + constructor(); + + /** + * + * @brief 从流内读取指定大小的数据,此方法为 body 相应方法的别名 + * @param bytes 指定要读取的数据量,缺省为读取随机大小的数据块,读出的数据尺寸取决于设备 + * @return 返回从流内读取的数据,若无数据可读,或者连接中断,则返回 null + * + * + * @async + */ + read(bytes?: number/** = -1*/): Class_Buffer; + + /** + * + * @brief 从流内读取剩余的全部数据,此方法为 body 相应方法的别名 + * @return 返回从流内读取的数据,若无数据可读,或者连接中断,则返回 null + * + * + * @async + */ + readAll(): Class_Buffer; + + /** + * + * @brief 写入给定的数据,此方法为 body 相应方法的别名 + * @param data 给定要写入的数据 + * + * + * @async + */ + write(data: Class_Buffer): void; + + /** + * + * @brief 以 JSON 编码写入给定的数据 + * @param data 给定要写入的数据 + * @return 此方法不会返回数据 + * + * + * + */ + json(data: any): any; + + /** + * + * @brief 以 JSON 编码解析消息中的数据 + * @return 返回解析的结果 + * + * + * + */ + json(): any; + + /** + * + * @brief 设置当前消息处理结束,Chain 处理器不再继续后面的事务 + * + * + */ + end(): void; + + /** + * + * @brief 查询当前消息是否结束 + * @return 结束则返回 true + * + * + * + */ + isEnded(): boolean; + + /** + * + * @brief 清除消息的内容 + * + * + */ + clear(): void; + + /** + * + * @brief 发送格式化消息到给定的流对象 + * @param stm 指定接收格式化消息的流对象 + * + * + * @async + */ + sendTo(stm: Class_Stream): void; + + /** + * + * @brief 从给定的缓存流对象中读取格式化消息,并解析填充对象 + * @param stm 指定读取格式化消息的流对象 + * + * + * @async + */ + readFrom(stm: Class_Stream): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/MongoCollection.d.ts b/types/fibjs/declare/MongoCollection.d.ts new file mode 100644 index 0000000000..348ec36812 --- /dev/null +++ b/types/fibjs/declare/MongoCollection.d.ts @@ -0,0 +1,227 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief mongodb 数据库数据集对象 + * @detail 使用 MongoDB.getCollection 创建:,```JavaScript,var col1 = mdb.getCollection('test');,var col = mdb.test;,``` + */ + +declare class Class_MongoCollection extends Class__object { + + + + /** + * + * @brief 根据给定的查询条件和返回字段设定,建立游标对象 + * @param query 指定查询条件的对象 + * @param projection 指定返回字段的对象 + * @return 返回游标对象 + * + * + * + */ + find(query?: Object/** = v8::Object::New(isolate)*/, projection?: Object/** = v8::Object::New(isolate)*/): Class_MongoCursor; + + /** + * + * @brief 根据给定的查询条件和返回字段设定,查询一条结果 + * @param query 指定查询条件的对象 + * @param projection 指定返回字段的对象 + * @return 返回第一条结果 + * + * + * + */ + findOne(query?: Object/** = v8::Object::New(isolate)*/, projection?: Object/** = v8::Object::New(isolate)*/): Object; + + /** + * + * @brief 查询并修改 + * @param query 指定查询条件,修改数据 + * @return 返回修改前的结果及其他信息 + * + * + * + */ + findAndModify(query: Object): Object; + + /** + * + * @brief 插入一组数据 + * @param documents 指定要插入的数据数组 + * + * + * + */ + insert(documents: any[]): void; + + /** + * + * @brief 插入一条数据 + * @param document 指定要插入的数据 + * + * + * + */ + insert(document: Object): void; + + /** + * + * @brief 保存一条数据,若数据包含 _id 字段,则为更新,否则为插入 + * @param document 指定要保存的数据 + * + * + * + */ + save(document: Object): void; + + /** + * + * @brief 根据给定的查询条件更新数据 + * @param query 指定查询条件的对象 + * @param document 指定要更新的数据 + * @param upsert 数据不存在时,插入一条新数据,缺省为 false,不插入 + * @param multi 当符合条件的数据多于一条时,更新所有数据,缺省为 false,只更新第一条 + * + * + * + */ + update(query: Object, document: Object, upsert?: boolean/** = false*/, multi?: boolean/** = false*/): void; + + /** + * + * @brief 根据给定的查询条件更新数据 + * @param query 指定查询条件的对象 + * @param document 指定要更新的数据 + * @param options 以对象字段传递的 upsert 和 multi 选项 + * + * + * + */ + update(query: Object, document: Object, options: Object): void; + + /** + * + * @brief 根据给定的查询条件删除数据 + * @param query 指定查询条件的对象 + * + * + * + */ + remove(query: Object): void; + + /** + * + * @brief 执行数据库命令 + * @param cmd 给定命令对象 + * @return 返回命令返回结果 + * + * + * + */ + runCommand(cmd: Object): Object; + + /** + * + * @brief 执行数据库命令 + * @param cmd 给定命令名称 + * @param arg 给定命令参数选项 + * @return 返回命令返回结果 + * + * + * + */ + runCommand(cmd: string, arg?: Object/** = v8::Object::New(isolate)*/): Object; + + /** + * + * @brief 删除当前集合 + * + * + */ + drop(): void; + + /** + * + * @brief 在当前集合上创建索引 + * @param keys 给定索引字段、顺序和方向 + * @param options 给定索引的选项,唯一索引等 + * + * + * + */ + ensureIndex(keys: Object, options?: Object/** = v8::Object::New(isolate)*/): void; + + /** + * + * @brief 重建当前集合的索引 + * @return 返回命令执行结果 + * + * + * + */ + reIndex(): Object; + + /** + * + * @brief 删除当前集合指定名称的索引 + * @param name 给定要删除的索引名称 + * @return 返回命令执行结果 + * + * + * + */ + dropIndex(name: string): Object; + + /** + * + * @brief 删除当前集合全部索引 + * @return 返回命令执行结果 + * + * + * + */ + dropIndexes(): Object; + + /** + * + * @brief 查询当前集合全部索引 + * @return 返回包含索引的结果集 + * + * + * + */ + getIndexes(): Class_MongoCursor; + + /** + * + * @brief 获取当前集合子命名空间的集合对象 + * @param name 子命名空间名称 + * @return 返回新集合对象 + * + * + * + */ + getCollection(name: string): Class_MongoCollection; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/MongoCursor.d.ts b/types/fibjs/declare/MongoCursor.d.ts new file mode 100644 index 0000000000..8b8e903f35 --- /dev/null +++ b/types/fibjs/declare/MongoCursor.d.ts @@ -0,0 +1,149 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief mongodb 数据库数据游标对象 + * @detail + */ + +declare class Class_MongoCursor extends Class__object { + + + + /** + * + * @brief 指定返回结果时跳过的记录数 + * @param num 记录数 + * @return 返回游标对象本身便于链式调用 + * + * + * @async + */ + skip(num: number): Class_MongoCursor; + + /** + * + * @brief 指定返回结果的最大记录数 + * @param size 记录数 + * @return 返回游标对象本身便于链式调用 + * + * + * @async + */ + limit(size: number): Class_MongoCursor; + + /** + * + * @brief 设定返回结果的排序 + * @param opts 指定排序条件 + * @return 返回游标对象本身便于链式调用 + * + * + * + */ + sort(opts: Object): Class_MongoCursor; + + /** + * + * @brief 查询当前游标是否有下一条记录 + * @return 有记录则返回 true + * + * + * + */ + hasNext(): boolean; + + /** + * + * @brief 返回当前游标的下一条记录 + * @return 记录对象,无记录则返回 null + * + * + * + */ + next(): Object; + + /** + * + * @brief 查询游标的记录总数 + * @param applySkipLimit 指定是否查询 skip 和 limit 后的记录数,缺省为 false,查询全部记录数 + * @return 返回记录总数 + * + * + * + */ + count(applySkipLimit?: boolean/** = false*/): number; + + /** + * + * @brief 查询游标的记录总数,相当于 count(true) + * @return 返回记录总数 + * + * + * + */ + size(): number; + + /** + * + * @brief 遍历全部记录并回调处理函数 + * @param func 指定处理函数 + * + * + * + */ + forEach(func: Function): void; + + /** + * + * @brief 遍历处理全部记录,并返回处理结果 + * @param func 指定处理函数 + * @return 返回处理结果数组 + * + * + * + */ + map(func: Function): any[]; + + /** + * + * @brief 返回当前游标全部记录的数组 + * @return 返回包含全部数据的 Javascript 数组 + * + * + * + */ + toArray(): any[]; + + /** + * + * @brief 修改 mongodb 服务器缺省索引策略,使用指定的索引进行查询 + * @param opts 指定强制使用的索引 + * @return 返回游标对象本身便于链式调用 + * + * + * + */ + hint(opts: Object): Class_MongoCursor; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/MongoDB.d.ts b/types/fibjs/declare/MongoDB.d.ts new file mode 100644 index 0000000000..19dd8a7369 --- /dev/null +++ b/types/fibjs/declare/MongoDB.d.ts @@ -0,0 +1,86 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief mongodb 数据库连接对象 + * @detail 使用 db.open 或 db.openMongoDB 创建,创建方式:,```JavaScript,var mdb = db.openMongoDB("mongodb://host/db");,``` + */ + +declare class Class_MongoDB extends Class__object { + + + + /** + * + * @brief 获取指定集合访问对象 + * @param name 指定集合的名称 + * @return 返回指定的集合对象 + * + * + * + */ + getCollection(name: string): Class_MongoCollection; + + /** + * + * @brief 指定一个 MongoDB 数据库命令 + * @param cmd 指定命令和参数的字典对象 + * @return 返回命令执行结果 + * + * + * + */ + runCommand(cmd: Object): Object; + + /** + * + * @brief 指定一个简单的 MongoDB 数据库命令 + * @param cmd 指定命令名 + * @param arg 指定命令参数 + * @return 返回命令执行结果 + * + * + * + */ + runCommand(cmd: string, arg: any): Object; + + /** + * + * @brief 生成一个 mongodb _objectid 对象 + * @param hexStr 初始化 16 进制字符串,缺省生成新的 id + * @return 新 _objectid 对象 + * + * + * + */ + oid(hexStr?: string/** = ""*/): Class_MongoID; + + /** + * + * @brief 关闭当前数据库连接 + * + * @async + */ + close(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/MongoID.d.ts b/types/fibjs/declare/MongoID.d.ts new file mode 100644 index 0000000000..8fd002b02f --- /dev/null +++ b/types/fibjs/declare/MongoID.d.ts @@ -0,0 +1,33 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief mongodb 数据库数据唯一标识对象,用于存储传递 oid + * @detail + */ + +declare class Class_MongoID extends Class__object { + + + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/MySQL.d.ts b/types/fibjs/declare/MySQL.d.ts new file mode 100644 index 0000000000..edc974a1d5 --- /dev/null +++ b/types/fibjs/declare/MySQL.d.ts @@ -0,0 +1,67 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief mysql 数据库连接对象 + * @detail 使用 db.open 或 db.openMySQL 创建,创建方式:,```JavaScript,var msql = db.openMySQL("mysql://user:pass@host/db");,``` + */ +/// +declare class Class_MySQL extends Class_DbConnection { + + /** + * class prop + * + * + * @brief 数据库连接接收缓存尺寸 + * + * + * @type Integer + */ + + rxBufferSize: number + + /** + * class prop + * + * + * @brief 数据库连接发送缓存尺寸 + * + * + * @type Integer + */ + + txBufferSize: number + + + + /** + * + * @brief 选择当前数据库连接的缺省数据库 + * @param dbName 指定数据库名 + * + * + * @async + */ + use(dbName: string): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/PKey.d.ts b/types/fibjs/declare/PKey.d.ts new file mode 100644 index 0000000000..3d25308696 --- /dev/null +++ b/types/fibjs/declare/PKey.d.ts @@ -0,0 +1,355 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 不对称加密算法对象 + * @detail PKey 对象属于 crypto 模块,创建:,```JavaScript,var k = new crypto.PKey();,``` + */ + +declare class Class_PKey extends Class__object { + + /** + * class prop + * + * + * @brief 返回当前算法名称 + * + * @readonly + * @type String + */ + + name: string + + /** + * class prop + * + * + * @brief 返回当前算法密码长度,以位为单位 + * + * @readonly + * @type Integer + */ + + keySize: number + + /** + * class prop + * + * + * @brief 返回当前密钥的公钥 + * @return 当前密钥的公钥 + * + * + * @readonly + * @type PKey + */ + + publicKey: Class_PKey + + + + /** + * + * @brief PKey 构造函数 + * + * + */ + constructor(); + + /** + * + * @brief 通过 DER 格式的密钥构造 PKey + * @param DerKey DER 格式的密钥 + * @param password 解密密码 + * + * + * + */ + constructor(DerKey: Class_Buffer, password?: string/** = ""*/); + + /** + * + * @brief 通过 PEM 格式的密钥构造 PKey + * @param pemKey PEM 格式的密钥 + * @param password 解密密码 + * + * + * + */ + constructor(pemKey: string, password?: string/** = ""*/); + + /** + * + * @brief 通过 JSON 格式的密钥构造 PKey + * + * jsonKey 的格式支持以下四种,RSA 私钥: + * ```JavaScript + * { + * "kty": "RSA", + * "n": "0m5lvKpWqy9JS7tV2HIPqHCYHLquSuxIC3F8strIQLJKO3rZmTT96KTnhsOfBO7Y1bI7mnT0PB3_vcHd9ekWMEoZJQw7MuB8KeM_Wn54-elJr5DNLk5bMppSGxX7ZnumiXGG51_X3Yp-_EbGtDG80GxXXix7Mucyo7K25uE0uW8=", + * "e": "AQAB", + * "d": "agN2O9NxMHL1MTMi75WfL9Pxvl-KWXKqZSF6mjzAsF9iKI8euyHIXYFepzU8kual1RsjDhCnzvWqFvZplW8lXqrHf_P-rS_9Y4gBUw6pjnI_DnFIRwWHRvrUHHSCfWOdTCIKdOTkgLZuGFuhEY3RMIW0WSYejjLtftwy0RVxAzk=", + * "p": "6a4G1qmfwWmn1biigN7IVFlkbLf9oVe6g7rOmHxI-hn1GRxKDSVuAUrmR1IhuAnca9M0y7SD-7TUs6wjOxWxaw==", + * "q": "5ofkxFKdPBD0CQHMb9q13AMHUVe0rJ-hSjqqIBrmqApUOneyAcMV76M0QyIQnI2p3POa4Qu_7XChDwRVl7LlDQ==", + * "dp": "2mXGiGwCHl8j-FBWuID-1C6z-BRB3MBEVoeKPOOzxOPruatB3mWEGXsqG7A8SWgV9URxTI2K6P3J6Z7RUpBkvw==", + * "dq": "oagn5vfb5NQqnOpS9xkSsD67cfIj821ZSFlNFYhnuOzNVda7z_qCtnHm4zDPH0lEFXoKYMfBhfqWJpaugttjPQ==", + * "qi": "dqEQgxNmOVFrF4s776hTqeC6oEDila8EvpVb2F2ZvwAOLjCQ66OiAZK1BiYGHqUy0NeqNmtlsLSuBEZQZvqZwg==" + * } + * ``` + * RSA 公钥: + * ```JavaScript + * { + * "kty": "RSA", + * "n": "0m5lvKpWqy9JS7tV2HIPqHCYHLquSuxIC3F8strIQLJKO3rZmTT96KTnhsOfBO7Y1bI7mnT0PB3_vcHd9ekWMEoZJQw7MuB8KeM_Wn54-elJr5DNLk5bMppSGxX7ZnumiXGG51_X3Yp-_EbGtDG80GxXXix7Mucyo7K25uE0uW8=", + * "e": "AQAB" + * } + * ``` + * EC 私钥: + * ```JavaScript + * { + * "kty": "EC", + * "crv": "P-521", + * "x": "ATfNNFuuvlGxrTGoXgyfSAGgRNNDnO3rN3k74urKJdVS14RYhdnSwm91Bm-F1l-T1XKlAY2yRnzG9w1Ukvo8c0wL", + * "y": "ASBHqrruB6kdkEUB3vlW3-UIkk4HtKdUeTwN-7m3j2rgZvYR1ffRAapDvWqKGiBjomqWafxokBkbDI0c95f6f4XU", + * "d": "AfkIbUHXfW41njdpoKuqqKludcoLJS8D_oMEwkj-GVaXFNKccIoF5iKGu2c69kNDjo83R_7wyGlfRczsklkik1ST" + * } + * ``` + * EC 公钥: + * ```JavaScript + * { + * "kty": "EC", + * "crv": "P-521", + * "x": "ATfNNFuuvlGxrTGoXgyfSAGgRNNDnO3rN3k74urKJdVS14RYhdnSwm91Bm-F1l-T1XKlAY2yRnzG9w1Ukvo8c0wL", + * "y": "ASBHqrruB6kdkEUB3vlW3-UIkk4HtKdUeTwN-7m3j2rgZvYR1ffRAapDvWqKGiBjomqWafxokBkbDI0c95f6f4XU" + * } + * ``` + * @param jsonKey JSON 格式的密钥 + * + * + * + */ + constructor(jsonKey: Object); + + /** + * + * @brief 生成一个 RSA 私钥 + * @param size 指定 RSA 密钥长度,bit 为单位 + * + * + * @async + */ + genRsaKey(size: number): void; + + /** + * + * @brief 生成一个 EC 私钥 + * @param curve 指定预置椭圆曲线,可选值为:"secp521r1", "brainpoolP512r1", "secp384r1", "brainpoolP384r1", "secp256r1", "secp256k1", "brainpoolP256r1", "secp224r1", "secp224k1", "secp192r1", "secp192k1" + * + * + * @async + */ + genEcKey(curve?: string/** = "secp521r1"*/): void; + + /** + * + * @brief 查询当前密钥是否为私钥 + * @return 为 True 表示为私钥 + * + * + * + */ + isPrivate(): boolean; + + /** + * + * @brief 复制当前密钥 + * @return 当前密钥的复制对象 + * + * + * + */ + clone(): Class_PKey; + + /** + * + * @brief 加载一个 DER 格式的密钥 + * @param DerKey DER 格式的密钥 + * @param password 解密密码 + * + * + * + */ + importKey(DerKey: Class_Buffer, password?: string/** = ""*/): void; + + /** + * + * @brief 加载一个 PEM 格式的密钥 + * @param pemKey PEM 格式的密钥 + * @param password 解密密码 + * + * + * + */ + importKey(pemKey: string, password?: string/** = ""*/): void; + + /** + * + * @brief 加载一个 JSON 格式的密钥 + * + * jsonKey 的格式支持以下四种,RSA 私钥: + * ```JavaScript + * { + * "kty": "RSA", + * "n": "0m5lvKpWqy9JS7tV2HIPqHCYHLquSuxIC3F8strIQLJKO3rZmTT96KTnhsOfBO7Y1bI7mnT0PB3_vcHd9ekWMEoZJQw7MuB8KeM_Wn54-elJr5DNLk5bMppSGxX7ZnumiXGG51_X3Yp-_EbGtDG80GxXXix7Mucyo7K25uE0uW8=", + * "e": "AQAB", + * "d": "agN2O9NxMHL1MTMi75WfL9Pxvl-KWXKqZSF6mjzAsF9iKI8euyHIXYFepzU8kual1RsjDhCnzvWqFvZplW8lXqrHf_P-rS_9Y4gBUw6pjnI_DnFIRwWHRvrUHHSCfWOdTCIKdOTkgLZuGFuhEY3RMIW0WSYejjLtftwy0RVxAzk=", + * "p": "6a4G1qmfwWmn1biigN7IVFlkbLf9oVe6g7rOmHxI-hn1GRxKDSVuAUrmR1IhuAnca9M0y7SD-7TUs6wjOxWxaw==", + * "q": "5ofkxFKdPBD0CQHMb9q13AMHUVe0rJ-hSjqqIBrmqApUOneyAcMV76M0QyIQnI2p3POa4Qu_7XChDwRVl7LlDQ==", + * "dp": "2mXGiGwCHl8j-FBWuID-1C6z-BRB3MBEVoeKPOOzxOPruatB3mWEGXsqG7A8SWgV9URxTI2K6P3J6Z7RUpBkvw==", + * "dq": "oagn5vfb5NQqnOpS9xkSsD67cfIj821ZSFlNFYhnuOzNVda7z_qCtnHm4zDPH0lEFXoKYMfBhfqWJpaugttjPQ==", + * "qi": "dqEQgxNmOVFrF4s776hTqeC6oEDila8EvpVb2F2ZvwAOLjCQ66OiAZK1BiYGHqUy0NeqNmtlsLSuBEZQZvqZwg==" + * } + * ``` + * RSA 公钥: + * ```JavaScript + * { + * "kty": "RSA", + * "n": "0m5lvKpWqy9JS7tV2HIPqHCYHLquSuxIC3F8strIQLJKO3rZmTT96KTnhsOfBO7Y1bI7mnT0PB3_vcHd9ekWMEoZJQw7MuB8KeM_Wn54-elJr5DNLk5bMppSGxX7ZnumiXGG51_X3Yp-_EbGtDG80GxXXix7Mucyo7K25uE0uW8=", + * "e": "AQAB" + * } + * ``` + * EC 私钥: + * ```JavaScript + * { + * "kty": "EC", + * "crv": "P-521", + * "x": "ATfNNFuuvlGxrTGoXgyfSAGgRNNDnO3rN3k74urKJdVS14RYhdnSwm91Bm-F1l-T1XKlAY2yRnzG9w1Ukvo8c0wL", + * "y": "ASBHqrruB6kdkEUB3vlW3-UIkk4HtKdUeTwN-7m3j2rgZvYR1ffRAapDvWqKGiBjomqWafxokBkbDI0c95f6f4XU", + * "d": "AfkIbUHXfW41njdpoKuqqKludcoLJS8D_oMEwkj-GVaXFNKccIoF5iKGu2c69kNDjo83R_7wyGlfRczsklkik1ST" + * } + * ``` + * EC 公钥: + * ```JavaScript + * { + * "kty": "EC", + * "crv": "P-521", + * "x": "ATfNNFuuvlGxrTGoXgyfSAGgRNNDnO3rN3k74urKJdVS14RYhdnSwm91Bm-F1l-T1XKlAY2yRnzG9w1Ukvo8c0wL", + * "y": "ASBHqrruB6kdkEUB3vlW3-UIkk4HtKdUeTwN-7m3j2rgZvYR1ffRAapDvWqKGiBjomqWafxokBkbDI0c95f6f4XU" + * } + * ``` + * @param jsonKey JSON 格式的密钥 + * + * + * + */ + importKey(jsonKey: Object): void; + + /** + * + * @brief 加载一个 PEM/DER 格式的密钥文件 + * @param filename 密钥文件名 + * @param password 解密密码 + * + * + * + */ + importFile(filename: string, password?: string/** = ""*/): void; + + /** + * + * @brief 返回当前 key 的 PEM 格式编码 + * @return 当前 key 的 PEM 格式编码 + * + * + * + */ + exportPem(): string; + + /** + * + * @brief 返回当前 key 的 DER 格式编码 + * @return 当前 key 的 DER 格式编码 + * + * + * + */ + exportDer(): Class_Buffer; + + /** + * + * @brief 返回当前 key 的 DER 格式编码 + * @return 当前 key 的 DER 格式编码 + * + * + * + */ + exportJson(): Object; + + /** + * + * @brief 使用当前算法密码公钥加密数据 + * @param data 指定要加密的数据 + * @return 返回加密后的数据 + * + * + * @async + */ + encrypt(data: Class_Buffer): Class_Buffer; + + /** + * + * @brief 使用当前算法密码私钥解密数据 + * @param data 指定要解密的数据 + * @return 返回解密后的数据 + * + * + * @async + */ + decrypt(data: Class_Buffer): Class_Buffer; + + /** + * + * @brief 使用当前算法密码私钥签名数据 + * @param data 指定要签名的数据 + * @param alg 指定要签名的算法, 默认0. 支持算法: 0=NONE,1=MD2,2=MD4,3=MD5,4=SHA1,5=SHA224,6=SHA256,7=SHA384,8=SHA512,9=RIPEMD160 + * @return 返回签名后的数据 + * + * + * @async + */ + sign(data: Class_Buffer, alg?: number/** = 0*/): Class_Buffer; + + /** + * + * @brief 使用当前算法密码公钥验证数据 + * @param data 指定要验证的数据 + * @param sign 指定要验证的签名 + * @param alg 指定要签名的算法, 默认0. 支持算法: 0=NONE,1=MD2,2=MD4,3=MD5,4=SHA1,5=SHA224,6=SHA256,7=SHA384,8=SHA512,9=RIPEMD160 + * @return 返回验证后的结果 + * + * + * @async + */ + verify(data: Class_Buffer, sign: Class_Buffer, alg?: number/** = 0*/): boolean; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Redis.d.ts b/types/fibjs/declare/Redis.d.ts new file mode 100644 index 0000000000..ed5d498a98 --- /dev/null +++ b/types/fibjs/declare/Redis.d.ts @@ -0,0 +1,576 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief Redis 数据库客户端对象 + * @detail 用以创建和管理 Redis 数据库,创建方法:,```JavaScript,var db = require("db");,var test = new db.openRedis("redis-server");,``` + */ + +declare class Class_Redis extends Class__object { + + /** + * class prop + * + * + * @brief 查询和设置错误处理函数,当 sub 出现错误或者网络中断时回调,当回调发生后,本对象的一切 sub 都将中止 + * + * + * + * @type Function + */ + + onsuberror: Function + + + + /** + * + * @brief redis 基础命令方法 + * @param cmd 指定发送的命令 + * @param args 指定发送的参数 + * @return 返回服务器返回的结果 + * + * + */ + command(cmd: string, ...args: any[]): any; + + /** + * + * @brief 将字符串值 value 关联到 key,如果 key 已经持有其他值, SET 就覆写旧值,无视类型 + * @param key 指定要关联的 key + * @param value 指定要关联的数据 + * @param ttl 以毫秒为单位为 key 设置生存时间;如果 ttl 为 0 ,那么不设置生存时间 + * + * + */ + set(key: Class_Buffer, value: Class_Buffer, ttl?: number/** = 0*/): void; + + /** + * + * @brief 将 key 的值设为 value ,当且仅当 key 不存在。若给定的 key 已经存在,则 SETNX 不做任何动作。 + * @param key 指定要关联的 key + * @param value 指定要关联的数据 + * @param ttl 以毫秒为单位为 key 设置生存时间;如果 ttl 为 0 ,那么不设置生存时间 + * + * + */ + setNX(key: Class_Buffer, value: Class_Buffer, ttl?: number/** = 0*/): void; + + /** + * + * @brief 将 key 的值设为 value,只在键已经存在时,才对键进行设置操作。 + * @param key 指定要关联的 key + * @param value 指定要关联的数据 + * @param ttl 以毫秒为单位为 key 设置生存时间;如果 ttl 为 0 ,那么不设置生存时间 + * + * + */ + setXX(key: Class_Buffer, value: Class_Buffer, ttl?: number/** = 0*/): void; + + /** + * + * @brief 同时设置一个或多个 key-value 对。如果某个给定 key 已经存在,那么 MSET 会用新值覆盖原来的旧值 + * @param kvs 指定要设置的 key/value 对象 + * + * + */ + mset(kvs: Object): void; + + /** + * + * @brief 同时设置一个或多个 key-value 对。如果某个给定 key 已经存在,那么 MSET 会用新值覆盖原来的旧值 + * @param kvs 指定要设置的 key/value 列表 + * + * + */ + mset(...kvs: any[]): void; + + /** + * + * @brief 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在 + * @param kvs 指定要设置的 key/value 对象 + * + * + */ + msetNX(kvs: Object): void; + + /** + * + * @brief 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在 + * @param kvs 指定要设置的 key/value 列表 + * + * + */ + msetNX(...kvs: any[]): void; + + /** + * + * @brief 如果 key 已经存在并且是一个字符串,append 命令将 value 追加到 key 原来的值的末尾。如果 key 不存在,append 就简单地将给定 key 设为 value + * @param key 指定要追加的 key + * @param value 指定要追加的数据 + * @return 追加 value 之后, key 中字符串的长度 + * + * + */ + append(key: Class_Buffer, value: Class_Buffer): number; + + /** + * + * @brief 用 value 参数覆写给定 key 所储存的字符串值,从偏移量 offset 开始 + * @param key 指定要修改的 key + * @param offset 指定修改的字节偏移 + * @param value 指定要覆盖的数据 + * @return 被修改之后,字符串的长度 + * + * + */ + setRange(key: Class_Buffer, offset: number, value: Class_Buffer): number; + + /** + * + * @brief 返回 key 中字符串值的子字符串,字符串的截取范围由 start 和 end 两个偏移量决定(包括 start 和 end 在内) + * @param key 指定要查询的 key + * @param start 指定查询的起始字节偏移 + * @param end 指定查询的结束字节偏移 + * @return 截取得出的子字符串 + * + * + */ + getRange(key: Class_Buffer, start: number, end: number): Class_Buffer; + + /** + * + * @brief 返回 key 所储存的字符串值的长度。当 key 储存的不是字符串值时,返回一个错误 + * @param key 指定要计算的 key + * @return 字符串值的长度。当 key 不存在时,返回 0 + * + * + */ + strlen(key: Class_Buffer): number; + + /** + * + * @brief 计算给定字符串中,被设置为 1 的比特位的数量 + * @param key 指定要计算的 key + * @param start 指定要计算的起始字节,可以使用负数值,-1 表示最后一个字节,而 -2 表示倒数第二个字节,以此类推 + * @param end 指定要计算的结束字节,可以使用负数值,-1 表示最后一个字节,而 -2 表示倒数第二个字节,以此类推 + * @return 被设置为 1 的位的数量 + * + * + */ + bitcount(key: Class_Buffer, start?: number/** = 0*/, end?: number/** = -1*/): number; + + /** + * + * @brief 返回 key 所关联的字符串值,如果 key 不存在那么返回特殊值 Null + * @param key 指定要关联的 key + * @return 当 key 不存在时,返回 Null ,否则,返回 key 的值 + * + * + */ + get(key: Class_Buffer): Class_Buffer; + + /** + * + * @brief 返回所有(一个或多个)给定 key 的值。如果给定的 key 里面,有某个 key 不存在,那么这个 key 返回特殊值 nil 。 + * @param keys 指定要查询的 key 数组 + * @return 一个包含所有给定 key 的值的列表 + * + * + */ + mget(keys: any[]): any[]; + + /** + * + * @brief 返回所有(一个或多个)给定 key 的值。如果给定的 key 里面,有某个 key 不存在,那么这个 key 返回特殊值 nil 。 + * @param keys 指定要查询的 key 列表 + * @return 一个包含所有给定 key 的值的列表 + * + * + */ + mget(...keys: any[]): any[]; + + /** + * + * @brief 将给定 key 的值设为 value ,并返回 key 的旧值(old value) + * @param key 指定要查询修改的 key + * @param value 指定修改的数值 + * @return 返回给定 key 的旧值 + * + * + */ + getset(key: Class_Buffer, value: Class_Buffer): Class_Buffer; + + /** + * + * @brief 将 key 所储存的值减去减量 + * @param key 指定要修改的 key + * @param num 指定要减去的数值 + * @return 减去 num 之后,key 的值 + * + * + */ + decr(key: Class_Buffer, num?: number/** = 1*/): number; + + /** + * + * @brief 将 key 所储存的值加上增量 + * @param key 指定要修改的 key + * @param num 指定要加上的数值 + * @return 加上 num 之后,key 的值 + * + * + */ + incr(key: Class_Buffer, num?: number/** = 1*/): number; + + /** + * + * @brief 对 key 所储存的字符串值,设置或清除指定偏移量上的位(bit) + * @param key 指定要修改的 key + * @param offset 指定修改的位偏移 + * @param value 指定设置或清除的参数,可以是 0 也可以是 1 + * @return 指定偏移量原来储存的位 + * + * + */ + setBit(key: Class_Buffer, offset: number, value: number): number; + + /** + * + * @brief 对 key 所储存的字符串值,获取指定偏移量上的位(bit) + * @param key 指定要查询的 key + * @param offset 指定查询的位偏移 + * @return 字符串值指定偏移量上的位(bit) + * + * + */ + getBit(key: Class_Buffer, offset: number): number; + + /** + * + * @brief 检查给定 key 是否存在 + * @param key 指定要关联的 key + * @return 若 key 存在,返回 True,否则返回 False + * + * + */ + exists(key: Class_Buffer): boolean; + + /** + * + * @brief 返回 key 所储存的值的类型 + * @param key 指定要查询的 key + * @return 返回 key 所储存的值的类型,可能的值为 none(key不存在) string(字符串) list(列表) set(集合) zset(有序集) hash(哈希表) + * + * + */ + type(key: Class_Buffer): string; + + /** + * + * @brief 查找所有符合给定模式 pattern 的 key + * @param pattern 指定查询模式 + * @return 符合给定模式的 key 列表 + * + * + */ + keys(pattern: string): any[]; + + /** + * + * @brief 删除给定的一个或多个 key,不存在的 key 会被忽略 + * @param keys 指定要删除的 key 数组 + * @return 被删除 key 的数量 + * + * + */ + del(keys: any[]): number; + + /** + * + * @brief 删除给定的一个或多个 key,不存在的 key 会被忽略 + * @param keys 指定要删除的 key 列表 + * @return 被删除 key 的数量 + * + * + */ + del(...keys: any[]): number; + + /** + * + * @brief 为给定 key 设置生存时间,当 key 过期时,它会被自动删除 + * @param key 指定要设定的 key + * @param ttl 以毫秒为单位为 key 设置生存时间 + * @return 若 key 存在,返回 True,否则返回 False + * + * + */ + expire(key: Class_Buffer, ttl: number): boolean; + + /** + * + * @brief 返回给定 key 的剩余生存时间 + * @param key 指定要查询的 key + * @return 以毫秒为单位,返回 key 的剩余生存时间,当 key 不存在时,返回 -2,当 key 存在但没有设置剩余生存时间时,返回 -1 + * + * + */ + ttl(key: Class_Buffer): number; + + /** + * + * @brief 移除给定 key 的生存时间,将这个 key 从『易失的』(带生存时间 key )转换成『持久的』(一个不带生存时间、永不过期的 key) + * @param key 指定要设定的 key + * @return 若 key 存在,返回 True,否则返回 False + * + * + */ + persist(key: Class_Buffer): boolean; + + /** + * + * @brief 将 key 改名为 newkey,当 key 和 newkey 相同,或者 key 不存在时,返回一个错误 + * @param key 指定要改名的 key + * @param newkey 指定要改名的目的 key + * + * + */ + rename(key: Class_Buffer, newkey: Class_Buffer): void; + + /** + * + * @brief 当且仅当 newkey 不存在时,将 key 改名为 newkey,当 key 不存在时,返回一个错误 + * @param key 指定要改名的 key + * @param newkey 指定要改名的目的 key + * @return 修改成功时,返回 True,如果 newkey 已经存在,返回 False + * + * + */ + renameNX(key: Class_Buffer, newkey: Class_Buffer): boolean; + + /** + * + * @brief 订阅给定的一个频道的信息,当消息发生时自动调用 func,func 包含两个参数,依次为 channel 和 message,同一频道同一函数只会回调一次 + * @param channel 指定订阅的频道名称 + * @param func 指定回调函数 + * + * + * + */ + sub(channel: Class_Buffer, func: Function): void; + + /** + * + * @brief 订阅给定的一组频道的信息,当消息发生时自动调用相应的回调函数,同一频道同一函数只会回调一次 + * @param map 指定频道映射关系,对象属性名称将作为频道名称,属性的值将作为回调函数 + * + * + * + */ + sub(map: Object): void; + + /** + * + * @brief 退订给定的频道的全部回调 + * @param channel 指定退订的频道名称 + * + * + * + */ + unsub(channel: Class_Buffer): void; + + /** + * + * @brief 退订给定的频道的指定回调函数 + * @param channel 指定退订的频道名称 + * @param func 指定退订的回调函数 + * + * + * + */ + unsub(channel: Class_Buffer, func: Function): void; + + /** + * + * @brief 退订一组给定的频道的全部回调 + * @param channels 指定退订的频道数组 + * + * + * + */ + unsub(channels: any[]): void; + + /** + * + * @brief 退订给定的一组频道的指定回调函数 + * @param map 指定频道映射关系,对象属性名称将作为频道名称,属性的值将作为回调函数 + * + * + * + */ + unsub(map: Object): void; + + /** + * + * @brief 按照模板订阅一组频道的信息,当消息发生时自动调用 func,func 包含三个参数,依次为 channel,message 和 pattern,同一模板同一函数只会回调一次 + * @param pattern 指定订阅的频道模板 + * @param func 指定回调函数 + * + * + * + */ + psub(pattern: string, func: Function): void; + + /** + * + * @brief 订阅给定的一组频道模板的信息,当消息发生时自动调用相应的 func,同一频道同一函数只会回调一次 + * @param map 指定频道映射关系,对象属性名称将作为频道模板,属性的值将作为回调函数 + * + * + * + */ + psub(map: Object): void; + + /** + * + * @brief 退订给定模板的频道的全部回调 + * @param pattern 指定退订的频道模板 + * + * + * + */ + unpsub(pattern: string): void; + + /** + * + * @brief 退订给定模板的频道的指定回调函数 + * @param pattern 指定退订的频道模板 + * @param func 指定退订的回调函数 + * + * + * + */ + unpsub(pattern: string, func: Function): void; + + /** + * + * @brief 退订一组给定模板的频道的全部回调 + * @param patterns 指定发布的频道模板数组 + * + * + * + */ + unpsub(patterns: any[]): void; + + /** + * + * @brief 退订一组模板的频道的指定回调函数 + * @param map 指定频道映射关系,对象属性名称将作为频道模板,属性的值将作为回调函数 + * + * + * + */ + unpsub(map: Object): void; + + /** + * + * @brief 将信息 message 发送到指定的频道 channel + * @param channel 指定发布的频道 + * @param message 指定发布的消息 + * @return 接收此消息的客户端数量 + * + * + * + */ + pub(channel: Class_Buffer, message: Class_Buffer): number; + + /** + * + * @brief 获取指定 key 的 Hash 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库 + * @param key 指定要获取的 key + * @return 返回包含指定 key 的 Hash 对象 + * + * + */ + getHash(key: Class_Buffer): Class_RedisHash; + + /** + * + * @brief 获取指定 key 的 List 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库 + * @param key 指定要获取的 key + * @return 返回包含指定 key 的 List 对象 + * + * + */ + getList(key: Class_Buffer): Class_RedisList; + + /** + * + * @brief 获取指定 key 的 Set 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库 + * @param key 指定要获取的 key + * @return 返回包含指定 key 的 Set 对象 + * + * + */ + getSet(key: Class_Buffer): Class_RedisSet; + + /** + * + * @brief 获取指定 key 的 SortedSet 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库 + * @param key 指定要获取的 key + * @return 返回包含指定 key 的 SortedSet 对象 + * + * + */ + getSortedSet(key: Class_Buffer): Class_RedisSortedSet; + + /** + * + * @brief 序列化给定 key ,并返回被序列化的值,使用 restore 命令可以将这个值反序列化为 Redis 键 + * @param key 指定要序列化的 key + * @return 返回序列化之后的值,如果 key 不存在,那么返回 null + * + * + */ + dump(key: Class_Buffer): Class_Buffer; + + /** + * + * @brief 反序列化给定的序列化值,并将它和给定的 key 关联 + * @param key 指定要反序列化的 key + * @param data 指定要反序列化的数据 + * @param ttl 以毫秒为单位为 key 设置生存时间;如果 ttl 为 0 ,那么不设置生存时间 + * + * + */ + restore(key: Class_Buffer, data: Class_Buffer, ttl?: number/** = 0*/): void; + + /** + * + * @brief 关闭当前数据库连接或事务 + * + * + */ + close(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/RedisHash.d.ts b/types/fibjs/declare/RedisHash.d.ts new file mode 100644 index 0000000000..9c2bc44ad7 --- /dev/null +++ b/types/fibjs/declare/RedisHash.d.ts @@ -0,0 +1,169 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief Redis 数据库客户端 Hash 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库 + * @detail 用以操作 Redis 的 Hash 对象,创建方法:,```JavaScript,var db = require("db");,var rdb = new db.openRedis("redis-server");,var hash = rdb.getHash("test");,``` + */ + +declare class Class_RedisHash extends Class__object { + + + + /** + * + * @brief 将哈希表中的域 field 的值设为 value,如果域 field 已经存在于哈希表中,旧值将被覆盖 + * @param field 指定要修改的 field + * @param value 指定要修改的数据 + * + * + */ + set(field: Class_Buffer, value: Class_Buffer): void; + + /** + * + * @brief 将哈希表中的域 field 的值设置为 value ,当且仅当域 field 不存在。若域 field 已经存在,该操作无效 + * @param field 指定要修改的 field + * @param value 指定要修改的数据 + * + * + */ + setNX(field: Class_Buffer, value: Class_Buffer): void; + + /** + * + * @brief 同时将多个 field-value (域-值)对设置到哈希表中,此命令会覆盖哈希表中已存在的域 + * @param kvs 指定要设置的 field/value 对象 + * + * + */ + mset(kvs: Object): void; + + /** + * + * @brief 同时将多个 field-value (域-值)对设置到哈希表中,此命令会覆盖哈希表中已存在的域 + * @param kvs 指定要设置的 field/value 列表 + * + * + */ + mset(...kvs: any[]): void; + + /** + * + * @brief 返回哈希表中给定域 field 的值 + * @param field 指定要查询的 field + * @return 给定域的值,当给定域不存在或是给定 key 不存在时,返回 null + * + * + */ + get(field: Class_Buffer): Class_Buffer; + + /** + * + * @brief 返回哈希表中,一个或多个给定域的值 + * @param fields 指定要查询的域数组 + * @return 一个包含所有给定域的值的列表 + * + * + */ + mget(fields: any[]): any[]; + + /** + * + * @brief 返回哈希表中,一个或多个给定域的值 + * @param fields 指定要查询的域列表 + * @return 一个包含所有给定域的值的列表 + * + * + */ + mget(...fields: any[]): any[]; + + /** + * + * @brief 将域所储存的值加上增量 + * @param field 指定要修改的域 + * @param num 指定要加上的数值 + * @return 加上 num 之后,域的值 + * + * + */ + incr(field: Class_Buffer, num?: number/** = 1*/): number; + + /** + * + * @brief 返回哈希表中,所有的域和值 + * @return 返回一个包含哈希表中所有域的列表 + * + * + */ + getAll(): any[]; + + /** + * + * @brief 返回哈希表中的所有域 + * @return 返回值里,紧跟每个域名(field name)之后是域的值(value),所以返回值的长度是哈希表大小的两倍 + * + * + */ + keys(): any[]; + + /** + * + * @brief 返回哈希表中域的数量 + * @return 返回哈希表中域的数量 + * + * + */ + len(): number; + + /** + * + * @brief 查看哈希表中,给定域 field 是否存在 + * @param field 指定要查询的 field + * @return 如果哈希表含有给定域,返回 true,如果哈希表不含有给定域,或 key 不存在,返回 false + * + * + */ + exists(field: Class_Buffer): boolean; + + /** + * + * @brief 删除哈希表中的一个或多个指定域,不存在的域将被忽略 + * @param fields 指定要删除的域数组 + * @return 被删除域的数量 + * + * + */ + del(fields: any[]): number; + + /** + * + * @brief 删除哈希表中的一个或多个指定域,不存在的域将被忽略 + * @param fields 指定要删除的域列表 + * @return 被删除域的数量 + * + * + */ + del(...fields: any[]): number; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/RedisList.d.ts b/types/fibjs/declare/RedisList.d.ts new file mode 100644 index 0000000000..64d56a04f7 --- /dev/null +++ b/types/fibjs/declare/RedisList.d.ts @@ -0,0 +1,174 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief Redis 数据库客户端 List 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库 + * @detail 用以操作 Redis 的 List 对象,创建方法:,```JavaScript,var db = require("db");,var rdb = new db.openRedis("redis-server");,var list = rdb.getList("test");,``` + */ + +declare class Class_RedisList extends Class__object { + + + + /** + * + * @brief 将一个或多个值 value 插入到列表的表头 + * @param values 指定要插入的数据 + * @return 插入后,列表的长度 + * + * + */ + push(values: any[]): number; + + /** + * + * @brief 将一个或多个值 value 插入到列表的表头 + * @param values 指定要插入的数据 + * @return 插入后,列表的长度 + * + * + */ + push(...values: any[]): number; + + /** + * + * @brief 移除并返回列表 key 的头元素 + * @return 列表的头元素,如果列表为空则返回 null + * + * + */ + pop(): Class_Buffer; + + /** + * + * @brief 将一个或多个值 value 插入到列表的表尾(最右边) + * @param values 指定要插入的数据 + * @return 插入后,列表的长度 + * + * + */ + rpush(values: any[]): number; + + /** + * + * @brief 将一个或多个值 value 插入到列表的表尾(最右边) + * @param values 指定要插入的数据 + * @return 插入后,列表的长度 + * + * + */ + rpush(...values: any[]): number; + + /** + * + * @brief 移除并返回列表 key 的表尾(最右边)元素 + * @return 列表的头元素,如果列表为空则返回 null + * + * + */ + rpop(): Class_Buffer; + + /** + * + * @brief 将列表下标为 index 的元素的值设置为 value + * @param index 指定要修改的下标 + * @param value 指定要修改的数据 + * + * + */ + set(index: number, value: Class_Buffer): void; + + /** + * + * @brief 返回列表中,下标为 index 的元素 + * @param index 指定要查询的下标 + * @return 列表中下标为 index 的元素 + * + * + */ + get(index: number): Class_Buffer; + + /** + * + * @brief 将值 value 插入到列表当中,位于值 pivot 之前 + * @param pivot 指定插入时查找的数据 + * @param value 指定要插入的数据 + * @return 插入后,列表的长度 + * + * + */ + insertBefore(pivot: Class_Buffer, value: Class_Buffer): number; + + /** + * + * @brief 将值 value 插入到列表当中,位于值 pivot 之后 + * @param pivot 指定插入时查找的数据 + * @param value 指定要插入的数据 + * @return 插入后,列表的长度 + * + * + */ + insertAfter(pivot: Class_Buffer, value: Class_Buffer): number; + + /** + * + * @brief 根据参数 count 的值,移除列表中与参数 value 相等的元素 + * @param count 指定删除的元素数量 + * @param value 指定要删除的数值 + * @return 被移除元素的数量 + * + * + */ + remove(count: number, value: Class_Buffer): number; + + /** + * + * @brief 对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除 + * @param start 指定修剪的起始下标,0 表示第一个元素,-1 表示最后一个元素 + * @param stop 指定修剪的结束下标,0 表示第一个元素,-1 表示最后一个元素 + * + * + */ + trim(start: number, stop: number): void; + + /** + * + * @brief 返回列表的长度 + * @return 返回列表的长度 + * + * + */ + len(): number; + + /** + * + * @brief 返回列表中指定区间内的元素,区间以偏移量 start 和 stop 指定,包含 start 和 stop 的元素 + * @param start 指定查询的起始下标,0 表示第一个元素,-1 表示最后一个元素 + * @param stop 指定查询的结束下标,0 表示第一个元素,-1 表示最后一个元素 + * @return 包含指定区间内的元素的数组 + * + * + */ + range(start: number, stop: number): any[]; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/RedisSet.d.ts b/types/fibjs/declare/RedisSet.d.ts new file mode 100644 index 0000000000..76e360ed7e --- /dev/null +++ b/types/fibjs/declare/RedisSet.d.ts @@ -0,0 +1,129 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief Redis 数据库客户端 Set 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库 + * @detail 用以操作 Redis 的 Set 对象,创建方法:,```JavaScript,var db = require("db");,var rdb = new db.openRedis("redis-server");,var set = rdb.getSet("test");,``` + */ + +declare class Class_RedisSet extends Class__object { + + + + /** + * + * @brief 将一个或多个 member 元素加入到集合 key 当中,已经存在于集合的 member 元素将被忽略 + * @param members 指定要添加的元素数组 + * @return 被添加到集合中的新元素的数量,不包括被忽略的元素 + * + * + */ + add(members: any[]): number; + + /** + * + * @brief 同时将多个 field-value (域-值)对设置到哈希表中,此命令会覆盖哈希表中已存在的域 + * @param members 指定要添加的元素列表 + * @return 被添加到集合中的新元素的数量,不包括被忽略的元素 + * + * + */ + add(...members: any[]): number; + + /** + * + * @brief 移除集合中的一个或多个 member 元素 + * @param members 指定要移除的元素数组 + * @return 被成功移除的元素的数量,不包括被忽略的元素 + * + * + */ + remove(members: any[]): number; + + /** + * + * @brief 移除集合中的一个或多个 member 元素 + * @param members 指定要移除的元素列表 + * @return 被成功移除的元素的数量,不包括被忽略的元素 + * + * + */ + remove(...members: any[]): number; + + /** + * + * @brief 返回集合中元素的数量 + * @return 返回集合的长度 + * + * + */ + len(): number; + + /** + * + * @brief 判断 member 元素是否集合的成员 + * @param member 指定检查的 member + * @return 如果 member 元素是集合的成员,返回 true + * + * + */ + exists(member: Class_Buffer): boolean; + + /** + * + * @brief 返回集合中的所有成员 + * @return 集合中所有成员的列表 + * + * + */ + members(): any[]; + + /** + * + * @brief 移除并返回集合中的一个随机元素 + * @return 被移除的随机元素。当集合是空集时,返回 null + * + * + */ + pop(): Class_Buffer; + + /** + * + * @brief 从集合中获取随机的一个元素 + * @return 返回一个元素;如果集合为空,返回 null + * + * + */ + randMember(): any; + + /** + * + * @brief 从集合中获取随机的若干元素 + * @param count 指定返回的元素个数。正数,返回一个包含 count 个元素的数组;负数,返回一个数组,数组中的元素可能会重复出现多次,而数组的长度为 count 的绝对值 + * @return 返回一个列表;如果集合为空,返回空列表 + * + * + */ + randMember(count: number): any; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/RedisSortedSet.d.ts b/types/fibjs/declare/RedisSortedSet.d.ts new file mode 100644 index 0000000000..8a98643ea9 --- /dev/null +++ b/types/fibjs/declare/RedisSortedSet.d.ts @@ -0,0 +1,158 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief Redis 数据库客户端 SortedSet 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库 + * @detail 用以操作 Redis 的 SortedSet 对象,创建方法:,```JavaScript,var db = require("db");,var rdb = new db.openRedis("redis-server");,var set = rdb.getSortedSet("test");,``` + */ + +declare class Class_RedisSortedSet extends Class__object { + + + + /** + * + * @brief 将一个或多个 member 元素及其 score 值加入到有序集当中 + * @param sms 指定要添加的 member/score 对象 + * @return 被成功添加的新成员的数量,不包括那些被更新的、已经存在的成员 + * + * + */ + add(sms: Object): number; + + /** + * + * @brief 将一个或多个 member 元素及其 score 值加入到有序集当中 + * @param sms 指定要添加的 member/score 列表 + * @return 被成功添加的新成员的数量,不包括那些被更新的、已经存在的成员 + * + * + */ + add(...sms: any[]): number; + + /** + * + * @brief 返回有序集中,成员 member 的 score 值 + * @param member 指定要查询的 member + * @return member 成员的 score 值,以字符串形式表示 + * + * + */ + score(member: Class_Buffer): Class_Buffer; + + /** + * + * @brief 为有序集的成员 member 的 score 值加上增量 num + * @param member 指定要修改的 member + * @param num 指定要加上的数值 + * @return member 成员的新 score 值,以字符串形式表示 + * + * + */ + incr(member: Class_Buffer, num?: number/** = 1*/): Class_Buffer; + + /** + * + * @brief 移除有序集中的一个或多个 member 元素 + * @param members 指定要移除的元素数组 + * @return 被成功移除的元素的数量,不包括被忽略的元素 + * + * + */ + remove(members: any[]): number; + + /** + * + * @brief 移除有序集中的一个或多个 member 元素 + * @param members 指定要移除的元素列表 + * @return 被成功移除的元素的数量,不包括被忽略的元素 + * + * + */ + remove(...members: any[]): number; + + /** + * + * @brief 返回有序集中元素的数量 + * @return 返回有序集的长度 + * + * + */ + len(): number; + + /** + * + * @brief 返回有序集中, score 值在 min 和 max 之间(默认包括 score 值等于 min 或 max )的成员的数量 + * @param min 指定统计的最小 score + * @param max 指定统计的最大 score + * @return score 值在 min 和 max 之间的成员的数量 + * + * + */ + count(min: number, max: number): number; + + /** + * + * @brief 返回有序集中,指定区间内的成员,成员的位置按 score 值递增(从小到大)来排序 + * @param start 指定查询的起始下标,0 表示第一个元素,-1 表示最后一个元素 + * @param stop 指定查询的结束下标,0 表示第一个元素,-1 表示最后一个元素 + * @param withScores 指定是否在结果中包含 score + * @return 指定区间内,带有 score 值(可选)的有序集成员的列表 + * + * + */ + range(start: number, stop: number, withScores?: boolean/** = false*/): any[]; + + /** + * + * @brief 返回有序集中,指定区间内的成员,成员的位置按 score 值递减(从大到小)来排序 + * @param start 指定查询的起始下标,0 表示第一个元素,-1 表示最后一个元素 + * @param stop 指定查询的结束下标,0 表示第一个元素,-1 表示最后一个元素 + * @param withScores 指定是否在结果中包含 score + * @return 指定区间内,带有 score 值(可选)的有序集成员的列表 + * + * + */ + rangeRev(start: number, stop: number, withScores?: boolean/** = false*/): any[]; + + /** + * + * @brief 有序集中成员 member 的排名。其中有序集成员按 score 值递增(从小到大)顺序排列 + * @param member 指定要查询的 member + * @return member 如果 member 是有序集 key 的成员,返回 member 的排名。如果 member 不是有序集 key 的成员,返回 nil + * + * + */ + rank(member: Class_Buffer): number; + + /** + * + * @brief 有序集中成员 member 的排名。其中有序集成员按 score 值递减(从大到小)顺序排列 + * @param member 指定要查询的 member + * @return member 如果 member 是有序集 key 的成员,返回 member 的排名。如果 member 不是有序集 key 的成员,返回 nil + * + * + */ + rankRev(member: Class_Buffer): number; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Routing.d.ts b/types/fibjs/declare/Routing.d.ts new file mode 100644 index 0000000000..af67796f22 --- /dev/null +++ b/types/fibjs/declare/Routing.d.ts @@ -0,0 +1,262 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 消息处理器路由对象 + * @detail 路由对象是 http 消息处理的核心对象,服务器根据路由的设定,匹配 url 和 method,并将 http 消息转发到相应的处理器,以完成不同的事务。,,一个简单的路由,可以直接以 JSON 对象的形式提供,比如:,```JavaScript,var http = require('http');,,var svr = new http.Server(8080, {, '/': r => r.response.write('home'),, '/help': r => r.response.write('help'),});,,svr.run();,```,如果需要更复杂的路由定制,可以自行创建 Routing 对象并根据需要处理路由策略:,```JavaScript,var http = require('http');,var mq = require('mq');,,var app = new mq.Routing();,,app.get('/', r => r.response.write('home'));,app.get('/help', r => r.response.write('help'));,,app.post('/help', r => r.response.write('post a help.'));,,app.get('/home/:user', (r, user) => r.response.write('hello ' + user));,,app.get('/user/:id(\\d+)', (r, id) => r.response.write('get ' + id));,,app.get('/actions', {, '/run': r => r.response.write('running'),, '/sleep': r => r.response.write('sleeping'),, '(.*)': r => r.response.write('........'),});,,var svr = new http.Server(8080, app);,svr.run();,```,路由对象根据设定的规则匹配消息,将消息传递给符合规则的第一个处理器。后加入的路由规则优先匹配。创建方法:,```JavaScript,var routing = new mq.Routing({, "^/func1(/.*)$": func1,, "^/func2(/.*)$": func2,});,```,正则表达式匹配的项目修改消息的 value 属性,子项目存入消息的 params 属性。例如:,```JavaScript,var routing = new mq.Routing({, "^/func1(/([0-9]+)/([0-9]+)\.html)$": func1,,});,```,匹配消息 "/func1/123/456.html" 后,value == "/123/456.html",params == ["123", "456"];,,如果匹配的结果没有子项,则 value 为空,params 为空。例如:,```JavaScript,var routing = new mq.Routing({, "^/func1/[0-9]+/[0-9]+\.html$": func1,,});,```,匹配消息 "/func1/123/456.html" 后,value == "",params == [];,,如果匹配的结果第一级有多个子项,则 value 为空,params 为第一级子项。例如:,```JavaScript,var routing = new mq.Routing({, "^/func1/([0-9]+)/([0-9]+)\.html$": func1,,});,```,匹配消息 "/func1/123/456.html" 后,value == "",params == ["123", "456"];,,如果匹配的结果只有一个子项,并且无下级子项,则 value 和 params 均为此子项。例如:,```JavaScript,var routing = new mq.Routing({, "^/func1/([0-9]+)/[0-9]+\.html$": func1,,});,```,匹配消息 "/func1/123/456.html" 后,value == "123",params == ["123"]; + */ +/// +declare class Class_Routing extends Class_Handler { + + + + /** + * + * @brief 创建一个消息处理器路由对象 + * @param map 初始化路由参数 + * + * + * + */ + constructor(map?: Object/** = v8::Object::New(isolate)*/); + + /** + * + * @brief 创建一个消息处理器路由对象 + * @param method 指定 http 请求方法,"*" 接受所有方法 + * @param map 初始化路由参数 + * + * + * + */ + constructor(method: string, map: Object); + + /** + * + * @brief 从已有路由对象中添加规则,添加后原路由将被清空 + * @param route 已经初始化的路由对象 + * @return 返回路由对象本身 + * + * + * + */ + append(route: Class_Routing): Class_Routing; + + /** + * + * @brief 添加一组路由规则 + * @param map 路由参数 + * @return 返回路由对象本身 + * + * + * + */ + append(map: Object): Class_Routing; + + /** + * + * @brief 添加一条路由规则 + * @param pattern 消息匹配格式 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * @return 返回路由对象本身 + * + * + * + */ + append(pattern: string, hdlr: Class_Handler): Class_Routing; + + /** + * + * @brief 添加一条路由规则 + * @param method 指定 http 请求方法,"*" 接受所有方法 + * @param pattern 消息匹配格式 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * @return 返回路由对象本身 + * + * + * + */ + append(method: string, pattern: string, hdlr: Class_Handler): Class_Routing; + + /** + * + * @brief 添加一组接受所有 http 方法路由规则 + * @param map 路由参数 + * @return 返回路由对象本身 + * + * + * + */ + all(map: Object): Class_Routing; + + /** + * + * @brief 添加一条接受所有 http 方法路由规则 + * @param pattern 消息匹配格式 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * @return 返回路由对象本身 + * + * + * + */ + all(pattern: string, hdlr: Class_Handler): Class_Routing; + + /** + * + * @brief 添加一组 GET 方法路由规则 + * @param map 路由参数 + * @return 返回路由对象本身 + * + * + * + */ + get(map: Object): Class_Routing; + + /** + * + * @brief 添加一条接受 http GET 方法路由规则 + * @param pattern 消息匹配格式 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * @return 返回路由对象本身 + * + * + * + */ + get(pattern: string, hdlr: Class_Handler): Class_Routing; + + /** + * + * @brief 添加一组接受 http POST 方法路由规则 + * @param map 路由参数 + * @return 返回路由对象本身 + * + * + * + */ + post(map: Object): Class_Routing; + + /** + * + * @brief 添加一条接受 http POST 方法路由规则 + * @param pattern 消息匹配格式 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * @return 返回路由对象本身 + * + * + * + */ + post(pattern: string, hdlr: Class_Handler): Class_Routing; + + /** + * + * @brief 添加一组接受 http DELETE 方法路由规则 + * @param map 路由参数 + * @return 返回路由对象本身 + * + * + * + */ + del(map: Object): Class_Routing; + + /** + * + * @brief 添加一条接受 http DELETE 方法路由规则 + * @param pattern 消息匹配格式 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * @return 返回路由对象本身 + * + * + * + */ + del(pattern: string, hdlr: Class_Handler): Class_Routing; + + /** + * + * @brief 添加一组 PUT 方法路由规则 + * @param map 路由参数 + * @return 返回路由对象本身 + * + * + * + */ + put(map: Object): Class_Routing; + + /** + * + * @brief 添加一条接受 http PUT 方法路由规则 + * @param pattern 消息匹配格式 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * @return 返回路由对象本身 + * + * + * + */ + put(pattern: string, hdlr: Class_Handler): Class_Routing; + + /** + * + * @brief 添加一组 PATCH 方法路由规则 + * @param map 路由参数 + * @return 返回路由对象本身 + * + * + * + */ + patch(map: Object): Class_Routing; + + /** + * + * @brief 添加一条接受 http PATCH 方法路由规则 + * @param pattern 消息匹配格式 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * @return 返回路由对象本身 + * + * + * + */ + patch(pattern: string, hdlr: Class_Handler): Class_Routing; + + /** + * + * @brief 添加一组 FIND 方法路由规则 + * @param map 路由参数 + * @return 返回路由对象本身 + * + * + * + */ + find(map: Object): Class_Routing; + + /** + * + * @brief 添加一条接受 http FIND 方法路由规则 + * @param pattern 消息匹配格式 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * @return 返回路由对象本身 + * + * + * + */ + find(pattern: string, hdlr: Class_Handler): Class_Routing; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/SQLite.d.ts b/types/fibjs/declare/SQLite.d.ts new file mode 100644 index 0000000000..0eb314fe3b --- /dev/null +++ b/types/fibjs/declare/SQLite.d.ts @@ -0,0 +1,66 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief sqlite 数据库连接对象 + * @detail 使用 db.open 或 db.openSQLite 创建,创建方式:,```JavaScript,var slite = db.openSQLite("sqlite:/path/to/db");,``` + */ +/// +declare class Class_SQLite extends Class_DbConnection { + + /** + * class prop + * + * + * @brief 当前数据库文件名 + * + * @readonly + * @type String + */ + + fileName: string + + /** + * class prop + * + * + * @brief 查询和设置数据库超时时间,以毫秒为单位 + * + * + * @type Integer + */ + + timeout: number + + + + /** + * + * @brief 备份当前数据库到新文件 + * @param fileName 指定备份的数据库文件名 + * + * @async + */ + backup(fileName: string): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/SandBox.d.ts b/types/fibjs/declare/SandBox.d.ts new file mode 100644 index 0000000000..5a0b2de6fb --- /dev/null +++ b/types/fibjs/declare/SandBox.d.ts @@ -0,0 +1,177 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 安全沙箱对象,用于管理一个独立的运行空间 + * @detail 所有的代码都运行在自己的沙箱中,全局的 require 会调用当前沙箱加载模块,沙箱会通过 require 传递给加载的沙箱。下面的示例创建一个沙箱,限制只允许访问全局基础模块中的 assert 模块,并添加 a 和 b 两个定制模块:,```JavaScript,var vm = require('vm');,var sbox = new vm.SandBox({, a: 100,, b: 200,, assert: require('assert'),});,,var mod_in_sbox = sbox.require('./path/to/mod');,``` + */ + +declare class Class_SandBox extends Class__object { + + /** + * class prop + * + * + * @brief 查询沙箱的 global 对象 + * + * @readonly + * @type Object + */ + + global: Object + + + + /** + * + * @brief 构造一个新的安全沙箱对象,并初始化基础模块 + * @param mods 指定要添加的模块对象字典 + * + * + * + */ + constructor(mods: Object); + + /** + * + * @brief 构造一个新的安全沙箱对象,并初始化基础模块 + * @param mods 指定要添加的模块对象字典 + * @param require 自定义 require 函数,当模块不存在时,先调用自定义函数,无返回再从文件中加载 + * + * + * + */ + constructor(mods: Object, require: Function); + + /** + * + * @brief 构造一个独立 Global 新的安全沙箱对象,并初始化基础模块 + * @param mods 指定要添加的模块对象字典 + * @param global 指定初始化的 Global 属性 + * + * + * + */ + constructor(mods: Object, global: Object); + + /** + * + * @brief 构造一个独立 Global 新的安全沙箱对象,并初始化基础模块 + * @param mods 指定要添加的模块对象字典 + * @param require 自定义 require 函数,当模块不存在时,先调用自定义函数,无返回再从文件中加载 + * @param global 指定初始化的 Global 属性 + * + * + * + */ + constructor(mods: Object, require: Function, global: Object); + + /** + * + * @brief 向沙箱中添加一个基础模块 + * @param id 指定要添加的模块名称,此路径与当前运行脚本无关,必须为绝对路径或者模块名 + * @param mod 指定要添加的模块对象 + * + * + * + */ + add(id: string, mod: any): void; + + /** + * + * @brief 向沙箱中添加一组基础模块 + * @param mods 指定要添加的模块对象字典,添加的 javascript 模块将会生成一份复制,以避免沙箱修改对象产生互相干扰 + * + * + * + */ + add(mods: Object): void; + + /** + * + * @brief 向沙箱中添加一个脚本模块 + * @param srcname 指定要添加的脚本名称,srcname 必须包含扩展名,比如 json 或者 js, jsc + * @param script 指定要添加的二进制代码 + * @return 返回加载的模块对象 + * + * + * + */ + addScript(srcname: string, script: Class_Buffer): any; + + /** + * + * @brief 从沙箱中删除指定的基础模块 + * @param id 指定要删除的模块名称,此路径与当前运行脚本无关,必须为绝对路径或者模块名 + * + * + * + */ + remove(id: string): void; + + /** + * + * @brief 复制当前沙箱,新沙箱包含当前沙箱的模块,以及相同的名称和 require 函数 + * @return 复制的新沙箱 + * + * + * + */ + clone(): Class_SandBox; + + /** + * + * @brief 运行一个脚本 + * @param fname 指定要运行的脚本路径,此路径与当前运行脚本无关,必须为绝对路径 + * @param argv 指定要运行的参数,此参数可在脚本内使用 argv 获取 + * + * + * + */ + run(fname: string, argv?: any[]/** = v8::Array::New(isolate)*/): void; + + /** + * + * @brief 查询一个模块并返回模块完整文件名 + * @param id 指定要加载的模块名称 + * @param base 指定查找路径 + * @return 返回加载的模块完整文件名 + * + * + * + */ + resolve(id: string, base: string): string; + + /** + * + * @brief 加载一个模块并返回模块对象 + * @param id 指定要加载的模块名称 + * @param base 指定查找路径 + * @return 返回加载的模块对象 + * + * + * + */ + require(id: string, base: string): any; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/SeekableStream.d.ts b/types/fibjs/declare/SeekableStream.d.ts new file mode 100644 index 0000000000..4b7a989346 --- /dev/null +++ b/types/fibjs/declare/SeekableStream.d.ts @@ -0,0 +1,112 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 可移动当前指针的流对象接口 + * @detail + */ +/// +declare class Class_SeekableStream extends Class_Stream { + + + + /** + * + * @brief 移动文件当前操作位置 + * @param offset 指定新的位置 + * @param whence 指定位置基准,允许的值为:SEEK_SET, SEEK_CUR, SEEK_END + * + * + * + */ + seek(offset: number, whence: number): void; + + /** + * + * @brief 查询流当前位置 + * @return 返回流当前位置 + * + * + * + */ + tell(): number; + + /** + * + * @brief 移动当前位置到流开头 + * + * + */ + rewind(): void; + + /** + * + * @brief 查询流尺寸 + * @return 返回流尺寸 + * + * + * + */ + size(): number; + + /** + * + * @brief 从流内读取剩余的全部数据 + * @return 返回从流内读取的数据,若无数据可读,或者连接中断,则返回 null + * + * + * @async + */ + readAll(): Class_Buffer; + + /** + * + * @brief 修改文件尺寸,如果新尺寸小于原尺寸,则文件被截断 + * @param bytes 新的文件尺寸 + * + * + * @async + */ + truncate(bytes: number): void; + + /** + * + * @brief 查询文件是否到结尾 + * @return 返回 True 表示结尾 + * + * + * + */ + eof(): boolean; + + /** + * + * @brief 查询当前文件的基础信息 + * @return 返回 Stat 对象描述文件信息 + * + * + * @async + */ + stat(): Class_Stat; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Semaphore.d.ts b/types/fibjs/declare/Semaphore.d.ts new file mode 100644 index 0000000000..b35c8636ab --- /dev/null +++ b/types/fibjs/declare/Semaphore.d.ts @@ -0,0 +1,69 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 纤程信号量对象 + * @detail 信号量对象管理一个内部计数器,此计数器调用 acquire 或者 wait 后减一,调用 release 或者 post 后加一。,计数器不会减至负数,因为 acquire 和 wait 在发现数值为 0 的时候,会休眠当前纤程,直至其它纤程通过 release 或 post 增加计数器的值。,,信号量常用的场合是限制资源并发使用,以及生产者/消费者模式的应用。,,以数据库请求为例,限制资源并发使用的情形:,```JavaScript,var maxconnections = 5;,var l = new coroutine.Semaphore(maxconnections);,,......,,l.acquire();,var conn = connectdb(),.....,conn.close();,l.release();,```,,生产者/消费者模式通常则将信号量与队列配合使用。生产者向队列中加入数据,并 post 一个信号,消费者则先 wait 信号,获取信号后去队查询取数据。 + */ +/// +declare class Class_Semaphore extends Class_Lock { + + + + /** + * + * @brief 信号量构造函数 + * @param value 计数器初始数值 + * + * + * + */ + constructor(value?: number/** = 1*/); + + /** + * + * @brief 等待一个信号量,等同于 acquire(true) + * + * + */ + wait(): void; + + /** + * + * @brief 释放一个信号量,等同于 release() + * + * + */ + post(): void; + + /** + * + * @brief 尝试获取一个信号,如不能获取,则立即返回并返回 false,等同于 acquire(false) + * @return 获取成功则返回 true + * + * + * + */ + trywait(): boolean; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Service.d.ts b/types/fibjs/declare/Service.d.ts new file mode 100644 index 0000000000..5ce3b5e064 --- /dev/null +++ b/types/fibjs/declare/Service.d.ts @@ -0,0 +1,176 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 系统服务管理对象 + * @detail + */ +/// +declare class Class_Service extends Class_EventEmitter { + + /** + * class prop + * + * + * @brief 查询和设置服务名称 + * + * + * @type String + */ + + name: string + + /** + * class prop + * + * + * @brief 查询和绑定服务停止事件,相当于 on("stop", func); + * + * + * @type Function + */ + + onstop: Function + + /** + * class prop + * + * + * @brief 查询和绑定服务暂停事件,相当于 on("pause", func); + * + * + * @type Function + */ + + onpause: Function + + /** + * class prop + * + * + * @brief 查询和绑定服务恢复事件,相当于 on("continue", func); + * + * + * @type Function + */ + + oncontinue: Function + + + + /** + * + * @brief 系统服务管理对象构造函数 + * @param name 服务名称 + * @param worker 服务运行函数 + * @param event 服务事件处理 + * + * + * + */ + constructor(name: string, worker: Function, event?: Object/** = v8::Object::New(isolate)*/); + + /** + * + * @brief 开始运行服务实体 + * + * @async + */ + run(): void; + + /** + * + * @brief 安装服务到系统 + * @param name 服务名称 + * @param cmd 服务命令行 + * @param displayName 服务显示名称 + * @param description 服务描述信息 + * + * + * + */ + static install(name: string, cmd: string, displayName?: string/** = ""*/, description?: string/** = ""*/): void; + + /** + * + * @brief 从系统中卸载服务 + * @param name 服务名称 + * + * + * + */ + static remove(name: string): void; + + /** + * + * @brief 启动服务 + * @param name 服务名称 + * + * + * + */ + static start(name: string): void; + + /** + * + * @brief 停止服务 + * @param name 服务名称 + * + * + * + */ + static stop(name: string): void; + + /** + * + * @brief 重启服务 + * @param name 服务名称 + * + * + * + */ + static restart(name: string): void; + + /** + * + * @brief 检测服务是否安装 + * @param name 服务名称 + * @return 服务安装返回 True + * + * + * + */ + static isInstalled(name: string): boolean; + + /** + * + * @brief 检测服务是否运行 + * @param name 服务名称 + * @return 服务运行返回 True + * + * + * + */ + static isRunning(name: string): boolean; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Smtp.d.ts b/types/fibjs/declare/Smtp.d.ts new file mode 100644 index 0000000000..9c320582be --- /dev/null +++ b/types/fibjs/declare/Smtp.d.ts @@ -0,0 +1,146 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief Smtp对象 + * @detail + */ + +declare class Class_Smtp extends Class__object { + + /** + * class prop + * + * + * @brief 查询和设置超时时间 单位毫秒 + * + * + * @type Integer + */ + + timeout: number + + /** + * class prop + * + * + * @brief 查询 Smtp 对象当前连接的 Socket + * + * @readonly + * @type Stream + */ + + socket: Class_Stream + + + + /** + * + * @brief Smtp 对象构造函数 + * + * + */ + constructor(); + + /** + * + * @brief 建立到指定的服务器 + * @param url 指定连接的协议,可以是:tcp://host:port 或者 ssl://host:port + * + * + * @async + */ + connect(url: string): void; + + /** + * + * @brief 发送指定命令,并返回响应,服务器报错则抛出错误 + * @param cmd 命令名 + * @param arg 参数 + * @return 如果成功,返回服务器响应 + * + * + * @async + */ + command(cmd: string, arg: string): string; + + /** + * + * @brief 发送 HELO 命令,服务器报错则抛出错误 + * @param hostname 主机名,缺省为“localhost” + * + * + * @async + */ + hello(hostname?: string/** = "localhost"*/): void; + + /** + * + * @brief 用指定的用户及密码登录服务器,服务器报错则抛出错误 + * @param username 用户名 + * @param password 密码 + * + * + * @async + */ + login(username: string, password: string): void; + + /** + * + * @brief 指定发件人信箱,服务器报错则抛出错误 + * @param address 发件人信箱 + * + * + * @async + */ + from(address: string): void; + + /** + * + * @brief 指定收件人信箱,服务器报错则抛出错误 + * @param address 收件人信箱 + * + * + * @async + */ + to(address: string): void; + + /** + * + * @brief 发送文本到收件人,服务器报错则抛出错误 + * @param txt 要发送的文本 + * + * + * @async + */ + data(txt: string): void; + + /** + * + * @brief 退出并关闭连接,服务器报错则抛出错误 + * + * @async + */ + quit(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Socket.d.ts b/types/fibjs/declare/Socket.d.ts new file mode 100644 index 0000000000..a3de6699a5 --- /dev/null +++ b/types/fibjs/declare/Socket.d.ts @@ -0,0 +1,232 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + + + +/** module Or Internal Object */ +/** + * @brief 网络套接口对象 + * @detail Socket 属于 net 模块,创建方法,```JavaScript,var s = new net.Socket();,``` + */ +/// +declare class Class_Socket extends Class_Stream { + + /** + * class prop + * + * + * @brief 查询当前 Socket 对象的地址集 + * + * @readonly + * @type Integer + */ + + family: number + + /** + * class prop + * + * + * @brief 查询当前 Socket 对象的协议族 + * + * @readonly + * @type Integer + */ + + type: number + + /** + * class prop + * + * + * @brief 查询当前连接的对方地址 + * + * @readonly + * @type String + */ + + remoteAddress: string + + /** + * class prop + * + * + * @brief 查询当前连接的对方端口 + * + * @readonly + * @type Integer + */ + + remotePort: number + + /** + * class prop + * + * + * @brief 查询当前连接的本地地址 + * + * @readonly + * @type String + */ + + localAddress: string + + /** + * class prop + * + * + * @brief 查询当前连接的本地端口 + * + * @readonly + * @type Integer + */ + + localPort: number + + /** + * class prop + * + * + * @brief 查询和设置超时时间 单位毫秒 + * + * + * @type Integer + */ + + timeout: number + + + + /** + * + * @brief Socket 构造函数,创建一个新的 Socket 对象 + * @param family 指定地址集,缺省为 AF_INET,ipv4 + * @param type 指定协议族,缺省为 SOCK_STREAM,tcp + * + * + * + */ + constructor(family?: number/** = undefined*/, type?: number/** = undefined*/); + + /** + * + * @brief 建立一个 tcp 连接 + * @param host 指定对方地址或主机名 + * @param port 指定对方端口 + * + * + * @async + */ + connect(host: string, port: number): void; + + /** + * + * @brief 将当前 Socket 绑定至本地所有地址的指定端口 + * @param port 指定绑定的端口 + * @param allowIPv4 指定是否接受 ipv4 连接,缺省为 true。本参数在 ipv6 时有效,并依赖于操作系统 + * + * + * + */ + bind(port: number, allowIPv4?: boolean/** = true*/): void; + + /** + * + * @brief 将当前 Socket 绑定至指定地址的指定端口 + * @param addr 指定绑定的地址 + * @param port 指定绑定的端口 + * @param allowIPv4 指定是否接受 ipv4 连接,缺省为 true。本参数在 ipv6 时有效,并依赖于操作系统 + * + * + * + */ + bind(addr: string, port: number, allowIPv4?: boolean/** = true*/): void; + + /** + * + * @brief 开始监听连接请求 + * @param backlog 指定请求队列长度,超出的请求将被拒绝,缺省为 120 + * + * + * + */ + listen(backlog?: number/** = 120*/): void; + + /** + * + * @brief 等待并接受一个连接 + * @return 返回接收到得连接对象 + * + * + * @async + */ + accept(): Class_Socket; + + /** + * + * @brief 从连接读取指定大小的数据,不同于 read 方法,recv 并不保证读完要求的数据,而是在读取到数据后立即返回 + * @param bytes 指定要读取的数据量,缺省读取任意尺寸的数据 + * @return 返回从连接读取的数据 + * + * + * @async + */ + recv(bytes?: number/** = -1*/): Class_Buffer; + + /** + * + * @brief 读取一个 UDP 包 + * recvfrom 返回结果中包含以下内容: + * - data: 接收到的二进制数据块 + * - address: 发送方的地址 + * - port: 发送方的端口 + * @param bytes 指定要读取的数据量,缺省读取任意尺寸的数据 + * @return 返回从连接读取的数据包 + * + * + * @async + */ + recvfrom(bytes?: number/** = -1*/): any; + + /** + * + * @brief 将给定的数据写入连接,此方法等效于 write 方法 + * @param data 给定要写入的数据 + * + * + * @async + */ + send(data: Class_Buffer): void; + + /** + * + * @brief 向给定 ip:port 发送一个 UDP 包 + * @param data 给定要写入的数据 + * @param host 指定目标 ip 或主机名 + * @param port 指定目标端口 + * + * + * @async + */ + sendto(data: Class_Buffer, host: string, port: number): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/SslHandler.d.ts b/types/fibjs/declare/SslHandler.d.ts new file mode 100644 index 0000000000..1ed85a5ce0 --- /dev/null +++ b/types/fibjs/declare/SslHandler.d.ts @@ -0,0 +1,106 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief ssl 协议转换处理器 + * @detail 用以将数据流转换为 ssl 流协议。SslHandler 是对 SslSocket 的封装,用于构建服务器,逻辑上相当于:,```JavaScript,var ss = new ssl.Socket(crt, key);,,function(s){, var s1 = ss.accept(s);, hdlr.invoke(s1);, s1.close();,},``` + */ +/// +declare class Class_SslHandler extends Class_Handler { + + /** + * class prop + * + * + * @brief 设定证书验证模式,缺省为 VERIFY_NONE + * + * + * @type Integer + */ + + verification: number + + /** + * class prop + * + * + * @brief 客户端证书验证证书链 + * + * @readonly + * @type X509Cert + */ + + ca: Class_X509Cert + + /** + * class prop + * + * + * @brief ssl 协议转换处理器当前事件处理接口对象 + * + * + * @type Handler + */ + + handler: Class_Handler + + + + /** + * + * @brief SslHandler 构造函数,创建一个新的 SslHandler 对象 + * + * certs 格式为: + * ```JavaScript + * [ + * { + * crt: [X509Cert object], + * key: [PKey object] + * }, + * { + * crt: [X509Cert object], + * key: [PKey object] + * } + * ] + * ``` + * @param certs 服务器证书列表 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(certs: any[], hdlr: Class_Handler); + + /** + * + * @brief SslHandler 构造函数,创建一个新的 SslHandler 对象 + * @param crt X509Cert 证书,用于客户端验证服务器 + * @param key PKey 私钥,用于与客户端会话 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(crt: Class_X509Cert, key: Class_PKey, hdlr: Class_Handler); + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/SslServer.d.ts b/types/fibjs/declare/SslServer.d.ts new file mode 100644 index 0000000000..0213c0b10e --- /dev/null +++ b/types/fibjs/declare/SslServer.d.ts @@ -0,0 +1,137 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief ssl 服务器对象,可方便创建一个标准多纤程 ssl 服务器 + * @detail SslServer 对象是将 TcpServer 和 SslHandler 组合封装的对象,方便快速搭建服务器,逻辑上相当于:,```JavaScript,var svr = new net.SslServer(addr, port, new ssl.Handler(crt, key, function(req){, ...,}));,```,,创建方法:,```JavaScript,var ssl = require("ssl");,var svr = new http.Server(crt, key, function(req){, ...,});,``` + */ +/// +declare class Class_SslServer extends Class_TcpServer { + + /** + * class prop + * + * + * @brief 设定证书验证模式,缺省为 VERIFY_NONE + * + * + * @type Integer + */ + + verification: number + + /** + * class prop + * + * + * @brief 客户端证书验证证书链 + * + * @readonly + * @type X509Cert + */ + + ca: Class_X509Cert + + + + /** + * + * @brief SslServer 构造函数,在所有本机地址侦听 + * + * certs 格式为: + * ```JavaScript + * [ + * { + * crt: [X509Cert object], + * key: [PKey object] + * }, + * { + * crt: [X509Cert object], + * key: [PKey object] + * } + * ] + * ``` + * @param certs 服务器证书列表 + * @param port 指定 ssl 服务器侦听端口 + * @param listener 指定 ssl 接收到的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(certs: any[], port: number, listener: Class_Handler); + + /** + * + * @brief SslServer 构造函数 + * + * certs 格式为: + * ```JavaScript + * [ + * { + * crt: [X509Cert object], + * key: [PKey object] + * }, + * { + * crt: [X509Cert object], + * key: [PKey object] + * } + * ] + * ``` + * @param certs 服务器证书列表 + * @param addr 指定 ssl 服务器侦听地址,为 "" 则在本机所有地址侦听 + * @param port 指定 ssl 服务器侦听端口 + * @param listener 指定 ssl 接收到的连接的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(certs: any[], addr: string, port: number, listener: Class_Handler); + + /** + * + * @brief SslServer 构造函数,在所有本机地址侦听 + * @param crt X509Cert 证书,用于客户端验证服务器 + * @param key PKey 私钥,用于与客户端会话 + * @param port 指定 ssl 服务器侦听端口 + * @param listener 指定 ssl 接收到的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(crt: Class_X509Cert, key: Class_PKey, port: number, listener: Class_Handler); + + /** + * + * @brief SslServer 构造函数 + * @param crt X509Cert 证书,用于客户端验证服务器 + * @param key PKey 私钥,用于与客户端会话 + * @param addr 指定 ssl 服务器侦听地址,为 "" 则在本机所有地址侦听 + * @param port 指定 ssl 服务器侦听端口 + * @param listener 指定 ssl 接收到的连接的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(crt: Class_X509Cert, key: Class_PKey, addr: string, port: number, listener: Class_Handler); + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/SslSocket.d.ts b/types/fibjs/declare/SslSocket.d.ts new file mode 100644 index 0000000000..4b7b6986e8 --- /dev/null +++ b/types/fibjs/declare/SslSocket.d.ts @@ -0,0 +1,139 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief ssl 网络套接口对象 + * @detail SslSocket 属于 ssl 模块,创建方法,```JavaScript,var s = new ssl.Socket();,``` + */ +/// +declare class Class_SslSocket extends Class_Stream { + + /** + * class prop + * + * + * @brief 设定证书验证模式,缺省为 VERIFY_REQUIRED + * + * + * @type Integer + */ + + verification: number + + /** + * class prop + * + * + * @brief 证书链,客户端模式 connect 时自动引用 ssl.ca,服务器模式 accept 生成 SslSocket 自动引用当前 SslSocket 的 ca + * + * @readonly + * @type X509Cert + */ + + ca: Class_X509Cert + + /** + * class prop + * + * + * @brief 连接对方的证书 + * + * @readonly + * @type X509Cert + */ + + peerCert: Class_X509Cert + + /** + * class prop + * + * + * @brief 查询消息 ssl 建立时的下层流对象 + * + * @readonly + * @type Stream + */ + + stream: Class_Stream + + + + /** + * + * @brief SslSocket 构造函数,创建一个新的 SslSocket 对象 + * + * certs 格式为: + * ```JavaScript + * [ + * { + * crt: [X509Cert object], + * key: [PKey object] + * }, + * { + * crt: [X509Cert object], + * key: [PKey object] + * } + * ] + * ``` + * @param certs 服务器证书列表 + * + * + * + */ + constructor(certs?: any[]/** = v8::Array::New(isolate)*/); + + /** + * + * @brief SslSocket 构造函数,创建一个新的 SslSocket 对象 + * @param crt X509Cert 证书,用于客户端验证服务器 + * @param key PKey 私钥,用于与客户端会话 + * + * + * + */ + constructor(crt: Class_X509Cert, key: Class_PKey); + + /** + * + * @brief 在给定的连接上连接 ssl 连接,客户端模式 + * @param s 给定的底层连接 + * @param server_name 指定服务器名称,可缺省 + * @return 连接成功返回 0,证书可选验证时,验证不成功则返回非 0,详细错误见 ssl 模块 + * + * + * @async + */ + connect(s: Class_Stream, server_name?: string/** = ""*/): number; + + /** + * + * @brief 在给定的连接上接收一个 ssl 连接,并生成一个新的 SslSocket + * @param s 给定的底层连接 + * @return 返回新建立的 SslSocket 对象 + * + * + * @async + */ + accept(s: Class_Stream): Class_SslSocket; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Stat.d.ts b/types/fibjs/declare/Stat.d.ts new file mode 100644 index 0000000000..fef64f6c73 --- /dev/null +++ b/types/fibjs/declare/Stat.d.ts @@ -0,0 +1,219 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 文件的基础信息对象 + * @detail Stat 对象通过 fs.stat, File.stat, fs.readdir 查询,不可独立创建 + */ + +declare class Class_Stat extends Class__object { + + /** + * class prop + * + * + * @brief 文件名称 + * + * @readonly + * @type String + */ + + name: string + + /** + * class prop + * + * + * @brief 文件尺寸 + * + * @readonly + * @type Long + */ + + size: number + + /** + * class prop + * + * + * @brief 文件权限,Windows 不支持此属性 + * + * @readonly + * @type Integer + */ + + mode: number + + /** + * class prop + * + * + * @brief 文件最后修改时间 + * + * @readonly + * @type Date + */ + + mtime: Date + + /** + * class prop + * + * + * @brief 文件最后访问时间 + * + * @readonly + * @type Date + */ + + atime: Date + + /** + * class prop + * + * + * @brief 文件创建时间 + * + * @readonly + * @type Date + */ + + ctime: Date + + /** + * class prop + * + * + * @brief 文件拥有者的id + * + * @readonly + * @type Integer + */ + + uid: number + + /** + * class prop + * + * + * @brief 文件所属的组id + * + * @readonly + * @type Integer + */ + + gid: number + + + + /** + * + * @brief 查询文件是否有写入权限 + * @return 为 true 则有写入权限 + * + * + * + */ + isWritable(): boolean; + + /** + * + * @brief 查询文件是否有读权限 + * @return 为 true 则有读权限 + * + * + * + */ + isReadable(): boolean; + + /** + * + * @brief 查询文件是否有执行权限 + * @return 为 true 则有执行权限 + * + * + * + */ + isExecutable(): boolean; + + /** + * + * @brief 查询文件是否隐藏 + * @return 为 true 则隐藏 + * + * + * + */ + isHidden(): boolean; + + /** + * + * @brief 查询文件是否是目录 + * @return 为 true 则是目录 + * + * + * + */ + isDirectory(): boolean; + + /** + * + * @brief 查询文件是否是文件 + * @return 为 true 则是文件 + * + * + * + */ + isFile(): boolean; + + /** + * + * @brief 查询文件是否是符号链接 + * @return 为 true 则是符号链接 + * + * + * + */ + isSymbolicLink(): boolean; + + /** + * + * @brief 查询文件是否是内存文件 + * @return 为 true 则是内存文件 + * + * + * + */ + isMemory(): boolean; + + /** + * + * @brief 查询文件是否是 Socket + * @return 为 true 则是 Socket + * + * + * + */ + isSocket(): boolean; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Stats.d.ts b/types/fibjs/declare/Stats.d.ts new file mode 100644 index 0000000000..7e9a96d1c4 --- /dev/null +++ b/types/fibjs/declare/Stats.d.ts @@ -0,0 +1,103 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 数据统计对象,用以构建应用运行时数据收集 + * @detail 创建方法:,```JavaScript,var util = require("util");,var stats = new util.Stats(["begin", "end", "error"]);,```,一些内部对象会提供预先定义的的统计对象 + */ + +declare class Class_Stats extends Class__object { + + + + /** + * + * @brief 数据统计对象构造方法 + * @param keys 指定计数器的名称 + * + * + * + */ + constructor(keys: any[]); + + /** + * + * @brief 数据统计对象构造方法 + * @param staticKeys 指定静态计数器的名称,静态计数器不会被 reset + * @param keys 指定计数器的名称 + * + * + * + */ + constructor(staticKeys: any[], keys: any[]); + + /** + * + * @brief 指定的计数器增一 + * @param key 指定计数器名称 + * + * + * + */ + inc(key: string): void; + + /** + * + * @brief 指定的计数器减一 + * @param key 指定计数器名称 + * + * + * + */ + dec(key: string): void; + + /** + * + * @brief 指定的计数器加指定值 + * @param key 指定计数器名称 + * @param value 指定数值 + * + * + * + */ + add(key: string, value: number): void; + + /** + * + * @brief 初始化计数器,除 staticKeys 指定的计数器全部清零 + * + * + */ + reset(): void; + + /** + * + * @brief 查询上次 reset 到现在的运行时间 + * @return 返回上次 reset 到现在的运行时间 + * + * + * + */ + uptime(): number; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Stream.d.ts b/types/fibjs/declare/Stream.d.ts new file mode 100644 index 0000000000..723cc78fae --- /dev/null +++ b/types/fibjs/declare/Stream.d.ts @@ -0,0 +1,82 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 流操作对象,用于二进制数据流读写 + * @detail Stream 为基础对象,用于为流处理定义标准借口,不能独立创建 + */ + +declare class Class_Stream extends Class__object { + + + + /** + * + * @brief 从流内读取指定大小的数据 + * @param bytes 指定要读取的数据量,缺省为读取随机大小的数据块,读出的数据尺寸取决于设备 + * @return 返回从流内读取的数据,若无数据可读,或者连接中断,则返回 null + * + * + * @async + */ + read(bytes?: number/** = -1*/): Class_Buffer; + + /** + * + * @brief 将给定的数据写入流 + * @param data 给定要写入的数据 + * + * + * @async + */ + write(data: Class_Buffer): void; + + /** + * + * @brief 将文件缓冲区内容写入物理设备 + * + * @async + */ + flush(): void; + + /** + * + * @brief 关闭当前流对象 + * + * @async + */ + close(): void; + + /** + * + * @brief 复制流数据到目标流中 + * @param stm 目标流对象 + * @param bytes 复制的字节数 + * @return 返回复制的字节数 + * + * + * @async + */ + copyTo(stm: Class_Stream, bytes?: number/** = -1*/): number; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/StringDecoder.d.ts b/types/fibjs/declare/StringDecoder.d.ts new file mode 100644 index 0000000000..7958f2d74d --- /dev/null +++ b/types/fibjs/declare/StringDecoder.d.ts @@ -0,0 +1,146 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 流解码对象 + * @detail + */ + +declare class Class_StringDecoder extends Class__object { + + /** + * class prop + * + * + * @brief 内部使用。 + * + * + * @type Integer + */ + + lastNeed: number + + /** + * class prop + * + * + * @brief 内部使用。 + * + * + * @type Integer + */ + + lastTotal: number + + /** + * class prop + * + * + * @brief 内部使用。 + * + * + * @type Buffer + */ + + lastChar: Class_Buffer + + /** + * class prop + * + * + * @brief 解码编码.内部使用。 + * + * + * @type String + */ + + encoding: string + + + + /** + * + * @brief 解码器构造函数 + * @param encoding 解码编码. 默认 'utf8'. + * + * + * + */ + constructor(encoding?: string/** = "utf8"*/); + + /** + * + * @brief 将内部存留的 buffer 作为字符返回。不完整的 UTF-8 和 UTF-16 字节会尝试补全。 + * @return 解码后的字符串. + * + * + * + */ + end(): string; + + /** + * + * @brief 将内部存留的 buffer 作为字符返回。不完整的 UTF-8 和 UTF-16 字节会尝试补全。 + * @param buf 需要解码的 Buffer. 在执行 end 之前,会先调用 write 将 buffer 写入。 + * @return 解码后的字符串. + * + * + * + */ + end(buf: Class_Buffer): string; + + /** + * + * @brief 返回一个解码后的字符串, 确保任何非完整的末尾字符被省略此次不返回,并被存储在内部供下一次的 write 或者 end 方法使用。 + * @param buf 需要解码的 Buffer。 + * @return 解码后的字符串. + * + * + * + */ + write(buf: Class_Buffer): string; + + /** + * + * @brief 内部使用。. + * @param buf 需要解码的 Buffer。 + * @param offset 解码偏移量 + * @return 解码后的字符串. + * + * + * + */ + text(buf: Class_Buffer, offset: number): string; + + /** + * + * @brief 内部使用。. + * @param buf A Buffer containing the bytes to decode. + * @return 解码后的字符串. + * + * + * + */ + fillLast(buf: Class_Buffer): string; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/SubProcess.d.ts b/types/fibjs/declare/SubProcess.d.ts new file mode 100644 index 0000000000..774e121eb5 --- /dev/null +++ b/types/fibjs/declare/SubProcess.d.ts @@ -0,0 +1,103 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 子进程对象 + * @detail ```JavaScript,var process = require("process");,var sub = process.open("ls");,``` + */ +/// +declare class Class_SubProcess extends Class_BufferedStream { + + /** + * class prop + * + * + * @brief 读取当前对象指向的进程的 id + * + * + * @readonly + * @type Integer + */ + + pid: number + + /** + * class prop + * + * + * @brief 读取当前对象指向的进程的标准输入对象 + * + * + * @readonly + * @type BufferedStream + */ + + stdin: Class_BufferedStream + + /** + * class prop + * + * + * @brief 读取当前对象指向的进程的标准输出对象 + * + * + * @readonly + * @type BufferedStream + */ + + stdout: Class_BufferedStream + + + + /** + * + * @brief 杀掉当前对象指向的进程,并传递信号 + * @param signal 传递的信号 + * + * + * + */ + kill(signal: number): void; + + /** + * + * @brief 等待当前对象指向的进程结束,并返回进程结束代码 + * @return 进程的结束代码 + * + * + * @async + */ + wait(): number; + + /** + * + * @brief 查询当前对象所指向的进程是否存在指定名称的窗口,仅限 windows + * @param name 窗口名称 + * @return 窗口存在则返回窗口的 rect,否则返回 undefined + * + * + * + */ + findWindow(name: string): any; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/TcpServer.d.ts b/types/fibjs/declare/TcpServer.d.ts new file mode 100644 index 0000000000..065288c1f1 --- /dev/null +++ b/types/fibjs/declare/TcpServer.d.ts @@ -0,0 +1,127 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief tcp 服务器对象,可方便创建一个标准多纤程 tcp 服务器 + * @detail 使用 TcpServer 对象可以迅速创建一个多纤程并发处理的 tcp 服务器。,```JavaScript,function func(conn),{, var data;,, while(data = conn.read()), conn.write(data);,, conn.close();,},,new net.TcpServer(8080, func).run();,``` + */ + +declare class Class_TcpServer extends Class__object { + + /** + * class prop + * + * + * @brief 服务器当前侦听的 Socket 对象 + * + * @readonly + * @type Socket + */ + + socket: Class_Socket + + /** + * class prop + * + * + * @brief 服务器当前事件处理接口对象 + * + * + * @type Handler + */ + + handler: Class_Handler + + /** + * class prop + * + * + * @brief 查询当前服务器运行状态 + * + * 返回的结果为一个 Stats 对象,初始化计数器如下: + * ```JavaScript + * { + * total : 1000, // 总计处理的连接 + * connections : 100, // 当前正在处理的连接 + * accept : 10, // 上次查询后新建的连接 + * close : 10 // 上次查询后关闭的连接 + * } + * ``` + * + * + * @readonly + * @type Stats + */ + + stats: Class_Stats + + + + /** + * + * @brief TcpServer 构造函数,在所有本机地址侦听 + * @param port 指定 tcp 服务器侦听端口 + * @param listener 指定 tcp 接收到的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(port: number, listener: Class_Handler); + + /** + * + * @brief TcpServer 构造函数 + * @param addr 指定 tcp 服务器侦听地址,为 "" 则在本机所有地址侦听 + * @param port 指定 tcp 服务器侦听端口 + * @param listener 指定 tcp 接收到的连接的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler + * + * + * + */ + constructor(addr: string, port: number, listener: Class_Handler); + + /** + * + * @brief 运行服务器并开始接收和分发连接,此函数不会返回 + * + * @async + */ + run(): void; + + /** + * + * @brief 异步运行服务器并开始接收和分发连接,调用后立即返回,服务器在后台运行 + * + * + */ + asyncRun(): void; + + /** + * + * @brief 关闭 socket中止正在运行的服务器 + * + * @async + */ + stop(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Timer.d.ts b/types/fibjs/declare/Timer.d.ts new file mode 100644 index 0000000000..b512d36afb --- /dev/null +++ b/types/fibjs/declare/Timer.d.ts @@ -0,0 +1,73 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 定时器处理器对象 + * @detail + */ + +declare class Class_Timer extends Class__object { + + /** + * class prop + * + * + * @brief 查询当前定时器是否已经终止 + * + * @readonly + * @type Boolean + */ + + stopped: boolean + + + + /** + * + * @brief 维持 fibjs 进程不退出,在定时器等待期间阻止 fibjs 进程退出 + * @return 返回定时器对象 + * + * + * + */ + ref(): Class_Timer; + + /** + * + * @brief 允许 fibjs 进程退出,在定时器等待期间允许 fibjs 进程退出 + * @return 返回定时器对象 + * + * + * + */ + unref(): Class_Timer; + + /** + * + * @brief 取消当前定时器 + * + * + */ + clear(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/UrlObject.d.ts b/types/fibjs/declare/UrlObject.d.ts new file mode 100644 index 0000000000..65d9d59e38 --- /dev/null +++ b/types/fibjs/declare/UrlObject.d.ts @@ -0,0 +1,279 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief Url 处理对象 + * @detail 基础模块。提供 url 的格式化,解析与拼装,```JavaScript,var url = new net.Url('http://www.xici.net/');,var url = new net.Url({protocol: 'http:', hostname:'www.xici.net', pathname:'/'});,``` + */ + +declare class Class_UrlObject extends Class__object { + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的完整 url 地址描述,此描述由其他所有属性组装而成 + * + * + * + * @type String + */ + + href: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的协议名称 + * + * + * + * @type String + */ + + protocol: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象是否包含双斜杠 + * + * + * + * @type Boolean + */ + + slashes: boolean + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的完整验证字符串,由 username 和 password 属性组装而成 + * + * + * + * @type String + */ + + auth: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的验证用户 + * + * + * + * @type String + */ + + username: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的验证密码 + * + * + * + * @type String + */ + + password: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的完整主机描述,由 hastname 和 port 组装而成 + * + * + * + * @type String + */ + + host: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的主机名 + * + * + * + * @type String + */ + + hostname: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的端口号 + * + * + * + * @type String + */ + + port: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的请求完整路径(含请求),由 pathname 和 query 组装而成 + * + * + * + * @type String + */ + + path: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的路径 + * + * + * + * @type String + */ + + pathname: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的请求字符串(含“?”),等效于“?”+query + * + * + * + * @type String + */ + + search: string + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的请求字符串( 不含“?”) + * + * + * + * @type Value + */ + + query: any + + /** + * class prop + * + * + * @brief 查询和设置当前 UrlObject 对象中的请求锚点(含“\#”) + * + * + * + * @type String + */ + + hash: string + + + + /** + * + * @brief UrlObject 对象构造函数,使用参数构造 + * @param args 指定构造参数的字典对象,支持的字段有:protocol, slashes, username, password, hostname, port, pathname, query, hash + * + * + * + */ + constructor(args: Object); + + /** + * + * @brief UrlObject 对象构造函数,使用 url 字符串构造 + * @param url 指定构造 url 字符串 + * @param parseQueryString 指定是否解析 query + * @param slashesDenoteHost 默认为false, 如果设置为true,则从字符串'//'之后到下一个'/'之前的字符串会被解析为host,例如'//foo/bar', 结果应该是{host: 'foo', pathname: '/bar'}而不是{pathname: '//foo/bar'} + * + * + * + */ + constructor(url?: string/** = ""*/, parseQueryString?: boolean/** = false*/, slashesDenoteHost?: boolean/** = false*/); + + /** + * + * @brief 解析一个 url 字符串 + * @param url 指定需要解析的 url 字符串 + * @param parseQueryString 指定是否解析 query + * @param slashesDenoteHost 默认为false, 如果设置为true,则从字符串'//'之后到下一个'/'之前的字符串会被解析为host,例如'//foo/bar', 结果应该是{host: 'foo', pathname: '/bar'}而不是{pathname: '//foo/bar'} + * + * + * + */ + parse(url: string, parseQueryString?: boolean/** = false*/, slashesDenoteHost?: boolean/** = false*/): void; + + /** + * + * @brief 使用指定的参数构造 UrlObject + * @param args 指定构造参数的字典对象,支持的字段有:protocol, slashes, username, password, hostname, port, pathname, query, hash + * + * + * + */ + format(args: Object): void; + + /** + * + * @brief 重定位 url 路径,自动识别新路径为相对路径还是绝对路径 + * @param url 指定新的路径 + * @return 返回包含重定位数据的对象 + * + * + * + */ + resolve(url: string): Class_UrlObject; + + /** + * + * @brief 标准化路径 + * + * + * + */ + normalize(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/WebSocket.d.ts b/types/fibjs/declare/WebSocket.d.ts new file mode 100644 index 0000000000..08201ff96e --- /dev/null +++ b/types/fibjs/declare/WebSocket.d.ts @@ -0,0 +1,192 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief WebSocket 包协议转换处理器 + * @detail 用以将 Http 协议转换为 WebSocket 包协议消息。创建方式:,```JavaScript,var ws = require('ws');,var http = require('http');,,var serv = new http.Server(8811, ws.upgrade((conn) => {,conn.onmessage = msg => {, conn.send(new Date());,};,}));,,serv.run(r => 0);,,var sock = new ws.Socket('ws://127.0.0.1:8811');,sock.on('open', () => {, setInterval(() => {, sock.send('get date');, }, 1000);,});,,sock.onmessage = evt => {, console.log(evt.data);,},``` + */ +/// +declare class Class_WebSocket extends Class_EventEmitter { + + /** + * class prop + * + * + * @brief 查询当前对象连接的服务器 + * + * @readonly + * @type String + */ + + url: string + + /** + * class prop + * + * + * @brief 查询当前对象连接时的协议 + * + * @readonly + * @type String + */ + + protocol: string + + /** + * class prop + * + * + * @brief 查询当前对象连接的源 + * + * @readonly + * @type String + */ + + origin: string + + /** + * class prop + * + * + * @brief 查询当前对象的连接状态,参见 ws + * + * @readonly + * @type Integer + */ + + readyState: number + + /** + * class prop + * + * + * @brief 查询和绑定连接成功事件,相当于 on("open", func); + * + * + * @type Function + */ + + onopen: Function + + /** + * class prop + * + * + * @brief 查询和绑定接受到对方消息的事件,相当于 on("message", func); + * + * + * @type Function + */ + + onmessage: Function + + /** + * class prop + * + * + * @brief 查询和绑定连接关闭的事件,相当于 on("close", func); + * + * + * @type Function + */ + + onclose: Function + + /** + * class prop + * + * + * @brief 查询和绑定错误发生的事件,相当于 on("error", func); + * + * + * @type Function + */ + + onerror: Function + + + + /** + * + * @brief WebSocket 构造函数 + * @param url 指定连接的服务器 + * @param protocol 指定握手协议,缺省为 "" + * @param origin 指定握手时模拟的源 + * + * + * + */ + constructor(url: string, protocol?: string/** = ""*/, origin?: string/** = ""*/); + + /** + * + * @brief 关闭当前连接,此操作会向对方发送 CLOSE 数据包,并等待对方响应 + * @param code 指定关闭的代码,允许值为 3000-4999 或者 1000,缺省为 1000 + * @param reason 指定关闭的原因,缺省为 "" + * + * + * + */ + close(code?: number/** = 1000*/, reason?: string/** = ""*/): void; + + /** + * + * @brief 向对方发送一段文本 + * @param data 指定发送的文本 + * + * + * + */ + send(data: string): void; + + /** + * + * @brief 向对方发送一段二进制数据 + * @param data 指定发送的二进制数据 + * + * + * + */ + send(data: Class_Buffer): void; + + /** + * + * @brief 维持 fibjs 进程不退出,在对象绑定期间阻止 fibjs 进程退出 + * @return 返回当前对象 + * + * + * + */ + ref(): Class_WebSocket; + + /** + * + * @brief 允许 fibjs 进程退出,在对象绑定期间允许 fibjs 进程退出 + * @return 返回当前对象 + * + * + * + */ + unref(): Class_WebSocket; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/WebSocketMessage.d.ts b/types/fibjs/declare/WebSocketMessage.d.ts new file mode 100644 index 0000000000..989a12c2ff --- /dev/null +++ b/types/fibjs/declare/WebSocketMessage.d.ts @@ -0,0 +1,84 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + + + +/** module Or Internal Object */ +/** + * @brief websocket 消息对象 + * @detail 创建方法:,```JavaScript,var ws = require("ws");,,var msg = new ws.Message();,``` + */ +/// +declare class Class_WebSocketMessage extends Class_Message { + + /** + * class prop + * + * + * @brief 查询和读取 websocket 掩码标记,缺省为 true + * + * + * @type Boolean + */ + + masked: boolean + + /** + * class prop + * + * + * @brief 查询和读取 websocket 压缩状态,缺省为 false + * + * + * @type Boolean + */ + + compress: boolean + + /** + * class prop + * + * + * @brief 查询和设置最大包尺寸,以字节为单位,缺省为 67108864(64M) + * + * + * @type Integer + */ + + maxSize: number + + + + /** + * + * @brief 包处理消息对象构造函数 + * @param type websocket 消息类型,缺省为 websocket.BINARY + * @param masked websocket 消息掩码,缺省为 true + * @param compress 标记消息是否压缩,缺省为 false + * @param maxSize 最大包尺寸,以 MB 为单位,缺省为 67108864(64M) + * + * + * + */ + constructor(type?: number/** = undefined*/, masked?: boolean/** = true*/, compress?: boolean/** = false*/, maxSize?: number/** = 67108864*/); + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/WebView.d.ts b/types/fibjs/declare/WebView.d.ts new file mode 100644 index 0000000000..2bf1258bcf --- /dev/null +++ b/types/fibjs/declare/WebView.d.ts @@ -0,0 +1,172 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 浏览器窗口对象 + * @detail WebView 是一个嵌入浏览器的窗口组件,目前仅支持 windows ie。,,由于 WebView 内的 JavaScript 程序与 fibjs 并不在同一个引擎内,所以如果需要与宿主程序进行通讯,需要通过消息进行。,,WebView 用于通讯的对象是 external,external 支持一个方法 postMessage 和两个事件 onmessage、onclose。,,一个简单的通讯示例代码如下:,```JavaScript,// index.js,var gui = require('gui');,var webview = gui.open('fs:index.html');,,webview.onmessage = msg => console.log(msg);,,webview.onload = evt => webview.postMessage("hello from fibjs");,,webview.wait();,```,,index.html 的内容如下:,```html,,```, 在用户窗口关闭之前,会触发 external.onclose 事件,external.onclose 可以决定是否关闭。如果 external.onclose 返回 false,则此次操作取消,否则将关闭窗口。,,以下的例子,会在用户点关闭后等待 5 秒后再关闭窗口。,```html,,```,上面的代码中,因为 window.close 本身也会触发 onclose 事件,所以需要增加一个开关变量,用于识别是否需要处理此次事件。 + */ +/// +declare class Class_WebView extends Class_EventEmitter { + + /** + * class prop + * + * + * @brief 查询和设置窗口是否显示 + * + * + * @type Boolean + */ + + visible: boolean + + /** + * class prop + * + * + * @brief 查询和绑定加载成功事件,相当于 on("load", func); + * + * + * @type Function + */ + + onload: Function + + /** + * class prop + * + * + * @brief 查询和绑定窗口移动事件,相当于 on("move", func); + * + * 以下示例会在窗口移动时输出窗口的左上角坐标: + * ```JavaScript + * var gui = require('gui'); + * var webview = gui.open('fs:index.html'); + * + * webview.onmove = evt => console.log(evt.left, evt.top); + * ``` + * + * + * + * @type Function + */ + + onmove: Function + + /** + * class prop + * + * + * @brief 查询和绑定窗口尺寸改变事件,相当于 on("size", func); + * + * 以下示例会在窗口改变大小时输出窗口的尺寸: + * ```JavaScript + * var gui = require('gui'); + * var webview = gui.open('fs:index.html'); + * + * webview.onresize = evt => console.log(evt.width, evt.height); + * ``` + * + * + * + * @type Function + */ + + onresize: Function + + /** + * class prop + * + * + * @brief 查询和绑定窗口关闭事件,WebView 关闭后会触发此时间,相当于 on("closed", func); + * + * + * @type Function + */ + + onclosed: Function + + /** + * class prop + * + * + * @brief 查询和绑定接受 webview 内 postMessage 消息事件,相当于 on("message", func); + * + * + * @type Function + */ + + onmessage: Function + + + + /** + * + * @brief 设置 webview 的页面 html + * @param html 设置的 html + * + * + * @async + */ + setHtml(html: string): void; + + /** + * + * @brief 打印当前窗口文档 + * @param mode 打印参数,0: 快速打印; 1: 标准打印; 2: 打印预览。缺省为 1 + * + * + * @async + */ + print(mode?: number/** = 1*/): void; + + /** + * + * @brief 关闭当前窗口 + * + * @async + */ + close(): void; + + /** + * + * @brief 等待当前窗口关闭 + * 宿主程序在创建窗口后,需要进入等待,否则随着宿主程序的退出,窗口将自动关闭。同时 wait 的调用也并不是必须的,你可以在打开窗口后处理其它业务,只需要保证程序不会自行退出即可。 + * + * + * @async + */ + wait(): void; + + /** + * + * @brief 向 webview 内发送消息 + * postMessage 需要在窗口加载完成后发送消息,在此之前发送的消息会丢失。因此建议在 onload 事件触发后再调用此方法。 + * @param msg 要发送的消息 + * + * + * @async + */ + postMessage(msg: string): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/Worker.d.ts b/types/fibjs/declare/Worker.d.ts new file mode 100644 index 0000000000..9e8fa4f50a --- /dev/null +++ b/types/fibjs/declare/Worker.d.ts @@ -0,0 +1,66 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief 独立线程工作对象 + * @detail + */ +/// +declare class Class_Worker extends Class_EventEmitter { + + /** + * class prop + * + * + * @brief 查询和绑定接受 postMessage 消息事件,相当于 on("message", func); + * + * + * @type Function + */ + + onmessage: Function + + + + /** + * + * @brief Worker 对象构造函数 + * @param path 指定 Worker 入口脚本,只接受绝对路径 + * @param opts 构造选项,暂未支持 + * + * + * + */ + constructor(path: string, opts?: Object/** = v8::Object::New(isolate)*/); + + /** + * + * @brief 向 Master 或 Worker 发送消息, + * @param data 指定发送的消息内容 + * + * + * + */ + postMessage(data: any): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/X509Cert.d.ts b/types/fibjs/declare/X509Cert.d.ts new file mode 100644 index 0000000000..17f4a259b4 --- /dev/null +++ b/types/fibjs/declare/X509Cert.d.ts @@ -0,0 +1,263 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief x509 证书对象 + * @detail X509Cert 对象属于 crypto 模块,创建:,```JavaScript,var k = new crypto.X509Cert();,``` + */ + +declare class Class_X509Cert extends Class__object { + + /** + * class prop + * + * + * @brief 获取证书的版本 + * + * @readonly + * @type Integer + */ + + version: number + + /** + * class prop + * + * + * @brief 获取证书的序列号 + * + * @readonly + * @type String + */ + + serial: string + + /** + * class prop + * + * + * @brief 获取证书颁发者的可分辨名称 + * + * @readonly + * @type String + */ + + issuer: string + + /** + * class prop + * + * + * @brief 获取证书的主题可分辨名称 + * + * @readonly + * @type String + */ + + subject: string + + /** + * class prop + * + * + * @brief 获取证书的生效时间 + * + * @readonly + * @type Date + */ + + notBefore: Date + + /** + * class prop + * + * + * @brief 获取证书的到期时间 + * + * @readonly + * @type Date + */ + + notAfter: Date + + /** + * class prop + * + * + * @brief 获取证书是否是 ca 证书 + * + * @readonly + * @type Boolean + */ + + ca: boolean + + /** + * class prop + * + * + * @brief 获取证书的 pathlen + * + * @readonly + * @type Integer + */ + + pathlen: number + + /** + * class prop + * + * + * @brief 获取证书的使用范围 + * + * 结果为全部或部分以下内容:digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign + * + * + * @readonly + * @type String + */ + + usage: string + + /** + * class prop + * + * + * @brief 获取证书的 Netscape 证书类型 + * + * 结果为全部或部分以下内容:client, server, email, objsign, reserved, sslCA, emailCA, objCA + * + * + * @readonly + * @type String + */ + + type: string + + /** + * class prop + * + * + * @brief 获取证书的公钥 + * + * @readonly + * @type PKey + */ + + publicKey: Class_PKey + + /** + * class prop + * + * + * @brief 获取证书链中得下一个证书 + * + * @readonly + * @type X509Cert + */ + + next: Class_X509Cert + + + + /** + * + * @brief X509Cert 构造函数 + * + * + */ + constructor(); + + /** + * + * @brief 加载一个 DER 格式的证书,可多次调用 + * @param derCert DER 格式的证书 + * + * + * + */ + load(derCert: Class_Buffer): void; + + /** + * + * @brief 加载一个 CRT/PEM/TXT 格式的证书,可多次调用 + * + * load 加载 mozilla 的 certdata,txt, 可于 http://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt 下载使用 + * @param txtCert PEM 格式的证书 + * + * + * + */ + load(txtCert: string): void; + + /** + * + * @brief 加载一个 CRT/PEM/DER/TXT 格式的证书,可多次调用 + * + * loadFile 加载 mozilla 的 certdata,txt, 可于 http://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt 下载使用 + * @param filename 证书文件名 + * + * + * + */ + loadFile(filename: string): void; + + /** + * + * @brief 加载自带的缺省根证书 + * 此证书内容源自:http://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt + * + * + */ + loadRootCerts(): void; + + /** + * + * @brief 使用当前证书链验证给定的证书 + * @param cert 给定需要验证的证书 + * @return 如果验证成功则返回 True + * + * + * @async + */ + verify(cert: Class_X509Cert): boolean; + + /** + * + * @brief 导出已经加载的证书 + * @return 以数组方式导出证书链 + * + * + * + */ + dump(): any[]; + + /** + * + * @brief 清空已经加载的证书 + * + * + */ + clear(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/X509Crl.d.ts b/types/fibjs/declare/X509Crl.d.ts new file mode 100644 index 0000000000..44c3f2a4fc --- /dev/null +++ b/types/fibjs/declare/X509Crl.d.ts @@ -0,0 +1,90 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief x509 撤销证书对象 + * @detail X509Crl 对象属于 crypto 模块,创建:,```JavaScript,var k = new crypto.X509Crl();,``` + */ + +declare class Class_X509Crl extends Class__object { + + + + /** + * + * @brief X509Crl 构造函数 + * + * + */ + constructor(); + + /** + * + * @brief 加载一个 DER 格式的撤销证书,可多次调用 + * @param derCrl DER 格式的撤销证书 + * + * + * + */ + load(derCrl: Class_Buffer): void; + + /** + * + * @brief 加载一个 PEM 格式的撤销证书,可多次调用 + * @param pemCrl PEM 格式的撤销证书 + * + * + * + */ + load(pemCrl: string): void; + + /** + * + * @brief 加载一个 PEM/DER 格式的撤销证书,可多次调用 + * @param filename 撤销证书文件名 + * + * + * + */ + loadFile(filename: string): void; + + /** + * + * @brief 导出已经加载的撤销证书 + * @return 以数组方式导出撤销证书链 + * + * + * + */ + dump(): any[]; + + /** + * + * @brief 清空已经加载的撤销证书 + * + * + * + */ + clear(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/X509Req.d.ts b/types/fibjs/declare/X509Req.d.ts new file mode 100644 index 0000000000..5474d3f6d8 --- /dev/null +++ b/types/fibjs/declare/X509Req.d.ts @@ -0,0 +1,155 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + + + +/** module Or Internal Object */ +/** + * @brief x509 证书请求对象 + * @detail X509Req 对象属于 crypto 模块,创建:,```JavaScript,var k = new crypto.X509Req();,``` + */ + +declare class Class_X509Req extends Class__object { + + /** + * class prop + * + * + * @brief 获取证书的主题可分辨名称 + * + * @readonly + * @type String + */ + + subject: string + + /** + * class prop + * + * + * @brief 获取证书的公钥 + * + * @readonly + * @type PKey + */ + + publicKey: Class_PKey + + + + /** + * + * @brief X509Req 构造函数 + * + * + */ + constructor(); + + /** + * + * @brief X509Req 构造函数,根据给定的信息创建一个证书请求 + * + * @param subject 证书的主题可分辨名称 + * @param key 证书的公钥 + * @param hash 证书摘要算法,缺省为 hash.SHA1 + * + * + * + */ + constructor(subject: string, key: Class_PKey, hash?: number/** = undefined*/); + + /** + * + * @brief 加载一个 DER 格式的证书请求 + * @param derReq DER 格式的证书请求 + * + * + * + */ + load(derReq: Class_Buffer): void; + + /** + * + * @brief 加载一个 PEM 格式的证书请求 + * @param pemReq PEM 格式的证书请求 + * + * + * + */ + load(pemReq: string): void; + + /** + * + * @brief 加载一个 PEM/DER 格式的证书请求,可多次调用 + * @param filename 证书请求文件名 + * + * + * + */ + loadFile(filename: string): void; + + /** + * + * @brief 返回当前证书请求的 PEM 格式编码 + * @return 当前证书请求的 PEM 格式编码 + * + * + * + */ + exportPem(): string; + + /** + * + * @brief 返回当前证书请求的 DER 格式编码 + * @return 当前证书请求的 DER 格式编码 + * + * + * + */ + exportDer(): Class_Buffer; + + /** + * + * @brief 签名当前证书请求为正式证书 + * + * opts 接收的字段如下: + * ```JavaScript + * { + * ca: false, // 证书为 ca,缺省为 false + * pathlen: -1, // 证书深度,缺省为 -1 + * notBefore: "", // 证书生效时间,缺省为当前时间 + * notAfter: "", // 证书失效时间,缺省为 notBefore 后一年 + * usage: "", // 证书使用范围,接收:digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign + * type: "" // 证书 Netscape 证书类型,接收:client, server, email, objsign, reserved, sslCA, emailCA, objCA + * } + * ``` + * @param issuer 签名机构的可分辨名称 + * @param key 签名机构的私钥 + * @param opts 其他可选参数 + * @return 返回签名后的正式证书 + * + * + * @async + */ + sign(issuer: string, key: Class_PKey, opts?: Object/** = v8::Object::New(isolate)*/): Class_X509Cert; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlAttr.d.ts b/types/fibjs/declare/XmlAttr.d.ts new file mode 100644 index 0000000000..b95e3902c9 --- /dev/null +++ b/types/fibjs/declare/XmlAttr.d.ts @@ -0,0 +1,124 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlAttr 对象表示 XmlElement 对象的属性 + * @detail + */ + +declare class Class_XmlAttr extends Class__object { + + /** + * class prop + * + * + * @brief 查询元素的本地名称。如果选定的节点无命名空间,则该属性等同于 nodeName + * + * + * @readonly + * @type String + */ + + localName: string + + /** + * class prop + * + * + * @brief 属性的值 + * + * + * + * @type String + */ + + value: string + + /** + * class prop + * + * + * @brief 属性的名称 + * + * + * @readonly + * @type String + */ + + name: string + + /** + * class prop + * + * + * @brief 查询元素的命名空间的 URI。如果选定的节点无命名空间,则该属性返回 NULL + * + * + * @readonly + * @type String + */ + + namespaceURI: string + + /** + * class prop + * + * + * @brief 查询和设置元素的命名空间前缀。如果选定的节点无命名空间,则该属性返回 NULL + * + * + * + * @type String + */ + + prefix: string + + /** + * class prop + * + * + * @brief 属性的名称,为兼容的目的 + * + * + * @readonly + * @type String + */ + + nodeName: string + + /** + * class prop + * + * + * @brief 属性的值,为兼容的目的 + * + * + * + * @type String + */ + + nodeValue: string + + + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlCDATASection.d.ts b/types/fibjs/declare/XmlCDATASection.d.ts new file mode 100644 index 0000000000..31fd64ecc9 --- /dev/null +++ b/types/fibjs/declare/XmlCDATASection.d.ts @@ -0,0 +1,33 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlCDATASection 对象表示文档中的 CDATA 区段 + * @detail XmlCDATASection 接口是 XmlText 接口的子接口,没有定义任何自己的属性和方法。通过从 XmlNode 接口继承 nodeValue 属性,或通过从 XmlCharacterData 接口继承 data 属性,可以访问 CDATA Section 的文本内容。,,虽然通常可以把 XmlCDATASection 节点作为 XmlText 节点处理,但要注意 XmlNode 的 normalize 方法不并入相邻的 CDATA 部分。,,使用 XmlDocument 的 createXmlCDATASection 方法来创建一个 XmlCDATASection 。,,CDATA 区段包含了不会被解析器解析的文本。CDATA 区段中的标签不会被视为标记,同时实体也不会被展开。主要的目的是为了包含诸如 XML 片段之类的材料,而无需转义所有的分隔符。,,在一个 CDATA 中唯一被识别的分隔符是 "]]>",它可标示 CDATA 区段的结束。CDATA 区段不能进行嵌套。 + */ +/// +declare class Class_XmlCDATASection extends Class_XmlText { + + + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlCharacterData.d.ts b/types/fibjs/declare/XmlCharacterData.d.ts new file mode 100644 index 0000000000..eb83981983 --- /dev/null +++ b/types/fibjs/declare/XmlCharacterData.d.ts @@ -0,0 +1,115 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlCharacterData 接口提供了 XmlText 和 XmlComment 节点的常用功能 + * @detail XmlCharacterData 是 XmlText 和 XmlComment 节点的超接口。文档从不包含 XmlCharacterData 节点,它们只包含 XmlText 节点和 XmlComment 节点。但由于这两种节点具有相似的功能,因此此处定义了这些函数,以便 XmlText 和 XmlComment 可以继承它。 + */ +/// +declare class Class_XmlCharacterData extends Class_XmlNode { + + /** + * class prop + * + * + * @brief 该节点包含的文本 + * + * + * + * @type String + */ + + data: string + + /** + * class prop + * + * + * @brief 该节点包含的字符数 + * + * + * @readonly + * @type Integer + */ + + length: number + + + + /** + * + * @brief 从节点中提取子串 + * @param offset 要返回的第一个字符的位置 + * @param count 要返回的子串中的字符数 + * @return 返回提取的字符串 + * + * + * + */ + substringData(offset: number, count: number): string; + + /** + * + * @brief 把字符串附加到节点上 + * @param arg 要附加到节点的字符串 + * + * + * + */ + appendData(arg: string): void; + + /** + * + * @brief 把字符串插入节点 + * @param offset 要把字符串插入节点的字符位置 + * @param arg 要插入的字符串 + * + * + * + */ + insertData(offset: number, arg: string): void; + + /** + * + * @brief 从节点删除文本 + * @param offset 要删除的第一个字符的位置 + * @param count 要删除的字符的数量 + * + * + * + */ + deleteData(offset: number, count: number): void; + + /** + * + * @brief 用指定的字符串替换节点的字符 + * @param offset 节点要替换的字符位置 + * @param count 要替换的字符的数量 + * @param arg 要插入的字符串 + * + * + * + */ + replaceData(offset: number, count: number, arg: string): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlComment.d.ts b/types/fibjs/declare/XmlComment.d.ts new file mode 100644 index 0000000000..7ba55a9740 --- /dev/null +++ b/types/fibjs/declare/XmlComment.d.ts @@ -0,0 +1,33 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlComment 对象表示文档中注释节点的内容 + * @detail XmlComment 节点表示 XML 文档中的注释。,使用由 XmlCharacterData 接口继承的 data 属性,或使用由 XmlNode 接口继承的 nodeValue 属性,可以访问注释的内容。(即 之间的文本)。使用由 XmlCharacterData 接口继承的各种方法可以操作注释的内容。,,使用 XmlDocument.createComment() 来创建一个注释对象。 + */ +/// +declare class Class_XmlComment extends Class_XmlCharacterData { + + + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlDocument.d.ts b/types/fibjs/declare/XmlDocument.d.ts new file mode 100644 index 0000000000..9e0b770e81 --- /dev/null +++ b/types/fibjs/declare/XmlDocument.d.ts @@ -0,0 +1,290 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlDocument 对象代表整个 XML 文档 + * @detail XmlDocument 对象是一棵文档树的根,可为我们提供对文档数据的最初(或最顶层)的访问入口。,用于元素节点、文本节点、注释、处理指令等均无法存在于 XmlDocument 之外, XmlDocument 对象同样提供了创建这些对象的方法。 XmlNode 对象提供了一个 ownerDocument 属性,此属性可把它们与在其中创建它们的 XmlDocument 关联起来。 + */ +/// +declare class Class_XmlDocument extends Class_XmlNode { + + /** + * class prop + * + * + * @brief 返回用于文档的编码(在解析时) + * + * + * @readonly + * @type String + */ + + inputEncoding: string + + /** + * class prop + * + * + * @brief 设置或返回文档是否为 standalone + * + * + * + * @type Boolean + */ + + xmlStandalone: boolean + + /** + * class prop + * + * + * @brief 设置或返回文档的 XML 版本 + * + * + * + * @type String + */ + + xmlVersion: string + + /** + * class prop + * + * + * @brief 返回与文档相关的文档类型声明(Document Type Declaration) + * + * 对于没有 DTD 的 XML 文档,则返回 null。此属性可提供对 XmlDocumentType 对象( XmlDocument 的一个子节点)的直接访问。 + * + * + * @readonly + * @type XmlDocumentType + */ + + doctype: Class_XmlDocumentType + + /** + * class prop + * + * + * @brief 返回文档的根节点 + * + * + * @readonly + * @type XmlElement + */ + + documentElement: Class_XmlElement + + /** + * class prop + * + * + * @brief 返回 HTML 文档的 head 节点,仅在 html 模式有效 + * + * + * @readonly + * @type XmlElement + */ + + head: Class_XmlElement + + /** + * class prop + * + * + * @brief 返回 HTML 文档的 title 节点的内容,仅在 html 模式有效 + * + * + * @readonly + * @type String + */ + + title: string + + /** + * class prop + * + * + * @brief 返回 HTML 文档的 body 节点,仅在 html 模式有效 + * + * + * @readonly + * @type XmlElement + */ + + body: Class_XmlElement + + + + /** + * + * @brief 构造一个 XmlDocument 对象 + * @param type 指定文档对象的类型,缺省为 "text/xml",若需要处理 html 则需要指定 "text/html" + * + * + * + */ + constructor(type?: string/** = "text/xml"*/); + + /** + * + * @brief 通过解析一个 XML/HTML 字符串来组成该文档,不支持多语种 + * @param source 要解析的 XML/HTML 文本,取决于文档创建时的类型 + * + * + * + */ + load(source: string): void; + + /** + * + * @brief 通过解析一个二进制 XML/HTML 字符串来组成该文档,并根据语种自动转换 + * @param source 要解析的 XML/HTML 文本,取决于文档创建时的类型 + * + * + * + */ + load(source: Class_Buffer): void; + + /** + * + * @brief 返回带有指定名称的所有元素的一个节点列表 + * + * 该方法将返回一个 XmlNodeList 对象(可以作为只读数组处理),该对象存放文档中具有指定标签名的所有 XmlElement 节点,它们存放的顺序就是在源文档中出现的顺序。 XmlNodeList 对象是“活”的,即如果在文档中添加或删除了指定标签名的元素,它的内容会自动进行必要的更新。 + * @param tagName 需检索的标签名。值 "*" 匹配所有的标签 + * @return 文档树中具有指定标记的 XmlElement 节点的 XmlNodeList 集合。返回的元素节点的顺序就是它们在源文档中出现的顺序。 + * + * + * + */ + getElementsByTagName(tagName: string): Class_XmlNodeList; + + /** + * + * @brief 返回带有指定命名空间和名称的所有元素的一个节点列表 + * + * 该方法与 getElementsByTagName() 方法相似,只是它根据命名空间和名称来检索元素。 + * @param namespaceURI 指定检索的命名空间 URI。值 "*" 可匹配所有的标签 + * @param localName 需检索的标签名。值 "*" 匹配所有的标签 + * @return 文档树中具有指定标记的 XmlElement 节点的 XmlNodeList 集合。返回的元素节点的顺序就是它们在源文档中出现的顺序。 + * + * + * + */ + getElementsByTagNameNS(namespaceURI: string, localName: string): Class_XmlNodeList; + + /** + * + * @brief 返回拥有指定 id 属性的元素 + * + * 该方法将遍历文档的子孙节点,返回一个 XmlElement 节点对象,表示第一个具有指定 id 属性的文档元素。。 + * @param id 需检索的 id + * @return 节点树中具有指定 id 属性的 XmlElement 节点 + * + * + * + */ + getElementById(id: string): Class_XmlElement; + + /** + * + * @brief 返回带有指定 class 名称的所有元素的一个节点列表 + * + * 该方法将返回一个 XmlNodeList 对象(可以作为只读数组处理),该对象存放文档中具有指定 class 名的所有 XmlElement 节点,它们存放的顺序就是在源文档中出现的顺序。 XmlNodeList 对象是“活”的,即如果在文档中添加或删除了指定标签名的元素,它的内容会自动进行必要的更新。 + * @param className 需检索的 class 名称 + * @return 文档树中具有指定 class 名的 XmlElement 节点的 XmlNodeList 集合。返回的元素节点的顺序就是它们在源文档中出现的顺序。 + * + * + * + */ + getElementsByClassName(className: string): Class_XmlNodeList; + + /** + * + * @brief 创建元素节点 + * @param tagName 指定元素节点规定名称 + * @return 返回新创建的 XmlElement 节点,具有指定的标签名 + * + * + * + */ + createElement(tagName: string): Class_XmlElement; + + /** + * + * @brief 创建带有指定命名空间的元素节点 + * @param namespaceURI 指定元素节点命名空间 URI + * @param qualifiedName 指定元素节点规定名称 + * @return 返回新创建的 XmlElement 节点,具有指定的标签名 + * + * + * + */ + createElementNS(namespaceURI: string, qualifiedName: string): Class_XmlElement; + + /** + * + * @brief 创建文本节点 + * @param data 指定此节点的文本 + * @return 返回新创建的 XmlText 节点,表示指定的 data 字符串 + * + * + * + */ + createTextNode(data: string): Class_XmlText; + + /** + * + * @brief 创建注释节点 + * @param data 指定此节点的注释文本 + * @return 返回新创建的 XmlComment 节点,注释文本为指定的 data + * + * + * + */ + createComment(data: string): Class_XmlComment; + + /** + * + * @brief 创建 XmlCDATASection 节点 + * @param data 指定此节点规定 CDATA 数据 + * @return 返回新创建的 XmlCDATASection 节点,内容为指定的 data + * + * + * + */ + createCDATASection(data: string): Class_XmlCDATASection; + + /** + * + * @brief 创建 XmlProcessingInstruction 节点 + * @param target 指定处理指令的目标 + * @param data 指定处理指令的内容文本 + * @return 新创建的 ProcessingInstruction 节点 + * + * + * + */ + createProcessingInstruction(target: string, data: string): Class_XmlProcessingInstruction; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlDocumentType.d.ts b/types/fibjs/declare/XmlDocumentType.d.ts new file mode 100644 index 0000000000..129b1c7f5c --- /dev/null +++ b/types/fibjs/declare/XmlDocumentType.d.ts @@ -0,0 +1,72 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlDocumentType 对象用于访问 XML 所定义的实体 + * @detail + */ +/// +declare class Class_XmlDocumentType extends Class_XmlNode { + + /** + * class prop + * + * + * @brief 返回 DTD 的名称 + * + * + * @readonly + * @type String + */ + + name: string + + /** + * class prop + * + * + * @brief 可返回外部 DTD 的公共识别符 + * + * + * @readonly + * @type String + */ + + publicId: string + + /** + * class prop + * + * + * @brief 可返回外部 DTD 的系统识别符 + * + * + * @readonly + * @type String + */ + + systemId: string + + + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlElement.d.ts b/types/fibjs/declare/XmlElement.d.ts new file mode 100644 index 0000000000..8b55b1a625 --- /dev/null +++ b/types/fibjs/declare/XmlElement.d.ts @@ -0,0 +1,301 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlElement 对象表示 XML 文档中的元素 + * @detail + */ +/// +declare class Class_XmlElement extends Class_XmlNode { + + /** + * class prop + * + * + * @brief 查询元素的命名空间的 URI。如果选定的节点无命名空间,则该属性返回 NULL + * + * + * @readonly + * @type String + */ + + namespaceURI: string + + /** + * class prop + * + * + * @brief 查询和设置元素的命名空间前缀。如果选定的节点无命名空间,则该属性返回 NULL + * + * + * + * @type String + */ + + prefix: string + + /** + * class prop + * + * + * @brief 查询元素的本地名称。如果选定的节点无命名空间,则该属性等同于 nodeName + * + * + * @readonly + * @type String + */ + + localName: string + + /** + * class prop + * + * + * @brief 返回元素的标签名 + * + * + * @readonly + * @type String + */ + + tagName: string + + /** + * class prop + * + * + * ! 查询和设置元素的 id 属性 + * + * + * + * @type String + */ + + id: string + + /** + * class prop + * + * + * ! 查询和设置选定元素的文本。查询时,返回元素节点内所有文本节点的值;设置时,删除所有子节点,并用单个文本节点来替换它们。 + * + * + * + * @type String + */ + + textContent: string + + /** + * class prop + * + * + * ! 查询和设置选定元素的 HTML 文本,仅在 html 模式有效。查询时,返回元素节点内所有子节点的 HTML 编码;设置时,删除所有子节点,并用指定的 HTML 解码后替换它们。 + * + * + * + * @type String + */ + + innerHTML: string + + /** + * class prop + * + * + * ! 查询和设置元素的 class 属性,仅在 html 模式有效 + * + * + * + * @type String + */ + + className: string + + /** + * class prop + * + * + * @brief 返回包含被选节点属性的 NamedNodeMap。如果被选节点不是元素,则该属性返回 NULL。 + * + * + * @readonly + * @type XmlNamedNodeMap + */ + + attributes: Class_XmlNamedNodeMap + + + + /** + * + * @brief 通过名称查询属性的值 + * @param name 指定查询的属性名 + * @return 返回属性的值 + * + * + * + */ + getAttribute(name: string): string; + + /** + * + * @brief 通过命名空间 URI 和名称来获取属性值 + * @param namespaceURI 指定查询的命名空间 URI + * @param localName 指定查询的属性名 + * @return 返回属性的值 + * + * + * + */ + getAttributeNS(namespaceURI: string, localName: string): string; + + /** + * + * @brief 创建或改变某个新属性 + * + * 该方法把指定的属性设置为指定的值。如果不存在具有指定名称的属性,该方法将创建一个新属性 + * @param name 指定要设置的属性名 + * @param value 指定要设置的属性值 + * + * + * + */ + setAttribute(name: string, value: string): void; + + /** + * + * @brief 创建或改变具有命名空间的属性 + * + * 该方法与 setAttribute 方法类似,只是要创建或设置的属性由命名空间 URI 和限定名(由名字空间前缀、冒号和名字空间中的本地名构成)共同指定。除了可以改变一个属性的值以外,使用该方法还可以改变属性的名字空间前缀 + * @param namespaceURI 指定要设置的命名空间 URI + * @param qualifiedName 指定要设置的属性名 + * @param value 指定要设置的属性值 + * + * + * + */ + setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; + + /** + * + * @brief 通过名称删除指定的属性 + * @param name 指定删除的属性名 + * + * + * + */ + removeAttribute(name: string): void; + + /** + * + * @brief 通过命名空间和名称删除指定的属性 + * @param namespaceURI 指定要删除的命名空间 URI + * @param localName 指定删除的属性名 + * + * + * + */ + removeAttributeNS(namespaceURI: string, localName: string): void; + + /** + * + * @brief 查询当前节点是否拥有指定名称的属性 + * @param name 指定查询的属性名称 + * @return 如果当前元素节点拥有指定属性,则返回 true,否则返回 false + * + * + * + */ + hasAttribute(name: string): boolean; + + /** + * + * @brief 查询当前节点是否拥有指定命名空间和名称的属性 + * @param namespaceURI 指定要查询的命名空间 URI + * @param localName 指定查询的属性名称 + * @return 如果当前元素节点拥有指定属性,则返回 true,否则返回 false + * + * + * + */ + hasAttributeNS(namespaceURI: string, localName: string): boolean; + + /** + * + * @brief 返回拥有指定名称的所有元素的 XmlNodeList + * + * 该方法将遍历指定元素的子孙节点,返回一个 XmlElement 节点的 XmlNodeList 对象,表示所有具有指定标签名的文档元素。元素在返回的数组中的顺序就是它们出现在文档源代码中的顺序。 + * + * XmlDocument 接口也定义了 getElementsByTagName 方法,它与该方法相似,但遍历整个文档,而不是遍历某个元素的子孙节点。 + * @param tagName 需检索的标签名。值 "*" 匹配所有的标签 + * @return 节点树中具有指定标记的 XmlElement 节点的 XmlNodeList 集合。返回的元素节点的顺序就是它们在源文档中出现的顺序。 + * + * + * + */ + getElementsByTagName(tagName: string): Class_XmlNodeList; + + /** + * + * @brief 返回拥有指定命名空间和名称的所有元素的 XmlNodeList + * + * 该方法与 getElementsByTagName 方法相似,只是想获取的元素的标记名被指定为命名空间 URI 和在命名空间中定义的本地名的组合。 + * @param namespaceURI 指定要查询的命名空间 URI + * @param localName 需检索的标签名。值 "*" 匹配所有的标签 + * @return 节点树中具有指定标记的 XmlElement 节点的 XmlNodeList 集合。返回的元素节点的顺序就是它们在源文档中出现的顺序。 + * + * + * + */ + getElementsByTagNameNS(namespaceURI: string, localName: string): Class_XmlNodeList; + + /** + * + * @brief 返回拥有指定 id 属性的元素 + * + * 该方法将遍历指定元素的子孙节点,返回一个 XmlElement 节点对象,表示第一个具有指定 id 属性的文档元素。。 + * + * XmlDocument 接口也定义了 getElementsByTagName 方法,它与该方法相似,但遍历整个文档,而不是遍历某个元素的子孙节点。 + * @param id 需检索的 id + * @return 节点树中具有指定 id 属性的 XmlElement 节点 + * + * + * + */ + getElementById(id: string): Class_XmlElement; + + /** + * + * @brief 返回带有指定 class 名称的所有元素的一个节点列表 + * + * 该方法将返回一个 XmlNodeList 对象(可以作为只读数组处理),该对象存放文档中具有指定 class 名的所有 XmlElement 节点,它们存放的顺序就是在源文档中出现的顺序。 XmlNodeList 对象是“活”的,即如果在文档中添加或删除了指定标签名的元素,它的内容会自动进行必要的更新。 + * @param className 需检索的 class 名称 + * @return 文档树中具有指定 class 名的 XmlElement 节点的 XmlNodeList 集合。返回的元素节点的顺序就是它们在源文档中出现的顺序。 + * + * + * + */ + getElementsByClassName(className: string): Class_XmlNodeList; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlNamedNodeMap.d.ts b/types/fibjs/declare/XmlNamedNodeMap.d.ts new file mode 100644 index 0000000000..ea852a624c --- /dev/null +++ b/types/fibjs/declare/XmlNamedNodeMap.d.ts @@ -0,0 +1,68 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlNamedNodeMap 对象表示一个无顺序的属性列表 + * @detail + */ + +declare class Class_XmlNamedNodeMap extends Class__object { + + /** + * class prop + * + * + * @brief 返回属性列表中的属性数目 + * + * + * @readonly + * @type Integer + */ + + length: number + + + + /** + * + * @brief 返回属性列表中处于指定的索引号的属性 + * @param index 指定要查询的索引 + * @return 指定索引号的属性 + * + * + * + */ + item(index: number): Class_XmlAttr; + + /** + * + * @brief 查询指定名称的属性 + * @param name 指定要查询的名称 + * @return 返回查询出的属性 + * + * + * + */ + getNamedItem(name: string): Class_XmlAttr; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlNode.d.ts b/types/fibjs/declare/XmlNode.d.ts new file mode 100644 index 0000000000..efab8bd60e --- /dev/null +++ b/types/fibjs/declare/XmlNode.d.ts @@ -0,0 +1,315 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlNode 对象是整个 DOM 的基础数据类型 + * @detail + */ + +declare class Class_XmlNode extends Class__object { + + /** + * class prop + * + * + * @brief 返回节点的节点类型 + * + * 不同对象的 nodeType 会返回不同的值: + * - XmlElement: ELEMENT_NODE(1) + * - XmlAttr: ATTRIBUTE_NODE(2) + * - XmlText: TEXT_NODE(3) + * - XmlCDATASection: CDATA_SECTION_NODE(4) + * - XmlProcessingInstruction: PROCESSING_INSTRUCTION_NODE(7) + * - XmlComment: COMMENT_NODE(8) + * - XmlDocument: DOCUMENT_NODE(9) + * - XmlDocumentType: DOCUMENT_TYPE_NODE(10) + * + * + * @readonly + * @type Integer + */ + + nodeType: number + + /** + * class prop + * + * + * @brief 返回节点的名称,根据其类型 + * + * 不同对象的 nodeName 会返回不同的值: + * - XmlElement: element name + * - XmlAttr: 属性名称 + * - XmlText: \#text + * - XmlCDATASection: \#cdata-section + * - XmlProcessingInstruction: 返回指定目标 target + * - XmlComment: \#comment + * - XmlDocument: \#document + * - XmlDocumentType: doctype 名称 + * + * + * @readonly + * @type String + */ + + nodeName: string + + /** + * class prop + * + * + * @brief 返回节点的名称,根据其类型 + * + * 不同对象的 nodeName 会返回不同的值: + * - XmlElement: null + * - XmlAttr: 属性的值 + * - XmlText: 节点的内容 + * - XmlCDATASection: 节点的内容 + * - XmlProcessingInstruction: 返回指定内容 data + * - XmlComment: 注释文本 + * - XmlDocument: null + * - XmlDocumentType: null + * + * + * + * @type String + */ + + nodeValue: string + + /** + * class prop + * + * + * @brief 返回节点的根元素(XmlDocument 对象) + * + * + * @readonly + * @type XmlDocument + */ + + ownerDocument: Class_XmlDocument + + /** + * class prop + * + * + * @brief 可返回某节点的父节点 + * + * + * @readonly + * @type XmlNode + */ + + parentNode: Class_XmlNode + + /** + * class prop + * + * + * @brief 返回指定节点的子节点的节点列表 + * + * + * @readonly + * @type XmlNodeList + */ + + childNodes: Class_XmlNodeList + + /** + * class prop + * + * + * @brief 返回节点的首个子节点 + * + * + * @readonly + * @type XmlNode + */ + + firstChild: Class_XmlNode + + /** + * class prop + * + * + * @brief 返回节点的最后一个子节点 + * + * + * @readonly + * @type XmlNode + */ + + lastChild: Class_XmlNode + + /** + * class prop + * + * + * @brief 返回某节点之前紧跟的节点(处于同一树层级),如果没有此节点,那么该属性返回 null + * + * + * @readonly + * @type XmlNode + */ + + previousSibling: Class_XmlNode + + /** + * class prop + * + * + * @brief 返回某个元素之后紧跟的节点(处于同一树层级中),如果无此节点,则属性返回 null + * + * + * @readonly + * @type XmlNode + */ + + nextSibling: Class_XmlNode + + + + /** + * + * @brief 查询是否存在子节点 + * @return 存在任何子节点时返回 true,否则返回 false + * + * + * + */ + hasChildNodes(): boolean; + + /** + * + * @brief 合并相邻的 Text 节点并删除空的 Text 节点 + * + * 这个方法将遍历当前节点的所有子孙节点,通过删除空的 Text 节点,已经合并所有相邻的 Text 节点来规范化文档。该方法在进行节点的插入或删除操作后,对于简化文档树的结构很有用。 + * + * + * + */ + normalize(): void; + + /** + * + * @brief 创建指定的节点的精确拷贝 + * + * 该方法将复制并返回调用它的节点的副本。如果传递给它的参数是 true,它还将递归复制当前节点的所有子孙节点。 否则,它只复制当前节点。返回的节点不属于文档树,它的 parentNode 属性为 null。当复制的是 Element 节点时,它的所有属性都将被复制。 + * @param deep 是否深度拷贝,为 true 时,被克隆的节点会克隆原节点的所有子节点 + * @return 返回所复制的节点 + * + * + * + */ + cloneNode(deep?: boolean/** = true*/): Class_XmlNode; + + /** + * + * @brief 返回在当前节点上匹配指定的命名空间 URI 的前缀 + * @param namespaceURI 指定匹配的命名空间 URI + * @return 返回匹配的前缀,未匹配到返回 null + * + * + * + */ + lookupPrefix(namespaceURI: string): string; + + /** + * + * @brief 返回在当前节点上匹配指定的前缀的命名空间 URI + * @param prefix 指定匹配的前缀 + * @return 返回匹配的命名空间 URI,未匹配到返回 null + * + * + * + */ + lookupNamespaceURI(prefix: string): string; + + /** + * + * @brief 在已有的子节点前插入一个新的子节点 + * + * 如果文档树中已经存在了 newChild,它将从文档树中删除,然后重新插入它的新位置。来自一个文档的节点(或由一个文档创建的节点)不能插入另一个文档。也就是说,newChild 的 ownerDocument 属性必须与当前节点的 ownerDocument 属性相同。 + * @param newChild 插入新的节点 + * @param refChild 在此节点前插入新节点 + * @return 返回新的子节点 + * + * + * + */ + insertBefore(newChild: Class_XmlNode, refChild: Class_XmlNode): Class_XmlNode; + + /** + * + * @brief 在已有的子节点后插入一个新的子节点 + * + * 如果文档树中已经存在了 newChild,它将从文档树中删除,然后重新插入它的新位置。来自一个文档的节点(或由一个文档创建的节点)不能插入另一个文档。也就是说,newChild 的 ownerDocument 属性必须与当前节点的 ownerDocument 属性相同。 + * @param newChild 插入新的节点 + * @param refChild 在此节点后插入新节点 + * @return 返回新的子节点 + * + * + * + */ + insertAfter(newChild: Class_XmlNode, refChild: Class_XmlNode): Class_XmlNode; + + /** + * + * @brief 向节点的子节点列表的末尾添加新的子节点 + * + * 如果文档树中已经存在了 newChild,它将从文档树中删除,然后重新插入它的新位置。来自一个文档的节点(或由一个文档创建的节点)不能插入另一个文档。也就是说,newChild 的 ownerDocument 属性必须与当前节点的 ownerDocument 属性相同。 + * @param newChild 指定添加的节点 + * @return 返回这个新的子节点 + * + * + * + */ + appendChild(newChild: Class_XmlNode): Class_XmlNode; + + /** + * + * @brief 将某个子节点替换为另一个 + * + * 如果文档树中已经存在了 newChild,它将从文档树中删除,然后重新插入它的新位置。来自一个文档的节点(或由一个文档创建的节点)不能插入另一个文档。也就是说,newChild 的 ownerDocument 属性必须与当前节点的 ownerDocument 属性相同。 + * @param newChild 指定新的节点 + * @param oldChild 指定被替换的节点 + * @return 如替换成功,此方法可返回被替换的节点,如替换失败,则返回 null + * + * + * + */ + replaceChild(newChild: Class_XmlNode, oldChild: Class_XmlNode): Class_XmlNode; + + /** + * + * @brief 从子节点列表中删除某个节点 + * @param oldChild 指定被删除的节点 + * @return 如删除成功,此方法可返回被删除的节点,如失败,则返回 null + * + * + * + */ + removeChild(oldChild: Class_XmlNode): Class_XmlNode; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlNodeList.d.ts b/types/fibjs/declare/XmlNodeList.d.ts new file mode 100644 index 0000000000..df0abeb83b --- /dev/null +++ b/types/fibjs/declare/XmlNodeList.d.ts @@ -0,0 +1,57 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlNodeList 对象代表一个有顺序的节点列表 + * @detail + */ + +declare class Class_XmlNodeList extends Class__object { + + /** + * class prop + * + * + * @brief 返回节点列表中的节点数目 + * + * + * @readonly + * @type Integer + */ + + length: number + + + + /** + * + * @brief 返回节点列表中处于指定的索引号的节点 + * @param index 指定要查询的索引 + * @return 指定索引号的节点 + * + * + * + */ + item(index: number): Class_XmlNode; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlProcessingInstruction.d.ts b/types/fibjs/declare/XmlProcessingInstruction.d.ts new file mode 100644 index 0000000000..b9d903d977 --- /dev/null +++ b/types/fibjs/declare/XmlProcessingInstruction.d.ts @@ -0,0 +1,59 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlProcessingInstruction 对象表示 xml 处理指令 + * @detail + */ +/// +declare class Class_XmlProcessingInstruction extends Class_XmlNode { + + /** + * class prop + * + * + * @brief 返回此处理指令的目标 + * + * + * @readonly + * @type String + */ + + target: string + + /** + * class prop + * + * + * @brief 设置或返回此处理指令的内容 + * + * + * + * @type String + */ + + data: string + + + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/XmlText.d.ts b/types/fibjs/declare/XmlText.d.ts new file mode 100644 index 0000000000..b950de3f1d --- /dev/null +++ b/types/fibjs/declare/XmlText.d.ts @@ -0,0 +1,48 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief XmlText 对象表示元素或属性的文本内容 + * @detail XmlText 节点表示 XML 文档中的一系列纯文本。因为纯文本出现在 XML 的元素和属性中,所以 XmlText 节点通常作为 XmlElement 节点和 XmlAttr 节点的子节点出现。,,XmlText 节点继承了 XmlCharacterData 接口,通过从 XmlCharacterData 接口继承的 data 属性或从 XmlNode 接口继承的 nadevalue 属性,可以访问 XmlText 节点的文本内容。,,用从 XmlCharacterData 继承的方法或 XmlText 接口自身定义的 splitText() 方法可以操作 XmlText 节点。使用 XmlDocument 的 createTextNode 来创建一个新的 XmlText 节点。,,XmlText 节点没有子节点。,,关于从文档的子树中删除空 XmlText 节点与合并相邻的 XmlText 节点的方法,请参阅 XmlNode.normalize 方法。 + */ +/// +declare class Class_XmlText extends Class_XmlCharacterData { + + + + /** + * + * @brief 按照指定的 offset 把文本节点分割为两个节点 + * + * 该方法将在指定的 offset 处把 XmlText 节点分割成两个节点。原始的 XmlText 节点将被修改,使它包含 offset 指定的位置之前的文本内容(但不包括文本内容)。新的 XmlText 节点将被创建,用于存放从 offset 位置(包括该位置上的字符)到原字符结尾的所有字符。新的 XmlText 节点是该方法的返回值。此外,如果原始的 XmlText 节点具有 parentNode,新的 XmlText 节点将插入这个父节点,紧邻在原始节点之后。 + * + * XmlCDATASection 接口继承了 XmlText 接口, XmlCDATASection 节点也可以使用该方法 ,只是新创建的节点是 XmlCDATASection 节点,而不是 XmlText 节点。 + * @param offset 规定在何处分割文本节点。开始值以 0 开始 + * @return 从当前节点分割出的 Text 节点 + * + * + * + */ + splitText(offset: number): Class_XmlText; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/ZipFile.d.ts b/types/fibjs/declare/ZipFile.d.ts new file mode 100644 index 0000000000..69cff23908 --- /dev/null +++ b/types/fibjs/declare/ZipFile.d.ts @@ -0,0 +1,168 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + +/** module Or Internal Object */ +/** + * @brief zip 文件访问对象 + * @detail + */ + +declare class Class_ZipFile extends Class__object { + + + + /** + * + * @brief 获取文件名列表 + * @return 返回包含文件名的列表对象 + * + * + * @async + */ + namelist(): any[]; + + /** + * + * @brief 获取文件信息列表 + * 文件信息包含字段有:filename, date, compress_type, compress_size, file_size, password, data + * @return 返回包含文件信息的列表对象 + * + * + * @async + */ + infolist(): any[]; + + /** + * + * @brief 获取文件信息 + * 文件信息包含字段有:filename, date, compress_type, compress_size, file_size, password, data + * @param member 指定要获取信息的文件名 + * @return 返回文件信息对象 + * + * + * @async + */ + getinfo(member: string): any; + + /** + * + * @brief 返回从压缩文件读取的数据 + * @param member 指定要读取的文件名 + * @param password 解压密码, 默认没有密码 + * @return 返回文件的所有数据 + * + * + * @async + */ + read(member: string, password?: string/** = ""*/): Class_Buffer; + + /** + * + * @brief 解压所有文件 + * @param password 解压密码, 默认没有密码 + * @return 包含所有文件数据及信息的列表 + * + * + * @async + */ + readAll(password?: string/** = ""*/): any[]; + + /** + * + * @brief 解压指定文件 + * @param member 指定要解压的文件名 + * @param path 指定要解压到的路径 + * @param password 解压密码, 默认没有密码 + * + * + * @async + */ + extract(member: string, path: string, password?: string/** = ""*/): void; + + /** + * + * @brief 解压指定文件到流 + * @param member 指定要解压的文件名 + * @param strm 指定要解压到的流 + * @param password 解压密码, 默认没有密码 + * + * + * @async + */ + extract(member: string, strm: Class_SeekableStream, password?: string/** = ""*/): void; + + /** + * + * @brief 解压所有文件到指定路径 + * @param path 指定要解压到的路径 + * @param password 解压密码, 默认没有密码 + * + * + * @async + */ + extractAll(path: string, password?: string/** = ""*/): void; + + /** + * + * @brief 写入指定文件到压缩文件 + * @param filename 指定要写入的文件 + * @param inZipName 压缩在zip文件内的文件名 + * @param password 解压密码, 默认没有密码 + * + * + * @async + */ + write(filename: string, inZipName: string, password?: string/** = ""*/): void; + + /** + * + * @brief 写入指定文件到压缩文件 + * @param data 指定要写入的文件数据 + * @param inZipName 压缩在zip文件内的文件名 + * @param password 解压密码, 默认没有密码 + * + * + * @async + */ + write(data: Class_Buffer, inZipName: string, password?: string/** = ""*/): void; + + /** + * + * @brief 写入指定文件到压缩文件 + * @param strm 指定要写入文件数据流 + * @param inZipName 压缩在zip文件内的文件名 + * @param password 解压密码, 默认没有密码 + * + * + * @async + */ + write(strm: Class_SeekableStream, inZipName: string, password?: string/** = ""*/): void; + + /** + * + * @brief 关闭打开的zip文件 + * + * @async + */ + close(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/ZmqSocket.d.ts b/types/fibjs/declare/ZmqSocket.d.ts new file mode 100644 index 0000000000..ffe2165928 --- /dev/null +++ b/types/fibjs/declare/ZmqSocket.d.ts @@ -0,0 +1,105 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ +/// + + + + + + +/** module Or Internal Object */ +/** + * @brief ZeroMQ 套接口对象 + * @detail + */ + +declare class Class_ZmqSocket extends Class__object { + + /** + * class prop + * + * + * @brief 查询当前 socket 类型 + * + * @readonly + * @type Integer + */ + + type: number + + + + /** + * + * @brief ZmqSocket 对象构造函数 + * @param type 指定 socket 类型,缺省为 zmq.PAIR + * + * + * + */ + constructor(type?: number/** = undefined*/); + + /** + * + * @brief 绑定指定地址和端口 + * @param addr 指定绑定的地址,如:"tcp://*:3000" + * + * + * + */ + bind(addr: string): void; + + /** + * + * @brief 连接到指定地址的服务器 + * @param addr 指定连接的地址,如:"tcp://*:3000" + * + * + * + */ + connect(addr: string): void; + + /** + * + * @brief 接收一个数据包 + * @return 返回接收到的数据包 + * + * + * @async + */ + recv(): Class_Buffer; + + /** + * + * @brief 发送一个数据包 + * @param data 指定发送的数据包 + * + * + * + */ + send(data: Class_Buffer): void; + + /** + * + * @brief 关闭当前 socket + * + * + */ + close(): void; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/_test_env.d.ts b/types/fibjs/declare/_test_env.d.ts new file mode 100644 index 0000000000..56bef11fa1 --- /dev/null +++ b/types/fibjs/declare/_test_env.d.ts @@ -0,0 +1,41 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + +/// +import test from 'test' + +/// +import _assert from 'assert' + +declare global { + const describe: typeof test.describe + const xdescribe: typeof test.xdescribe + const odescribe: typeof test.odescribe + const it: typeof test.it + const xit: typeof test.xit + const oit: typeof test.oit + const before: typeof test.before + const after: typeof test.after + const beforeEach: typeof test.beforeEach + const afterEach: typeof test.afterEach + const run: typeof test.run + const setup: typeof test.setup + + const assert: typeof _assert +} +/** declare const describe: test.describe; */ + + diff --git a/types/fibjs/declare/assert.d.ts b/types/fibjs/declare/assert.d.ts new file mode 100644 index 0000000000..239c02eb98 --- /dev/null +++ b/types/fibjs/declare/assert.d.ts @@ -0,0 +1,794 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 断言测试模块,如果测试值为假,则报错,报错行为可设定继续运行或者错误抛出 + * @detail 引用方法:,```JavaScript,var assert = require('assert');,```,或者通过 test 模块引用:,```JavaScript,var test = require('test');,var assert = test.assert;,```,或者通过 test.setup 配置:,```JavaScript,require("test").setup();,``` + */ +declare module "assert" { + + + module assert { + + + + + + /** + * + * @brief 测试数值为真,为假则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function Function(actual?: any/** = v8::Undefined(isolate)*/, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为真,为假则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function ok(actual?: any/** = v8::Undefined(isolate)*/, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为假,为真则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notOk(actual?: any/** = v8::Undefined(isolate)*/, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值等于预期值,不相等则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function equal(actual?: any/** = v8::Undefined(isolate)*/, expected?: any/** = v8::Undefined(isolate)*/, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不等于预期值,相等则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notEqual(actual?: any/** = v8::Undefined(isolate)*/, expected?: any/** = v8::Undefined(isolate)*/, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值严格等于预期值,不相等则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function strictEqual(actual?: any/** = v8::Undefined(isolate)*/, expected?: any/** = v8::Undefined(isolate)*/, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不严格等于预期值,相等则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notStrictEqual(actual?: any/** = v8::Undefined(isolate)*/, expected?: any/** = v8::Undefined(isolate)*/, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值深度等于预期值,不相等则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function deepEqual(actual?: any/** = v8::Undefined(isolate)*/, expected?: any/** = v8::Undefined(isolate)*/, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不深度等于预期值,相等则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notDeepEqual(actual?: any/** = v8::Undefined(isolate)*/, expected?: any/** = v8::Undefined(isolate)*/, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值近似等于预期值,否则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param delta 近似的小数精度 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function closeTo(actual: any, expected: any, delta: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不近似等于预期值,否则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param delta 近似的小数精度 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notCloseTo(actual: any, expected: any, delta: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值小于预期值,大于或等于则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function lessThan(actual: any, expected: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不小于预期值,小于则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notLessThan(actual: any, expected: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值大于预期值,小于或等于则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function greaterThan(actual: any, expected: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不大于预期值,大于则断言失败 + * @param actual 要测试的数值 + * @param expected 预期的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notGreaterThan(actual: any, expected: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试变量存在,为假则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function exist(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试变量不存在,为真则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notExist(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为布尔值真,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isTrue(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为布尔值真,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNotTrue(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为布尔值假,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isFalse(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为布尔值假,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNotFalse(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为 Null,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNull(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为 Null,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNotNull(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为 undefined,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isUndefined(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为 undefined,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isDefined(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为函数,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isFunction(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为函数,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNotFunction(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为对象,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isObject(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为对象,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNotObject(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为数组,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isArray(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为数组,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNotArray(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为字符串,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isString(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为字符串,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNotString(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为数字,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNumber(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为数字,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNotNumber(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为布尔,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isBoolean(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为布尔,否则断言失败 + * @param actual 要测试的数值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function isNotBoolean(actual: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值为给定类型,否则断言失败 + * @param actual 要测试的数值 + * @param type 指定的类型 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function typeOf(actual: any, type: string, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试数值不为给定类型,否则断言失败 + * @param actual 要测试的数值 + * @param type 指定的类型 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notTypeOf(actual: any, type: string, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试对象中包含指定属性,否则断言失败 + * @param object 要测试的对象 + * @param prop 要测试的属性 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function property(object: any, prop: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试对象中不包含指定属性,否则断言失败 + * @param object 要测试的对象 + * @param prop 要测试的属性 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notProperty(object: any, prop: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 深度测试对象中包含指定属性,否则断言失败 + * @param object 要测试的对象 + * @param prop 要测试的属性,以“.”分割 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function deepProperty(object: any, prop: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 深度测试对象中不包含指定属性,否则断言失败 + * @param object 要测试的对象 + * @param prop 要测试的属性,以“.”分割 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function notDeepProperty(object: any, prop: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试对象中指定属性的值为给定值,否则断言失败 + * @param object 要测试的对象 + * @param prop 要测试的属性 + * @param value 给定的值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function propertyVal(object: any, prop: any, value: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试对象中指定属性的值不为给定值,否则断言失败 + * @param object 要测试的对象 + * @param prop 要测试的属性 + * @param value 给定的值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function propertyNotVal(object: any, prop: any, value: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 深度测试对象中指定属性的值为给定值,否则断言失败 + * @param object 要测试的对象 + * @param prop 要测试的属性,以“.”分割 + * @param value 给定的值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function deepPropertyVal(object: any, prop: any, value: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 深度测试对象中指定属性的值不为给定值,否则断言失败 + * @param object 要测试的对象 + * @param prop 要测试的属性,以“.”分割 + * @param value 给定的值 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function deepPropertyNotVal(object: any, prop: any, value: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试给定的代码会抛出错误,未抛出则断言失败 + * @param block 指定测试的代码,以函数形式给出 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function throws(block: Function, msg?: string/** = ""*/): void; + + /** + * + * @brief 测试给定的代码不会抛出错误,抛出则断言失败 + * @param block 指定测试的代码,以函数形式给出 + * @param msg 断言失败时的提示信息 + * + * + * + */ + export function doesNotThrow(block: Function, msg?: string/** = ""*/): void; + + /** + * + * @brief 如果参数为真,则抛出 + * @param object 参数 + * + * + * + */ + export function ifError(object?: any/** = v8::Undefined(isolate)*/): void; + + } /** end of `module assert` */ + export = assert +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/base32.d.ts b/types/fibjs/declare/base32.d.ts new file mode 100644 index 0000000000..289e9799f8 --- /dev/null +++ b/types/fibjs/declare/base32.d.ts @@ -0,0 +1,239 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief base32 编码与解码模块 + * @detail 引用方式:,```JavaScript,var encoding = require('encoding');,var base32 = encoding.base32;,```,或者,```JavaScript,var base32 = require('base32');,``` + */ +declare module "base32" { + + + module base32 { + + + + + + /** + * + * @brief 以 base32 方式编码数据 + * @param data 要编码的数据 + * @return 返回编码的字符串 + * + * + * + */ + export function encode(data: Class_Buffer): string; + + /** + * + * @brief 以 base32 方式解码字符串为二进制数据 + * @param data 要解码的字符串 + * @return 返回解码的二进制数据 + * + * + * + */ + export function decode(data: string): Class_Buffer; + + } /** end of `module base32` */ + export = base32 +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/base64.d.ts b/types/fibjs/declare/base64.d.ts new file mode 100644 index 0000000000..7112c938e6 --- /dev/null +++ b/types/fibjs/declare/base64.d.ts @@ -0,0 +1,240 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief base64 编码与解码模块 + * @detail 引用方式:,```JavaScript,var encoding = require('encoding');,var base64 = encoding.base64;,```,或者,```JavaScript,var base64 = require('base64');,``` + */ +declare module "base64" { + + + module base64 { + + + + + + /** + * + * @brief 以 base64 方式编码数据 + * @param data 要编码的数据 + * @param url 指定是否使用 url 安全字符编码 + * @return 返回编码的字符串 + * + * + * + */ + export function encode(data: Class_Buffer, url?: boolean/** = false*/): string; + + /** + * + * @brief 以 base64 方式解码字符串为二进制数据 + * @param data 要解码的字符串 + * @return 返回解码的二进制数据 + * + * + * + */ + export function decode(data: string): Class_Buffer; + + } /** end of `module base64` */ + export = base64 +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/base64vlq.d.ts b/types/fibjs/declare/base64vlq.d.ts new file mode 100644 index 0000000000..983bc2ad47 --- /dev/null +++ b/types/fibjs/declare/base64vlq.d.ts @@ -0,0 +1,250 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief base64vlq 编码与解码模块 + * @detail 引用方式:,```JavaScript,var encoding = require('encoding');,var base64vlq = encoding.base64vlq;,```,或者,```JavaScript,var base64vlq = require('base64vlq');,``` + */ +declare module "base64vlq" { + + + module base64vlq { + + + + + + /** + * + * @brief 以 base64vlq 方式编码数据 + * @param data 要编码的数据 + * @return 返回编码的字符串 + * + * + * + */ + export function encode(data: number): string; + + /** + * + * @brief 以 base64vlq 方式编码数据 + * @param data 要编码的数据 + * @return 返回编码的字符串 + * + * + * + */ + export function encode(data: any[]): string; + + /** + * + * @brief 以 base64vlq 方式解码字符串为二进制数据 + * @param data 要解码的字符串 + * @return 返回解码的二进制数据 + * + * + * + */ + export function decode(data: string): any[]; + + } /** end of `module base64vlq` */ + export = base64vlq +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/bson.d.ts b/types/fibjs/declare/bson.d.ts new file mode 100644 index 0000000000..31079539f8 --- /dev/null +++ b/types/fibjs/declare/bson.d.ts @@ -0,0 +1,239 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief bson 编码与解码模块 + * @detail 引用方式:,```JavaScript,var encoding = require('encoding');,var bson = encoding.bson;,```,或者,```JavaScript,var bson = require('bson');,``` + */ +declare module "bson" { + + + module bson { + + + + + + /** + * + * @brief 以 bson 格式编码变量 + * @param data 要编码的变量 + * @return 返回编码的二进制数据 + * + * + * + */ + export function encode(data: Object): Class_Buffer; + + /** + * + * @brief 以 bson 方式解码字符串为一个变量 + * @param data 要解码的二进制数据 + * @return 返回解码的变量 + * + * + * + */ + export function decode(data: Class_Buffer): Object; + + } /** end of `module bson` */ + export = bson +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/console.d.ts b/types/fibjs/declare/console.d.ts new file mode 100644 index 0000000000..87fe5f2cc1 --- /dev/null +++ b/types/fibjs/declare/console.d.ts @@ -0,0 +1,892 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 控制台访问对象 + * @detail 全局对象。可用于提示信息,警告和错误记录。通过启动配置文件,可将日志定位到不同的设备,以便于跟踪。日志支持格式化输出,例如:,```JavaScript,console.log("%d + %d = %d", 100, 200, 100 + 200);,```,可以使用的格式化参数如下:,- %s - 字符串,- %d - 数字,包括整数和数字,- %j - 以 JSON 格式输出对象,- %% - 输出字符 '%' 本身 + */ +declare module "console" { + + + module console { + + /** + * + * @brief loglevel 级别常量 + * + * + */ + export const FATAL = 0; + + /** + * + * @brief loglevel 级别常量 + * + * + */ + export const ALERT = 1; + + /** + * + * @brief loglevel 级别常量 + * + * + */ + export const CRIT = 2; + + /** + * + * @brief loglevel 级别常量 + * + * + */ + export const ERROR = 3; + + /** + * + * @brief loglevel 级别常量 + * + * + */ + export const WARN = 4; + + /** + * + * @brief loglevel 级别常量 + * + * + */ + export const NOTICE = 5; + + /** + * + * @brief loglevel 级别常量 + * + * + */ + export const INFO = 6; + + /** + * + * @brief loglevel 级别常量 + * + * + */ + export const DEBUG = 7; + + /** + * + * @brief loglevel 仅用于输出,信息输出后不换行,file 和 syslog 不保存此级别信息 + * + * + */ + export const PRINT = 9; + + /** + * + * @brief loglevel 级别常量 + * + * + */ + export const NOTSET = 10; + + + + + + /** + * + * @brief 添加 console 输出系统,支持的设备为 console, syslog, event,最多可以添加 10 个输出 + * + * 通过配置 console,可以将程序输出和系统错误发往不同设备,用于运行环境信息收集。 + * + * type 为配置,为设备名称字符串: + * + * ```JavaScript + * console.add("console"); + * ``` + * + * syslog 仅在 posix 平台有效: + * ```JavaScript + * console.add("syslog"); + * ``` + * + * event 仅在 windows 平台有效: + * ```JavaScript + * console.add("event"); + * ``` + * + * @param type 输出设备 + * + * + * + */ + export function add(type: string): void; + + /** + * + * @brief 添加 console 输出系统,支持的设备为 console, syslog, event 和 file,最多可以添加 10 个输出 + * + * 通过配置 console,可以将程序输出和系统错误发往不同设备,用于运行环境信息收集。 + * + * cfg 可以为一个设备配置对象: + * ```JavaScript + * console.add({ + * type: "console", + * levels: [console.INFO, console.ERROR] // 选项,省略则输出全部级别日志 + * }); + * ``` + * + * syslog 仅在 posix 平台有效: + * ```JavaScript + * console.add({ + * type: "syslog", + * levels: [console.INFO, console.ERROR] + * }); + * ``` + * + * event 仅在 windows 平台有效: + * ```JavaScript + * console.add({ + * type: "event", + * levels: [console.INFO, console.ERROR] + * }); + * ``` + * + * file 日志: + * ```JavaScript + * console.add({ + * type: "file", + * levels: [console.INFO, console.ERROR], + * // 必选项,指定日志输出文件,可使用 s% 指定插入日期位置,不指定则添加在结尾 + * path: "path/to/file_%s.log", + * // 选项,可选值为 "day", "hour", "minute", "###k", "###m", "###g",缺省为 "1m" + * split: "30m", + * // 选项,可选范围为 2-128,缺省为 128 + * count: 10 + * }); + * ``` + * + * @param cfg 输出配置 + * + * + * + */ + export function add(cfg: Object): void; + + /** + * + * @brief 批量添加 console 输出系统,支持的设备为 console, syslog, event 和 file,最多可以添加 10 个输出 + * + * 通过配置 console,可以将程序输出和系统错误发往不同设备,用于运行环境信息收集。 + * + * ```JavaScript + * console.add(["console", { + * type: "syslog", + * levels: [console.INFO, console.ERROR] + * }]); + * ``` + * + * @param cfg 输出配置数组 + * + * + * + */ + export function add(cfg: any[]): void; + + /** + * + * @brief 初始化到缺省设置,只在 console 输出信息 + * + * + */ + export function reset(): void; + + /** + * + * @brief 记录普通日志信息,与 info 等同 + * + * 记录一般等级的日志信息。通常用于输出非错误性提示信息。 + * @param fmt 格式化字符串 + * @param args 可选参数列表 + * + * + * + */ + export function log(fmt: string, ...args: any[]): void; + + /** + * + * @brief 记录普通日志信息,与 info 等同 + * + * 记录一般等级的日志信息。通常用于输出非错误性提示信息。 + * @param args 可选参数列表 + * + * + * + */ + export function log(...args: any[]): void; + + /** + * + * @brief 记录调试日志信息 + * + * 记录调试日志信息。通常用于输出调试信息。不重要。 + * @param fmt 格式化字符串 + * @param args 可选参数列表 + * + * + * + */ + export function debug(fmt: string, ...args: any[]): void; + + /** + * + * @brief 记录调试日志信息 + * + * 记录调试日志信息。通常用于输出调试信息。不重要。 + * @param args 可选参数列表 + * + * + * + */ + export function debug(...args: any[]): void; + + /** + * + * @brief 记录普通日志信息,与 log 等同 + * + * 记录一般等级的日志信息。通常用于输出非错误性提示信息。 + * @param fmt 格式化字符串 + * @param args 可选参数列表 + * + * + * + */ + export function info(fmt: string, ...args: any[]): void; + + /** + * + * @brief 记录普通日志信息,与 log 等同 + * + * 记录一般等级的日志信息。通常用于输出非错误性提示信息。 + * @param args 可选参数列表 + * + * + * + */ + export function info(...args: any[]): void; + + /** + * + * @brief 记录警告日志信息 + * + * 记录警告日志信息。通常用于输出提示性调试信息。一般重要。 + * @param fmt 格式化字符串 + * @param args 可选参数列表 + * + * + * + */ + export function notice(fmt: string, ...args: any[]): void; + + /** + * + * @brief 记录警告日志信息 + * + * 记录警告日志信息。通常用于输出提示性调试信息。一般重要。 + * @param args 可选参数列表 + * + * + * + */ + export function notice(...args: any[]): void; + + /** + * + * @brief 记录警告日志信息 + * + * 记录警告日志信息。通常用于输出警告性调试信息。重要。 + * @param fmt 格式化字符串 + * @param args 可选参数列表 + * + * + * + */ + export function warn(fmt: string, ...args: any[]): void; + + /** + * + * @brief 记录警告日志信息 + * + * 记录警告日志信息。通常用于输出警告性调试信息。重要。 + * @param args 可选参数列表 + * + * + * + */ + export function warn(...args: any[]): void; + + /** + * + * @brief 记录错误日志信息 + * + * 记录用于错误日志信息。通常用于输出错误信息。非常重要。系统的出错信息也会以此等级记录。 + * @param fmt 格式化字符串 + * @param args 可选参数列表 + * + * + * + */ + export function error(fmt: string, ...args: any[]): void; + + /** + * + * @brief 记录错误日志信息 + * + * 记录用于错误日志信息。通常用于输出错误信息。非常重要。系统的出错信息也会以此等级记录。 + * @param args 可选参数列表 + * + * + * + */ + export function error(...args: any[]): void; + + /** + * + * @brief 记录关键错误日志信息 + * + * 记录用于关键错误日志信息。通常用于输出关键错误信息。非常重要。 + * @param fmt 格式化字符串 + * @param args 可选参数列表 + * + * + * + */ + export function crit(fmt: string, ...args: any[]): void; + + /** + * + * @brief 记录关键错误日志信息 + * + * 记录用于关键错误日志信息。通常用于输出关键错误信息。非常重要。 + * @param args 可选参数列表 + * + * + * + */ + export function crit(...args: any[]): void; + + /** + * + * @brief 记录警报错误日志信息 + * + * 记录用于警报错误日志信息。通常用于输出警报错误信息。非常重要。为最高级别信息。 + * @param fmt 格式化字符串 + * @param args 可选参数列表 + * + * + * + */ + export function alert(fmt: string, ...args: any[]): void; + + /** + * + * @brief 记录警报错误日志信息 + * + * 记录用于警报错误日志信息。通常用于输出警报错误信息。非常重要。为最高级别信息。 + * @param args 可选参数列表 + * + * + * + */ + export function alert(...args: any[]): void; + + /** + * + * @brief 用 JSON 格式输出对象 + * @param obj 给定要显示的对象 + * + * + * + */ + export function dir(obj: any): void; + + /** + * + * @brief 启动一个计时器 + * + * @param label 标题,缺省为空字符串。 + * + * + * + */ + export function time(label?: string/** = "time"*/): void; + + /** + * + * @brief 输出指定计时器当前计时值 + * + * @param label 标题,缺省为空字符串。 + * + * + * + */ + export function timeElapse(label?: string/** = "time"*/): void; + + /** + * + * @brief 结束指定计时器,并输出最后计时值 + * + * @param label 标题,缺省为空字符串。 + * + * + * + */ + export function timeEnd(label?: string/** = "time"*/): void; + + /** + * + * @brief 输出当前调用堆栈 + * + * 通过日志输出当前调用堆栈。 + * @param label 标题,缺省为空字符串。 + * + * + * + */ + export function trace(label?: string/** = "trace"*/): void; + + /** + * + * @brief 断言测试,如果测试值为假,则报错 + * @param value 测试的数值 + * @param msg 报错信息 + * + * + * + */ + export function assert(value: any, msg?: string/** = ""*/): void; + + /** + * + * @brief 向控制台输出格式化文本,输出内容不会记入日志系统,输出文本后不会自动换行,可连续输出 + * @param fmt 格式化字符串 + * @param args 可选参数列表 + * + * + * + */ + export function print(fmt: string, ...args: any[]): void; + + /** + * + * @brief 向控制台输出格式化文本,输出内容不会记入日志系统,输出文本后不会自动换行,可连续输出 + * @param args 可选参数列表 + * + * + * + */ + export function print(...args: any[]): void; + + /** + * + * @brief 移动控制台光标到指定位置 + * @param row 指定新光标的行坐标 + * @param column 指定新光标的列坐标 + * + * + * + */ + export function moveTo(row: number, column: number): void; + + /** + * + * @brief 隐藏控制台光标 + * + * + */ + export function hideCursor(): void; + + /** + * + * @brief 显示控制台光标 + * + * + */ + export function showCursor(): void; + + /** + * + * @brief 清除控制台 + * + * + */ + export function clear(): void; + + /** + * + * @brief 按下一个按键 + * + * 参数 key 可以使用字符串传入功能键: + * - 功能键:f1 - f12 + * - 方向键:up, down,left, right, home, end, pageup, pagedown + * - 编辑键:backspace, delete, insert, enter, tab, escape, space + * - 控制键:control, alt, shift, command + * @param key 指定按键,单字符直接传入,功能键传入名称 + * @param modifier 指定控制键,可以为:control, alt, shift, command + * + * + * + */ + export function keyDown(key: string, modifier?: string/** = ""*/): void; + + /** + * + * @brief 按下一个按键 + * + * 参数 key 可以使用字符串传入功能键: + * - 功能键:f1 - f12 + * - 方向键:up, down,left, right, home, end, pageup, pagedown + * - 编辑键:backspace, delete, insert, enter, tab, escape, space + * - 控制键:control, alt, shift, command + * @param key 指定按键,单字符直接传入,功能键传入名称 + * @param modifier 指定控制键数组,可以为:control, alt, shift, command + * + * + * + */ + export function keyDown(key: string, modifier: any[]): void; + + /** + * + * @brief 松开一个按键 + * + * 参数 key 可以使用字符串传入功能键: + * - 功能键:f1 - f12 + * - 方向键:up, down,left, right, home, end, pageup, pagedown + * - 编辑键:backspace, delete, insert, enter, tab, escape, space + * - 控制键:control, alt, shift, command + * @param key 指定按键,单字符直接传入,功能键传入名称 + * @param modifier 指定控制键,可以为:control, alt, shift, command + * + * + * + */ + export function keyUp(key: string, modifier?: string/** = ""*/): void; + + /** + * + * @brief 松开一个按键 + * + * 参数 key 可以使用字符串传入功能键: + * - 功能键:f1 - f12 + * - 方向键:up, down,left, right, home, end, pageup, pagedown + * - 编辑键:backspace, delete, insert, enter, tab, escape, space + * - 控制键:control, alt, shift, command + * @param key 指定按键,单字符直接传入,功能键传入名称 + * @param modifier 指定控制键数组,可以为:control, alt, shift, command + * + * + * + */ + export function keyUp(key: string, modifier: any[]): void; + + /** + * + * @brief 点击并松开一个按键 + * + * 参数 key 可以使用字符串传入功能键: + * - 功能键:f1 - f12 + * - 方向键:up, down,left, right, home, end, pageup, pagedown + * - 编辑键:backspace, delete, insert, enter, tab, escape, space + * - 控制键:control, alt, shift, command + * @param key 指定按键,单字符直接传入,功能键传入名称 + * @param modifier 指定控制键,可以为:control, alt, shift, command + * + * + * + */ + export function keyTap(key: string, modifier?: string/** = ""*/): void; + + /** + * + * @brief 点击并松开一个按键 + * + * 参数 key 可以使用字符串传入功能键: + * - 功能键:f1 - f12 + * - 方向键:up, down,left, right, home, end, pageup, pagedown + * - 编辑键:backspace, delete, insert, enter, tab, escape, space + * - 控制键:control, alt, shift, command + * @param key 指定按键,单字符直接传入,功能键传入名称 + * @param modifier 指定控制键数组,可以为:control, alt, shift, command + * + * + * + */ + export function keyTap(key: string, modifier: any[]): void; + + /** + * + * @brief 输入一个字符串 + * @param text 指定输入的字符串 + * + * + * + */ + export function typeString(text: string): void; + + /** + * + * @brief 移动鼠标到指定的位置 + * @param x 指定 x 坐标 + * @param y 指定 y 坐标 + * + * + * + */ + export function moveMouse(x: number, y: number): void; + + /** + * + * @brief 按下一个鼠标键 + * @param button 指定鼠标键名称,允许值为: left, right, moddle + * + * + * + */ + export function mouseUp(button: string): void; + + /** + * + * @brief 放开一个鼠标键 + * @param button 指定鼠标键名称,允许值为: left, right, moddle + * + * + * + */ + export function mouseDown(button: string): void; + + /** + * + * @brief 点击一个鼠标键 + * @param button 指定鼠标键名称,允许值为: left, right, moddle + * @param dbclick 指定是否双击,缺省为 false + * + * + * + */ + export function clickMouse(button: string, dbclick?: boolean/** = false*/): void; + + /** + * + * @brief 从控制台读取用户输入 + * @param msg 提示信息 + * @return 返回用户输入的信息 + * + * + * @async + */ + export function readLine(msg?: string/** = ""*/): string; + + } /** end of `module console` */ + export = console +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/constants.d.ts b/types/fibjs/declare/constants.d.ts new file mode 100644 index 0000000000..4c98aa29ce --- /dev/null +++ b/types/fibjs/declare/constants.d.ts @@ -0,0 +1,217 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 常用常量定义模块 + * @detail 引用方法:,```JavaScript,var constants = require('constants');,``` + */ +declare module "constants" { + + + module constants { + + + + + + } /** end of `module constants` */ + export = constants +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/coroutine.d.ts b/types/fibjs/declare/coroutine.d.ts new file mode 100644 index 0000000000..70a295cc8a --- /dev/null +++ b/types/fibjs/declare/coroutine.d.ts @@ -0,0 +1,343 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 并发控制模块 + * @detail 引用方法:,```JavaScript,var coroutine = require('coroutine');,``` + */ +declare module "coroutine" { + + + module coroutine { + + + + /** + * + * @brief 锁对象,参见 Lock + * + * + */ + export class Lock extends Class_Lock {} + + + /** + * + * @brief 信号量对象,参见 Semaphore + * + * + */ + export class Semaphore extends Class_Semaphore {} + + + /** + * + * @brief 条件变量对象,参见 Condition + * + * + */ + export class Condition extends Class_Condition {} + + + /** + * + * @brief 事件对象,参见 Event + * + * + */ + export class Event extends Class_Event {} + + + /** + * + * @brief 独立线程工作对象,参见 Worker + * + * + */ + export class Worker extends Class_Worker {} + + + + + /** + * + * @brief 启动一个纤程并返回纤程对象 + * @param func 制定纤程执行的函数 + * @param args 可变参数序列,此序列会在纤程内传递给函数 + * @return 返回纤程对象 + * + * + * + */ + export function start(func: Function, ...args: any[]): Class_Fiber; + + /** + * + * @brief 并行执行一组函数,并等待返回 + * @param funcs 并行执行的函数数组 + * @param fibers 限制并发 fiber 数量,缺省为 -1,启用与 funcs 数量相同 fiber + * @return 返回函数执行结果的数组 + * + * + * + */ + export function parallel(funcs: any[], fibers?: number/** = -1*/): any[]; + + /** + * + * @brief 并行执行一个函数处理一组数据,并等待返回 + * @param datas 并行执行的数据数组 + * @param func 并行执行的函数 + * @param fibers 限制并发 fiber 数量,缺省为 -1,启用与 datas 数量相同 fiber + * @return 返回函数执行结果的数组 + * + * + * + */ + export function parallel(datas: any[], func: Function, fibers?: number/** = -1*/): any[]; + + /** + * + * @brief 并行执行一个函数多次,并等待返回 + * @param func 并行执行的函数数 + * @param num 重复任务数量 + * @param fibers 限制并发 fiber 数量,缺省为 -1,启用与 funcs 数量相同 fiber + * @return 返回函数执行结果的数组 + * + * + * + */ + export function parallel(func: Function, num: number, fibers?: number/** = -1*/): any[]; + + /** + * + * @brief 并行执行一组函数,并等待返回 + * @param funcs 一组并行执行的函数 + * @return 返回函数执行结果的数组 + * + * + * + */ + export function parallel(...funcs: any[]): any[]; + + /** + * + * @brief 返回当前纤程 + * @return 当前纤程对象 + * + * + * + */ + export function current(): Class_Fiber; + + /** + * + * @brief 暂停当前纤程指定的时间 + * @param ms 指定要暂停的时间,以毫秒为单位,缺省为 0,即有空闲立即回恢复运行 + * + * + * @async + */ + export function sleep(ms?: number/** = 0*/): void; + + } /** end of `module coroutine` */ + export = coroutine +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/crypto.d.ts b/types/fibjs/declare/crypto.d.ts new file mode 100644 index 0000000000..18be4fbabc --- /dev/null +++ b/types/fibjs/declare/crypto.d.ts @@ -0,0 +1,606 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 加密算法模块 + * @detail 使用方法:,```JavaScript,var crypto = require('crypto');,``` + */ +declare module "crypto" { + + + module crypto { + + /** + * + * @brief 指定对称加密算法 AES,支持 128, 192, 256 位 key,分组密码工作模式支持 ECB, CBC, CFB128, CTR, GCM + * + * + */ + export const AES = 1; + + /** + * + * @brief 指定对称加密算法 CAMELLIA,支持 128, 192, 256 位 key,分组密码工作模式支持 ECB, CBC, CFB128, CTR, GCM + * + * + */ + export const CAMELLIA = 2; + + /** + * + * @brief 指定对称加密算法 DES,支持 64 位 key,分组密码工作模式支持 ECB, CBC + * + * + */ + export const DES = 3; + + /** + * + * @brief 指定对称加密算法 DES-EDE,支持 128 位 key,分组密码工作模式支持 ECB, CBC + * + * + */ + export const DES_EDE = 4; + + /** + * + * @brief 指定对称加密算法 DES-EDE3,支持 192 位 key,分组密码工作模式支持 ECB, CBC + * + * + */ + export const DES_EDE3 = 5; + + /** + * + * @brief 指定对称加密算法 BLOWFISH,支持 192 位 key,分组密码工作模式支持 ECB, CBC, CFB64, CTR + * + * + */ + export const BLOWFISH = 6; + + /** + * + * @brief 指定对称加密算法 ARC4,支持 40, 56, 64, 128 位 key + * + * + */ + export const ARC4 = 7; + + /** + * + * @brief 指定分组密码工作模式支持 ECB + * + * + */ + export const ECB = 1; + + /** + * + * @brief 指定分组密码工作模式支持 CBC + * + * + */ + export const CBC = 2; + + /** + * + * @brief 指定分组密码工作模式支持 CFB64 + * + * + */ + export const CFB64 = 3; + + /** + * + * @brief 指定分组密码工作模式支持 CFB128 + * + * + */ + export const CFB128 = 4; + + /** + * + * @brief 指定分组密码工作模式支持 OFB + * + * + */ + export const OFB = 5; + + /** + * + * @brief 指定分组密码工作模式支持 CTR + * + * + */ + export const CTR = 6; + + /** + * + * @brief 指定分组密码工作模式支持 GCM + * + * + */ + export const GCM = 7; + + /** + * + * @brief 指定流密码模式 + * + * + */ + export const STREAM = 8; + + /** + * + * @brief 指定分组密码工作模式支持 CCM + * + * + */ + export const CCM = 9; + + /** + * + * @brief 指定填充模式为 PKCS7 + * + * + */ + export const PKCS7 = 0; + + /** + * + * @brief 指定填充模式为 ONE_AND_ZEROS + * + * + */ + export const ONE_AND_ZEROS = 1; + + /** + * + * @brief 指定填充模式为 ZEROS_AND_LEN + * + * + */ + export const ZEROS_AND_LEN = 2; + + /** + * + * @brief 指定填充模式为 ZEROS + * + * + */ + export const ZEROS = 3; + + /** + * + * @brief 指定填充模式为 NOPADDING + * + * + */ + export const NOPADDING = 4; + + + + /** + * + * @brief Cipher 构造函数,参见 Cipher + * + * + */ + export class Cipher extends Class_Cipher {} + + + /** + * + * @brief PKey 构造函数,参见 PKey + * + * + */ + export class PKey extends Class_PKey {} + + + /** + * + * @brief X509Cert 构造函数,参见 X509Cert + * + * + */ + export class X509Cert extends Class_X509Cert {} + + + /** + * + * @brief X509Crl 构造函数,参见 X509Crl + * + * + */ + export class X509Crl extends Class_X509Crl {} + + + /** + * + * @brief X509Req 构造函数,参见 X509Req + * + * + */ + export class X509Req extends Class_X509Req {} + + + + + /** + * + * @brief 根据给定的算法名称创建一个信息摘要对象 + * @param algo 指定信息摘要对象的算法 + * @return 返回信息摘要对象 + * + * + * + */ + export function createHash(algo: string): Class_Digest; + + /** + * + * @brief 根据给定的算法名称创建一个 hmac 信息摘要对象 + * @param algo 指定信息摘要对象的算法 + * @param key 二进制签名密钥 + * @return 返回信息摘要对象 + * + * + * + */ + export function createHmac(algo: string, key: Class_Buffer): Class_Digest; + + /** + * + * @brief 加载一个 PEM/DER 格式的密钥文件 + * @param filename 密钥文件名 + * @param password 解密密码 + * @return 返回包含密钥的对象 + * + * + * + */ + export function loadPKey(filename: string, password?: string/** = ""*/): Class_PKey; + + /** + * + * @brief 加载一个 CRT/PEM/DER/TXT 格式的证书,可多次调用 + * + * loadFile 加载 mozilla 的 certdata,txt, 可于 http://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt 下载使用 + * @param filename 证书文件名 + * @return 返回包含证书的对象 + * + * + * + */ + export function loadCert(filename: string): Class_X509Cert; + + /** + * + * @brief 加载一个 PEM/DER 格式的撤销证书,可多次调用 + * @param filename 撤销证书文件名 + * @return 返回包含撤销证书的对象 + * + * + * + */ + export function loadCrl(filename: string): Class_X509Crl; + + /** + * + * @brief 加载一个 PEM/DER 格式的证书请求,可多次调用 + * @param filename 证书请求文件名 + * @return 返回包含请求证书的对象 + * + * + * + */ + export function loadReq(filename: string): Class_X509Req; + + /** + * + * @brief 生成指定尺寸的随机数,使用 havege 生成器 + * @param size 指定生成的随机数尺寸 + * @return 返回生成的随机数 + * + * + * @async + */ + export function randomBytes(size: number): Class_Buffer; + + /** + * + * @brief 生成指定尺寸的低强度随机数,使用快速的算法 + * @param size 指定生成的随机数尺寸 + * @return 返回生成的随机数 + * + * + * @async + */ + export function simpleRandomBytes(size: number): Class_Buffer; + + /** + * + * @brief 生成指定尺寸的伪随机数,使用 entropy 生成器 + * @param size 指定生成的随机数尺寸 + * @return 返回生成的随机数 + * + * + * @async + */ + export function pseudoRandomBytes(size: number): Class_Buffer; + + /** + * + * @brief 生成给定数据的可视化字符图像 + * @param data 指定要展示的数据 + * @param title 指定字符图像的标题,多字节字符会导致宽度错误 + * @param size 字符图像尺寸 + * @return 返回生成的可视化字符串图像 + * + * + * + */ + export function randomArt(data: Class_Buffer, title: string, size?: number/** = 8*/): string; + + /** + * + * @brief 依据 pbkdf1 根据明文 password 生成要求的二进制钥匙 + * @param password 指定使用的密码 + * @param salt 指定 hmac 使用的 salt + * @param iterations 指定迭代次数 + * @param size 指定钥匙尺寸 + * @param algo 指定要使用的 hash 算法,详见 hash 模块 + * @return 返回生成的二进制钥匙 + * + * + * @async + */ + export function pbkdf1(password: Class_Buffer, salt: Class_Buffer, iterations: number, size: number, algo: number): Class_Buffer; + + /** + * + * @brief 依据 pbkdf1 根据明文 password 生成要求的二进制钥匙 + * @param password 指定使用的密码 + * @param salt 指定 hmac 使用的 salt + * @param iterations 指定迭代次数 + * @param size 指定钥匙尺寸 + * @param algoName 指定要使用的 hash 算法,详见 hash 模块 + * @return 返回生成的二进制钥匙 + * + * + * @async + */ + export function pbkdf1(password: Class_Buffer, salt: Class_Buffer, iterations: number, size: number, algoName: string): Class_Buffer; + + /** + * + * @brief 依据 rfc2898 根据明文 password 生成要求的二进制钥匙 + * @param password 指定使用的密码 + * @param salt 指定 hmac 使用的 salt + * @param iterations 指定迭代次数 + * @param size 指定钥匙尺寸 + * @param algo 指定要使用的 hash 算法,详见 hash 模块 + * @return 返回生成的二进制钥匙 + * + * + * @async + */ + export function pbkdf2(password: Class_Buffer, salt: Class_Buffer, iterations: number, size: number, algo: number): Class_Buffer; + + /** + * + * @brief 依据 rfc2898 根据明文 password 生成要求的二进制钥匙 + * @param password 指定使用的密码 + * @param salt 指定 hmac 使用的 salt + * @param iterations 指定迭代次数 + * @param size 指定钥匙尺寸 + * @param algoName 指定要使用的 hash 算法,详见 hash 模块 + * @return 返回生成的二进制钥匙 + * + * + * @async + */ + export function pbkdf2(password: Class_Buffer, salt: Class_Buffer, iterations: number, size: number, algoName: string): Class_Buffer; + + } /** end of `module crypto` */ + export = crypto +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/db.d.ts b/types/fibjs/declare/db.d.ts new file mode 100644 index 0000000000..5e69a8489e --- /dev/null +++ b/types/fibjs/declare/db.d.ts @@ -0,0 +1,345 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 数据库访问模块 + * @detail 基础模块。可用于创建和操作数据库资源,引用方式:,```JavaScript,var db = require('db');,``` + */ +declare module "db" { + + + module db { + + + + + + /** + * + * @brief 打开一个数据库,此方法为通用入口,根据提供的 connString 不同调用不同的引擎 + * @param connString 数据库描述,如:mysql://user:pass\@host/db + * @return 返回数据库连接对象 + * + * + * @async + */ + export function open(connString: string): Class__object; + + /** + * + * @brief 打开一个 mysql 数据库 + * @param connString 数据库描述,如:mysql://user:pass\@host/db + * @return 返回数据库连接对象 + * + * + * @async + */ + export function openMySQL(connString: string): Class_MySQL; + + /** + * + * @brief 打开一个 mysql 数据库 + * @param connString 数据库描述,如:mssql://user:pass\@host/db + * @return 返回数据库连接对象 + * + * + * @async + */ + export function openMSSQL(connString: string): Class_MSSQL; + + /** + * + * @brief 打开一个 sqlite 数据库 + * @param connString 数据库描述,如:sqlite:test.db 或者 test.db + * @return 返回数据库连接对象 + * + * + * @async + */ + export function openSQLite(connString: string): Class_SQLite; + + /** + * + * @brief 打开一个 mongodb 数据库 + * @param connString 数据库描述 + * @return 返回数据库连接对象 + * + * + * @async + */ + export function openMongoDB(connString: string): Class_MongoDB; + + /** + * + * @brief 打开一个 leveldb 数据库 + * @param connString 数据库描述,如:level:test.db 或者 test.db + * @return 返回数据库对象 + * + * + * @async + */ + export function openLevelDB(connString: string): Class_LevelDB; + + /** + * + * @brief 打开一个 Redis 数据库 + * @param connString 数据库描述,如:redis://server:port 或者 "server" + * @return 返回数据库连接对象 + * + * + * @async + */ + export function openRedis(connString: string): Class_Redis; + + /** + * + * @brief 格式化一个 sql 命令,并返回格式化结果 + * + * @param sql 格式化字符串,可选参数用 ? 指定。例如:'SELECT FROM TEST WHERE [id]=?' + * @param args 可选参数列表 + * @return 返回格式化之后的 sql 命令 + * + * + * + */ + export function format(sql: string, ...args: any[]): string; + + /** + * + * @brief 格式化一个 mysql 命令,并返回格式化结果 + * + * @param sql 格式化字符串,可选参数用 ? 指定。例如:'SELECT FROM TEST WHERE [id]=?' + * @param args 可选参数列表 + * @return 返回格式化之后的 sql 命令 + * + * + * + */ + export function formatMySQL(sql: string, ...args: any[]): string; + + /** + * + * @brief 格式化一个 mssql 命令,并返回格式化结果 + * + * @param sql 格式化字符串,可选参数用 ? 指定。例如:'SELECT FROM TEST WHERE [id]=?' + * @param args 可选参数列表 + * @return 返回格式化之后的 sql 命令 + * + * + * + */ + export function formatMSSQL(sql: string, ...args: any[]): string; + + /** + * + * @brief 将字符串编码为 SQL 安全编码字符串 + * @param str 要编码的字符串 + * @param mysql 指定 mysql 编码,缺省为 false + * @return 返回编码后的字符串 + * + * + * + */ + export function escape(str: string, mysql?: boolean/** = false*/): string; + + } /** end of `module db` */ + export = db +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/dgram.d.ts b/types/fibjs/declare/dgram.d.ts new file mode 100644 index 0000000000..1f87090814 --- /dev/null +++ b/types/fibjs/declare/dgram.d.ts @@ -0,0 +1,294 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief dgram 模块提供了 UDP 数据包 socket 的实现 + * @detail 基础模块,引用方式:,```JavaScript,var dgram = require('dgram');,``` + */ +declare module "dgram" { + + + module dgram { + + + + /** + * + * @brief dgram.Socket 对象是一个封装了数据包函数功能的 EventEmitter。参见 DgramSocket + * dgram.Socket 实例是由 dgram.createSocket() 创建的。创建 dgram.Socket 实例不需要使用 new 关键字。 + * + * + * + */ + export class DgramSocket extends Class_DgramSocket {} + + + + + /** + * + * @brief 创建一个 dgram.Socket 对象 + * + * opts 允许的选项是: + * ```JavaScript + * { + * "type": "udp4" | "udp6", // 必填 + * "reuseAddr": true | false, //若设置为 true,socket.bind() 则会重用地址,即时另一个进程已经在其上面绑定了一个套接字。 默认是 false + * "recvBufferSize": ###, // 设置 SO_RCVBUF 套接字值 + * "sendBufferSize": ### //设置 SO_RCVBUF 套接字值 + * } + * ``` + * @param opts + * @return 返回创建的 Socket 对象 + * + * + * + */ + export function createSocket(opts: Object): Class_DgramSocket; + + /** + * + * @brief 创建一个 dgram.Socket 对象 + * + * opts 允许的选项是: + * ```JavaScript + * { + * "type": "udp4" | "udp6", // 必填 + * "reuseAddr": true | false, //若设置为 true,socket.bind() 则会重用地址,即时另一个进程已经在其上面绑定了一个套接字。 默认是 false + * "recvBufferSize": ###, // 设置 SO_RCVBUF 套接字值 + * "sendBufferSize": ### //设置 SO_RCVBUF 套接字值 + * } + * ``` + * @param opts + * @param callback 为 'message' 事件添加一个监听器。 + * @return 返回创建的 Socket 对象 + * + * + * + */ + export function createSocket(opts: Object, callback: Function): Class_DgramSocket; + + /** + * + * @brief 创建一个 dgram.Socket 对象 + * @param type 套接字族,'udp4' 或 'udp6'。 + * @return 返回创建的 Socket 对象 + * + * + * + */ + export function createSocket(type: string): Class_DgramSocket; + + /** + * + * @brief 创建一个 dgram.Socket 对象 + * @param type 套接字族,'udp4' 或 'udp6'。 + * @param callback 为 'message' 事件添加一个监听器。 + * @return 返回创建的 Socket 对象 + * + * + * + */ + export function createSocket(type: string, callback: Function): Class_DgramSocket; + + } /** end of `module dgram` */ + export = dgram +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/dns.d.ts b/types/fibjs/declare/dns.d.ts new file mode 100644 index 0000000000..80a8d5fb32 --- /dev/null +++ b/types/fibjs/declare/dns.d.ts @@ -0,0 +1,239 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief dns 域名查询模块 + * @detail 基础模块,引用方式:,```JavaScript,var dns = require('dns');,``` + */ +declare module "dns" { + + + module dns { + + + + + + /** + * + * @brief 查询给定的主机名的地址 + * @param name 指定主机名 + * @return 返回查询的 ip 字符串数组 + * + * + * @async + */ + export function resolve(name: string): any[]; + + /** + * + * @brief 查询给定的主机名的地址 + * @param name 指定主机名 + * @return 返回查询的 ip 字符串 + * + * + * @async + */ + export function lookup(name: string): string; + + } /** end of `module dns` */ + export = dns +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/encoding.d.ts b/types/fibjs/declare/encoding.d.ts new file mode 100644 index 0000000000..3b02a36c47 --- /dev/null +++ b/types/fibjs/declare/encoding.d.ts @@ -0,0 +1,346 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + + + + + + + + + + + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 编码与解码模块,用于处理不同的数据编码格式与二进制之间的转换 + * @detail 引用方式:,```JavaScript,var encoding = require('encoding');,``` + */ +declare module "encoding" { + + import base32NS = require('base32') + import base64NS = require('base64') + import base64vlqNS = require('base64vlq') + import hexNS = require('hex') + import iconvNS = require('iconv') + import jsonNS = require('json') + import bsonNS = require('bson') + + module encoding { + + + + /** + * + * @brief base32 编码与解码模块 + * + * + */ + + export const base32: typeof base32NS + + /** + * + * @brief base64 编码与解码模块 + * + * + */ + + export const base64: typeof base64NS + + /** + * + * @brief base64vlq 编码与解码模块 + * + * + */ + + export const base64vlq: typeof base64vlqNS + + /** + * + * @brief hex 编码与解码模块 + * + * + */ + + export const hex: typeof hexNS + + /** + * + * @brief iconv 编码与解码模块 + * + * + */ + + export const iconv: typeof iconvNS + + /** + * + * @brief json 编码与解码模块 + * + * + */ + + export const json: typeof jsonNS + + /** + * + * @brief bson 编码与解码模块 + * + * + */ + + export const bson: typeof bsonNS + + + + /** + * + * @brief 将字符串编码为 javascript 转义字符串,用以在 javascript 代码中包含文本 + * @param str 要编码的字符串 + * @param json 是否生成json兼容字符串 + * @return 返回编码的字符串 + * + * + * + */ + export function jsstr(str: string, json?: boolean/** = false*/): string; + + /** + * + * @brief url 字符串安全编码 + * @param url 要编码的 url + * @return 返回编码的字符串 + * + * + * + */ + export function encodeURI(url: string): string; + + /** + * + * @brief url 部件字符串安全编码 + * @param url 要编码的 url + * @return 返回编码的字符串 + * + * + * + */ + export function encodeURIComponent(url: string): string; + + /** + * + * @brief url 安全字符串解码 + * @param url 要解码的 url + * @return 返回解码的字符串 + * + * + * + */ + export function decodeURI(url: string): string; + + } /** end of `module encoding` */ + export = encoding +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/fs.d.ts b/types/fibjs/declare/fs.d.ts new file mode 100644 index 0000000000..4fbc6988ed --- /dev/null +++ b/types/fibjs/declare/fs.d.ts @@ -0,0 +1,648 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 文件系统处理模块 + * @detail 使用方法:,```JavaScript,var fs = require('fs');,``` + */ +declare module "fs" { + + + module fs { + + /** + * + * @brief seek 方式常量,移动到绝对位置 + * + * + */ + export const SEEK_SET = 0; + + /** + * + * @brief seek 方式常量,移动到当前位置的相对位置 + * + * + */ + export const SEEK_CUR = 1; + + /** + * + * @brief seek 方式常量,移动到文件结尾的相对位置 + * + * + */ + export const SEEK_END = 2; + + + + + + /** + * + * @brief 查询指定的文件或目录是否存在 + * @param path 指定要查询的路径 + * @return 返回 True 表示文件或目录存在 + * + * + * @async + */ + export function exists(path: string): boolean; + + /** + * + * @brief 查询用户对指定的文件的权限 + * @param path 指定要查询的路径 + * @param mode 指定查询的权限,默认为文件是否存在 + * + * + * @async + */ + export function access(path: string, mode?: number/** = 0*/): void; + + /** + * + * @brief 创建硬链接文件, windows 下不支持此方法 + * @param oldPath 源文件 + * @param newPath 将要被创建的文件 + * + * + * @async + */ + export function link(oldPath: string, newPath: string): void; + + /** + * + * @brief 删除指定的文件 + * @param path 指定要删除的路径 + * + * + * @async + */ + export function unlink(path: string): void; + + /** + * + * @brief 创建一个目录 + * @param path 指定要创建的目录名 + * @param mode 指定文件权限,Windows 忽略此参数 + * + * + * @async + */ + export function mkdir(path: string, mode?: number/** = 0777*/): void; + + /** + * + * @brief 删除一个目录 + * @param path 指定要删除的目录名 + * + * + * @async + */ + export function rmdir(path: string): void; + + /** + * + * @brief 重新命名一个文件 + * @param from 指定更名的文件 + * @param to 指定要修改的新文件名 + * + * + * @async + */ + export function rename(from: string, to: string): void; + + /** + * + * @brief 复制一个文件 + * @param from 指定更名的文件 + * @param to 指定要修改的新文件名 + * + * + * @async + */ + export function copy(from: string, to: string): void; + + /** + * + * @brief 设置指定文件的访问权限,Windows 不支持此方法 + * @param path 指定操作的文件 + * @param mode 指定设定的访问权限 + * + * + * @async + */ + export function chmod(path: string, mode: number): void; + + /** + * + * @brief 设置指定文件的访问权限,若文件是软连接则不改变指向文件的权限,只在macOS、BSD 系列平台上可用 + * @param path 指定操作的文件 + * @param mode 指定设定的访问权限 + * + * + * @async + */ + export function lchmod(path: string, mode: number): void; + + /** + * + * @brief 设置指定文件的拥有者,Windows 不支持此方法 + * @param path 指定设置的文件 + * @param uid 文件拥有者用户id + * @param gid 文件拥有者组id + * + * + * @async + */ + export function chown(path: string, uid: number, gid: number): void; + + /** + * + * @brief 设置指定文件的拥有者,如果指定的文件是软连接则不会改变其指向文件的拥有者,Windows 不支持此方法 + * @param path 指定设置的文件 + * @param uid 文件拥有者用户id + * @param gid 文件拥有者组id + * + * + * @async + */ + export function lchown(path: string, uid: number, gid: number): void; + + /** + * + * @brief 查询指定文件的基础信息 + * @param path 指定查询的文件 + * @return 返回文件的基础信息 + * + * + * @async + */ + export function stat(path: string): Class_Stat; + + /** + * + * @brief 查询指定文件的基础信息, 和stat不同的是, 当path是一个软连接的时候,返回的将是这个软连接的信息而不是指向的文件的信息 + * @param path 指定查询的文件 + * @return 返回文件的基础信息 + * + * + * @async + */ + export function lstat(path: string): Class_Stat; + + /** + * + * @brief 读取指定的软连接文件, windows 下不支持此方法 + * @param path 指定读取的软连接文件 + * @return 返回软连接指向的文件名 + * + * + * @async + */ + export function readlink(path: string): string; + + /** + * + * @brief 返回指定路径的绝对路径,如果指定路径中包含相对路径也会被展开 + * @param path 指定读取的路径 + * @return 返回处理后的绝对路径 + * + * + * @async + */ + export function realpath(path: string): string; + + /** + * + * @brief 创建软连接文件 + * @param target 目标文件,可以是文件、目录、或不存在的路径 + * @param linkpath 将被创建的软连接文件 + * @param type 创建的软连接类型, 可选类型为'file', 'dir', 'junction', 默认为'file', 该参数只在windows上有效,当为'junction'的时候将要创建的目标路径linkpath必须为绝对路径, 而target则会被自动转化为绝对路径。 + * + * + * @async + */ + export function symlink(target: string, linkpath: string, type?: string/** = "file"*/): void; + + /** + * + * @brief 修改文件尺寸,如果指定的长度大于源文件大小则用'\0'填充,否则多于的文件内容将丢失 + * @param path 指定被修改文件的路径 + * @param len 指定修改后文件的大小 + * + * + * @async + */ + export function truncate(path: string, len: number): void; + + /** + * + * @brief 根据文件描述符,读取文件内容 + * @param fd 文件描述符 + * @param buffer 读取结果写入的 Buffer 对象 + * @param offset Buffer 写入偏移量, 默认为 0 + * @param length 文件读取字节数,默认为 0 + * @param position 文件读取位置,默认为当前文件位置 + * @return 实际读取的字节数 + * + * + * @async + */ + export function read(fd: number, buffer: Class_Buffer, offset?: number/** = 0*/, length?: number/** = 0*/, position?: number/** = -1*/): number; + + /** + * + * @brief 根据文件描述符,改变文件模式。只在 POSIX 系统有效。 + * @param fd 文件描述符 + * @param mode 文件的模式 + * + * + * @async + */ + export function fchmod(fd: number, mode: number): void; + + /** + * + * @brief 根据文件描述符,改变所有者。只在 POSIX 系统有效。 + * @param fd 文件描述符 + * @param uid 用户id + * @param gid 组id + * + * + * @async + */ + export function fchown(fd: number, uid: number, gid: number): void; + + /** + * + * @brief 根据文件描述符,同步数据到磁盘 + * @param fd 文件描述符 + * + * + * @async + */ + export function fdatasync(fd: number): void; + + /** + * + * @brief 根据文件描述符,同步数据到磁盘 + * @param fd 文件描述符 + * + * + * @async + */ + export function fsync(fd: number): void; + + /** + * + * @brief 读取指定目录的文件信息 + * @param path 指定查询的目录 + * @return 返回目录的文件信息数组 + * + * + * @async + */ + export function readdir(path: string): any[]; + + /** + * + * @brief 打开文件,用于读取,写入,或者同时读写 + * + * 参数 flags 支持的方式如下: + * - 'r' 只读方式,文件不存在则抛出错误。 + * - 'r+' 读写方式,文件不存在则抛出错误。 + * - 'w' 只写方式,文件不存在则自动创建,存在则将被清空。 + * - 'w+' 读写方式,文件不存在则自动创建。 + * - 'a' 只写添加方式,文件不存在则自动创建。 + * - 'a+' 读写添加方式,文件不存在则自动创建。 + * @param fname 指定文件名 + * @param flags 指定文件打开方式,缺省为 "r",只读方式 + * @return 返回打开的文件对象 + * + * + * @async + */ + export function openFile(fname: string, flags?: string/** = "r"*/): Class_SeekableStream; + + /** + * + * @brief 打开文件描述符 + * + * 参数 flags 支持的方式如下: + * - 'r' 只读方式,文件不存在则抛出错误。 + * - 'r+' 读写方式,文件不存在则抛出错误。 + * - 'w' 只写方式,文件不存在则自动创建,存在则将被清空。 + * - 'w+' 读写方式,文件不存在则自动创建。 + * - 'a' 只写添加方式,文件不存在则自动创建。 + * - 'a+' 读写添加方式,文件不存在则自动创建。 + * @param fname 指定文件名 + * @param flags 指定文件打开方式,缺省为 "r",只读方式 + * @param mode 当创建文件的时候,指定文件的模式,默认 0666 + * @return 返回打开的文件描述符 + * + * + * @async + */ + export function open(fname: string, flags?: string/** = "r"*/, mode?: number/** = 0666*/): number; + + /** + * + * @brief 关闭文件描述符 + * @param fd 文件描述符 + * + * + * @async + */ + export function close(fd: number): void; + + /** + * + * @brief 打开文本文件,用于读取,写入,或者同时读写 + * + * 参数 flags 支持的方式如下: + * - 'r' 只读方式,文件不存在则抛出错误。 + * - 'r+' 读写方式,文件不存在则抛出错误。 + * - 'w' 只写方式,文件不存在则自动创建,存在则将被清空。 + * - 'w+' 读写方式,文件不存在则自动创建。 + * - 'a' 只写添加方式,文件不存在则自动创建。 + * - 'a+' 读写添加方式,文件不存在则自动创建。 + * @param fname 指定文件名 + * @param flags 指定文件打开方式,缺省为 "r",只读方式 + * @return 返回打开的文件对象 + * + * + * @async + */ + export function openTextStream(fname: string, flags?: string/** = "r"*/): Class_BufferedStream; + + /** + * + * @brief 打开文本文件,并读取内容 + * @param fname 指定文件名 + * @return 返回文件文本内容 + * + * + * @async + */ + export function readTextFile(fname: string): string; + + /** + * + * @brief 打开二进制文件,并读取内容 + * @param fname 指定文件名 + * @param encoding 指定解码方式,缺省不解码 + * @return 返回文件文本内容 + * + * + * @async + */ + export function readFile(fname: string, encoding?: string/** = ""*/): any; + + /** + * + * @brief 打开文件,以数组方式读取一组文本行,行结尾标识基于 EOL 属性的设置,缺省时,posix:"\n";windows:"\r\n" + * @param fname 指定文件名 + * @param maxlines 指定此次读取的最大行数,缺省读取全部文本行 + * @return 返回读取的文本行数组,若无数据可读,或者连接中断,空数组 + * + * + * + */ + export function readLines(fname: string, maxlines?: number/** = -1*/): any[]; + + /** + * + * @brief 创建文本文件,并写入内容 + * @param fname 指定文件名 + * @param txt 指定要写入的字符串 + * + * + * @async + */ + export function writeTextFile(fname: string, txt: string): void; + + /** + * + * @brief 创建二进制文件,并写入内容 + * @param fname 指定文件名 + * @param data 指定要写入的二进制数据 + * + * + * @async + */ + export function writeFile(fname: string, data: Class_Buffer): void; + + /** + * + * @brief 创建二进制文件,并写入内容 + * @param fname 指定文件名 + * @param data 指定要写入的二进制数据 + * + * + * @async + */ + export function appendFile(fname: string, data: Class_Buffer): void; + + } /** end of `module fs` */ + export = fs +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/gd.d.ts b/types/fibjs/declare/gd.d.ts new file mode 100644 index 0000000000..5629834b34 --- /dev/null +++ b/types/fibjs/declare/gd.d.ts @@ -0,0 +1,587 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 图像文件处理模块 + * @detail 基础模块。可用于创建和操作图像文件,引用方式:,```JavaScript,var gd = require('gd');,``` + */ +declare module "gd" { + + + module gd { + + /** + * + * @brief 图像格式常量,标示当前图像来源为未知 + * + * + */ + export const NONE = 0; + + /** + * + * @brief 图像格式常量,标示当前图像来源为 jpeg 格式数据 + * + * + */ + export const JPEG = 1; + + /** + * + * @brief 图像格式常量,标示当前图像来源为 gif 格式数据 + * + * + */ + export const GIF = 2; + + /** + * + * @brief 图像格式常量,标示当前图像来源为 png 格式数据 + * + * + */ + export const PNG = 3; + + /** + * + * @brief 图像格式常量,标示当前图像来源为 tiff 格式数据 + * + * + */ + export const TIFF = 4; + + /** + * + * @brief 图像格式常量,标示当前图像来源为 bmp 格式数据 + * + * + */ + export const BMP = 5; + + /** + * + * @brief 图像格式常量,标示当前图像来源为 webp 格式数据 + * + * + */ + export const WEBP = 6; + + /** + * + * @brief 图像类型常量,标示当前图像为真彩色图像 + * + * + */ + export const TRUECOLOR = 0; + + /** + * + * @brief 图像类型常量,标示当前图像为调色板图像 + * + * + */ + export const PALETTE = 1; + + /** + * + * @brief 扇形绘制样式,绘制一条连接开始和结束点的圆弧 + * + * + */ + export const ARC = 0; + + /** + * + * @brief 扇形绘制样式,绘制一条连接原点,开始和结束点的直线 + * + * + */ + export const CHORD = 1; + + /** + * + * @brief 扇形绘制样式,绘制不填充的扇形 + * + * + */ + export const NOFILL = 2; + + /** + * + * @brief 扇形绘制样式,绘制一条连接起点和终点的弧和连接原点的直线 + * + * + */ + export const EDGED = 4; + + /** + * + * @brief 镜像方向,横向做镜像处理 + * + * + */ + export const HORIZONTAL = 1; + + /** + * + * @brief 镜像方向,纵向做镜像处理 + * + * + */ + export const VERTICAL = 2; + + /** + * + * @brief 镜像方向,横向和纵向都做镜像处理 + * + * + */ + export const BOTH = 3; + + /** + * + * @brief 旋转方向,向左旋转 + * + * + */ + export const LEFT = 1; + + /** + * + * @brief 旋转方向,向右旋转 + * + * + */ + export const RIGHT = 2; + + /** + * + * @brief 滤波器类型:用平均移除法来达到轮廓效果 + * + * + */ + export const MEAN_REMOVAL = 0; + + /** + * + * @brief 滤波器类型:用边缘检测来突出图像的边缘 + * + * + */ + export const EDGEDETECT = 1; + + /** + * + * @brief 滤波器类型:使图像浮雕化 + * + * + */ + export const EMBOSS = 2; + + /** + * + * @brief 滤波器类型:模糊图像 + * + * + */ + export const SELECTIVE_BLUR = 3; + + /** + * + * @brief 滤波器类型:用高斯算法模糊图像 + * + * + */ + export const GAUSSIAN_BLUR = 4; + + /** + * + * @brief 滤波器类型:将图像中所有颜色反转 + * + * + */ + export const NEGATE = 5; + + /** + * + * @brief 滤波器类型:将图像转换为灰度图 + * + * + */ + export const GRAYSCALE = 6; + + /** + * + * @brief 滤波器类型:使图像更柔滑,用arg1设定柔滑级别 + * + * + */ + export const SMOOTH = 7; + + /** + * + * @brief 滤波器类型:改变图像的亮度,用arg1设定亮度级别,取值范围是-255~255 + * + * + */ + export const BRIGHTNESS = 8; + + /** + * + * @brief 滤波器类型:改变图像的对比度,用arg1设定对比度级别,取值范围是0~100 + * + * + */ + export const CONTRAST = 9; + + /** + * + * @brief 滤波器类型:改变图像的色调,用arg1、arg2、arg3分别指定red、blue、green,每种颜色范围是0~255,arg4为透明度,取值返回是0~127 + * + * + */ + export const COLORIZE = 10; + + + + + + /** + * + * @brief 创建一个新图像 + * @param width 指定图像宽度 + * @param height 指定图像高度 + * @param color 指定图像类型,允许值为 gd.TRUECOLOR 或 gd.PALETTE + * @return 返回创建成功的图像对象 + * + * + * @async + */ + export function create(width: number, height: number, color?: number/** = undefined*/): Class_Image; + + /** + * + * @brief 从格式数据中解码图像 + * @param data 给定解码的图像数据 + * @return 返回解码成功的图像对象 + * + * + * @async + */ + export function load(data: Class_Buffer): Class_Image; + + /** + * + * @brief 从流对象中解码图像 + * @param stm 给定图像数据所在的流对象 + * @return 返回解码成功的图像对象 + * + * + * @async + */ + export function load(stm: Class_SeekableStream): Class_Image; + + /** + * + * @brief 从指定文件中解码图像 + * @param fname 指定文件名 + * @return 返回解码成功的图像对象 + * + * + * @async + */ + export function load(fname: string): Class_Image; + + /** + * + * @brief 通过 rgb 颜色分量生成组合颜色 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @return 返回组合颜色 + * + * + * + */ + export function rgb(red: number, green: number, blue: number): number; + + /** + * + * @brief 通过 rgba 颜色分量生成组合颜色 + * @param red 红色分量,范围为 0-255 + * @param green 绿色分量,范围为 0-255 + * @param blue 蓝色分量,范围为 0-255 + * @param alpha 透明分量,范围为 0.0-1.0 + * @return 返回组合颜色 + * + * + * + */ + export function rgba(red: number, green: number, blue: number, alpha: number): number; + + /** + * + * @brief 通过 hsl 颜色分量生成组合颜色 + * @param hue 色相分量,范围为 0-360 + * @param saturation 饱和度分量,范围为 0.0-1.0 + * @param lightness 亮度分量,范围为 0.0-1.0 + * @return 返回组合颜色 + * + * + * + */ + export function hsl(hue: number, saturation: number, lightness: number): number; + + /** + * + * @brief 通过 hsla 颜色分量生成组合颜色 + * @param hue 色相分量,范围为 0-360 + * @param saturation 饱和度分量,范围为 0.0-1.0 + * @param lightness 亮度分量,范围为 0.0-1.0 + * @param alpha 透明分量,范围为 0.0-1.0 + * @return 返回组合颜色 + * + * + * + */ + export function hsla(hue: number, saturation: number, lightness: number, alpha: number): number; + + /** + * + * @brief 通过 hsb 颜色分量生成组合颜色 + * @param hue 色相分量,范围为 0-360 + * @param saturation 饱和度分量,范围为 0.0-1.0 + * @param brightness 明亮程度分量,范围为 0.0-1.0 + * @return 返回组合颜色 + * + * + * + */ + export function hsb(hue: number, saturation: number, brightness: number): number; + + /** + * + * @brief 通过 hsba 颜色分量生成组合颜色 + * @param hue 色相分量,范围为 0-360 + * @param saturation 饱和度分量,范围为 0.0-1.0 + * @param brightness 明亮程度分量,范围为 0.0-1.0 + * @param alpha 透明分量,范围为 0.0-1.0 + * @return 返回组合颜色 + * + * + * + */ + export function hsba(hue: number, saturation: number, brightness: number, alpha: number): number; + + /** + * + * @brief 通过字符串生成组合颜色 + * @param color 指定颜色的字符串,如:"#ff0000", "ff0000", "#f00", "f00" + * @return 返回组合颜色 + * + * + * + */ + export function color(color: string): number; + + } /** end of `module gd` */ + export = gd +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/global.d.ts b/types/fibjs/declare/global.d.ts new file mode 100644 index 0000000000..4ab9eb1713 --- /dev/null +++ b/types/fibjs/declare/global.d.ts @@ -0,0 +1,513 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 全局对象,所有脚本均可以访问的基础对象 + * @detail + */ +declare module "global" { + + import consoleNS = require('console') + import processNS = require('process') + + module global { + + + + /** + * + * @brief 二进制数据缓存对象,用于 io 读写的数据处理,参见 Buffer 对象。 + * + * + */ + export class Buffer extends Class_Buffer {} + + + /** + * + * @brief 64位整数对象,参见 Int64 对象。 + * + * + */ + export class Int64 extends Class_Int64 {} + + + /** + * + * @brief 控制台访问对象 + * + * + */ + + export const console: typeof consoleNS + + /** + * + * @brief 进程对象 + * + * + */ + + export const process: typeof processNS + + + + /** + * + * @brief 运行一个脚本 + * @param fname 指定要运行的脚本路径 + * @param argv 指定要运行的参数,此参数可在脚本内使用 argv 获取 + * + * + * + */ + export function run(fname: string, argv?: any[]/** = v8::Array::New(isolate)*/): void; + + /** + * + * @brief 加载一个模块并返回模块对象,更多信息参阅 @ref module + * + * require 可用于加载基础模块,文件模块。 + * + * 基础模块是沙箱创建时初始化的模块,引用时只需传递相应的 id,比如 require("net")。 + * + * 文件模块是用户自定义模块,引用时需传递以 ./ 或 ../ 开头的相对路径。文件模块支持 .js, .jsc 和 .json 文件。 + * + * 文件模块也支持 package.json 格式,当模块为目录结构时,require 会先查询 package.json 中的 main,未发现则尝试加载路径下的 index.js, index.jsc 或 index.json。 + * + * 若引用路径不是 ./ 或 ../ 开头,并且非基础模块,require 从当前模块所在路径下的 node_modules 查找,并上级目录递归。 + * + * 基础流程如下: + * + * ```dot + * digraph{ + * node [fontname = "Helvetica,sans-Serif", fontsize = 10]; + * edge [fontname = "Helvetica,sans-Serif", fontsize = 10]; + * + * start [label="起始"]; + * resolve [label="path.resolve" shape="rect"]; + * search [label="从当前路径\n向上递归查找\nnode_modules" shape="rect"]; + * load [label="加载" shape="rect"]; + * end [label="返回" shape="doublecircle"]; + * + * is_native [label="内置模块?" shape="diamond"]; + * is_mod [label="模块?" shape="diamond"]; + * is_abs [label="绝对路径?" shape="diamond"]; + * has_file [label="原名存在?" shape="diamond"]; + * has_ext [label="增加 .js 存在?" shape="diamond"]; + * has_package [label="/package.json\n存在?" shape="diamond"]; + * has_main [label="main 存在?" shape="diamond"]; + * has_index [label="index.js 存在?" shape="diamond"]; + * + * start -> is_native; + * is_native -> end [label="是"]; + * is_native -> is_mod [label="否"]; + * is_mod -> search [label="是"]; + * search -> has_file; + * is_mod -> is_abs [label="否"]; + * is_abs -> has_file [label="是"]; + * is_abs -> resolve [label="否"]; + * resolve -> has_file; + * has_file -> load [label="是"]; + * has_file -> has_ext [label="否"]; + * has_ext -> load [label="是"]; + * has_ext -> has_package [label="否"]; + * has_package -> has_main [label="是"]; + * has_package -> has_index [label="否"]; + * has_main -> load [label="是"]; + * has_main -> has_index [label="否"]; + * has_index -> load [label="是"]; + * has_index -> end [label="否"]; + * load -> end; + * } + * ``` + * + * @param id 指定要加载的模块名称 + * @return 返回加载模块的引出对象 + * + * + * + */ + export function require(id: string): any; + + /** + * + * @brief 在指定的时间后调用函数 + * @param callback 指定回调函数 + * @param timeout 指定延时的时间,以毫秒为单位。超过 2^31 的话,立即执行。 + * @param args 额外的参数,传入到指定的 callback 内,可选。 + * @return 返回定时器对象 + * + * + * + */ + export function setTimeout(callback: Function, timeout: number, ...args: any[]): Class_Timer; + + /** + * + * @brief 清除指定的定时器 + * @param t 指定要清除的定时器 + * + * + * + */ + export function clearTimeout(t: any): void; + + /** + * + * @brief 每间隔指定的时间后调用函数 + * @param callback 指定回调函数 + * @param timeout 指定间隔的时间,以毫秒为单位。超过 2^31 的话,立即执行。 + * @param args 额外的参数,传入到指定的 callback 内,可选。 + * @return 返回定时器对象 + * + * + * + */ + export function setInterval(callback: Function, timeout: number, ...args: any[]): Class_Timer; + + /** + * + * @brief 清除指定的定时器 + * @param t 指定要清除的定时器 + * + * + * + */ + export function clearInterval(t: any): void; + + /** + * + * @brief 每间隔指定的时间后调用函数,这是个高精度定时器,会主动打断正在运行的 JavaScript 脚本执行定时器 + * 由于 setHrInterval 的定时器会中断正在运行的代码执行回调,因此不要在回调函数内修改可能影响其它模块的数据,或者在回调中调用任何标记为 async 的 api 函数,否则将会产生不可预知的结果。例如: + * ```JavaScript + * var timers = require('timers'); + * + * var cnt = 0; + * timers.setHrInterval(() => { + * cnt++; + * }, 100); + * + * while (cnt < 10); + * + * console.error("===============================> done"); + * ``` + * 这段代码中,第 8 行的循环并不会因为 cnt 的改变而结束,因为 JavaScript 在优化代码时会认定在这个循环过程中 cnt 不会被改变。 + * @param callback 指定回调函数 + * @param timeout 指定间隔的时间,以毫秒为单位。超过 2^31 的话,立即执行。 + * @param args 额外的参数,传入到指定的 callback 内,可选。 + * @return 返回定时器对象 + * + * + * + */ + export function setHrInterval(callback: Function, timeout: number, ...args: any[]): Class_Timer; + + /** + * + * @brief 清除指定的定时器 + * @param t 指定要清除的定时器 + * + * + * + */ + export function clearHrInterval(t: any): void; + + /** + * + * @brief 下一个空闲时间立即执行回调函数 + * @param callback 指定回调函数 + * @param args 额外的参数,传入到指定的 callback 内,可选。 + * @return 返回定时器对象 + * + * + * + */ + export function setImmediate(callback: Function, ...args: any[]): Class_Timer; + + /** + * + * @brief 清除指定的定时器 + * @param t 指定要清除的定时器 + * + * + * + */ + export function clearImmediate(t: any): void; + + /** + * + * @brief 强制要求进行垃圾回收 + * + * + */ + export function GC(): void; + + /** + * + * @brief 进入交互模式,可以交互执行内部命令和代码,仅在启动 js 可以引用 + * + * 参数 cmd 格式如下: + * ```JavaScript + * [ + * { + * cmd: ".test", + * help: "this is a test", + * exec: function(argv) { + * console.log(argv); + * } + * }, + * { + * cmd: ".test1", + * help: "this is an other test", + * exec: function(argv) { + * console.log(argv); + * } + * } + * ] + * ``` + * @param cmds 补充命令 + * + * + * + */ + export function repl(cmds?: any[]/** = v8::Array::New(isolate)*/): void; + + /** + * + * @brief 进入交互模式,可以交互执行内部命令和代码,仅在启动 js 可以引用 + * + * 同一时刻只允许一个 Stream repl,新建一个 Stream repl 时,前一个 repl 将被关闭。 + * + * 参数 cmd 格式如下: + * ```JavaScript + * [ + * { + * cmd: ".test", + * help: "this is a test", + * exec: function(argv) { + * console.log(argv); + * } + * }, + * { + * cmd: ".test1", + * help: "this is an other test", + * exec: function(argv) { + * console.log(argv); + * } + * } + * ] + * ``` + * @param out 输入输出流对象,通常为网络连接 + * @param cmds 补充命令 + * + * + * + */ + export function repl(out: Class_Stream, cmds?: any[]/** = v8::Array::New(isolate)*/): void; + + } /** end of `module global` */ + export = global +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/gui.d.ts b/types/fibjs/declare/gui.d.ts new file mode 100644 index 0000000000..cacc474dd4 --- /dev/null +++ b/types/fibjs/declare/gui.d.ts @@ -0,0 +1,304 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief gui 模块 + * @detail 使用方法:,```JavaScript,var gui = require('gui');,``` + */ +declare module "gui" { + + + module gui { + + /** + * + * @brief WebView ie 模拟版本,指定 ie7 + * + * + */ + export const IE7 = 7000; + + /** + * + * @brief WebView ie 模拟版本,指定 ie8 + * + * + */ + export const IE8 = 8000; + + /** + * + * @brief WebView ie 模拟版本,指定 ie9 + * + * + */ + export const IE9 = 9000; + + /** + * + * @brief WebView ie 模拟版本,指定 ie10 + * + * + */ + export const IE10 = 10000; + + /** + * + * @brief WebView ie 模拟版本,指定 ie11 + * + * + */ + export const IE11 = 11000; + + /** + * + * @brief WebView ie 模拟版本,指定 edge + * + * + */ + export const EDGE = 11001; + + + + + + /** + * + * 设置 WebView 内 ie 最高模拟版本,当系统 ie 版本低于此版本时,将模拟系统安装版本 + * @param ver 指定 ie 模拟版本 + * + * + * + */ + export function setVersion(ver: number): void; + + /** + * + * @brief 打开一个窗口并访问指定网址 + * + * 支持以下参数: + * ```JavaScript + * { + * "left": 100, // 窗口左上角 x,缺省系统自动设定 + * "right": 100, // 窗口左上角 y,缺省系统自动设定 + * "width": 100, // 窗口宽度,缺省系统自动设定 + * "height": 100, // 窗口高度,缺省系统自动设定 + * "border": true, // 是否有边框,缺省有边框 + * "caption": true, // 是否有标题栏,缺省有标题栏 + * "resizable": true, // 是否可改变尺寸,缺省可以改变 + * "maximize": false, // 是否最大化显示,缺省不最大化 + * "visible": true, // 是否显示,缺省显示 + * "debug": true // 是否输出 WebView 内的错误和 console 信息,缺省显示 + * } + * ``` + * 当设定 width 和 height,而未设定 left 或 right 时,窗口将自动居中 + * @param url 指定的网址,,可以使用 fs:path 访问本地文件系统 + * @param opt 打开窗口参数 + * @return 返回打开的窗口对象 + * + * + * + */ + export function open(url: string, opt?: Object/** = v8::Object::New(isolate)*/): Class_WebView; + + } /** end of `module gui` */ + export = gui +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/hash.d.ts b/types/fibjs/declare/hash.d.ts new file mode 100644 index 0000000000..4058086545 --- /dev/null +++ b/types/fibjs/declare/hash.d.ts @@ -0,0 +1,522 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 信息摘要计算模块,可用于计算信息摘要和摘要签名 + * @detail + */ +declare module "hash" { + + + module hash { + + /** + * + * @brief MD2 信息摘要算法标识常量 + * + * + */ + export const MD2 = 1; + + /** + * + * @brief MD4 信息摘要算法标识常量 + * + * + */ + export const MD4 = 2; + + /** + * + * @brief MD5 信息摘要算法标识常量 + * + * + */ + export const MD5 = 3; + + /** + * + * @brief SHA1 信息摘要算法标识常量 + * + * + */ + export const SHA1 = 4; + + /** + * + * @brief SHA224 信息摘要算法标识常量 + * + * + */ + export const SHA224 = 5; + + /** + * + * @brief SHA256 信息摘要算法标识常量 + * + * + */ + export const SHA256 = 6; + + /** + * + * @brief SHA384 信息摘要算法标识常量 + * + * + */ + export const SHA384 = 7; + + /** + * + * @brief SHA512 信息摘要算法标识常量 + * + * + */ + export const SHA512 = 8; + + /** + * + * @brief RIPEMD160 信息摘要算法标识常量 + * + * + */ + export const RIPEMD160 = 9; + + + + + + /** + * + * @brief 根据指定的算法标识创建一个信息摘要运算对象 + * @param algo 指定摘要运算算法 + * @param data 创建同时更新的二进制数据 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function digest(algo: number, data: Class_Buffer): Class_Digest; + + /** + * + * @brief 根据指定的算法标识创建一个信息摘要运算对象 + * @param algo 指定摘要运算算法 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function digest(algo: number): Class_Digest; + + /** + * + * @brief 创建一个 MD2 信息摘要运算对象 + * @param data 创建同时更新的二进制数据 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function md2(data: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 MD4 信息摘要运算对象 + * @param data 创建同时更新的二进制数据 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function md4(data: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 MD5 信息摘要运算对象 + * @param data 创建同时更新的二进制数据 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function md5(data: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 SHA1 信息摘要运算对象 + * @param data 创建同时更新的二进制数据 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function sha1(data: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 SHA224 信息摘要运算对象 + * @param data 创建同时更新的二进制数据 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function sha224(data: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 SHA256 信息摘要运算对象 + * @param data 创建同时更新的二进制数据 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function sha256(data: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 SHA384 信息摘要运算对象 + * @param data 创建同时更新的二进制数据 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function sha384(data: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 SHA512 信息摘要运算对象 + * @param data 创建同时更新的二进制数据 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function sha512(data: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 RIPEMD160 信息摘要运算对象 + * @param data 创建同时更新的二进制数据 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function ripemd160(data: Class_Buffer): Class_Digest; + + /** + * + * @brief 根据指定的算法标识创建一个信息摘要签名运算对象 + * @param algo 指定摘要运算算法 + * @param key 二进制签名密钥 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function hmac(algo: number, key: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 MD2 信息摘要签名运算对象 + * @param key 二进制签名密钥 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function hmac_md2(key: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 MD4 信息摘要签名运算对象 + * @param key 二进制签名密钥 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function hmac_md4(key: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 MD5 信息摘要签名运算对象 + * @param key 二进制签名密钥 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function hmac_md5(key: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 SHA1 信息摘要签名运算对象 + * @param key 二进制签名密钥 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function hmac_sha1(key: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 SHA224 信息摘要签名运算对象 + * @param key 二进制签名密钥 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function hmac_sha224(key: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 SHA256 信息摘要签名运算对象 + * @param key 二进制签名密钥 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function hmac_sha256(key: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 SHA384 信息摘要签名运算对象 + * @param key 二进制签名密钥 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function hmac_sha384(key: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 SHA512 信息摘要签名运算对象 + * @param key 二进制签名密钥 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function hmac_sha512(key: Class_Buffer): Class_Digest; + + /** + * + * @brief 创建一个 RIPEMD160 信息摘要签名运算对象 + * @param key 二进制签名密钥 + * @return 返回构造的信息摘要对象 + * + * + * + */ + export function hmac_ripemd160(key: Class_Buffer): Class_Digest; + + } /** end of `module hash` */ + export = hash +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/hex.d.ts b/types/fibjs/declare/hex.d.ts new file mode 100644 index 0000000000..b05e3cf7bb --- /dev/null +++ b/types/fibjs/declare/hex.d.ts @@ -0,0 +1,239 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief hex 编码与解码模块 + * @detail 引用方式:,```JavaScript,var encoding = require('encoding');,var hex = encoding.hex;,```,或者,```JavaScript,var hex = require('hex');,``` + */ +declare module "hex" { + + + module hex { + + + + + + /** + * + * @brief 以 hex 方式编码数据 + * @param data 要编码的数据 + * @return 返回编码的字符串 + * + * + * + */ + export function encode(data: Class_Buffer): string; + + /** + * + * @brief 以 hex 方式解码字符串为二进制数据 + * @param data 要解码的字符串 + * @return 返回解码的二进制数据 + * + * + * + */ + export function decode(data: string): Class_Buffer; + + } /** end of `module hex` */ + export = hex +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/http.d.ts b/types/fibjs/declare/http.d.ts new file mode 100644 index 0000000000..d5080f12bb --- /dev/null +++ b/types/fibjs/declare/http.d.ts @@ -0,0 +1,441 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 超文本传输协议模块,用以支持 http 协议处理 + * @detail + */ +declare module "http" { + + + module http { + + + + /** + * + * @brief 创建一个 http 请求对象,参见 HttpRequest + * + * + */ + export class HttpRequest extends Class_HttpRequest {} + + + /** + * + * @brief 创建一个 http 响应对象,参见 HttpResponse + * + * + */ + export class HttpResponse extends Class_HttpResponse {} + + + /** + * + * @brief 创建一个 http cookie 对象,参见 HttpCookie + * + * + */ + export class HttpCookie extends Class_HttpCookie {} + + + /** + * + * @brief 创建一个 http 服务器,参见 HttpServer + * + * + */ + export class HttpServer extends Class_HttpServer {} + + + /** + * + * @brief 创建一个 http 客户端,参见 HttpClient + * + * + */ + export class HttpClient extends Class_HttpClient {} + + + /** + * + * @brief 创建一个 https 服务器,参见 HttpsServer + * + * + */ + export class HttpsServer extends Class_HttpsServer {} + + + /** + * + * @brief 创建一个 http 协议处理器对象,参见 HttpHandler + * + * + */ + export class HttpHandler extends Class_HttpHandler {} + + + + + /** + * + * @brief 创建一个 http 静态文件处理器,用以用静态文件响应 http 消息 + * + * fileHandler 支持 gzip 预压缩,当请求接受 gzip 编码,且相同路径下 filename.ext.gz 文件存在时,将直接返回此文件, + * 从而避免重复压缩带来服务器负载。 + * @param root 文件根路径 + * @param mimes 扩展 mime 设置 + * @param autoIndex 是否支持浏览目录文件,缺省为 false,不支持 + * @return 返回一个静态文件处理器用于处理 http 消息 + * + * + * + */ + export function fileHandler(root: string, mimes?: Object/** = v8::Object::New(isolate)*/, autoIndex?: boolean/** = false*/): Class_Handler; + + /** + * + * @brief 发送 http 请求到指定的流对象,并返回结果 + * @param conn 指定处理请求的流对象 + * @param req 要发送的 HttpRequest 对象 + * @return 返回服务器响应 + * + * + * @async + */ + export function request(conn: Class_Stream, req: Class_HttpRequest): Class_HttpResponse; + + /** + * + * @brief 请求指定的 url,并返回结果 + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param method 指定 http 请求方法:GET, POST 等 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + export function request(method: string, url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + /** + * + * @brief 用 GET 方法请求指定的 url,并返回结果,等同于 request("GET", ...) + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + export function get(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + /** + * + * @brief 用 POST 方法请求指定的 url,并返回结果,等同于 request("POST", ...) + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + export function post(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + /** + * + * @brief 用 DELETE 方法请求指定的 url,并返回结果,等同于 request("DELETE", ...) + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + export function del(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + /** + * + * @brief 用 PUT 方法请求指定的 url,并返回结果,等同于 request("PUT", ...) + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + export function put(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + /** + * + * @brief 用 PATCH 方法请求指定的 url,并返回结果,等同于 request("PATCH", ...) + * opts 包含请求的附加选项,支持的内容如下: + * ```JavaScript + * { + * "query": {}, + * "body": SeekedStream | Buffer | String | {}, + * "json": {}, + * "headers": {} + * } + * ``` + * 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息 + * @param url 指定 url,必须是包含主机的完整 url + * @param opts 指定附加信息 + * @return 返回服务器响应 + * + * + * @async + */ + export function patch(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse; + + } /** end of `module http` */ + export = http +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/iconv.d.ts b/types/fibjs/declare/iconv.d.ts new file mode 100644 index 0000000000..aa431209d3 --- /dev/null +++ b/types/fibjs/declare/iconv.d.ts @@ -0,0 +1,252 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief iconv 编码与解码模块 + * @detail 引用方式:,```JavaScript,var encoding = require('encoding');,var iconv = encoding.iconv;,```,或者,```JavaScript,var iconv = require('iconv');,``` + */ +declare module "iconv" { + + + module iconv { + + + + + + /** + * + * @brief 用 iconv 将文本转换为二进制数据 + * @param charset 指定字符集 + * @param data 要转换的文本 + * @return 返回解码的二进制数据 + * + * + * + */ + export function encode(charset: string, data: string): Class_Buffer; + + /** + * + * @brief 用 iconv 将 Buffer 内容转换为文本 + * @param charset 指定字符集 + * @param data 要转换的二进制数据 + * @return 返回编码的字符串 + * + * + * + */ + export function decode(charset: string, data: Class_Buffer): string; + + /** + * + * @brief 检测字符集是否被支持 + * @param charset 指定字符集 + * @return 返回是否支持该字符集 + * + * + * + */ + export function isEncoding(charset: string): boolean; + + } /** end of `module iconv` */ + export = iconv +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/index.d.ts b/types/fibjs/declare/index.d.ts new file mode 100644 index 0000000000..949a96997d --- /dev/null +++ b/types/fibjs/declare/index.d.ts @@ -0,0 +1,116 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// + +import _Global from 'global'; +import _Process from 'process'; + +// declare const process: typeof _Process; +// declare const global: typeof _Global; +// declare const __filename: string; +// declare const __dirname: string; +// declare const require: typeof _Global.require; + +type GlobalExportsType = any; +interface ModuleType { + exports: GlobalExportsType; +} + +type O_Process = typeof _Process +interface RealProcess extends O_Process { + env: { + [key: string]: string; + } +} + +declare global { + var exports: GlobalExportsType; + const module: ModuleType; + const __filename: string; + const __dirname: string; + const process: RealProcess; + const global: typeof _Global; + + + const Buffer: typeof Class_Buffer; + const Int64: typeof Class_Int64; + /** const console: console; */ + /** const process: process; */ + const Master: typeof Class_Worker; + /** const global: Object; */ + /** const run: null; */ + const require: typeof _Global.require + /** const setTimeout: Timer; */ + /** const clearTimeout: null; */ + /** const setInterval: Timer; */ + /** const clearInterval: null; */ + const setHrInterval: typeof _Global.setHrInterval + const clearHrInterval: typeof _Global.clearHrInterval + /** const setImmediate: Timer; */ + /** const clearImmediate: null; */ + const GC: typeof _Global.GC + const repl: typeof _Global.repl +} + + diff --git a/types/fibjs/declare/io.d.ts b/types/fibjs/declare/io.d.ts new file mode 100644 index 0000000000..e0886c95ef --- /dev/null +++ b/types/fibjs/declare/io.d.ts @@ -0,0 +1,259 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 输入输出处理模块 + * @detail 使用方法:,```JavaScript,var io = require('io');,``` + */ +declare module "io" { + + + module io { + + + + /** + * + * @brief 创建一个内存流对象,参见 MemoryStream + * + * + */ + export class MemoryStream extends Class_MemoryStream {} + + + /** + * + * @brief 创建一个缓存流读取对象,参见 BufferedStream + * + * + */ + export class BufferedStream extends Class_BufferedStream {} + + + + + /** + * + * @brief 复制流数据到目标流中 + * @param from 源流对象 + * @param to 目标流对象 + * @param bytes 复制的字节数 + * @return 返回复制的字节数 + * + * + * @async + */ + export function copyStream(from: Class_Stream, to: Class_Stream, bytes?: number/** = -1*/): number; + + /** + * + * @brief 双向复制流数据,直到流中无数据,或者流被关闭 + * @param stm1 流对象一 + * @param stm2 流对象二 + * + * + * @async + */ + export function bridge(stm1: Class_Stream, stm2: Class_Stream): void; + + } /** end of `module io` */ + export = io +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/json.d.ts b/types/fibjs/declare/json.d.ts new file mode 100644 index 0000000000..0dfba0a3d5 --- /dev/null +++ b/types/fibjs/declare/json.d.ts @@ -0,0 +1,239 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief json 编码与解码模块 + * @detail 引用方式:,```JavaScript,var encoding = require('encoding');,var json = encoding.json;,```,或者,```JavaScript,var json = require('json');,``` + */ +declare module "json" { + + + module json { + + + + + + /** + * + * @brief 以 json 格式编码变量 + * @param data 要编码的变量 + * @return 返回编码的字符串 + * + * + * + */ + export function encode(data: any): string; + + /** + * + * @brief 以 json 方式解码字符串为一个变量 + * @param data 要解码的字符串 + * @return 返回解码的变量 + * + * + * + */ + export function decode(data: string): any; + + } /** end of `module json` */ + export = json +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/mq.d.ts b/types/fibjs/declare/mq.d.ts new file mode 100644 index 0000000000..21e4a5a25e --- /dev/null +++ b/types/fibjs/declare/mq.d.ts @@ -0,0 +1,307 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 消息队列模块 + * @detail + */ +declare module "mq" { + + + module mq { + + + + /** + * + * @brief 创建一个消息对象,参见 Message + * + * + */ + export class Message extends Class_Message {} + + + /** + * + * @brief 创建一个 http 协议处理器对象,参见 HttpHandler + * + * + */ + export class HttpHandler extends Class_HttpHandler {} + + + /** + * + * @brief 创建一个消息处理器对象,传递值内置处理器则直接返回 + * + * hdlr 接受内置消息处理器,处理函数,链式处理数组,路由对象: + * - Function javascript 函数,将使用此函数进行处理 + * - Handler 内置处理器,将使用此处理器进行处理 + * - 链式处理数组,等同于返回 new mq.Chain(hdlr),参见 Chain + * - 路由对象,等同于返回 new mq.Routing(hdlr),参见 Routing + * + * 消息处理函数语法如下: + * ```JavaScript + * function func(v){ + * } + * ``` + * 参数 v 为正在处理的消息,返回结果允许有四种: + * - Function javascript 函数,将使用此函数进行下一阶段处理 + * - Handler 内置处理器,将使用此处理器进行下一阶段处理 + * - 链式处理数组,等同于 new mq.Chain(v),参见 Chain + * - 路由对象,等同于 new mq.Routing(v),参见 Routing + * + * 无返回或者其他的返回结果将结束消息处理。 + * @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象 + * @return 返回封装了处理函数的处理器 + * + * + * + */ + export class Handler extends Class_Handler {} + + + /** + * + * @brief 创建一个消息处理器链处理对象,参见 Chain + * + * + */ + export class Chain extends Class_Chain {} + + + /** + * + * @brief 创建一个消息处理器路由对象,参见 Routing + * + * + */ + export class Routing extends Class_Routing {} + + + + + /** + * + * @brief 创建一个空处理器对象,次处理对象不做任何处理直接返回 + * @return 返回空处理函数 + * + * + * + */ + export function nullHandler(): Class_Handler; + + /** + * + * @brief 使用给定的处理器处理一个消息或对象 + * + * 不同于处理器的 invoke 方法,此方法将循环调用每个处理器的返回处理器,直到处理器返回 null 为止。 + * @param hdlr 指定使用的处理器 + * @param v 指定要处理的消息或对象 + * + * + * @async + */ + export function invoke(hdlr: Class_Handler, v: Class__object): void; + + } /** end of `module mq` */ + export = mq +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/net.d.ts b/types/fibjs/declare/net.d.ts new file mode 100644 index 0000000000..dcf90e72eb --- /dev/null +++ b/types/fibjs/declare/net.d.ts @@ -0,0 +1,396 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 网络访问模块 + * @detail 基础模块。可用于创建和操作网络资源,引用方式:,```JavaScript,var net = require('net');,``` + */ +declare module "net" { + + + module net { + + /** + * + * @brief 地址集常量,指定 ipv4 + * + * + */ + export const AF_INET = 2; + + /** + * + * @brief 地址集常量,指定 ipv6 + * + * + */ + export const AF_INET6 = 10; + + /** + * + * @brief 协议族常量,指定 tcp + * + * + */ + export const SOCK_STREAM = 1; + + /** + * + * @brief 协议族常量,指定 udp + * + * + */ + export const SOCK_DGRAM = 2; + + + + /** + * + * @brief 创建一个 Socket 对象,参见 Socket + * + * + */ + export class Socket extends Class_Socket {} + + + /** + * + * @brief 创建一个 Smtp 对象,参见 Smtp + * + * + */ + export class Smtp extends Class_Smtp {} + + + /** + * + * @brief 创建一个 TcpServer 对象,参见 TcpServer + * + * + */ + export class TcpServer extends Class_TcpServer {} + + + /** + * + * @brief 创建一个 UrlObject 对象,参见 UrlObject + * + * + */ + export class UrlObject extends Class_UrlObject {} + + + + + /** + * + * @brief 查询当前运行环境网络信息 + * @return 返回网卡信息 + * + * + * + */ + export function info(): Object; + + /** + * + * @brief 查询给定的主机名的地址 + * @param name 指定主机名 + * @param family 指定查询返回类型,缺省为 AF_INET + * @return 返回查询的 ip 字符串 + * + * + * @async + */ + export function resolve(name: string, family?: number/** = undefined*/): string; + + /** + * + * @brief 快速查询的主机地址,等效与 resolve(name) + * @param name 指定主机名 + * @return 返回查询的 ip 字符串 + * + * + * @async + */ + export function ip(name: string): string; + + /** + * + * @brief 快速查询的主机 ipv6 地址,等效与 resolve(name, net.AF_INET6) + * @param name 指定主机名 + * @return 返回查询的 ipv6 字符串 + * + * + * @async + */ + export function ipv6(name: string): string; + + /** + * + * @brief 创建一个 Socket 或 SslSocket 对象并建立连接 + * @param url 指定连接的协议,可以是:tcp://host:port 或者 ssl://host:port + * @param timeout 指定超时时间,单位是毫秒,默认为0 + * @return 返回连接成功的 Socket 或者 SslSocket 对象 + * + * + * @async + */ + export function connect(url: string, timeout?: number/** = 0*/): Class_Stream; + + /** + * + * @brief 创建一个 Smtp 对象并建立连接,参见 Smtp + * @param url 指定连接的协议,可以是:tcp://host:port 或者 ssl://host:port + * @param timeout 指定超时时间,单位是毫秒,默认为0 + * @return 返回连接成功的 Smtp 对象 + * + * + * @async + */ + export function openSmtp(url: string, timeout?: number/** = 0*/): Class_Smtp; + + /** + * + * @brief 查询当前系统异步网络引擎 + * @return 返回网络引擎名称 + * + * + * + */ + export function backend(): string; + + /** + * + * @brief 检测输入是否是 IP 地址 + * @param ip 指定要检测的字符串 + * @return 非合法的 IP 地址,返回 0, 如果是 IPv4 则返回 4,如果是 IPv6 则返回 6 + * + * + * + */ + export function isIP(ip?: string/** = ""*/): number; + + /** + * + * @brief 检测输入是否是 IPv4 地址 + * @param ip 指定要检测的字符串 + * @return 如果是 IPv4 则返回 true.否则返回 false + * + * + * + */ + export function isIPv4(ip?: string/** = ""*/): boolean; + + /** + * + * @brief 检测输入是否是 IPv6 地址 + * @param ip 指定要检测的字符串 + * @return 如果是 IPv6 则返回 true.否则返回 false + * + * + * + */ + export function isIPv6(ip?: string/** = ""*/): boolean; + + } /** end of `module net` */ + export = net +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/object.d.ts b/types/fibjs/declare/object.d.ts new file mode 100644 index 0000000000..c6f46e8ec9 --- /dev/null +++ b/types/fibjs/declare/object.d.ts @@ -0,0 +1,54 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/** module Or Internal Object */ +/** + * @brief 基础对象,所有对象均继承于此 + * @detail + */ + +declare class Class__object { + + + + /** + * + * @brief 返回对象的字符串表示,一般返回 "[Native Object]",对象可以根据自己的特性重新实现 + * @return 返回对象的字符串表示 + * + * + * + */ + toString(): string; + + /** + * + * @brief 返回对象的 JSON 格式表示,一般返回对象定义的可读属性集合 + * @param key 未使用 + * @return 返回包含可 JSON 序列化的值 + * + * + * + */ + toJSON(key?: string/** = ""*/): any; + +} /** endof class */ + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/os.d.ts b/types/fibjs/declare/os.d.ts new file mode 100644 index 0000000000..bf8244203e --- /dev/null +++ b/types/fibjs/declare/os.d.ts @@ -0,0 +1,457 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 操作系统与文件系统处理模块 + * @detail 使用方法:,```JavaScript,var os = require('os');,``` + */ +declare module "os" { + + + module os { + + + + /** + * + * @brief Service 构造函数,参见 Service + * + * + */ + export class Service extends Class_Service {} + + + + + /** + * + * @brief 查询当前运行环境主机名 + * @return 返回主机名 + * + * + * + */ + export function hostname(): string; + + /** + * + * @brief 查询当前 CPU 的字节顺序 + * @return 返回字节顺序 + * + * + * + */ + export function endianness(): string; + + /** + * + * @brief 查询当前运行环境操作系统名称 + * @return 返回系统名称 + * + * + * + */ + export function type(): string; + + /** + * + * @brief 查询当前运行环境操作系统版本 + * @return 返回版本信息 + * + * + * + */ + export function release(): string; + + /** + * + * @brief 查询当前用户目录 + * @return 返回目录字符串 + * + * + * + */ + export function homedir(): string; + + /** + * + * @brief 查询当前 cpu 环境 + * @return 返回 cpu 类型,可能的结果为 'amd64', 'arm', 'arm64', 'ia32' + * + * + * + */ + export function arch(): string; + + /** + * + * @brief 查询运行环境运行时间,以秒为单位 + * @return 返回表示时间的数值 + * + * + * + */ + export function uptime(): number; + + /** + * + * @brief 查询运行环境 1分钟,5分钟,15分钟平均负载 + * @return 返回包含三个负载数据的数组 + * + * + * + */ + export function loadavg(): any[]; + + /** + * + * @brief 查询运行环境总内存,以字节为单位 + * @return 返回内存数据 + * + * + * + */ + export function totalmem(): number; + + /** + * + * @brief 查询运行环境可用内存,以字节为单位 + * @return 返回内存数据 + * + * + * + */ + export function freemem(): number; + + /** + * + * @brief 查询当前运行环境 cpu 个数和参数 + * @return 返回包含 cpu 参数的数组,每一项对应一个 cpu + * + * + * + */ + export function cpus(): any[]; + + /** + * + * @brief 查询当前运行环境 cpu 个数 + * @return 返回 cpu 个数 + * + * + * + */ + export function cpuNumbers(): number; + + /** + * + * @brief 查询当前运行环境临时文件目录 + * @return 返回临时文件目录 + * + * + * + */ + export function tmpdir(): string; + + /** + * + * @brief 返回当前有效执行用户信息 + * @param options 用于解释结果字符串的字符编码 + * @return 当前有效执行用户信息 + * + * + * + */ + export function userInfo(options?: Object/** = v8::Object::New(isolate)*/): Object; + + /** + * + * @brief 查询当前运行环境网络信息 + * @return 返回网卡信息 + * + * + * + */ + export function networkInterfaces(): Object; + + /** + * + * @brief 查询当前主机的打印机信息 + * @return 返回打印机信息 + * + * + * + */ + export function printerInfo(): any[]; + + /** + * + * @brief 创建一个打印机输出对象 + * @param name 打印机名称 + * @return 返回打印机输出对象 + * + * + * @async + */ + export function openPrinter(name: string): Class_BufferedStream; + + /** + * + * @brief 查询当前平台名称 + * @return 返回平台名称,可能的结果为 'darwin', 'freebsd', 'linux', 或 'win32' + * + * + * + */ + export function platform(): string; + + /** + * + * @brief 解析时间字符串或查询运行环境当前时间 + * @param tmString 时间字符串,缺省则查询当前时间 + * @return 返回 javascript Date 对象 + * + * + * + */ + export function time(tmString?: string/** = ""*/): Date; + + /** + * + * @brief 时间计算函数,根据 part 指定计算时间 + * @param d 指定用于计算 Date 对象 + * @param num 指定运算的数值 + * @param part 指定运算的时间部位,接收值为:"year", "month", "day", "hour", "minute", "second" + * @return 返回 javascript Date 对象 + * + * + * + */ + export function dateAdd(d: Date, num: number, part: string): Date; + + /** + * + * @brief 查询当前进程内存使用报告 + * + * 内存报告生成类似以下结果: + * ```JavaScript + * { + * "rss": 8622080, + * "heapTotal": 4083456, + * "heapUsed": 1621800, + * "nativeObjects": 122 + * } + * ``` + * 其中: + * - rss 返回进程当前占用物理内存大小 + * - heapTotal 返回 v8 引擎堆内存大小 + * - heapUsed 返回 v8 引擎正在使用堆内存大小 + * - nativeObjects 返回当前有效内置对象数 + * @return 返回包含内存报告 + * + * + * + */ + export function memoryUsage(): Object; + + } /** end of `module os` */ + export = os +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/path.d.ts b/types/fibjs/declare/path.d.ts new file mode 100644 index 0000000000..ac33e6db2c --- /dev/null +++ b/types/fibjs/declare/path.d.ts @@ -0,0 +1,326 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 文件路径处理模块 + * @detail 引用方法:,```JavaScript,var path = require('path');,``` + */ +declare module "path" { + + + module path { + + + + + + /** + * + * @brief 标准化路径,处理路径中父目录等信息 + * + * @param path 给定的未处理的路径 + * @return 返回经过处理的路径 + * + * + * + */ + export function normalize(path: string): string; + + /** + * + * @brief 查询路径中的文件名称,若指定扩展名,则自动取消匹配的扩展名 + * + * @param path 给定查询的路径 + * @param ext 指定扩展名,若文件名中有符合条件的扩展名,将自动取消 + * @return 返回文件名称 + * + * + * + */ + export function basename(path: string, ext?: string/** = ""*/): string; + + /** + * + * @brief 查询路径中的文件扩展名 + * + * @param path 给定查询的路径 + * @return 返回得到的扩展名 + * + * + * + */ + export function extname(path: string): string; + + /** + * + * @brief 查询路径中的目录路径 + * + * @param path 给定查询的路径 + * @return 返回得到的目录的路径 + * + * + * + */ + export function dirname(path: string): string; + + /** + * + * @brief 转换给定路径为全路径 + * + * @param path 给定转换的路径 + * @return 返回转换的全路径 + * + * + * + */ + export function fullpath(path: string): string; + + /** + * + * @brief 识别给定的路径是否是绝对路径 + * + * @param path 给定需要识别的路径 + * @return 是绝对路径则返回 true + * + * + * + */ + export function isAbsolute(path: string): boolean; + + /** + * + * @brief 合并一系列路径成为一个单一路径 + * + * @param ps 一个或多个相关的路径 + * @return 返回得到的新路径 + * + * + * + */ + export function join(...ps: any[]): string; + + /** + * + * @brief 合并一系列路径成为一个绝对路径 + * + * @param ps 一个或多个相关的路径 + * @return 返回得到的新路径 + * + * + * + */ + export function resolve(...ps: any[]): string; + + /** + * + * @brief 转换成 namespace-prefixed 路径。只在 windows 有效,其他系统直接返回。 + * see: https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces + * @param path 给定的路径。 + * @return 返回得到的新路径 + * + * + * + */ + export function toNamespacedPath(path?: any/** = v8::Undefined(isolate)*/): any; + + } /** end of `module path` */ + export = path +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/path_posix.d.ts b/types/fibjs/declare/path_posix.d.ts new file mode 100644 index 0000000000..afc2cf132b --- /dev/null +++ b/types/fibjs/declare/path_posix.d.ts @@ -0,0 +1,326 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 文件路径处理模块 + * @detail 引用方法:,```JavaScript,var path = require('path').posix;,``` + */ +declare module "path_posix" { + + + module path_posix { + + + + + + /** + * + * @brief 标准化路径,处理路径中父目录等信息 + * + * @param path 给定的未处理的路径 + * @return 返回经过处理的路径 + * + * + * + */ + export function normalize(path: string): string; + + /** + * + * @brief 查询路径中的文件名称,若指定扩展名,则自动取消匹配的扩展名 + * + * @param path 给定查询的路径 + * @param ext 指定扩展名,若文件名中有符合条件的扩展名,将自动取消 + * @return 返回文件名称 + * + * + * + */ + export function basename(path: string, ext?: string/** = ""*/): string; + + /** + * + * @brief 查询路径中的文件扩展名 + * + * @param path 给定查询的路径 + * @return 返回得到的扩展名 + * + * + * + */ + export function extname(path: string): string; + + /** + * + * @brief 查询路径中的目录路径 + * + * @param path 给定查询的路径 + * @return 返回得到的目录的路径 + * + * + * + */ + export function dirname(path: string): string; + + /** + * + * @brief 转换给定路径为全路径 + * + * @param path 给定转换的路径 + * @return 返回转换的全路径 + * + * + * + */ + export function fullpath(path: string): string; + + /** + * + * @brief 识别给定的路径是否是绝对路径 + * + * @param path 给定需要识别的路径 + * @return 是绝对路径则返回 true + * + * + * + */ + export function isAbsolute(path: string): boolean; + + /** + * + * @brief 合并一系列路径成为一个单一路径 + * + * @param ps 一个或多个相关的路径 + * @return 返回得到的新路径 + * + * + * + */ + export function join(...ps: any[]): string; + + /** + * + * @brief 合并一系列路径成为一个绝对路径 + * + * @param ps 一个或多个相关的路径 + * @return 返回得到的新路径 + * + * + * + */ + export function resolve(...ps: any[]): string; + + /** + * + * @brief 转换成 namespace-prefixed 路径。只在 windows 有效,其他系统直接返回。 + * see: https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces + * @param path 给定的路径。 + * @return 返回得到的新路径 + * + * + * + */ + export function toNamespacedPath(path?: any/** = v8::Undefined(isolate)*/): any; + + } /** end of `module path_posix` */ + export = path_posix +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/path_win32.d.ts b/types/fibjs/declare/path_win32.d.ts new file mode 100644 index 0000000000..8cb0812a0e --- /dev/null +++ b/types/fibjs/declare/path_win32.d.ts @@ -0,0 +1,326 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 文件路径处理模块 + * @detail 引用方法:,```JavaScript,var path = require('path').win32;,``` + */ +declare module "path_win32" { + + + module path_win32 { + + + + + + /** + * + * @brief 标准化路径,处理路径中父目录等信息 + * + * @param path 给定的未处理的路径 + * @return 返回经过处理的路径 + * + * + * + */ + export function normalize(path: string): string; + + /** + * + * @brief 查询路径中的文件名称,若指定扩展名,则自动取消匹配的扩展名 + * + * @param path 给定查询的路径 + * @param ext 指定扩展名,若文件名中有符合条件的扩展名,将自动取消 + * @return 返回文件名称 + * + * + * + */ + export function basename(path: string, ext?: string/** = ""*/): string; + + /** + * + * @brief 查询路径中的文件扩展名 + * + * @param path 给定查询的路径 + * @return 返回得到的扩展名 + * + * + * + */ + export function extname(path: string): string; + + /** + * + * @brief 查询路径中的目录路径 + * + * @param path 给定查询的路径 + * @return 返回得到的目录的路径 + * + * + * + */ + export function dirname(path: string): string; + + /** + * + * @brief 转换给定路径为全路径 + * + * @param path 给定转换的路径 + * @return 返回转换的全路径 + * + * + * + */ + export function fullpath(path: string): string; + + /** + * + * @brief 识别给定的路径是否是绝对路径 + * + * @param path 给定需要识别的路径 + * @return 是绝对路径则返回 true + * + * + * + */ + export function isAbsolute(path: string): boolean; + + /** + * + * @brief 合并一系列路径成为一个单一路径 + * + * @param ps 一个或多个相关的路径 + * @return 返回得到的新路径 + * + * + * + */ + export function join(...ps: any[]): string; + + /** + * + * @brief 合并一系列路径成为一个绝对路径 + * + * @param ps 一个或多个相关的路径 + * @return 返回得到的新路径 + * + * + * + */ + export function resolve(...ps: any[]): string; + + /** + * + * @brief 转换成 namespace-prefixed 路径。只在 windows 有效,其他系统直接返回。 + * see: https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces + * @param path 给定的路径。 + * @return 返回得到的新路径 + * + * + * + */ + export function toNamespacedPath(path?: any/** = v8::Undefined(isolate)*/): any; + + } /** end of `module path_win32` */ + export = path_win32 +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/process.d.ts b/types/fibjs/declare/process.d.ts new file mode 100644 index 0000000000..eebbf49c2c --- /dev/null +++ b/types/fibjs/declare/process.d.ts @@ -0,0 +1,465 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 进程处理模块,用以管理当前进程的资源 + * @detail 引用方法:,```JavaScript,var process = require('process');,```,,## 进程事件,process 模块对象是 EventEmitter 的实例,可以通过注册事件监听器响应进程级别的事件。,,### beforeExit 事件,**当 fibjs 的任务已经为空,并且没有额外的工作被添加进来,事件 `beforeExit` 会被触发**,```JavaScript,process.on('beforeExit', exitCode => {});,```,正常情况下,如果没有额外的工作被添加到任务队列,fibjs 进程会结束。但是如果 `beforeExit` 事件绑定的监听器的回调函数中,启动了一个新的任务,比如开启一个 fiber,那么 fibjs 进程会继续运行。,,process.exitCode 作为唯一的参数值传递给 `beforeExit` 事件监听器的回调函数。如果进程由于显式的原因而将要终止,例如直接调用 process.exit 或抛出未捕获的异常,`beforeExit`事件不会被触发。,,### exit 事件,**当 fibjs 退出时,事件 `exit` 会被触发,一旦所有与 `exit` 事件绑定的监听器执行完成,进程会终止**,```JavaScript,process.on('exit', exitCode => {});,```,`exit` 事件监听器的回调函数,只有一个入参,这个参数的值可以是 process.exitCode 的属性值,或者是调用 process.exit 方法时传入的 `exitCode` 值。,,### Signal 事件,**当 fibjs 进程接收到一个信号时,会触发信号事件,目前支持的信号有 SIGINT 和 SIGTERM。每个事件名称,以信号名称的大写表示 (比如事件'SIGINT' 对应信号 SIGINT)。**,,信号事件不同于其它进程事件,信号事件是抢占的,当信号发生时,无论当前在 io 操作,还是 JavaScript 运算,都会尽快触发相应事件。比如你可以用下面的代码,中断当前应用,并输出运行状态:,```JavaScript,var coroutine = require('coroutine');,,process.on('SIGINT', () => {, coroutine.fibers.forEach(f => console.error("Fiber %d:\n%s", f.id, f.stack));, process.exit();,});,```,信号名称及其意义如下:,* SIGINT:在终端运行时,可以被所有平台支持,通常可以通过 CTRL+C 触发。,* SIGTERM:当进程被 kill 时触发此信号。Windows 下不支持。 + */ +declare module "process" { + + + module process { + + + + + + /** + * + * @brief 改变当前的 umask,Windows 不支持此方法 + * @param mask 指定新的掩码 + * @return 返回之前的 mask + * + * + * + */ + export function umask(mask: number): number; + + /** + * + * @brief 改变当前的 umask,Windows 不支持此方法 + * @param mask 指定新的掩码, 字符串类型八进制(e.g: "0664") + * @return 返回之前的 mask + * + * + * + */ + export function umask(mask: string): number; + + /** + * + * @brief 返回当前的 umask,Windows 不支持此方法 + * @return 返回当前的 mask 值 + * + * + * + */ + export function umask(): number; + + /** + * + * @brief 返回系统高精度时间,此时间与当前时间无关,仅用于高精度计时 + * @param diff 用于比较的初始时间 + * @return 返回计时时间,格式为 [seconds, nanoseconds] + * + * + * + */ + export function hrtime(diff?: any[]/** = v8::Array::New(isolate)*/): any[]; + + /** + * + * @brief 退出当前进程,并返回 exitCode 作为进程结果 + * + * + */ + export function exit(): void; + + /** + * + * @brief 退出当前进程,并返回结果 + * @param code 返回进程结果 + * + * + * + */ + export function exit(code: number): void; + + /** + * + * @brief 返回操作系统当前工作路径 + * @return 返回当前系统路径 + * + * + * + */ + export function cwd(): string; + + /** + * + * @brief 修改操作系统当前工作路径 + * @param directory 指定设定的新路径 + * + * + * + */ + export function chdir(directory: string): void; + + /** + * + * @brief 查询运行环境运行时间,以秒为单位 + * @return 返回表示时间的数值 + * + * + * + */ + export function uptime(): number; + + /** + * + * @brief 查询当前进程内存使用报告 + * + * 内存报告生成类似以下结果: + * ```JavaScript + * { + * "rss": 8622080, + * "heapTotal": 4083456, + * "heapUsed": 1621800 + * } + * ``` + * 其中: + * - rss 返回进程当前占用物理内存大小 + * - heapTotal 返回 v8 引擎堆内存大小 + * - heapUsed 返回 v8 引擎正在使用堆内存大小 + * @return 返回包含内存报告 + * + * + * + */ + export function memoryUsage(): Object; + + /** + * + * @brief 启动一个纤程 + * @param func 制定纤程执行的函数 + * @param args 可变参数序列,此序列会在纤程内传递给函数 + * + * + * + */ + export function nextTick(func: Function, ...args: any[]): void; + + /** + * + * @brief 运行指定的命令行,接管进程输入输出流,并返回进程对象 + * + * opts 支持的选项如下: + * ```JavaScript + * { + * "timeout": 100, // 单位为 ms + * "envs": [] // 进程环境变量 + * } + * ``` + * @param command 指定运行的命令行 + * @param args 指定运行的参数列表 + * @param opts 指定运行的选项 + * @return 返回包含运行结果的进程对象 + * + * + * + */ + export function open(command: string, args: any[], opts?: Object/** = v8::Object::New(isolate)*/): Class_SubProcess; + + /** + * + * @brief 运行指定的命令行,接管进程输入输出流,并返回进程对象 + * + * opts 支持的选项如下: + * ```JavaScript + * { + * "timeout": 100, // 单位为 ms + * "envs": [] // 进程环境变量 + * } + * ``` + * @param command 指定运行的命令行 + * @param opts 指定运行的选项 + * @return 返回包含运行结果的进程对象 + * + * + * + */ + export function open(command: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_SubProcess; + + /** + * + * @brief 运行指定的命令行,并返回进程对象 + * + * opts 支持的选项如下: + * ```JavaScript + * { + * "timeout": 100, // 单位为 ms + * "envs": [] // 进程环境变量 + * } + * ``` + * @param command 指定运行的命令行 + * @param args 指定运行的参数列表 + * @param opts 指定运行的选项 + * @return 返回包含运行结果的进程对象 + * + * + * + */ + export function start(command: string, args: any[], opts?: Object/** = v8::Object::New(isolate)*/): Class_SubProcess; + + /** + * + * @brief 运行指定的命令行,并返回进程对象 + * + * opts 支持的选项如下: + * ```JavaScript + * { + * "timeout": 100, // 单位为 ms + * "envs": [] // 进程环境变量 + * } + * ``` + * @param command 指定运行的命令行 + * @param opts 指定运行的选项 + * @return 返回包含运行结果的进程对象 + * + * + * + */ + export function start(command: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_SubProcess; + + /** + * + * @brief 运行指定的命令行,并返回进程的结束代码 + * + * opts 支持的选项如下: + * ```JavaScript + * { + * "timeout": 100, // 单位为 ms + * "envs": [] // 进程环境变量 + * } + * ``` + * @param command 指定运行的命令行 + * @param args 指定运行的参数列表 + * @param opts 指定运行的选项 + * @return 返回命令的运行结果 + * + * + * + */ + export function run(command: string, args: any[], opts?: Object/** = v8::Object::New(isolate)*/): number; + + /** + * + * @brief 运行指定的命令行,并返回进程的结束代码 + * + * opts 支持的选项如下: + * ```JavaScript + * { + * "timeout": 100, // 单位为 ms + * "envs": [] // 进程环境变量 + * } + * ``` + * @param command 指定运行的命令行 + * @param opts 指定运行的选项 + * @return 返回命令的运行结果 + * + * + * + */ + export function run(command: string, opts?: Object/** = v8::Object::New(isolate)*/): number; + + } /** end of `module process` */ + export = process +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/profiler.d.ts b/types/fibjs/declare/profiler.d.ts new file mode 100644 index 0000000000..e6f7345927 --- /dev/null +++ b/types/fibjs/declare/profiler.d.ts @@ -0,0 +1,440 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 内存 profiler 模块 + * @detail 使用方法:,```JavaScript,var profiler = require('profiler');,``` + */ +declare module "profiler" { + + + module profiler { + + /** + * + * @brief 隐藏节点,当显示给用户时可以被过滤掉 + * + * + */ + export const Node_Hidden = 0; + + /** + * + * @brief 数组 + * + * + */ + export const Node_Array = 1; + + /** + * + * @brief 字符串 + * + * + */ + export const Node_String = 2; + + /** + * + * @brief JS对象(字符串和数组除外) + * + * + */ + export const Node_Object = 3; + + /** + * + * @brief 编译后的代码 + * + * + */ + export const Node_Code = 4; + + /** + * + * @brief 函数闭包 + * + * + */ + export const Node_Closure = 5; + + /** + * + * @brief 正则表达式 + * + * + */ + export const Node_RegExp = 6; + + /** + * + * @brief 堆中排好序的数字 + * + * + */ + export const Node_HeapNumber = 7; + + /** + * + * @brief Native对象(非v8堆上的) + * + * + */ + export const Node_Native = 8; + + /** + * + * @brief Synthetic对象 + * + * + */ + export const Node_Synthetic = 9; + + /** + * + * @brief 拼接的字符串 + * + * + */ + export const Node_ConsString = 10; + + /** + * + * @brief 分割的字符串 + * + * + */ + export const Node_SlicedString = 11; + + /** + * + * @brief 符号(ES6) + * + * + */ + export const Node_Symbol = 12; + + /** + * + * @brief 堆中排好序的SIMD值(ES7) + * + * + */ + export const Node_SimdValue = 13; + + /** + * + * @brief 函数中的变量 + * + * + */ + export const Edge_ContextVariable = 0; + + /** + * + * @brief 数组中的元素 + * + * + */ + export const Edge_Element = 1; + + /** + * + * @brief 有名对象的属性 + * + * + */ + export const Edge_Property = 2; + + /** + * + * @brief JS无法进入的链接 + * + * + */ + export const Edge_Internal = 3; + + /** + * + * @brief 指向需要事先计算出空间大小的节点 + * + * + */ + export const Edge_Hidden = 4; + + /** + * + * @brief 指向无法事先计算出空间大小的节点 + * + * + */ + export const Edge_Shortcut = 5; + + /** + * + * @brief 一个弱引用(被GC忽视) + * + * + */ + export const Edge_Weak = 6; + + + + + + /** + * + * @brief 根据指定名称保存一个堆快照 + * @param fname 堆快照名称 + * + * + * + */ + export function saveSnapshot(fname: string): void; + + /** + * + * @brief 根据指定名称读取一个堆快照 + * @param fname 堆快照名称 + * @return 返回读取到的堆快照 + * + * + * + */ + export function loadSnapshot(fname: string): Class_HeapSnapshot; + + /** + * + * @brief 获取当前时间节点的堆快照,堆快照记录了当前时刻JS堆的状态 + * @return 返回获取到的堆信息快照 + * + * + * + */ + export function takeSnapshot(): Class_HeapSnapshot; + + /** + * + * @brief 执行给定的函数,并对比执行前后 v8 堆的变化 + * @param test 给定要测试的函数 + * @return 返回对比的结果 + * + * + * + */ + export function diff(test: Function): Object; + + /** + * + * @brief 启动一次运行状态采样日志 + * @param fname 给定日志存储文件名 + * @param time 指定采样时间,缺省 1 分钟 + * @param interval 指定间隔时间,缺省 100 毫秒 + * @return 返回采样定时器,可以通过 clear 方法提前停止采样 + * + * + * + */ + export function start(fname: string, time?: number/** = 60000*/, interval?: number/** = 100*/): Class_Timer; + + } /** end of `module profiler` */ + export = profiler +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/punycode.d.ts b/types/fibjs/declare/punycode.d.ts new file mode 100644 index 0000000000..c33938dd48 --- /dev/null +++ b/types/fibjs/declare/punycode.d.ts @@ -0,0 +1,261 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief punycode 国际化域名转换模块 + * @detail Punycode 是由 RFC 3492 定义的主要用于国际化域名的字符编码方案。因为 URL 中主机名限制只能是 ASCII 字符,包括非 ASCII 字符的主机名必须使用 punycode 算法转化为ASCII。,,使用方法:,```JavaScript,var punycode = require('punycode');,``` + */ +declare module "punycode" { + + + module punycode { + + + + + + /** + * + * @brief 将一个 Unicode 字符串转化为等价的只含有 ASCII 字符的 Punycode 字符串 + * @param domain 给定Unicode 字符串 + * @return 返回编码后的只含有 ASCII 字符的 Punycode 字符串 + * + * + * + */ + export function encode(domain: string): string; + + /** + * + * @brief 将一个 Punycode 字符串转化为等价的 Unicode 字符串 + * @param domain 给定Unicode 字符串 + * @return 返回解码后的 Unicode 字符串 + * + * + * + */ + export function decode(domain: string): string; + + /** + * + * @brief 转换一个代表了一个域名的Unicode字符串为一个只含有 ASCII 字符的字符串。只有代表了域名的部分的非 ASCII 字符串会被转换。也就是说,如果你调用了一个已经被转换为ASCII的字符串,也是没有问题的。 + * @param domain 给定Unicode 字符串 + * @return 返回编码后的 ASCII 字符串 + * + * + * + */ + export function toASCII(domain: string): string; + + /** + * + * @brief 转换一个代表了一个域名的Punycode字符串为一个Unicode字符串。只有代表了域名的部分的Punycode字符串会被转换。也就是说,如果你调用了一个已经被转换为Unicode的字符串,也是没有问题的。 + * @param domain 给定 ASCII 字符串 + * @return 返回解码后的 Unicode 字符串 + * + * + * + */ + export function toUnicode(domain: string): string; + + } /** end of `module punycode` */ + export = punycode +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/querystring.d.ts b/types/fibjs/declare/querystring.d.ts new file mode 100644 index 0000000000..c2a9e0284f --- /dev/null +++ b/types/fibjs/declare/querystring.d.ts @@ -0,0 +1,267 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief http query 处理模块 + * @detail 引用方法:,```JavaScript,var querystring = require('querystring');,``` + */ +declare module "querystring" { + + + module querystring { + + + + + + /** + * + * @brief url 部件字符串安全编码 + * @param str 要编码的 url + * @return 返回编码的字符串 + * + * + * + */ + export function escape(str: string): string; + + /** + * + * @brief url 安全字符串解码 + * @param str 要解码的 url + * @return 返回解码的字符串 + * + * + * + */ + export function unescape(str: string): string; + + /** + * + * @brief 解析 query 字符串 + * @param str 要解析的字符串 + * @param sep 解析时使用的分割字符串,缺省为 & + * @param eq 解析时使用的赋值字符串,缺省为 = + * @param opt 解析参数,暂未支持 + * @return 返回解码的对象 + * + * + * + */ + export function parse(str: string, sep?: string/** = "&"*/, eq?: string/** = "="*/, opt?: Object/** = v8::Object::New(isolate)*/): Class_HttpCollection; + + /** + * + * @brief 序列化一个对象为 query 字符串 + * @param obj 要序列化的对象 + * @param sep 序列化时使用的分割字符串,缺省为 & + * @param eq 序列化时使用的赋值字符串,缺省为 = + * @param opt 解析参数,暂未支持 + * @return 返回序列化后的字符串 + * + * + * + */ + export function stringify(obj: Object, sep?: string/** = "&"*/, eq?: string/** = "="*/, opt?: Object/** = v8::Object::New(isolate)*/): string; + + } /** end of `module querystring` */ + export = querystring +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/registry.d.ts b/types/fibjs/declare/registry.d.ts new file mode 100644 index 0000000000..99e9cf7bb7 --- /dev/null +++ b/types/fibjs/declare/registry.d.ts @@ -0,0 +1,386 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief Windows 注册表访问模块 + * @detail 引用方式:,```JavaScript,var registry = require('registry');,var value = registry.get(registry.CLASSES_ROOT, "\node1\node2\value");,``` + */ +declare module "registry" { + + + module registry { + + /** + * + * @brief 注册表根,存储Windows可识别的文件类型的详细列表,以及相关联的程序 + * + * + */ + export const CLASSES_ROOT = 0; + + /** + * + * @brief 注册表根,存储当前用户设置的信息 + * + * + */ + export const CURRENT_USER = 1; + + /** + * + * @brief 注册表根,包括安装在计算机上的硬件和软件的信息 + * + * + */ + export const LOCAL_MACHINE = 2; + + /** + * + * @brief 注册表根,包含使用计算机的用户的信息 + * + * + */ + export const USERS = 3; + + /** + * + * @brief 注册表根,这个分支包含计算机当前的硬件配置信息 + * + * + */ + export const CURRENT_CONFIG = 5; + + /** + * + * @brief 注册表数据类型,字符串 + * + * + */ + export const SZ = 1; + + /** + * + * @brief 注册表数据类型,扩展字符串 + * + * + */ + export const EXPAND_SZ = 2; + + /** + * + * @brief 注册表数据类型,32 位数值 + * + * + */ + export const DWORD = 4; + + /** + * + * @brief 注册表数据类型,64 位数值 + * + * + */ + export const QWORD = 11; + + + + + + /** + * + * @brief 返回指定键值下的所有子健 + * @param root 指定注册表根 + * @param key 指定键值 + * @return 返回该键值下所有子健 + * + * + * + */ + export function listSubKey(root: number, key: string): any[]; + + /** + * + * @brief 返回指定键值下的所有数据的健 + * @param root 指定注册表根 + * @param key 指定键值 + * @return 返回该键值下所有数据的健 + * + * + * + */ + export function listValue(root: number, key: string): any[]; + + /** + * + * @brief 查询指定键值的数值 + * @param root 指定注册表根 + * @param key 指定键值 + * @return 返回指定键值的数值 + * + * + * + */ + export function get(root: number, key: string): any; + + /** + * + * @brief 设置指定键值为数字 + * @param root 指定注册表根 + * @param key 指定键值 + * @param value 指定数字 + * @param type 指定类型,允许的类型为 DWORD 和 QWORD,缺省为 DWORD + * + * + * + */ + export function set(root: number, key: string, value: number, type?: number/** = undefined*/): void; + + /** + * + * @brief 设置指定键值为字符串 + * @param root 指定注册表根 + * @param key 指定键值 + * @param value 指定字符串 + * @param type 指定类型,允许的类型为 SZ 和 EXPAND_SZ,缺省为 SZ + * + * + * + */ + export function set(root: number, key: string, value: string, type?: number/** = undefined*/): void; + + /** + * + * @brief 设置指定键值为多字符串 + * @param root 指定注册表根 + * @param key 指定键值 + * @param value 指定多字符串数组 + * + * + * + */ + export function set(root: number, key: string, value: any[]): void; + + /** + * + * @brief 设置指定键值为二进制 + * @param root 指定注册表根 + * @param key 指定键值 + * @param value 指定二进制数据 + * + * + * + */ + export function set(root: number, key: string, value: Class_Buffer): void; + + /** + * + * @brief 删除指定键值的数值 + * @param root 指定注册表根 + * @param key 指定键值 + * + * + * + */ + export function del(root: number, key: string): void; + + } /** end of `module registry` */ + export = registry +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/ssl.d.ts b/types/fibjs/declare/ssl.d.ts new file mode 100644 index 0000000000..befed4f19a --- /dev/null +++ b/types/fibjs/declare/ssl.d.ts @@ -0,0 +1,376 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief ssl/tls 模块 + * @detail + */ +declare module "ssl" { + + + module ssl { + + /** + * + * @brief 证书验证模式,不验证 + * + * + */ + export const VERIFY_NONE = 0; + + /** + * + * @brief 证书验证模式,可选验证,允许验证不通过 + * + * + */ + export const VERIFY_OPTIONAL = 1; + + /** + * + * @brief 证书验证模式,要求验证,验证不通过则中断 + * + * + */ + export const VERIFY_REQUIRED = 2; + + /** + * + * @brief 证书验证结果,证书超时 + * + * + */ + export const BADCERT_EXPIRED = 1; + + /** + * + * @brief 证书验证结果,证书被撤销 + * + * + */ + export const BADCERT_REVOKED = 2; + + /** + * + * @brief 证书验证结果,证书名错误 + * + * + */ + export const BADCERT_CN_MISMATCH = 4; + + /** + * + * @brief 证书验证结果,证书不可信 + * + * + */ + export const BADCERT_NOT_TRUSTED = 8; + + /** + * + * @brief ssl 协议版本 ssl 3.0 + * + * + */ + export const ssl3 = 0; + + /** + * + * @brief ssl 协议版本 tls 1.0 + * + * + */ + export const tls1 = 1; + + /** + * + * @brief ssl 协议版本 tls 1.1 + * + * + */ + export const tls1_1 = 2; + + /** + * + * @brief ssl 协议版本 tls 1.2 + * + * + */ + export const tls1_2 = 3; + + + + /** + * + * @brief 创建一个 SslSocket 对象,参见 SslSocket + * + * + */ + export class SslSocket extends Class_SslSocket {} + + + /** + * + * @brief 创建一个 SslHandler 对象,参见 SslHandler + * + * + */ + export class SslHandler extends Class_SslHandler {} + + + /** + * + * @brief 创建一个 SslServer 对象,参见 SslServer + * + * + */ + export class SslServer extends Class_SslServer {} + + + + + /** + * + * @brief 创建一个 SslSocket 对象并建立连接 + * @param url 指定连接的协议,可以是:ssl://host:port + * @param timeout 指定超时时间,单位是毫秒,默认为0 + * @return 返回连接成功的 SslSocket 对象 + * + * + * @async + */ + export function connect(url: string, timeout?: number/** = 0*/): Class_Stream; + + /** + * + * @brief 设定缺省客户端证书 + * @param crt X509Cert 证书,用于客户端验证服务器 + * @param key PKey 私钥,用于与客户端会话 + * + * + * + */ + export function setClientCert(crt: Class_X509Cert, key: Class_PKey): void; + + /** + * + * @brief 从文件中加载缺省客户端证书 + * @param crtFile X509Cert 证书文件,用于客户端验证服务器 + * @param keyFile PKey 私钥文件,用于与客户端会话 + * @param password 解密密码 + * + * + * + */ + export function loadClientCertFile(crtFile: string, keyFile: string, password?: string/** = ""*/): void; + + /** + * + * @brief 加载自带的缺省根证书,等同于 ssl.ca.loadRootCerts + * 此证书内容源自:http://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt + * + * + */ + export function loadRootCerts(): void; + + } /** end of `module ssl` */ + export = ssl +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/string_decoder.d.ts b/types/fibjs/declare/string_decoder.d.ts new file mode 100644 index 0000000000..233ab0c76e --- /dev/null +++ b/types/fibjs/declare/string_decoder.d.ts @@ -0,0 +1,226 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 解码 Buffer 到字符串 + * @detail 使用方法:,```JavaScript, const { StringDecoder } = require('string_decoder');, const decoder = new StringDecoder('utf8');,, const cent = Buffer.from([0xC2, 0xA2]);, console.log(decoder.write(cent));,, const euro = Buffer.from([0xE2, 0x82, 0xAC]);, console.log(decoder.write(euro));,``` + */ +declare module "string_decoder" { + + + module string_decoder { + + + + /** + * + * @brief 创建一个解码对象,参见 StringDecoder + * + * + */ + export class StringDecoder extends Class_StringDecoder {} + + + + + } /** end of `module string_decoder` */ + export = string_decoder +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/test.d.ts b/types/fibjs/declare/test.d.ts new file mode 100644 index 0000000000..5c4b539a14 --- /dev/null +++ b/types/fibjs/declare/test.d.ts @@ -0,0 +1,357 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 测试套件模块,用以定义管理测试套件 + * @detail 使用方法 :,,```JavaScript,var test = require('test');,test.setup();,,describe('test', () => {, before(() => {, // setup before the whole test, });,, beforeEach(() => {, // setup before each test, });,, after(() => {, // cleanup after the whole test, });,, afterEach(() => {, // cleanup after each test, });,, it('case', () => {, assert.ok(true);, });,, // ignored test case, xit('case', () => {, assert.ok(true);, });,, // ignored test case, it.skip('case', () => {, assert.ok(true);, });,, // only test case, oit('case', () => {, assert.ok(true);, });,, // only test case, it.only('case', () => {, assert.ok(true);, });,});,,// async function test,describe('test async', () => {,it('pass case', async() => {, assert.ok(true);,});,,it('error case', async() => {, throw new Error('some thing wrong!');,});,});,,// callback function test,// cannot use callback mode in jsc,describe('test callback', () => {,it('pass case', done => {, setTimeout(() => {, assert.ok(true);, done();, }, 0);,});,,it('error case', done => {, setTimeout(() => {, done(new Error('some thing wrong!'));, }, 0);,});,});,,process.exit(-test.run(console.DEBUG));,``` + */ +declare module "test" { + + import consoleNS = require('console') + import assertNS = require('assert') + + module test { + + + + /** + * + * @brief 断言测试模块,如果测试值为假,则报错,报错行为可设定继续运行或者错误抛出 + * + * + */ + + export const assert: typeof assertNS + + + + /** + * + * @brief 定义一个测试模块,可嵌套定义 + * @param name 定义模块名称 + * @param block 模块初始化代码 + * + * + * + */ + export function describe(name: string, block: Function): void; + + /** + * + * @brief 暂停测试的模块定义,test.setup 后可使用 describe.skip 调用 + * @param name 定义模块名称 + * @param block 模块初始化代码 + * + * + * + */ + export function xdescribe(name: string, block: Function): void; + + /** + * + * @brief 独立测试的模块定义,test.setup 后可使用 describe.only 调用 + * @param name 定义模块名称 + * @param block 模块初始化代码 + * + * + * + */ + export function odescribe(name: string, block: Function): void; + + /** + * + * @brief 定义一个测试项目 + * @param name 定义项目名称 + * @param block 测试内容 + * + * + * + */ + export function it(name: string, block: Function): void; + + /** + * + * @brief 暂停测试的项目定义,test.setup 后可使用 it.skip 调用 + * @param name 定义项目名称 + * @param block 测试内容 + * + * + * + */ + export function xit(name: string, block: Function): void; + + /** + * + * @brief 独立测试的项目定义,test.setup 后可使用 it.only 调用 + * @param name 定义项目名称 + * @param block 测试内容 + * + * + * + */ + export function oit(name: string, block: Function): void; + + /** + * + * @brief 定义当前测试模块进入事件 + * @param func 事件函数 + * + * + * + */ + export function before(func: Function): void; + + /** + * + * @brief 定义当前测试模块退出事件 + * @param func 事件函数 + * + * + * + */ + export function after(func: Function): void; + + /** + * + * @brief 定义当前测试模块测试项目进入事件 + * @param func 事件函数 + * + * + * + */ + export function beforeEach(func: Function): void; + + /** + * + * @brief 定义当前测试模块测试项目退出事件 + * @param func 事件函数 + * + * + * + */ + export function afterEach(func: Function): void; + + /** + * + * @brief 开始执行定义的测试模块 + * @param loglevel 指定进行测试时的日志输出级别,ERROR 时,项目报错信息集中在报告后显示,低于 ERROR 时,输出信息随时显示,高于 ERROR 时,只显示报告 + * @return 返回测试用例统计结果,正确则返回 0,错误则返回错误个数 + * + * + * + */ + export function run(loglevel?: number/** = undefined*/): number; + + /** + * + * @brief 初始化当前脚本的测试环境,将 test 模块方法复制为当前脚本全局变量 + * + * + */ + export function setup(): void; + + } /** end of `module test` */ + export = test +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/timers.d.ts b/types/fibjs/declare/timers.d.ts new file mode 100644 index 0000000000..158dcc8f84 --- /dev/null +++ b/types/fibjs/declare/timers.d.ts @@ -0,0 +1,322 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief timers 模块 + * @detail + */ +declare module "timers" { + + + module timers { + + + + + + /** + * + * @brief 在指定的时间后调用函数 + * @param callback 指定回调函数 + * @param timeout 指定延时的时间,以毫秒为单位。超过 2^31 的话,立即执行。 + * @param args 额外的参数,传入到指定的 callback 内,可选。 + * @return 返回定时器对象 + * + * + * + */ + export function setTimeout(callback: Function, timeout: number, ...args: any[]): Class_Timer; + + /** + * + * @brief 清除指定的定时器 + * @param t 指定要清除的定时器 + * + * + * + */ + export function clearTimeout(t: any): void; + + /** + * + * @brief 每间隔指定的时间后调用函数 + * @param callback 指定回调函数 + * @param timeout 指定间隔的时间,以毫秒为单位。超过 2^31 的话,立即执行。 + * @param args 额外的参数,传入到指定的 callback 内,可选。 + * @return 返回定时器对象 + * + * + * + */ + export function setInterval(callback: Function, timeout: number, ...args: any[]): Class_Timer; + + /** + * + * @brief 清除指定的定时器 + * @param t 指定要清除的定时器 + * + * + * + */ + export function clearInterval(t: any): void; + + /** + * + * @brief 每间隔指定的时间后调用函数,这是个高精度定时器,会主动打断正在运行的 JavaScript 脚本执行定时器 + * 由于 setHrInterval 的定时器会中断正在运行的代码执行回调,因此不要在回调函数内修改可能影响其它模块的数据,或者在回调中调用任何标记为 async 的 api 函数,否则将会产生不可预知的结果。例如: + * ```JavaScript + * var timers = require('timers'); + * + * var cnt = 0; + * timers.setHrInterval(() => { + * cnt++; + * }, 100); + * + * while (cnt < 10); + * + * console.error("===============================> done"); + * ``` + * 这段代码中,第 8 行的循环并不会因为 cnt 的改变而结束,因为 JavaScript 在优化代码时会认定在这个循环过程中 cnt 不会被改变。 + * @param callback 指定回调函数 + * @param timeout 指定间隔的时间,以毫秒为单位。超过 2^31 的话,立即执行。 + * @param args 额外的参数,传入到指定的 callback 内,可选。 + * @return 返回定时器对象 + * + * + * + */ + export function setHrInterval(callback: Function, timeout: number, ...args: any[]): Class_Timer; + + /** + * + * @brief 清除指定的定时器 + * @param t 指定要清除的定时器 + * + * + * + */ + export function clearHrInterval(t: any): void; + + /** + * + * @brief 下一个空闲时间立即执行回调函数 + * @param callback 指定回调函数 + * @param args 额外的参数,传入到指定的 callback 内,可选。 + * @return 返回定时器对象 + * + * + * + */ + export function setImmediate(callback: Function, ...args: any[]): Class_Timer; + + /** + * + * @brief 清除指定的定时器 + * @param t 指定要清除的定时器 + * + * + * + */ + export function clearImmediate(t: any): void; + + } /** end of `module timers` */ + export = timers +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/tty.d.ts b/types/fibjs/declare/tty.d.ts new file mode 100644 index 0000000000..bb35dc9195 --- /dev/null +++ b/types/fibjs/declare/tty.d.ts @@ -0,0 +1,228 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief tty 模块 + * @detail 使用方法:,```JavaScript,const tty = require('tty');,``` + */ +declare module "tty" { + + + module tty { + + + + + + /** + * + * @brief 查询是否是命令交互窗口 + * @param fd 文件描述符 + * @return 如果文件描述符同一个终端窗口关联则返回 true ,否则返回 false + * + * + * + */ + export function isatty(fd: number): boolean; + + } /** end of `module tty` */ + export = tty +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/url.d.ts b/types/fibjs/declare/url.d.ts new file mode 100644 index 0000000000..5a2706abfd --- /dev/null +++ b/types/fibjs/declare/url.d.ts @@ -0,0 +1,241 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief url 处理模块 + * @detail + */ +declare module "url" { + + + module url { + + + + + + /** + * + * @brief 参数构造 UrlObject 对象 + * @param args 指定构造参数的字典对象,支持的字段有:protocol, slashes, username, password, hostname, port, pathname, query, hash + * @return 返回构造成功的字符串 + * + * + * + */ + export function format(args: Object): string; + + /** + * + * @brief 解析一个 url 字符串 + * @param url 指定需要解析的 url 字符串 + * @param parseQueryString 指定是否解析 query + * @param slashesDenoteHost 默认为false, 如果设置为true,则从字符串'//'之后到下一个'/'之前的字符串会被解析为host,例如'//foo/bar', 结果应该是{host: 'foo', pathname: '/bar'}而不是{pathname: '//foo/bar'} + * @return 返回包含解析数据的对象 + * + * + * + */ + export function parse(url: string, parseQueryString?: boolean/** = false*/, slashesDenoteHost?: boolean/** = false*/): Class_UrlObject; + + } /** end of `module url` */ + export = url +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/util.d.ts b/types/fibjs/declare/util.d.ts new file mode 100644 index 0000000000..e49ae9feae --- /dev/null +++ b/types/fibjs/declare/util.d.ts @@ -0,0 +1,974 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 常用工具模块 + * @detail + */ +declare module "util" { + + + module util { + + + + /** + * + * @brief 数据统计对象,用以构建应用运行时数据收集,参见 Stats 对象。 + * + * + */ + export class Stats extends Class_Stats {} + + + /** + * + * @brief LRU(least recently used) 缓存对象,参见 LruCache 对象。 + * + * + */ + export class LruCache extends Class_LruCache {} + + + + + /** + * + * @brief 按照指定的格式格式化变量 + * + * @param fmt 格式化字符串 + * @param args 可选参数列表 + * @return 返回格式化后的字符串 + * + * + * + */ + export function format(fmt: string, ...args: any[]): string; + + /** + * + * @brief 格式格式化变量 + * + * @param args 可选参数列表 + * @return 返回格式化后的字符串 + * + * + * + */ + export function format(...args: any[]): string; + + /** + * + * @brief 从一个构造函数 constructor 继承原型方法到另一个。构造函数的原型将被设置为一个新的从超类(superConstructor)创建的对象。 + * + * @param constructor 初始的构造函数 + * @param superConstructor 被继承的超类 + * + * + * + */ + export function inherits(constructor: any, superConstructor: any): void; + + /** + * + * @brief 方法返回 obj 的字符串表示,主要用于调试。 附加的 options 可用于改变格式化字符串的某些方面。 + * + * @param obj 指定需要处理的对象 + * @param options 指定格式控制选项 + * @return 返回格式化后的字符串 + * + * + * + */ + export function inspect(obj: Object, options?: Object/** = v8::Object::New(isolate)*/): string; + + /** + * + * @brief 检测给定的变量是否不包含任何值(没有可枚举的属性) + * + * @param v 给定需要检测的变量 + * @return 如果为空则返回 True + * + * + * + */ + export function isEmpty(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是数组 + * + * @param v 给定需要检测的变量 + * @return 如果是数组则返回 True + * + * + * + */ + export function isArray(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 Boolean + * + * @param v 给定需要检测的变量 + * @return 如果是 Boolean 则返回 True + * + * + * + */ + export function isBoolean(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 Null + * + * @param v 给定需要检测的变量 + * @return 如果是 Null 则返回 True + * + * + * + */ + export function isNull(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 Null 或者 Undefined + * + * @param v 给定需要检测的变量 + * @return 如果是 Null 或者 Undefined 则返回 True + * + * + * + */ + export function isNullOrUndefined(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是数字 + * + * @param v 给定需要检测的变量 + * @return 如果是数字则返回 True + * + * + * + */ + export function isNumber(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是字符串 + * + * @param v 给定需要检测的变量 + * @return 如果是字符串则返回 True + * + * + * + */ + export function isString(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 Undefined + * + * @param v 给定需要检测的变量 + * @return 如果是 Undefined 则返回 True + * + * + * + */ + export function isUndefined(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是正则对象 + * + * @param v 给定需要检测的变量 + * @return 如果是正则对象则返回 True + * + * + * + */ + export function isRegExp(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是对象 + * + * @param v 给定需要检测的变量 + * @return 如果是对象则返回 True + * + * + * + */ + export function isObject(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是日期对象 + * + * @param v 给定需要检测的变量 + * @return 如果是日期对象则返回 True + * + * + * + */ + export function isDate(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是错误对象 + * + * @param v 给定需要检测的变量 + * @return 如果是错误对象则返回 True + * + * + * + */ + export function isNativeError(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是原始类型 + * + * @param v 给定需要检测的变量 + * @return 如果是原始类型则返回 True + * + * + * + */ + export function isPrimitive(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是Symbol类型 + * + * @param v 给定需要检测的变量 + * @return 如果是Symbol类型则返回 True + * + * + * + */ + export function isSymbol(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 DataView 类型 + * + * @param v 给定需要检测的变量 + * @return 如果是 DataView 类型则返回 True + * + * + * + */ + export function isDataView(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 External 类型 + * + * @param v 给定需要检测的变量 + * @return 如果是 External 类型则返回 True + * + * + * + */ + export function isExternal(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 Map 类型 + * + * @param v 给定需要检测的变量 + * @return 如果是 Map 类型则返回 True + * + * + * + */ + export function isMap(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 MapIterator 类型 + * + * @param v 给定需要检测的变量 + * @return 如果是 MapIterator 类型则返回 True + * + * + * + */ + export function isMapIterator(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 Promise 类型 + * + * @param v 给定需要检测的变量 + * @return 如果是 Promise 类型则返回 True + * + * + * + */ + export function isPromise(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 AsyncFunction 类型 + * + * @param v 给定需要检测的变量 + * @return 如果是 AsyncFunction 类型则返回 True + * + * + * + */ + export function isAsyncFunction(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 Set 类型 + * + * @param v 给定需要检测的变量 + * @return 如果是 Set 类型则返回 True + * + * + * + */ + export function isSet(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 SetIterator 类型 + * + * @param v 给定需要检测的变量 + * @return 如果是 SetIterator 类型则返回 True + * + * + * + */ + export function isSetIterator(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 TypedArray 类型 + * + * @param v 给定需要检测的变量 + * @return 如果是 TypedArray 类型则返回 True + * + * + * + */ + export function isTypedArray(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是 Uint8Array 类型 + * + * @param v 给定需要检测的变量 + * @return 如果是 Uint8Array 类型则返回 True + * + * + * + */ + export function isUint8Array(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是函数对象 + * + * @param v 给定需要检测的变量 + * @return 如果是函数对象则返回 True + * + * + * + */ + export function isFunction(v: any): boolean; + + /** + * + * @brief 检测给定的变量是否是函数 Buffer 对象 + * + * @param v 给定需要检测的变量 + * @return 如果是函数 Buffer 对象则返回 True + * + * + * + */ + export function isBuffer(v: any): boolean; + + /** + * + * @brief 查询指定对象是否包含给定的键 + * + * @param v 给定需要查询的对象 + * @param key 指定需要查询的键 + * @return 返回对象的全部键数组 + * + * + * + */ + export function has(v: any, key: string): boolean; + + /** + * + * @brief 查询指定对象的全部键数组 + * + * @param v 给定需要查询的对象 + * @return 返回对象的全部键数组 + * + * + * + */ + export function keys(v: any): any[]; + + /** + * + * @brief 查询指定对象的全部值数组 + * + * @param v 给定需要查询的对象 + * @return 返回对象的全部值数组 + * + * + * + */ + export function values(v: any): any[]; + + /** + * + * @brief 克隆给定变量,如果是对象或数组,则复制内容到新对象 + * + * @param v 给定要克隆的变量 + * @return 返回克隆结果 + * + * + * + */ + export function clone(v: any): any; + + /** + * + * @brief 将一个或者多个对象的键值扩展到指定对象 + * + * @param v 指定要扩展的对象 + * @param objs 指定一个或者多个用于扩展的对象 + * @return 返回扩展的结果 + * + * + * + */ + export function extend(v: any, ...objs: any[]): any; + + /** + * + * @brief 将一个或者多个对象的键值扩展到指定对象,是 extend 的别名 + * + * @param v 指定要扩展的对象 + * @param objs 指定一个或者多个用于扩展的对象 + * @return 返回扩展的结果 + * + * + * + */ + export function _extend(v: any, ...objs: any[]): any; + + /** + * + * @brief 返回一个object副本,只过滤出指定键的属性值 + * + * @param v 指定要过滤的对象 + * @param objs 指定一个或者多个用于选择的键 + * @return 返回过滤的结果 + * + * + * + */ + export function pick(v: any, ...objs: any[]): Object; + + /** + * + * @brief 返回一个object副本,只过排除指定键的属性值 + * + * @param v 指定要过滤的对象 + * @param keys 指定一个或者多个用于排除的键 + * @return 返回排除的结果 + * + * + * + */ + export function omit(v: any, ...keys: any[]): Object; + + /** + * + * @brief 获取数组的第一个元素 + * + * @param v 给定要获取的数组 + * @return 返回获取的元素 + * + * + * + */ + export function first(v: any): any; + + /** + * + * @brief 获取数组的开始多个元素 + * + * @param v 给定要获取的数组 + * @param n 指定要获取的元素个数 + * @return 返回获取的元素数组 + * + * + * + */ + export function first(v: any, n: number): any; + + /** + * + * @brief 获取数组的第后一个元素 + * + * @param v 给定要获取的数组 + * @return 返回获取的元素 + * + * + * + */ + export function last(v: any): any; + + /** + * + * @brief 获取数组的结尾多个元素 + * + * @param v 给定要获取的数组 + * @param n 指定要获取的元素个数 + * @return 返回获取的元素数组 + * + * + * + */ + export function last(v: any, n: number): any; + + /** + * + * @brief 获取数组的元素去重后的副本 + * + * @param v 给定要去重的数组 + * @param sorted 指定数组是否排序,如果指定数组排序,将使用快速算法 + * @return 返回去重元素后的数组 + * + * + * + */ + export function unique(v: any, sorted?: boolean/** = false*/): any[]; + + /** + * + * @brief 将一个或者多个数组的值合并成一个值唯一的数组 + * + * @param arrs 指定一个或者多个用于合并的数组 + * @return 返回合并的结果 + * + * + * + */ + export function union(...arrs: any[]): any[]; + + /** + * + * @brief 返回一个包含 arr 数组中排除一个或者多个数组元素的交集 + * + * @param arrs 指定一个或者多个用于计算交集的数组 + * @return 返回计算交集的结果 + * + * + * + */ + export function intersection(...arrs: any[]): any[]; + + /** + * + * @brief 将一个嵌套多层的数组(嵌套可以是任何层数)转换为只有一层的数组。 如果你传递 shallow 参数,数组将只减少一维的嵌套。 + * + * @param arr 指定需要转换的数组 + * @param shallow 指定是否只减少一维的嵌套,缺省为 false + * @return 返回转换的结果 + * + * + * + */ + export function flatten(arr: any, shallow?: boolean/** = false*/): any[]; + + /** + * + * @brief 返回一个包含 arr 数组中排除一个或者多个元素后的数组 + * + * @param arr 指定需要排除的数组 + * @param els 指定一个或者多个用于排除的元素 + * @return 返回排除的结果 + * + * + * + */ + export function without(arr: any, ...els: any[]): any[]; + + /** + * + * @brief 返回一个包含 arr 数组中排除 without 数组元素之后的数组 + * + * @param list 指定需要排除的数组 + * @param arrs 指定用于排除的一个或者多个数组 + * @return 返回排除的结果 + * + * + * + */ + export function difference(list: any[], ...arrs: any[]): any[]; + + /** + * + * @brief 遍历 list 中的所有元素,按顺序用遍历输出每个元素。如果传递了 context 参数,则把 iterator 绑定到 context 对象上。每次调用 iterator 都会传递三个参数:(element, index, list) + * + * @param list 指定需要遍历的列表或对象 + * @param iterator 指定用于遍历的回调函数 + * @param context 指定调用 iterator 时绑定的 context 对象 + * @return 返回 list 本身 + * + * + * + */ + export function each(list: any, iterator: Function, context?: any/** = v8::Undefined(isolate)*/): any; + + /** + * + * @brief 通过变换函数(iterator迭代器)把 list 中的每个值映射到一个新的数组中。如果传递了 context 参数,则把 iterator 绑定到 context 对象上。每次调用 iterator 都会传递三个参数:(element, index, list) + * + * @param list 指定需要变换的列表或对象 + * @param iterator 指定用于变换的回调函数 + * @param context 指定调用 iterator 时绑定的 context 对象 + * @return 返回变换的结果 + * + * + * + */ + export function map(list: any, iterator: Function, context?: any/** = v8::Undefined(isolate)*/): any[]; + + /** + * + * @brief 把 list中 元素归结为一个单独的数值。如果传递了 context 参数,则把 iterator 绑定到 context 对象上。每次调用 iterator 都会传递三个参数:(memo, element, index, list) + * + * @param list 指定需要归结的列表或对象 + * @param iterator 指定用于归结的回调函数 + * @param memo 指定归结的初始值 + * @param context 指定调用 iterator 时绑定的 context 对象 + * @return 返回归结的结果 + * + * + * + */ + export function reduce(list: any, iterator: Function, memo: any, context?: any/** = v8::Undefined(isolate)*/): any; + + /** + * + * @brief 编译脚本为二进制代码 + * util.compile 可以将脚本编译为 v8 内部运行数据块(非机器执行代码)。编译以后的代码,保存为 *.jsc 后,可以由 run 和 require 直接加载执行。 + * + * 由于编译之后,目标代码将不能逆向获取源代码,依赖于 Function.toString 的程序将不能正常运行。 + * + * @param srcname 指定要添加的脚本名称 + * @param script 指定要编译的脚本代码 + * @param mode 编译模式,0: module, 1: script, 2: worker,缺省为 0 + * @return 返回编译出的二进制代码 + * + * + * + */ + export function compile(srcname: string, script: string, mode?: number/** = 0*/): Class_Buffer; + + /** + * + * @brief 包裹 callback 或 async 方法为同步调用 + * + * util.sync 将 callback 方法或者 async 方法处理为 sync 方法,以方便调用。 + * + * callback 示例如下: + * ```JavaScript + * // callback + * var util = require('util'); + * + * function cb_test(a, b, cb) { + * setTimeout(() => { + * cb(null, a + b); + * }, 100); + * } + * + * var fn_sync = util.sync(cb_test); + * console.log(fn_sync(100, 200)); + * ``` + * async 示例如下: + * ```JavaScript + * // async/await + * var util = require('util'); + * + * async function async_test(a, b) { + * return a + b; + * } + * + * var fn_sync = util.sync(async_test); + * console.log(fn_sync(100, 200)); + * ``` + * 对于未标记为 async 的返回 promise 的函数,可以手动指定 sync 模式: + * ```JavaScript + * // async/await + * var util = require('util'); + * + * function async_test(a, b) { + * return new Promise(function (resolve, reject) { + * resolve(a + b); + * }); + * } + * + * var fn_sync = util.sync(async_test, true); + * console.log(fn_sync(100, 200)); + * ``` + * + * @param func 给定需要包裹的方法 + * @param async_func 指定以 async 函数方式处理 func,为 false 则自动判断 + * @return 返回同步运行的方法 + * + * + * + */ + export function sync(func: Function, async_func?: boolean/** = false*/): Function; + + /** + * + * @brief 查询当前引擎及各组件版本信息 + * + * ```JavaScript + * { + * "fibjs": "0.1.0", + * "svn": 1753, + * "build": "Dec 10 2013 21:44:17", + * "vender": { + * "ev": "4.11", + * "exif": "0.6.21", + * "gd": "2.1.0-alpha", + * "jpeg": "8.3", + * "log4cpp": "1.0", + * "mongo": "0.7", + * "pcre": "8.21", + * "png": "1.5.4", + * "sqlite": "3.8.1", + * "tiff": "3.9.5", + * "uuid": "1.6.2", + * "v8": "3.23.17 (candidate)", + * "zlib": "1.2.7", + * "zmq": "3.1" + * } + * } + * ``` + * @return 返回组件版本对象 + * + * + * + */ + export function buildInfo(): Object; + + } /** end of `module util` */ + export = util +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/uuid.d.ts b/types/fibjs/declare/uuid.d.ts new file mode 100644 index 0000000000..7300b8f875 --- /dev/null +++ b/types/fibjs/declare/uuid.d.ts @@ -0,0 +1,303 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief uuid 唯一 id 模块 + * @detail 基础模块。提供唯一 id 的创建于操作,```JavaScript,var uuid = require('uuid');,``` + */ +declare module "uuid" { + + + module uuid { + + /** + * + * @brief md5 与 sha1 创建 uuid 时指定 name 命名为域名 + * + * + */ + export const DNS = 0; + + /** + * + * @brief md5 与 sha1 创建 uuid 时指定 name 命名为 url 地址 + * + * + */ + export const URL = 1; + + /** + * + * @brief md5 与 sha1 创建 uuid 时指定 name 命名为 ISO OID + * + * + */ + export const OID = 2; + + /** + * + * @brief md5 与 sha1 创建 uuid 时指定 name 命名为 X.500 DN + * + * + */ + export const X509 = 3; + + + + + + /** + * + * @brief 使用时间和主机名创建 uuid + * @return 返回一个生成的二进制 id + * + * + * + */ + export function node(): Class_Buffer; + + /** + * + * @brief 使用特定命名的 md5 创建 uuid + * @param ns 指定命名空间,可以为 uuid.DNS, uuid.URL, uuid.OID, uuid.X509 + * @param name 指定名称 + * @return 返回一个生成的二进制 id + * + * + * + */ + export function md5(ns: number, name: string): Class_Buffer; + + /** + * + * @brief 使用随机数创建 uuid + * @return 返回一个生成的二进制 id + * + * + * + */ + export function random(): Class_Buffer; + + /** + * + * @brief 使用特定命名的 sha1 创建 uuid + * @param ns 指定命名空间,可以为 uuid.DNS, uuid.URL, uuid.OID, uuid.X509 + * @param name 指定名称 + * @return 返回一个生成的二进制 id + * + * + * + */ + export function sha1(ns: number, name: string): Class_Buffer; + + /** + * + * @brief 使用 Snowflake 算法创建 uuid + * @return 返回一个生成的二进制 id + * + * + * + */ + export function snowflake(): Class_Buffer; + + } /** end of `module uuid` */ + export = uuid +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/vm.d.ts b/types/fibjs/declare/vm.d.ts new file mode 100644 index 0000000000..b9615198d5 --- /dev/null +++ b/types/fibjs/declare/vm.d.ts @@ -0,0 +1,226 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief 安全沙箱模块,用于隔离不同安全等级的运行环境 + * @detail 通过建立安全沙箱,可以限制脚本运行时可以接触的资源,隔离不同脚本执行环境,并可以为不同的环境定制基础模块,以保障整体运行环境的安全。,,下面的示例创建一个沙箱,限制只允许访问全局基础模块中的 assert 模块,并添加 a 和 b 两个定制模块:,```JavaScript,var vm = require('vm');,var sbox = new vm.SandBox({, a: 100,, b: 200,, assert: require('assert'),});,,var mod_in_sbox = sbox.require('./path/to/mod');,``` + */ +declare module "vm" { + + + module vm { + + + + /** + * + * @brief 创建一个 SandBox 对象,参见 SandBox + * + * + */ + export class SandBox extends Class_SandBox {} + + + + + } /** end of `module vm` */ + export = vm +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/ws.d.ts b/types/fibjs/declare/ws.d.ts new file mode 100644 index 0000000000..d5402ad972 --- /dev/null +++ b/types/fibjs/declare/ws.d.ts @@ -0,0 +1,327 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief websocket 支持模块 + * @detail 使用方法:,```JavaScript,var ws = require('ws');,```,创建一个服务器:,```JavaScript,var ws = require('ws');,var http = require('http');,,var svr = new http.Server(80, {, '/ws': ws.upgrade((conn, req) => {, conn.onmessage = e => console.log(e.data);, }),});,svr.run();,```,使用 WebSocket 客户端:,```JavaScript,var ws = require('ws');,,var conn = new ws.Socket('ws://127.0.0.1/ws');,conn.ommessage = e => console.log(e.data);,``` + */ +declare module "ws" { + + + module ws { + + /** + * + * @brief 指定 websocket 消息类型 0,代表一个继续帧 + * + * + */ + export const CONTINUE = 0; + + /** + * + * @brief 指定 websocket 消息类型 1,代表一个文本帧 + * + * + */ + export const TEXT = 1; + + /** + * + * @brief 指定 websocket 消息类型 2,代表一个二进制帧 + * + * + */ + export const BINARY = 2; + + /** + * + * @brief 指定 websocket 消息类型 8,连接关闭 + * + * + */ + export const CLOSE = 8; + + /** + * + * @brief 指定 websocket 消息类型 9,代表一个 ping 帧 + * + * + */ + export const PING = 9; + + /** + * + * @brief 指定 websocket 消息类型 10,代表一个 pong 帧 + * + * + */ + export const PONG = 10; + + /** + * + * @brief 指定 WebSocket 状态,表示正在连接中 + * + * + */ + export const CONNECTING = 0; + + /** + * + * @brief 指定 WebSocket 状态,表示打开状态 + * + * + */ + export const OPEN = 1; + + /** + * + * @brief 指定 WebSocket 状态,表示已发送 CLOSE 消息,等待关闭中 + * + * + */ + export const CLOSING = 2; + + /** + * + * @brief 指定 WebSocket 状态,表示已经关闭 + * + * + */ + export const CLOSED = 3; + + + + /** + * + * @brief 创建一个 websocket 消息对象,参见 WebSocketMessage + * + * + */ + export class WebSocketMessage extends Class_WebSocketMessage {} + + + /** + * + * @brief WebSocket 对象,参见 WebSocket + * + * + */ + export class WebSocket extends Class_WebSocket {} + + + + + /** + * + * @brief 创建一个 websocket 协议处理器,从 http 接收 upgrade 请求并握手,生成 WebSocket 对象 + * accept 函数调用时,将传递两个参数,第一个参数为接收到的 WebSocket 对象,第二个参数为握手时的 HttpRequest 对象。 + * @param accept 连接成功处理函数 + * @return 返回协议处理器,可与 HttpServer, Chain, Routing 等对接 + * + * + * + */ + export function upgrade(accept: Function): Class_Handler; + + } /** end of `module ws` */ + export = ws +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/xml.d.ts b/types/fibjs/declare/xml.d.ts new file mode 100644 index 0000000000..4dbb477dc1 --- /dev/null +++ b/types/fibjs/declare/xml.d.ts @@ -0,0 +1,333 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief xml 处理模块 + * @detail + */ +declare module "xml" { + + + module xml { + + /** + * + * @brief XmlNode 的 nodeType 属性常量,表示节点为 XmlElement 对象 + * + * + * + */ + export const ELEMENT_NODE = 1; + + /** + * + * @brief XmlNode 的 nodeType 属性常量,表示节点为 XmlAttr 对象 + * + * + * + */ + export const ATTRIBUTE_NODE = 2; + + /** + * + * @brief XmlNode 的 nodeType 属性常量,表示节点为 XmlText 对象 + * + * + * + */ + export const TEXT_NODE = 3; + + /** + * + * @brief XmlNode 的 nodeType 属性常量,表示节点为 XmlCDATASection 对象 + * + * + * + */ + export const CDATA_SECTION_NODE = 4; + + /** + * + * @brief XmlNode 的 nodeType 属性常量,表示节点为 XmlProcessingInstruction 对象 + * + * + * + */ + export const PROCESSING_INSTRUCTION_NODE = 7; + + /** + * + * @brief XmlNode 的 nodeType 属性常量,表示节点为 XmlComment 对象 + * + * + * + */ + export const COMMENT_NODE = 8; + + /** + * + * @brief XmlNode 的 nodeType 属性常量,表示节点为 XmlDocument 对象 + * + * + * + */ + export const DOCUMENT_NODE = 9; + + /** + * + * @brief XmlNode 的 nodeType 属性常量,表示节点为 XmlDocumentType 对象 + * + * + * + */ + export const DOCUMENT_TYPE_NODE = 10; + + + + /** + * + * @brief xml 文档对象,参见 XmlDocument 对象 + * + * + */ + export class XmlDocument extends Class_XmlDocument {} + + + + + /** + * + * @brief 解析 xml/html 文本,并创建 XmlDocument 对象,不支持多语种 + * @param source 指定需要解析的 xml/html 文本 + * @param type 指定文本类型,缺省为 text/xml,也可指定为 text/html + * @return 返回创建的 XmlDocument 对象 + * + * + * + */ + export function parse(source: string, type?: string/** = "text/xml"*/): Class_XmlDocument; + + /** + * + * @brief 解析 xml/html,并创建 XmlDocument 对象,解析时会根据指定的语种转换 + * @param source 指定需要解析的 xml/html 二进制数据 + * @param type 指定文本类型,缺省为 text/xml,也可指定为 text/html + * @return 返回创建的 XmlDocument 对象 + * + * + * + */ + export function parse(source: Class_Buffer, type?: string/** = "text/xml"*/): Class_XmlDocument; + + /** + * + * @brief 序列化 XmlNode 为字符串 + * @param node 指定需要序列化的 XmlNode + * @return 返回序列化的字符串 + * + * + * + */ + export function serialize(node: Class_XmlNode): string; + + } /** end of `module xml` */ + export = xml +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/zip.d.ts b/types/fibjs/declare/zip.d.ts new file mode 100644 index 0000000000..0aa19eaed4 --- /dev/null +++ b/types/fibjs/declare/zip.d.ts @@ -0,0 +1,283 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief zip 格式文件压缩解压模块 + * @detail 使用方法:,```JavaScript,var zip = require('zip');,``` + */ +declare module "zip" { + + + module zip { + + /** + * + * @brief 压缩类型常量, 不压缩, 仅存储 + * + * + */ + export const ZIP_STORED = 0; + + /** + * + * @brief 压缩类型常量, 需要依赖zlib库进行压缩 + * + * + */ + export const ZIP_DEFLATED = 1; + + + + + + /** + * + * @brief 判断文件是否是zip格式 + * @param filename 文件名 + * @return 返回true代表文件是zip文件 + * + * + * @async + */ + export function isZipFile(filename: string): boolean; + + /** + * + * @brief 打开一个zip文件 + * @param path 文件路径 + * @param mod 打开文件模式, "r"代表读取, "w"代表创建, "a"代表在zip文件后追加 + * @param compress_type 压缩类型, ZIP_STORED 代表不压缩, 仅存储。 默认使用ZIP_DEFLATED 代表使用zlib库进行压缩。 + * @return 返回zip文件对象 + * + * + * @async + */ + export function open(path: string, mod?: string/** = "r"*/, compress_type?: number/** = undefined*/): Class_ZipFile; + + /** + * + * @brief 打开一个zip文件 + * @param data zip文件数据 + * @param mod 打开文件模式, "r"代表读取, "w"代表创建, "a"代表在zip文件后追加 + * @param compress_type 压缩类型, ZIP_STORED 代表不压缩, 仅存储。 默认使用ZIP_DEFLATED 代表使用zlib库进行压缩。 + * @return 返回zip文件对象 + * + * + * @async + */ + export function open(data: Class_Buffer, mod?: string/** = "r"*/, compress_type?: number/** = undefined*/): Class_ZipFile; + + /** + * + * @brief 打开一个zip文件 + * @param strm zip文件流 + * @param mod 打开文件模式, "r"代表读取, "w"代表创建, "a"代表在zip文件后追加 + * @param compress_type 压缩类型, ZIP_STORED 代表不压缩, 仅存储。 默认使用ZIP_DEFLATED 代表使用zlib库进行压缩。 + * @return 返回zip文件对象 + * + * + * @async + */ + export function open(strm: Class_SeekableStream, mod?: string/** = "r"*/, compress_type?: number/** = undefined*/): Class_ZipFile; + + } /** end of `module zip` */ + export = zip +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/zlib.d.ts b/types/fibjs/declare/zlib.d.ts new file mode 100644 index 0000000000..42e7236f5e --- /dev/null +++ b/types/fibjs/declare/zlib.d.ts @@ -0,0 +1,513 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief zlib 压缩解压模块 + * @detail 使用方法:,```JavaScript,var zlib = require('zlib');,``` + */ +declare module "zlib" { + + + module zlib { + + /** + * + * @brief deflate 压缩级别,设定不压缩 + * + * + */ + export const NO_COMPRESSION = 0; + + /** + * + * @brief deflate 压缩级别,设定最快压缩 + * + * + */ + export const BEST_SPEED = 1; + + /** + * + * @brief deflate 压缩级别,设定最高压缩 + * + * + */ + export const BEST_COMPRESSION = 9; + + /** + * + * @brief deflate 压缩级别,设定缺省设置 + * + * + */ + export const DEFAULT_COMPRESSION = -1; + + + + + + /** + * + * @brief 创建一个 deflate 流对象 + * @param to 用于存储处理结果的流 + * @return 返回封装过的流对象 + * + * + */ + export function createDeflate(to: Class_Stream): Class_Stream; + + /** + * + * @brief 创建一个 deflateRaw 流对象 + * @param to 用于存储处理结果的流 + * @return 返回封装过的流对象 + * + * + */ + export function createDeflateRaw(to: Class_Stream): Class_Stream; + + /** + * + * @brief 创建一个 gunzip 流对象 + * @param to 用于存储处理结果的流 + * @return 返回封装过的流对象 + * + * + */ + export function createGunzip(to: Class_Stream): Class_Stream; + + /** + * + * @brief 创建一个 gzip 流对象 + * @param to 用于存储处理结果的流 + * @return 返回封装过的流对象 + * + * + */ + export function createGzip(to: Class_Stream): Class_Stream; + + /** + * + * @brief 创建一个 inflate 流对象 + * @param to 用于存储处理结果的流 + * @return 返回封装过的流对象 + * + * + */ + export function createInflate(to: Class_Stream): Class_Stream; + + /** + * + * @brief 创建一个 inflateRaw 流对象 + * @param to 用于存储处理结果的流 + * @return 返回封装过的流对象 + * + * + */ + export function createInflateRaw(to: Class_Stream): Class_Stream; + + /** + * + * @brief 使用 deflate 算法压缩数据(zlib格式) + * @param data 给定要压缩的数据 + * @param level 指定压缩级别,缺省为 DEFAULT_COMPRESSION + * @return 返回压缩后的二进制数据 + * + * + * @async + */ + export function deflate(data: Class_Buffer, level?: number/** = undefined*/): Class_Buffer; + + /** + * + * @brief 使用 deflate 算法压缩数据到流对象中(zlib格式) + * @param data 给定要压缩的数据 + * @param stm 指定存储压缩数据的流 + * @param level 指定压缩级别,缺省为 DEFAULT_COMPRESSION + * + * + * @async + */ + export function deflateTo(data: Class_Buffer, stm: Class_Stream, level?: number/** = undefined*/): void; + + /** + * + * @brief 使用 deflate 算法压缩源流中的数据到流对象中(zlib格式) + * @param src 给定要压缩的数据所在的流 + * @param stm 指定存储压缩数据的流 + * @param level 指定压缩级别,缺省为 DEFAULT_COMPRESSION + * + * + * @async + */ + export function deflateTo(src: Class_Stream, stm: Class_Stream, level?: number/** = undefined*/): void; + + /** + * + * @brief 解压缩 deflate 算法压缩的数据(zlib格式) + * @param data 给定压缩后的数据 + * @return 返回解压缩后的二进制数据 + * + * + * @async + */ + export function inflate(data: Class_Buffer): Class_Buffer; + + /** + * + * @brief 解压缩 deflate 算法压缩的数据到流对象中(zlib格式) + * @param data 给定要解压缩的数据 + * @param stm 指定存储解压缩数据的流 + * + * + * @async + */ + export function inflateTo(data: Class_Buffer, stm: Class_Stream): void; + + /** + * + * @brief 解压缩源流中 deflate 算法压缩的数据到流对象中(zlib格式) + * @param src 给定要解压缩的数据所在的流 + * @param stm 指定存储解压缩数据的流 + * + * + * @async + */ + export function inflateTo(src: Class_Stream, stm: Class_Stream): void; + + /** + * + * @brief 使用 gzip 算法压缩数据 + * @param data 给定要压缩的数据 + * @return 返回压缩后的二进制数据 + * + * + * @async + */ + export function gzip(data: Class_Buffer): Class_Buffer; + + /** + * + * @brief 使用 gzip 算法压缩数据到流对象中 + * @param data 给定要压缩的数据 + * @param stm 指定存储压缩数据的流 + * + * + * @async + */ + export function gzipTo(data: Class_Buffer, stm: Class_Stream): void; + + /** + * + * @brief 使用 gzip 算法压缩源流中的数据到流对象中 + * @param src 给定要压缩的数据所在的流 + * @param stm 指定存储压缩数据的流 + * + * + * @async + */ + export function gzipTo(src: Class_Stream, stm: Class_Stream): void; + + /** + * + * @brief 解压缩 gzip 算法压缩的数据 + * @param data 给定压缩后的数据 + * @return 返回解压缩后的二进制数据 + * + * + * @async + */ + export function gunzip(data: Class_Buffer): Class_Buffer; + + /** + * + * @brief 解压缩 gzip 算法压缩的数据到流对象中 + * @param data 给定要解压缩的数据 + * @param stm 指定存储解压缩数据的流 + * + * + * @async + */ + export function gunzipTo(data: Class_Buffer, stm: Class_Stream): void; + + /** + * + * @brief 解压缩源流中 gzip 算法压缩的数据到流对象中 + * @param src 给定要解压缩的数据所在的流 + * @param stm 指定存储解压缩数据的流 + * + * + * @async + */ + export function gunzipTo(src: Class_Stream, stm: Class_Stream): void; + + /** + * + * @brief 使用 deflate 算法压缩数据(deflateRaw) + * @param data 给定要压缩的数据 + * @param level 指定压缩级别,缺省为 DEFAULT_COMPRESSION + * @return 返回压缩后的二进制数据 + * + * + * @async + */ + export function deflateRaw(data: Class_Buffer, level?: number/** = undefined*/): Class_Buffer; + + /** + * + * @brief 使用 deflate 算法压缩数据到流对象中(deflateRaw) + * @param data 给定要压缩的数据 + * @param stm 指定存储压缩数据的流 + * @param level 指定压缩级别,缺省为 DEFAULT_COMPRESSION + * + * + * @async + */ + export function deflateRawTo(data: Class_Buffer, stm: Class_Stream, level?: number/** = undefined*/): void; + + /** + * + * @brief 使用 deflate 算法压缩源流中的数据到流对象中(deflateRaw) + * @param src 给定要压缩的数据所在的流 + * @param stm 指定存储压缩数据的流 + * @param level 指定压缩级别,缺省为 DEFAULT_COMPRESSION + * + * + * @async + */ + export function deflateRawTo(src: Class_Stream, stm: Class_Stream, level?: number/** = undefined*/): void; + + /** + * + * @brief 解压缩 deflate 算法压缩的数据(inflateRaw) + * @param data 给定压缩后的数据 + * @return 返回解压缩后的二进制数据 + * + * + * @async + */ + export function inflateRaw(data: Class_Buffer): Class_Buffer; + + /** + * + * @brief 解压缩 deflate 算法压缩的数据到流对象中(inflateRaw) + * @param data 给定要解压缩的数据 + * @param stm 指定存储解压缩数据的流 + * + * + * @async + */ + export function inflateRawTo(data: Class_Buffer, stm: Class_Stream): void; + + /** + * + * @brief 解压缩源流中 deflate 算法压缩的数据到流对象中(inflateRaw) + * @param src 给定要解压缩的数据所在的流 + * @param stm 指定存储解压缩数据的流 + * + * + * @async + */ + export function inflateRawTo(src: Class_Stream, stm: Class_Stream): void; + + } /** end of `module zlib` */ + export = zlib +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/declare/zmq.d.ts b/types/fibjs/declare/zmq.d.ts new file mode 100644 index 0000000000..04f7b59815 --- /dev/null +++ b/types/fibjs/declare/zmq.d.ts @@ -0,0 +1,314 @@ +/*************************************************************************** + * * + * This file was automatically generated with idlc.js * + * build info: * + * - fibjs : 0.25.0 * + * - date : Jun 11 2018 14:17:22 * + * * + ***************************************************************************/ + +/** + * @author Richard + * + */ + + + + + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + +/// + + + +/** module Or Internal Object */ +/** + * @brief zeroMQ 消息队列模块 + * @detail 基础模块。提供 zeroMQ 消息队列支撑。,```JavaScript,var zmq = require('zmq');,``` + */ +declare module "zmq" { + + + module zmq { + + /** + * + * + * + * + */ + export const PAIR = 0; + + /** + * + * @brief 发布类型,所发送的消息将会分发给所有订阅者。 + * + * + */ + export const PUB = 1; + + /** + * + * @brief 订阅类型,用于接收 PUB 分发的消息。 + * + * + */ + export const SUB = 2; + + /** + * + * @brief 请求类型,此类型的接口只允许交替进行 send 和 recv 消息,每一个接受的消息都是最后一次发送请求的响应。 + * + * + */ + export const REQ = 3; + + /** + * + * @brief 响应类型,此类型的接口只允许交替进行 recv 和 send 消息,每一个发送的消息都会作为最后一次接受的请求的回应。 + * + * + */ + export const REP = 4; + + /** + * + * + * + * + */ + export const DEALER = 5; + + /** + * + * + * + * + */ + export const ROUTER = 6; + + /** + * + * @brief 获取消息类型,上游推送的消息将被公平的分发到此类接口。 + * + * + */ + export const PULL = 7; + + /** + * + * @brief 推送类型,推送的消息将均衡发送到下游接口。 + * + * + */ + export const PUSH = 8; + + /** + * + * + * + * + */ + export const XPUB = 9; + + /** + * + * + * + * + */ + export const XSUB = 10; + + + + /** + * + * @brief ZmqSocket 对象,参见 ZmqSocket + * + * + */ + export class ZmqSocket extends Class_ZmqSocket {} + + + + + } /** end of `module zmq` */ + export = zmq +} + +/** } /** endof `module Or Internal Object` */ + + diff --git a/types/fibjs/fibjs-tests.ts b/types/fibjs/fibjs-tests.ts new file mode 100644 index 0000000000..90b5f5ff6c --- /dev/null +++ b/types/fibjs/fibjs-tests.ts @@ -0,0 +1,48 @@ +import assert = require('assert'); +import base32 = require('base32'); +import base64 = require('base64'); +import base64vlq = require('base64vlq'); +import bson = require('bson'); +import console = require('console'); +import constants = require('constants'); +import coroutine = require('coroutine'); +import crypto = require('crypto'); +import db = require('db'); +import dgram = require('dgram'); +import dns = require('dns'); +// import encoding = require('encoding'); +import fs = require('fs'); +import gd = require('gd'); +// import global = require('global'); +import gui = require('gui'); +import hash = require('hash'); +import hex = require('hex'); +import http = require('http'); +import iconv = require('iconv'); +import io = require('io'); +import json = require('json'); +import mq = require('mq'); +import net = require('net'); +import os = require('os'); +import path = require('path'); +import path_posix = require('path_posix'); +import path_win32 = require('path_win32'); +import process = require('process'); +import profiler = require('profiler'); +import punycode = require('punycode'); +import querystring = require('querystring'); +import registry = require('registry'); +import ssl = require('ssl'); +import string_decoder = require('string_decoder'); +// import test = require('test'); +import timers = require('timers'); +import tty = require('tty'); +import url = require('url'); +import util = require('util'); +import uuid = require('uuid'); +import vm = require('vm'); +import ws = require('ws'); +import xml = require('xml'); +import zip = require('zip'); +import zlib = require('zlib'); +import zmq = require('zmq'); diff --git a/types/fibjs/index.d.ts b/types/fibjs/index.d.ts new file mode 100644 index 0000000000..67bc9f3a4e --- /dev/null +++ b/types/fibjs/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for fibjs 0.25 +// Project: https://github.com/fibjs/fibjs +// Definitions by: Richard +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// diff --git a/types/fibjs/tsconfig.json b/types/fibjs/tsconfig.json new file mode 100644 index 0000000000..c42204e812 --- /dev/null +++ b/types/fibjs/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fibjs-tests.ts" + ] +} diff --git a/types/fibjs/tslint.json b/types/fibjs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/fibjs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/flatbuffers/index.d.ts b/types/flatbuffers/index.d.ts index b95741200b..bd74387bf2 100644 --- a/types/flatbuffers/index.d.ts +++ b/types/flatbuffers/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for flatbuffers 1.6 +// Type definitions for flatbuffers 1.9 // Project: http://google.github.io/flatbuffers/index.html // Definitions by: Kamil Rojewski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,7 +10,7 @@ declare global { type Offset = number; interface Table { - bb: ByteBuffer; + bb: ByteBuffer|null; bb_pos: number; } @@ -241,6 +241,8 @@ declare global { writeFloat32(offset: number, value: number): void; writeFloat64(offset: number, value: number): void; + getBufferIdentifier(): string; + /** * Look up a field in the vtable, return an offset into the object, or 0 if the * field is not present. diff --git a/types/geojson/index.d.ts b/types/geojson/index.d.ts index ac1bf84e99..93f66d3f27 100644 --- a/types/geojson/index.d.ts +++ b/types/geojson/index.d.ts @@ -80,7 +80,7 @@ export interface GeometryObject extends GeoJsonObject { * Union of geometry objects. * https://tools.ietf.org/html/rfc7946#section-3 */ -export type Geometry = Point | MultiPoint | LineString | Polygon | MultiPolygon | GeometryCollection; +export type Geometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon | GeometryCollection; /** * Point geometry object. diff --git a/types/http-link-header/index.d.ts b/types/http-link-header/index.d.ts index a8dca563d2..cbcb4cbfdb 100644 --- a/types/http-link-header/index.d.ts +++ b/types/http-link-header/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for http-link-header 0.6 // Project: https://github.com/jhermsmeier/node-http-link-header -// Definitions by: Christian Rackerseder +// Definitions by: Christian Rackerseder // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface Reference { diff --git a/types/inboxsdk/inboxsdk-tests.ts b/types/inboxsdk/inboxsdk-tests.ts new file mode 100644 index 0000000000..a763674c73 --- /dev/null +++ b/types/inboxsdk/inboxsdk-tests.ts @@ -0,0 +1,815 @@ +import ComposeView = InboxSDK.Compose.ComposeView; +import Contact = InboxSDK.Common.Contact; +import ThreadRowView = InboxSDK.Lists.ThreadRowView; +import ThreadView = InboxSDK.Conversations.ThreadView; +import SimpleElementView = InboxSDK.Common.SimpleElementView; +import ContentPanelView = InboxSDK.Conversations.ContentPanelView; +import MessageView = InboxSDK.Conversations.MessageView; +import AttachmentCardView = InboxSDK.Conversations.AttachmentCardView; +import AttachmentCardClickEvent = InboxSDK.Conversations.AttachmentCardClickEvent; +import MessageViewLinkDescriptor = InboxSDK.Conversations.MessageViewLinkDescriptor; +import SectionDescriptor = InboxSDK.Router.SectionDescriptor; +import NavItemDescriptor = InboxSDK.NavMenu.NavItemDescriptor; + +InboxSDK.load(1, '1234').then((_sdk: InboxSDK.InboxSDKInstance) => { + _sdk.ButterBar.hideGmailMessage(); +}); + +InboxSDK.load(1, '1234', {}).then(() => console.log('done')); +InboxSDK.load(1, '1234', { + appIconUrl: 'url', + appName: 'name', + suppressAddonTitle: 'su' +}).then(() => console.log('done')); + +InboxSDK.loadScript('https://google.com').then(() => console.log('done')); +InboxSDK.loadScript('https://google.com', {}).then(() => console.log('done')); +InboxSDK.loadScript('https://google.com', {nowrap: true}).then(() => console.log('done')); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + sdk.ButterBar.showMessage({ + text: 'text', + }); + + sdk.ButterBar.showMessage({ + text: 'text', + className: 'c', + hideOnViewChanged: true, + persistent: true, + priority: 1, + time: 1, + messageKey: '1' + }); + + const el: HTMLElement = new HTMLElement(); + + sdk.ButterBar.showMessage({ + el, + }); + + sdk.ButterBar.showMessage({ + el, + className: 'c', + hideOnViewChanged: true, + persistent: true, + priority: 1, + time: 1, + messageKey: '1' + }); + + sdk.ButterBar.showMessage({ + html: '

', + }); + + sdk.ButterBar.showMessage({ + html: '

', + className: 'c', + hideOnViewChanged: true, + persistent: true, + priority: 1, + time: 1, + messageKey: '1' + }); + + sdk.ButterBar.showLoading(); + + sdk.ButterBar.showError({ + text: 'error' + }); + + sdk.ButterBar.showSaving({ + text: 'saving' + }); + + sdk.ButterBar.hideMessage('key'); + sdk.ButterBar.hideGmailMessage(); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const unregister = sdk.Compose.registerComposeViewHandler((composeView: ComposeView) => { + composeView.addButton({ + title: 'button title', + onClick: e => { + const eq = e.composeView === composeView; + const dropdownDestroyed = e.dropdown.destroyed; + + e.dropdown.close(); + + const el: HTMLElement = e.dropdown.el; + + e.dropdown.setPlacementOptions({}); + e.dropdown.setPlacementOptions({ + bottomBuffer: 1, + buffer: 1, + forceHAlign: true, + forcePosition: true, + forceVAlign: true, + hAlign: 'center', + position: 'middle', + rightBuffer: 1, + topBuffer: 1, + vAlign: 'top', + leftBuffer: 1 + }); + } + }); + + const statusBarView = composeView.addStatusBar({}); + statusBarView.setHeight(1); + + composeView.addStatusBar({ + height: 1, + orderHint: 1 + }); + + composeView.close(); + + composeView.send(); + composeView.send({sendAndArchive: true}); + + const element: HTMLElement = composeView.getBodyElement(); + const msgId: string = composeView.getInitialMessageID(); + const threadId: string = composeView.getThreadID(); + composeView.getDraftID().then(draftId => { + const id: string = draftId.toLowerCase(); + }); + composeView.getCurrentDraftID().then(draftId => { + if (draftId) { + const id: string = draftId.toLowerCase(); + } + }); + + const html: string = composeView.getHTMLContent(); + const bodyHtml: string = composeView.getSelectedBodyHTML(); + const bodyText: string = composeView.getSelectedBodyText(); + const subject: string = composeView.getSubject(); + const textContent: string = composeView.getTextContent(); + const contacts: Contact[] = composeView.getToRecipients(); + const contactsCC: Contact[] = composeView.getCcRecipients(); + const contactsBCC: Contact[] = composeView.getBccRecipients(); + + composeView.insertTextIntoBodyAtCursor('text'); + const el1: HTMLElement = composeView.insertHTMLIntoBodyAtCursor(new HTMLElement()); + const el2: HTMLElement = composeView.insertHTMLIntoBodyAtCursor('html'); + + const el3: HTMLElement = composeView.insertLinkChipIntoBodyAtCursor('text', 'http://url.com', 'http://url.com/favicon.ico'); + const el4: HTMLElement = composeView.insertLinkIntoBodyAtCursor('text', 'http://url.com'); + + const inline: boolean = composeView.isInlineReplyForm(); + const fullScreen: boolean = composeView.isFullscreen(); + const minimized: boolean = composeView.isMinimized(); + composeView.setFullscreen(true); + composeView.setMinimized(true); + composeView.popOut().then(view => view === composeView); + + const removeColor = composeView.setTitleBarColor('red'); + removeColor(); + + const isReply: boolean = composeView.isReply(); + + composeView.setToRecipients(['a@a.com', 'b@b.com']); + composeView.setCcRecipients(['a@a.com', 'b@b.com']); + composeView.setBccRecipients(['a@a.com', 'b@b.com']); + + const fromContact: InboxSDK.Common.Contact = composeView.getFromContact(); + const fromContacts: InboxSDK.Common.Contact[] = composeView.getFromContactChoices(); + + composeView.setFromEmail('a@a.com'); + composeView.setSubject('subject'); + composeView.setBodyHTML('

'); + composeView.setBodyText('text'); + composeView.attachFiles([new Blob()]).then(() => console.log()); + composeView.attachInlineFiles([new Blob()]).then(() => console.log()); + + composeView.on('destroy', event => { + const msgId: string = event.messageID; + const byInbox: boolean = event.closedByInboxSDK; + }); + + composeView.on('fullscreenChanged', event => { + const fs: boolean = event.fullscreen; + }); + + composeView.on('fromContactChanged', event => { + const c: InboxSDK.Common.Contact = event.contact; + }); + + composeView.on('toContactAdded', event => { + const c: InboxSDK.Common.Contact = event.contact; + }); + + composeView.on('toContactRemoved', event => { + const c: InboxSDK.Common.Contact = event.contact; + }); + + composeView.on('ccContactAdded', event => { + const c: InboxSDK.Common.Contact = event.contact; + }); + + composeView.on('ccContactRemoved', event => { + const c: InboxSDK.Common.Contact = event.contact; + }); + + composeView.on('bccContactAdded', event => { + const c: InboxSDK.Common.Contact = event.contact; + }); + + composeView.on('bccContactRemoved', event => { + const c: InboxSDK.Common.Contact = event.contact; + }); + + composeView.on('recipientsChanged', event => { + let c: InboxSDK.Common.Contact; + c = event.to.added[0]; + c = event.to.removed[0]; + c = event.cc.added[0]; + c = event.cc.removed[0]; + c = event.bcc.added[0]; + c = event.bcc.removed[0]; + }); + + composeView.on('presending', event => { + event.cancel(); + }); + + composeView.on('sent', event => { + event.getMessageID().then(msgId => msgId.toLowerCase()); + event.getThreadID().then(threadId => threadId.toLowerCase()); + }); + + composeView.on('discard', () => { + console.log(); + }); + composeView.on('sendCanceled', () => { + console.log(); + }); + composeView.on('sending', () => { + console.log(); + }); + composeView.on('bodyChanged', () => { + console.log(); + }); + composeView.on('minimized', () => { + console.log(); + }); + composeView.on('restored', () => { + console.log(); + }); + + const destroyed: boolean = composeView.destroyed; + }); + + unregister(); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const unregister = sdk.Lists.registerThreadRowViewHandler((threadRowView: ThreadRowView) => { + threadRowView.addLabel({ + title: 'title', + iconUrl: 'http://url.com' + }); + + threadRowView.addLabel({ + title: 'title', + iconUrl: 'http://url.com', + backgroundColor: 'red', + foregroundColor: 'blue', + iconBackgroundColor: 'yellow', + iconClass: 'big' + }); + + threadRowView.addImage({ + imageUrl: 'http://url.com' + }); + + threadRowView.addImage({ + imageUrl: 'http://url.com', + imageClass: 'big', + tooltip: 'tooltip', + orderHint: 1 + }); + + threadRowView.addButton({ + title: 'title', + iconUrl: 'http://url.com', + onClick: event => { + const eq = event.threadRowView === threadRowView; + if (event.dropdown) { + event.dropdown.close(); + } + }, + hasDropdown: true + }); + + threadRowView.addButton({ + title: 'title', + iconUrl: 'http://url.com', + onClick: event => { + }, + hasDropdown: false, + iconClass: 'big' + }); + + threadRowView.addActionButton({ + type: 'LINK', + title: 'title', + className: 'big', + url: 'http://url.com', + onClick: () => { + } + }); + + threadRowView.addAttachmentIcon({}); + threadRowView.addAttachmentIcon({ + tooltip: 'tooltip', + iconClass: 'big', + iconUrl: 'http://url.com' + }); + + threadRowView.replaceDate({ + text: '1/1/2000' + }); + threadRowView.replaceDate({ + text: '1/1/2000', + textColor: 'red', + tooltip: 'tooltip' + }); + + threadRowView.replaceDraftLabel({ + text: 'my draft' + }); + threadRowView.replaceDraftLabel({ + text: 'my draft', + count: '2' + }); + + const subject: string = threadRowView.getSubject(); + const date: string = threadRowView.getDateString(); + threadRowView.getThreadIDAsync().then(threadId => threadId.toLowerCase()); + threadRowView.getThreadIDIfStableAsync().then(threadId => { + if (threadId) { + threadId.toLowerCase(); + } + }); + threadRowView.getDraftID().then(draftId => draftId.toLowerCase()); + + const count1: number = threadRowView.getVisibleDraftCount(); + const count2: number = threadRowView.getVisibleMessageCount(); + + const contacts: InboxSDK.Common.Contact[] = threadRowView.getContacts(); + + threadRowView.on('destroyed', () => console.log()); + + const destroyed: boolean = threadRowView.destroyed; + }); + + unregister(); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const unregister = sdk.Conversations.registerThreadViewHandler((threadView: ThreadView) => { + const noticeBar: SimpleElementView = threadView.addNoticeBar(); + noticeBar.destroy(); + + const contentPanel: ContentPanelView = threadView.addSidebarContentPanel({ + el: new HTMLElement(), + title: 'title', + iconUrl: 'http://url.com', + }); + + contentPanel.remove(); + const destroyed: boolean = contentPanel.destroyed; + contentPanel.on('destroy', () => console.log()); + contentPanel.on('deactivate', () => console.log()); + contentPanel.on('activate', () => console.log()); + + threadView.addSidebarContentPanel({ + el: new HTMLElement(), + title: 'title', + iconUrl: 'http://url.com', + appIconUrl: 'http://url.com', + appName: 'app name', + id: '1', + orderHint: 1, + hideTitleBar: true + }); + + const messageViews: MessageView[] = threadView.getMessageViews(); + const allMessageViews: MessageView[] = threadView.getMessageViewsAll(); + const subject: string = threadView.getSubject(); + threadView.getThreadIDAsync().then(threadId => threadId.toLowerCase()); + + threadView.on('contactHover', event => { + const contact: Contact = event.contact; + const eq1 = event.messageView === messageViews[0]; + const eq2 = event.threadView === threadView; + const isSender: boolean = event.contactType === 'sender'; + }); + + threadView.on('destroy', () => console.log()); + }); + + unregister(); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const unregister = sdk.Conversations.registerMessageViewHandler((messageView: MessageView) => { + const attachmentCardView: AttachmentCardView = messageView.addAttachmentCardView({ + title: 'title', + description: 'desc', + previewUrl: 'http://url.com', + previewThumbnailUrl: 'http://url.com', + failoverPreviewIconUrl: 'http://url.com', + previewOnClick: event => { + const eq = event.attachmentCardView === attachmentCardView; + event.preventDefault(); + }, + fileIconImageUrl: 'http://url.com', + buttons: [ + { + downloadUrl: 'http://url.com', + downloadFilename: 'file.txt', + openInNewTab: true, + onClick: () => { + } + }, + { + iconUrl: 'http://url.com', + tooltip: 'tooltip', + onClick: (event: AttachmentCardClickEvent) => event.getDownloadURL().then(url => url.toLowerCase()) + } + ], + foldColor: 'red', + mimeType: 'text' + }); + + const attachmentType: string = attachmentCardView.getAttachmentType(); + const title: string = attachmentCardView.getTitle(); + const msgView: MessageView | null = attachmentCardView.getMessageView(); + attachmentCardView.addButton({ + iconUrl: 'http://url.com', + tooltip: 'tooltip', + onClick: (event: AttachmentCardClickEvent) => event.getDownloadURL().then(url => url.toLowerCase()) + }); + + attachmentCardView.on('destroy', () => console.log()); + const destroyed: boolean = attachmentCardView.destroyed; + + messageView.addAttachmentsToolbarButton({ + iconUrl: 'http://url.com', + tooltip: 'tooltip', + onClick: event => { + const attType: string = event.attachmentCardViews[0].getAttachmentType(); + } + }); + + messageView.addToolbarButton({ + section: 'MORE', + title: 'title', + iconUrl: 'http://url.com', + iconClass: 'big', + onClick: () => { + }, + orderHint: 1 + }); + + const el: HTMLElement = messageView.getBodyElement(); + messageView.getMessageIDAsync().then(msgId => msgId.toLowerCase()); + const attCardViews: AttachmentCardView[] = messageView.getFileAttachmentCardViews(); + const isQuotedArea = messageView.isElementInQuotedArea(); + const isLoaded = messageView.isLoaded(); + const links: MessageViewLinkDescriptor[] = messageView.getLinksInBody(); + links[0].text.toLowerCase(); + links[0].element.click(); + links[0].html.toLowerCase(); + const isInQuotedArea: boolean = links[0].isInQuotedArea; + links[0].href.toLowerCase(); + + const contact: Contact = messageView.getSender(); + const add: string[] = messageView.getRecipientEmailAddresses(); + messageView.getRecipientsFull().then(contacts => { + const c: Contact = contacts[0]; + }); + + const threadView: ThreadView = messageView.getThreadView(); + const date: string = messageView.getDateString(); + messageView.addAttachmentIcon({ + iconUrl: 'http://url.com', + iconClass: 'big', + onClick: () => { + }, + tooltip: 'tooltip' + }); + + const eq = messageView.getViewState() === 'HIDDEN'; + + messageView.on('viewStateChange', event => { + const eq1 = event.newViewState === 'COLLAPSED'; + const eq2 = event.oldViewState === 'EXPANDED'; + const eq3 = event.messageView === messageView; + }); + + messageView.on('contactHover', event => { + event.contact.name.toLowerCase(); + }); + + messageView.on('load', () => console.log()); + messageView.on('destroy', () => console.log()); + + const destroyed1: boolean = messageView.destroyed; + }); + + unregister(); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const unregister = sdk.Conversations.registerMessageViewHandlerAll((messageView: MessageView) => { + const isLoaded: boolean = messageView.isLoaded(); + }); + + unregister(); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const unregister = sdk.Conversations.registerFileAttachmentCardViewHandler((attachmentCardView: AttachmentCardView) => { + const messageView: MessageView | null = attachmentCardView.getMessageView(); + }); + + unregister(); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const unregister = sdk.Toolbars.registerThreadButton({ + hasDropdown: true, + hideFor: (routeView => routeView.getParams()), + iconClass: 'big', + iconUrl: 'http://url.com', + keyboardShortcutHandle: { + remove: () => { + } + }, + listSection: 'INBOX_STATE', + onClick: event => event.position === 'LIST', + orderHint: 1, + positions: ['LIST', 'ROW'], + threadSection: 'METADATA_STATE', + title: 'title' + }); + + unregister(); + + sdk.Toolbars.addToolbarButtonForApp({ + iconClass: 'big', + arrowColor: 'red', + iconUrl: 'http://url.com', + onClick: event => event.dropdown.close(), + title: 'title', + titleClass: 'big' + }); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + sdk.Router.createLink('1234', {p1: 1, 0: 1}).toLowerCase(); + sdk.Router.goto('1234', {p1: 1, 0: 1}); + + const unregister1 = sdk.Router.handleCustomRoute('1234', customRouteView => { + customRouteView.getParams(); + customRouteView.setFullWidth(true); + customRouteView.getElement().click(); + }); + + unregister1(); + + const unregister2 = sdk.Router.handleAllRoutes(routeView => { + routeView.getParams(); + routeView.getRouteID(); + routeView.getRouteType(); + routeView.on('destroy', () => { + }); + const destroyed: boolean = routeView.destroyed; + }); + + unregister2(); + + const unregister3 = sdk.Router.handleListRoute('ALL_MAIL', listRouteView => { + const sectionDescriptor: SectionDescriptor = { + contentElement: new HTMLElement(), + footerLinkText: 'text', + hasDropdown: true, + onDropdownClick: event => event.dropdown.close(), + onFooterLinkClick: event => { + }, + onTitleLinkClick: () => { + }, + subtitle: 'title', + tableRows: [{ + body: 'body', + iconClass: 'big', + iconUrl: 'http://url.com', + isRead: 'true', + labels: [{ + iconClass: 'big', + iconBackgroundColor: 'red', + foregroundColor: 'green', + backgroundColor: 'blue', + iconUrl: 'http://url.com', + title: 'title' + }], + onClick: () => { + }, + routeID: '1234', + routeParams: ['p1'], + shortDetailText: 'text', + title: 'title' + }], + title: 'title', + titleLinkText: 'text' + }; + + listRouteView.addCollapsibleSection(sectionDescriptor); + listRouteView.addSection(sectionDescriptor); + + listRouteView.refresh(); + }); + + unregister3(); + + const unregister4 = sdk.Router.handleCustomListRoute('1234', (offset, max) => { + return { + threads: [ + { + rfcMessageId: 'id', + gmailThreadId: 'id' + }, + 'id' + ], + total: 1, + hasMore: true, + }; + }); + + unregister4(); + + sdk.Router.getCurrentRouteView().getRouteID().toLowerCase(); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const navItemDescriptor: NavItemDescriptor = { + accessory: { + type: 'CREATE', + onClick: () => { + } + }, + backgroundColor: 'red', + expanderForegroundColor: 'green', + iconClass: 'big', + iconUrl: 'http://url.com', + name: 'name', + onClick: event => event.preventDefault(), + orderHint: 1, + routeID: '1234', + routeParams: {p: 1}, + type: 'MANAGE' + }; + + const navItem = sdk.NavMenu.addNavItem(navItemDescriptor); + const navItem1 = navItem.addNavItem(navItemDescriptor); + navItem.remove(); + navItem1.remove(); + + const isCollapsed: boolean = navItem.isCollapsed(); + navItem.setCollapsed(true); + + navItem.on('destroy', () => { + }); + const destroyed: boolean = navItem.destroyed; +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const modalView = sdk.Widgets.showModalView({ + buttons: [{ + color: 'red', + onClick: () => { + }, + orderHint: 1, + text: 'text', + title: 'title', + type: 'PRIMARY_ACTION' + }], + chrome: true, + constrainTitleWidth: true, + el: new HTMLElement(), + showCloseButton: true, + title: 'title' + }); + + modalView.close(); + modalView.on('destroyed', () => { + }); + const destroyed: boolean = modalView.destroyed; + + const moleView = sdk.Widgets.showMoleView({ + chrome: true, + className: 'big', + el: new HTMLElement(), + minimizedTitleEl: new HTMLElement(), + title: 'title', + titleEl: new HTMLElement(), + titleButtons: [{ + iconClass: 'big', + iconUrl: 'http://url.com', + onClick: () => { + }, + title: 'title' + }] + }); + + moleView.close(); + const minimized: boolean = moleView.getMinimized(); + moleView.setMinimized(true); + moleView.setTitle('title'); + moleView.on('destroyed', () => { + }); + moleView.on('minimize', () => { + }); + moleView.on('restore', () => { + }); + + const drawerView = sdk.Widgets.showDrawerView({ + chrome: true, + closeWithCompose: true, + el: new HTMLElement(), + title: 'title' + }); + + drawerView.close(); + drawerView.disassociateComposeView(); + const destroyed1: boolean = drawerView.destroyed; + drawerView.on('destroyed', () => { + }); + drawerView.on('slideAnimationDone', () => { + }); + drawerView.on('closing', () => { + }); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const searchResults = [{ + iconUrl: 'http://url.com', + onClick: () => { + }, + description: 'desc', + externalURL: 'http://url.com', + name: 'name', + routeName: 'name', + routeParams: ['a', 'b'] + }, { + iconUrl: 'http://url.com', + onClick: () => { + }, + descriptionHTML: 'desc', + externalURL: 'http://url.com', + nameHTML: 'name', + routeName: 'name', + routeParams: ['a', 'b'] + }]; + + sdk.Search.registerSearchSuggestionsProvider(query => searchResults); + sdk.Search.registerSearchSuggestionsProvider(query => Promise.resolve(searchResults)); + + sdk.Search.registerSearchQueryRewriter({ + term: 'a', + termReplacer: () => 'b' + }); + + sdk.Search.registerSearchQueryRewriter({ + term: 'a', + termReplacer: () => Promise.resolve('b') + }); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + sdk.User.getEmailAddress().toLowerCase(); + const isConversationViewDisabled: boolean = sdk.User.isConversationViewDisabled(); + const isUsingGmailMaterialUI: boolean = sdk.User.isUsingGmailMaterialUI(); + sdk.User.getLanguage().toLowerCase(); + sdk.User.getAccountSwitcherContactList()[0].name.toLowerCase(); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const panel = sdk.Global.addSidebarContentPanel({ + el: new HTMLElement(), + title: 'title', + iconUrl: 'http://url.com' + }); + panel.remove(); +}); + +InboxSDK.load(1, '1234').then((sdk: InboxSDK.InboxSDKInstance) => { + const handler = sdk.Keyboard.createShortcutHandle({ + chord: 'a', + description: 'b' + }); + + handler.remove(); +}); diff --git a/types/inboxsdk/index.d.ts b/types/inboxsdk/index.d.ts new file mode 100644 index 0000000000..66b696e05a --- /dev/null +++ b/types/inboxsdk/index.d.ts @@ -0,0 +1,1073 @@ +// Type definitions for InboxSDK 2.0 +// Project: https://www.inboxsdk.com/ +// Definitions by: Raphaël Doursenaud +// Amiram Korach +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/* + * Copyright (c) 2016 GPC.solutions + * Copyright (c) 2018 https://propelmypr.com + */ + +// tslint:disable-next-line:export-just-namespace +export = InboxSDK; +export as namespace InboxSDK; + +declare namespace InboxSDK { + function load(version: number, appId?: string, opts?: LoadOptions): Promise; + + function loadScript(url: string, options?: LoadScriptOptions): Promise; + +// // Undocummented +// var IMPL_VERSION: string; +// var LOADER_VERSION: string; +// var destroyed: boolean; //: false +// var Logger: { +// error: () => any; +// event: () => any; +// }; + + interface LoadOptions { + appName?: string; + appIconUrl?: string; + suppressAddonTitle?: string; + } + + interface LoadScriptOptions { + nowrap?: boolean; + } + + interface InboxSDKInstance { + Compose: Compose.ComposeInstance; + Lists: Lists.ListsInstance; + Conversations: Conversations.ConversationsInstance; + Toolbars: Toolbars.ToolbarsInstance; + Router: Router.RouterInstance; + NavMenu: NavMenu.NavMenuInstance; + Widgets: Widgets.WidgetsInstance; + ButterBar: ButterBar.ButterBarInstance; + Search: Search.SearchInstance; + User: User.UserInstance; + Keyboard: Keyboard.KeyboardInstance; + Global: Global.GlobalInstance; + } + + namespace Common { + interface Contact { + name: string; + emailAddress: string; + } + + interface DropdownView { + setPlacementOptions(options: PositionOptions): void; + + close(): void; + + reposition(): void; + + el: HTMLElement; + destroyed: boolean; + + on(name: 'destroy', cb: () => void): void; + + on(name: 'preautoclose', cb: (event: PreAutoCloseEvent) => void): void; + } + + interface PreAutoCloseEvent { + type: 'outsideInteraction' | 'escape'; + cause: Event; + + cancel(): void; + } + + interface PositionOptions { + position?: string; + forcePosition?: boolean; + hAlign?: string; + forceHAlign?: boolean; + vAlign?: string; + forceVAlign?: boolean; + buffer?: number; + topBuffer?: number; + bottomBuffer?: number; + leftBuffer?: number; + rightBuffer?: number; + } + + interface SimpleElementView { + destroy(): void; + + el: HTMLElement; + destroyed: boolean; + + on(name: 'destroy', cb: () => void): void; + } + } + + export namespace Compose { + interface ComposeInstance { + registerComposeViewHandler(handler: (composeView: ComposeView) => void): () => void; + + openNewComposeView(): Promise; + } + + interface ComposeView { + addButton(buttonDescriptor: ComposeButtonDescriptor): void; + + addStatusBar(statusBarDescriptor: StatusBarDescriptor): StatusBarView; + + close(): void; + + send(options?: SendOptions): void; + + getBodyElement(): HTMLElement; + + getInitialMessageID(): string; + + getThreadID(): string; + + getDraftID(): Promise; + + getCurrentDraftID(): Promise; + + getHTMLContent(): string; + + getSelectedBodyHTML(): string; + + getSelectedBodyText(): string; + + getSubject(): string; + + getTextContent(): string; + + getToRecipients(): Common.Contact[]; + + getCcRecipients(): Common.Contact[]; + + getBccRecipients(): Common.Contact[]; + + insertTextIntoBodyAtCursor(text: string): void; + + insertHTMLIntoBodyAtCursor(html: string | HTMLElement): HTMLElement; + + insertLinkChipIntoBodyAtCursor(text: string, url: string, iconUrl: string): HTMLElement; + + insertLinkIntoBodyAtCursor(text: string, url: string): HTMLElement; + + isInlineReplyForm(): boolean; + + isFullscreen(): boolean; + + setFullscreen(minimized: boolean): void; + + isMinimized(): boolean; + + setMinimized(minimized: boolean): void; + + popOut(): Promise; + + setTitleBarColor(color: string): () => void; + + isReply(): boolean; + + setToRecipients(emails: string[]): void; + + setCcRecipients(emails: string[]): void; + + setBccRecipients(emails: string[]): void; + + getFromContact(): Common.Contact; + + getFromContactChoices(): Common.Contact[]; + + setFromEmail(email: string): void; + + setSubject(text: string): void; + + setBodyHTML(html: string): void; + + setBodyText(text: string): void; + + attachFiles(files: Blob[]): Promise; + + attachInlineFiles(Files: Blob[]): Promise; + + on(name: 'destroy', cb: (event: { messageID: string, closedByInboxSDK: boolean }) => void): void; + + on(name: 'fullscreenChanged', cb: (event: { fullscreen: boolean }) => void): void; + + on(name: 'fromContactChanged' | 'toContactAdded' | 'toContactRemoved' | 'ccContactAdded' | 'ccContactRemoved' | 'bccContactAdded' | 'bccContactRemoved', + cb: (event: { contact: Common.Contact }) => void): void; + + on(name: 'recipientsChanged', cb: (event: RecipientsChangedEvent) => void): void; + + on(name: 'presending', cb: (event: { cancel: () => void }) => void): void; + + on(name: 'sent', cb: (event: { getThreadID: () => Promise, getMessageID: () => Promise }) => void): void; + + on(name: 'discard' | 'sendCanceled' | 'sending' | 'bodyChanged' | 'minimized' | 'restored', cb: () => void): void; + + destroyed: boolean; + } + + interface RecipientsChangedEvent { + to: { + added: Common.Contact[]; + removed: Common.Contact[]; + }; + cc: { + added: Common.Contact[]; + removed: Common.Contact[]; + }; + bcc: { + added: Common.Contact[]; + removed: Common.Contact[]; + }; + } + + interface ComposeButtonDescriptor { + title: string; + iconUrl?: string; + iconClass?: string; + onClick: (event: ComposeButtonClickEvent) => void; + hasDropdown?: boolean; + type?: 'MODIFIER' | 'SEND_ACTION'; + orderHint?: number; + enabled?: boolean; + } + + interface ComposeButtonClickEvent { + composeView: ComposeView; + dropdown: Common.DropdownView; + } + + interface StatusBarDescriptor { + height?: number; + orderHint?: number; + } + + interface StatusBarView extends Common.SimpleElementView { + setHeight(height: number): void; + } + + interface SendOptions { + sendAndArchive?: boolean; + } + } + + export namespace Lists { + interface ListsInstance { + registerThreadRowViewHandler(handler: (threadRowView: ThreadRowView) => any): () => void; + } + + interface ThreadRowView { + addLabel(labelDescriptor: LabelDescriptor): void; + + // addLabel(labelDescriptor: Stream): void; + + addImage(imageDescriptor: ImageDescriptor): void; + + // addImage(imageDescriptor: Stream): void; + + addButton(buttonDescriptor: ThreadRowButtonDescriptor): void; + + // addButton(buttonDescriptor: Stream): void; + + addActionButton(buttonDescriptor: ThreadRowActionButtonDescriptor): void; + + // addActionButton(buttonDescriptor: Stream): void; + + addAttachmentIcon(threadRowAttachmentIconDescriptor: ThreadRowAttachmentIconDescriptor): void; + + // addAttachmentIcon(threadRowAttachmentIconDescriptor: stream): void + + replaceDate(threadRowDateDescriptor: ThreadRowDateDescriptor): void; + + // replaceDate(threadRowDateDescriptor: Stream): void; + + replaceDraftLabel(draftLabelDescriptor: ThreadRowDraftLabelDescriptor): void; + + // replaceDraftLabel(draftLabelDescriptor: Stream): void; + + getSubject(): string; + + getDateString(): string; + + getThreadIDAsync(): Promise; + + getThreadIDIfStableAsync(): Promise; + + getDraftID(): Promise; + + getVisibleDraftCount(): number; + + getVisibleMessageCount(): number; + + getContacts(): Common.Contact[]; + + on(name: 'destroyed', cb: () => void): void; + + destroyed: boolean; + } + + interface ThreadRowButtonDescriptor { + title: string; + iconUrl: string; + iconClass?: string; + onClick: (event: ThreadRowButtonClickEvent) => void; + hasDropdown?: boolean; + } + + interface ThreadRowButtonClickEvent { + threadRowView: ThreadRowView; + dropdown?: Common.DropdownView; + } + + interface ThreadRowActionButtonDescriptor { + type: 'LINK'; + title: string; + className?: string; + onClick?: (event: any) => void; + url: string; + } + + interface LabelDescriptor { + title: string; + foregroundColor?: string; + backgroundColor?: string; + iconUrl: string; + iconClass?: string; + iconBackgroundColor?: string; + } + + interface ImageDescriptor { + imageUrl: string; + imageClass?: string; + tooltip?: string; + orderHint?: number; + } + + interface ThreadRowDateDescriptor { + text: string; + textColor?: string; + tooltip?: string; + } + + interface ThreadRowAttachmentIconDescriptor { + iconUrl?: string; + iconClass?: string; + tooltip?: string; + } + + interface ThreadRowDraftLabelDescriptor { + text: string; + count?: string; + } + } + + export namespace Conversations { + interface ConversationsInstance { + registerThreadViewHandler(handler: (threadView: ThreadView) => void): () => void; + + registerMessageViewHandler(handler: (messageView: MessageView) => void): () => void; + + registerMessageViewHandlerAll(handler: (messageView: MessageView) => void): () => void; + + registerFileAttachmentCardViewHandler(handler: (attachmentCardView: AttachmentCardView) => void): () => void; + } + + interface ThreadView { + addNoticeBar(): Common.SimpleElementView; + + addSidebarContentPanel(contentPanelDescriptor: ContentPanelDescriptor): ContentPanelView; + + getMessageViews(): MessageView[]; + + getMessageViewsAll(): MessageView[]; + + getSubject(): string; + + getThreadIDAsync(): Promise; + + on(name: 'contactHover', cb: (event: ContactHoverEvent) => void): void; + + on(name: 'destroy', cb: () => void): void; + + destroyed: boolean; + } + + interface ContactHoverEvent { + contact: Common.Contact; + contactType: 'sender' | 'recipient'; + messageView: MessageView; + threadView: ThreadView; + } + + interface MessageView { + addAttachmentCardView(cardOptions: AttachmentCardOptions | AttachmentCardNoPreviewOptions): AttachmentCardView; + + addAttachmentsToolbarButton(buttonOptions: AttachmentsToolbarButtonDescriptor): void; + + addToolbarButton(options: MessageViewToolbarButtonDescriptor): void; + + getBodyElement(): HTMLElement; + + getMessageIDAsync(): Promise; + + getFileAttachmentCardViews(): AttachmentCardView[]; + + isElementInQuotedArea(): boolean; + + isLoaded(): boolean; + + getLinksInBody(): MessageViewLinkDescriptor[]; + + getSender(): Common.Contact; + + getRecipientEmailAddresses(): string[]; + + getRecipientsFull(): Promise; + + getThreadView(): ThreadView; + + getDateString(): string; + + addAttachmentIcon(iconDescriptor: MessageAttachmentIconDescriptor): void; + + // addAttachmentIcon(iconDescriptor: Stream): void; + + getViewState(): MessageViewViewStates; + + on(name: 'viewStateChange', cb: (event: { newViewState: MessageViewViewStates, oldViewState: MessageViewViewStates, messageView: MessageView }) => void): void; + + on(name: 'contactHover', cb: (event: ContactHoverEvent) => void): void; + + on(name: 'destroy' | 'load', cb: () => void): void; + + destroyed: boolean; + } + + type MessageViewViewStates = 'HIDDEN' | 'COLLAPSED' | 'EXPANDED'; + + interface ContentPanelView { + remove(): void; + + on(name: 'destroy' | 'activate' | 'deactivate', cb: () => void): void; + + destroyed: boolean; + } + + interface AttachmentCardView { + getAttachmentType(): string; + + addButton(buttonDescriptor: CustomButtonDescriptor): void; + + getTitle(): string; + + /** + * @deprecated. Use AttachmentCardClickEvent.getDownloadURL() instead + */ + getDownloadURL(): Promise; + + getMessageView(): MessageView | null; + + on(name: 'destroy', cb: () => void): void; + + destroyed: boolean; + } + + // ConversationsDescriptors + + interface AttachmentCardOptions { + title: string; + description: string; + previewUrl: string; + previewThumbnailUrl: string; + failoverPreviewIconUrl: string; + previewOnClick: (event: PreviewClickEvent) => void; + fileIconImageUrl: string; + buttons: Array; + foldColor?: string; + mimeType?: string; + } + + interface AttachmentCardNoPreviewOptions { + title: string; + description: string; + previewUrl: string; + iconThumbnailUrl: string; + previewOnClick: (event: PreviewClickEvent) => void; + fileIconImageUrl: string; + buttons: Array; + foldColor?: string; + } + + interface PreviewClickEvent { + attachmentCardView: AttachmentCardView; + + preventDefault(): void; + } + + interface ContentPanelDescriptor { + el: HTMLElement; + title: string; + iconUrl: string; + appName?: string; + appIconUrl?: string; + id?: string; + hideTitleBar?: boolean; + orderHint?: number; + } + + interface DownloadButtonDescriptor { + downloadUrl: string; + downloadFilename?: string; + onClick: (event: any) => void; + openInNewTab?: boolean; + } + + interface CustomButtonDescriptor { + iconUrl: string; + tooltip: string; + onClick: (event: AttachmentCardClickEvent) => void; + } + + interface AttachmentCardClickEvent { + getDownloadURL(): Promise; + } + + interface AttachmentsToolbarButtonDescriptor { + tooltip: string; + iconUrl: string; + onClick: (event: AttachmentsToolbarButtonEvent) => void; + } + + interface AttachmentsToolbarButtonEvent { + attachmentCardViews: AttachmentCardView[]; + } + + interface MessageViewLinkDescriptor { + text: string; + html: string; + element: HTMLElement; + href: string; + isInQuotedArea: boolean; + } + + interface MessageAttachmentIconDescriptor { + iconUrl: string; + iconClass?: string; + tooltip: string; + onClick?: () => void; + } + + interface MessageViewToolbarButtonDescriptor { + section: 'MORE'; + title: string; + iconUrl: string; + onClick: () => void; + iconClass?: string; + orderHint: number; + } + } + + export namespace Toolbars { + interface ToolbarsInstance { + registerThreadButton(toolbarButtonDescriptor: ToolbarButtonDescriptor): () => void; + + /** + * @deprecated. use registerThreadButton + * @param toolbarButtonDescriptor + */ + registerToolbarButtonForList(toolbarButtonDescriptor: ToolbarButtonDescriptor): () => void; + + /** + * @deprecated. use registerThreadButton + * @param toolbarButtonDescriptor + */ + registerToolbarButtonForThreadView(toolbarButtonDescriptor: ToolbarButtonDescriptor): () => void; + + addToolbarButtonForApp(appToolbarButtonDescriptor: AppToolbarButtonDescriptor): AppToolbarButtonView; + } + + interface ToolbarButtonDescriptor { + title: string; + onClick: (event: ToolbarButtonEvent) => void; + iconUrl?: string; + iconClass?: string; + positions?: ToolbarButtonPosition[]; + threadSection?: SectionNames; + listSection?: SectionNames; + hasDropdown?: boolean; + hideFor?: (routeView: Router.RouteView) => void; + orderHint?: number; + keyboardShortcutHandle?: Keyboard.KeyboardShortcutHandle; + } + + type ToolbarButtonPosition = 'THREAD' | 'ROW' | 'LIST'; + + interface ToolbarButtonEvent { + position: ToolbarButtonPosition; + selectedThreadRowViews: Lists.ThreadRowView[]; + selectedThreadViews: Conversations.ThreadView[]; + dropdown?: Common.DropdownView; + } + + interface AppToolbarButtonDescriptor { + title: string; + titleClass?: string; + iconUrl: string; + iconClass?: string; + onClick: (event: AppToolbarButtonEvent) => void; + arrowColor?: string; + } + + interface AppToolbarButtonView { + open(): void; + + close(): void; + + remove(): void; + + on(name: 'destroy', cb: () => void): void; + + destroyed: boolean; + } + + interface AppToolbarButtonEvent { + dropdown: Common.DropdownView; + } + + type SectionNames = 'INBOX_STATE' | 'METADATA_STATE' | 'OTHER'; + } + + export namespace Router { + interface RouterInstance { + createLink(routeID: string | NativeRouteIDs, params: RouteParams): string; + + goto(routeID: string | NativeRouteIDs, params: RouteParams): void; + + handleCustomRoute(routeID: string, handler: (customRouteView: CustomRouteView) => void): () => void; + + handleAllRoutes(handler: (routeView: RouteView) => void): () => void; + + handleListRoute(routeID: NativeListRouteIDs, handler: (listRouteView: ListRouteView) => void): () => void; + + handleCustomListRoute(routeID: string, handler: (offset: number, max: number) => CustomListDescriptor | Promise): () => void; + + getCurrentRouteView(): RouteView; + } + + interface CustomListDescriptor { + threads: Array; + total?: number; + hasMore?: boolean; + } + + interface ThreadDescriptor { + rfcMessageId?: string; + gmailThreadId?: string; + } + + interface RouteParams { + [key: number]: string | number; + + [key: string]: string | number; + } + + interface RouteView { + getRouteID(): string; + + getRouteType(): RouteTypes; + + getParams(): RouteParams; + + on(name: 'destroy', cb: () => void): void; + + destroyed: boolean; + } + + type RouteTypes = 'LIST' | 'THREAD' | 'SETTINGS' | 'CHAT' | 'CUSTOM' | 'UNKNOWN'; + + interface CustomRouteView extends RouteView { + getElement(): HTMLElement; + + setFullWidth(fullWidth: boolean): void; + } + + interface ListRouteView extends RouteView { + addCollapsibleSection(options: SectionDescriptor): CollapsibleSectionView; + + // addCollapsibleSection(options: Stream): CollapsibleSectionView; + + addSection(options: SectionDescriptor): SectionView; + + // addSection(options: Stream): SectionView; + + refresh(): void; + } + + interface SectionView { + remove(): void; + + on(name: 'destroy', cb: () => void): void; + + destroyed: boolean; + } + + interface CollapsibleSectionView extends SectionView { + setCollapsed(value: boolean): void; + + remove(): void; + + on(name: 'destroy' | 'expanded' | 'collapsed', cb: () => void): void; + } + + interface SectionDescriptor { + title: string; + subtitle?: string; + titleLinkText?: string; + onTitleLinkClick?: () => void; + hasDropdown?: boolean; + onDropdownClick?: (event: SectionDropdownClickEvent) => void; + tableRows?: RowDescriptor[]; + contentElement?: HTMLElement; + footerLinkText?: string; + onFooterLinkClick?: (event: any) => void; + } + + interface SectionDropdownClickEvent { + dropdown: Common.DropdownView; + } + + interface RowDescriptor { + title: string; + body: string; + shortDetailText: string; + isRead: string; + labels: Lists.LabelDescriptor[]; + iconUrl?: string; + iconClass?: string; + routeID?: string; + routeParams?: string[]; + onClick?: () => void; + } + + type NativeRouteIDs = + 'INBOX' | + 'ALL_MAIL' | + 'SENT' | + 'STARRED' | + 'DRAFTS' | + 'SNOOZED' | + 'DONE' | + 'REMINDERS' | + 'LABEL' | + 'TRASH' | + 'SPAM' | + 'IMPORTANT' | + 'SEARCH' | + 'THREAD' | + 'CHATS' | + 'CHAT' | + 'CONTACTS' | + 'CONTACT' | + 'SETTINGS' | + 'ANY_LIST'; + + type NativeListRouteIDs = + 'INBOX' + | 'ALL_MAIL' + | 'SENT' + | 'STARRED' + | 'DRAFTS' + | 'SNOOZED' + | 'DONE' + | 'REMINDERS' + | 'LABEL' + | 'TRASH' + | 'SPAM' + | 'IMPORTANT' + | 'SEARCH' + | 'ANY_LIST'; + } + + export namespace NavMenu { + interface NavMenuInstance { + addNavItem(navItemDescriptor: NavItemDescriptor): NavItemView; + } + + interface NavItemView { + addNavItem(navItemDescriptor: NavItemDescriptor): NavItemView; + + remove(): void; + + isCollapsed(): boolean; + + setCollapsed(collapseValue: boolean): void; + + on(name: 'destroy', cb: () => void): void; + + destroyed: boolean; + } + + interface NavItemDescriptor { + name: string; + routeID?: string; + routeParams?: object; + + onClick?: (event: { preventDefault(): void }) => void; + + orderHint?: number; + accessory?: CreateAccessoryDescriptor | IconButtonAccessoryDescriptor | DropdownButtonAccessoryDescriptor; + iconUrl?: string; + iconClass?: string; + backgroundColor?: string; + expanderForegroundColor?: string; + type?: NavItemTypes; + } + + interface CreateAccessoryDescriptor { + type: 'CREATE'; + onClick: () => void; + } + + interface IconButtonAccessoryDescriptor { + type: 'ICON_BUTTON'; + onClick: () => void; + iconUrl: string; + iconClass?: string; + } + + interface DropdownButtonAccessoryDescriptor { + type: 'DROPDOWN_BUTTON'; + buttonBackgroundColor: string; + buttonForegroundColor: string; + onClick: (event: DropdownButtonClickEvent) => void; + } + + interface DropdownButtonClickEvent { + dropdown: Common.DropdownView; + } + + type NavItemTypes = 'MANAGE' | 'NAVIGATION'; + } + + export namespace Widgets { + interface WidgetsInstance { + showModalView(options: ModalOptions): ModalView; + + showMoleView(options: MoleOptions): MoleView; + + showDrawerView(options: DrawerOptions): DrawerView; + } + + interface ModalOptions { + el: HTMLElement; + chrome?: boolean; + constrainTitleWidth?: boolean; + showCloseButton?: boolean; + title?: string; + buttons?: ModalButtonDescriptor[]; + } + + interface ModalButtonDescriptor { + text: string; + title: string; + onClick: () => void; + type?: 'PRIMARY_ACTION' | 'SECONDARY_ACTION'; + color?: string; + orderHint?: number; + } + + interface MoleOptions { + el: HTMLElement; + title?: string; + titleEl?: HTMLElement; + minimizedTitleEl?: HTMLElement; + className?: string; + titleButtons?: MoleButtonDescriptor[]; + chrome?: boolean; + } + + interface MoleButtonDescriptor { + title: string; + iconUrl: string; + iconClass?: string; + onClick: () => void; + } + + interface DrawerOptions { + el: HTMLElement; + chrome?: boolean; + title?: string; + composeView?: Compose.ComposeView; + closeWithCompose?: boolean; + } + + interface ModalView { + close(): void; + + on(name: 'destroyed', cb: () => void): void; + + destroyed: boolean; + } + + interface MoleView { + close(): void; + + setTitle(text: string): void; + + setMinimized(minimized: boolean): void; + + getMinimized(): boolean; + + on(name: 'destroyed' | 'minimize' | 'restore', cb: () => void): void; + + destroyed: boolean; + } + + interface DrawerView { + close(): void; + + associateComposeView(composeView: Compose.ComposeView, closeWithCompose: boolean): void; + + disassociateComposeView(): void; + + on(name: 'destroyed' | 'slideAnimationDone' | 'closing', cb: () => void): void; + + destroyed: boolean; + } + } + + export namespace ButterBar { + interface ButterBarInstance { + showMessage(options: MessageDescriptor): object; + + showLoading(): object; + + showError(options: MessageDescriptor): object; + + showSaving(options: SavingMessageDescriptor): object; + + hideMessage(messageKey: object | string): void; + + hideGmailMessage(): void; + } + + interface MessageDescriptorBase { + className?: string; + priority?: number; + time?: number; + hideOnViewChanged?: boolean; + persistent?: boolean; + messageKey?: object | string; + } + + interface MessageDescriptorText extends MessageDescriptorBase { + text: string; + } + + interface MessageDescriptorHtml extends MessageDescriptorBase { + html: string; + } + + interface MessageDescriptorHtmlElement extends MessageDescriptorBase { + el: HTMLElement; + } + + type MessageDescriptor = MessageDescriptorText | MessageDescriptorHtml | MessageDescriptorHtmlElement; + + interface SavingMessageDescriptorBase extends MessageDescriptorBase { + confirmationText?: string; + confirmationTime?: number; + showConfirmation?: boolean; + } + + interface SavingMessageDescriptorText extends SavingMessageDescriptorBase { + text: string; + } + + interface SavingMessageDescriptorHtml extends SavingMessageDescriptorBase { + html: string; + } + + interface SavingMessageDescriptorHtmlElement extends SavingMessageDescriptorBase { + el: HTMLElement; + } + + type SavingMessageDescriptor = + SavingMessageDescriptorText + | SavingMessageDescriptorHtml + | SavingMessageDescriptorHtmlElement; + } + + export namespace Search { + interface SearchInstance { + registerSearchSuggestionsProvider(handler: (query: string) => AutocompleteSearchResult[] | Promise): void; + + registerSearchQueryRewriter(rewriter: SearchQueryRewriter): void; + } + + interface AutocompleteSearchResultBase { + iconUrl?: string; + routeName?: string; + routeParams?: string[]; + externalURL?: string; + onClick?: () => void; + } + + interface AutocompleteSearchResultText extends AutocompleteSearchResultBase { + name: string; + description: string; + } + + interface AutocompleteSearchResultHtml extends AutocompleteSearchResultBase { + nameHTML: string; + descriptionHTML: string; + } + + type AutocompleteSearchResult = AutocompleteSearchResultText | AutocompleteSearchResultHtml; + + interface SearchQueryRewriter { + term: string; + termReplacer: () => string | Promise; + } + } + + export namespace User { + interface UserInstance { + getEmailAddress(): string; + + isUsingGmailMaterialUI(): boolean; + + isConversationViewDisabled(): boolean; + + getLanguage(): string; + + getAccountSwitcherContactList(): Common.Contact[]; + } + } + + export namespace Keyboard { + interface KeyboardInstance { + createShortcutHandle(keyboardShortcutDescriptor: KeyboardShortcutDescriptor): KeyboardShortcutHandle; + } + + interface KeyboardShortcutHandle { + remove(): void; + } + + interface KeyboardShortcutDescriptor { + chord: string; + description: string; + } + } + + export namespace Global { + interface GlobalInstance { + addSidebarContentPanel(contentPanelDescriptor: Conversations.ContentPanelDescriptor): Conversations.ContentPanelView; + } + } +} diff --git a/types/inboxsdk/tsconfig.json b/types/inboxsdk/tsconfig.json new file mode 100644 index 0000000000..846443ce68 --- /dev/null +++ b/types/inboxsdk/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "inboxsdk-tests.ts" + ] +} diff --git a/types/inboxsdk/tslint.json b/types/inboxsdk/tslint.json new file mode 100644 index 0000000000..99ea174f67 --- /dev/null +++ b/types/inboxsdk/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "strict-export-declare-modifiers": false + } +} diff --git a/types/is-touch-device/index.d.ts b/types/is-touch-device/index.d.ts new file mode 100644 index 0000000000..7a17cbea63 --- /dev/null +++ b/types/is-touch-device/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for is-touch-device 1.0 +// Project: https://github.com/airbnb/is-touch-device +// Definitions by: Christian Rackerseder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export default function isTouchDevice(): boolean; diff --git a/types/is-touch-device/is-touch-device-tests.ts b/types/is-touch-device/is-touch-device-tests.ts new file mode 100644 index 0000000000..5ae2e1eff5 --- /dev/null +++ b/types/is-touch-device/is-touch-device-tests.ts @@ -0,0 +1,3 @@ +import isTouchDevice from 'is-touch-device'; + +if (isTouchDevice()) {} diff --git a/types/is-touch-device/tsconfig.json b/types/is-touch-device/tsconfig.json new file mode 100644 index 0000000000..4ab8fbd5cb --- /dev/null +++ b/types/is-touch-device/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-touch-device-tests.ts" + ] +} diff --git a/types/is-touch-device/tslint.json b/types/is-touch-device/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-touch-device/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/jquery-animate-scroll/index.d.ts b/types/jquery-animate-scroll/index.d.ts new file mode 100644 index 0000000000..a21b179738 --- /dev/null +++ b/types/jquery-animate-scroll/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for JQuery Animate Scroll 1.0 +// Project: https://github.com/risan/jquery-animate-scroll +// Definitions by: Anderson Friaça +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +export type Options = Partial<{ + $container: JQuery; + speed: number; + offset: number; +}>; + +declare global { + interface JQuery { + animateScroll(options?: Options): JQuery; + scrollHere(options?: Options): JQuery; + } + + interface JQueryStatic { + scrollTo(element: JQuery, options?: Options): void; + } +} diff --git a/types/jquery-animate-scroll/jquery-animate-scroll-tests.ts b/types/jquery-animate-scroll/jquery-animate-scroll-tests.ts new file mode 100644 index 0000000000..65bdb07aef --- /dev/null +++ b/types/jquery-animate-scroll/jquery-animate-scroll-tests.ts @@ -0,0 +1,21 @@ +import { Options } from "jquery-animate-scroll"; + +// basic usage +$('a').animateScroll(); + +$('#article-1').scrollHere(); + +$.scrollTo($('#article-1')); + +// with options +const options: Options = { + $container: $('body'), + speed: 1000, + offset: -100 +}; + +$('a').animateScroll(options); + +$('#article-1').scrollHere(options); + +$.scrollTo($('#article-1'), options); diff --git a/types/jquery-animate-scroll/tsconfig.json b/types/jquery-animate-scroll/tsconfig.json new file mode 100644 index 0000000000..94883a5e7b --- /dev/null +++ b/types/jquery-animate-scroll/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "jquery-animate-scroll-tests.ts" + ] +} \ No newline at end of file diff --git a/types/jquery-animate-scroll/tslint.json b/types/jquery-animate-scroll/tslint.json new file mode 100644 index 0000000000..d04fe2e1fa --- /dev/null +++ b/types/jquery-animate-scroll/tslint.json @@ -0,0 +1 @@ +{"extends": "dtslint/dt.json"} \ No newline at end of file diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 68f6079b87..4b0ebd1614 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -38,10 +38,11 @@ declare const $: JQueryStatic; // Used by JQuery.Event type _Event = Event; -interface JQueryStatic { +interface JQueryStatic { /** * @see \`{@link http://api.jquery.com/jquery.ajax/#jQuery-ajax1 }\` - * @deprecated Use jQuery.ajaxSetup(options) + * + * @deprecated Use \`{@link JQueryStatic.ajaxSetup }\`. */ ajaxSettings: JQuery.AjaxSettings; /** @@ -54,7 +55,7 @@ interface JQueryStatic { * @since 1.5 */ Deferred: JQuery.DeferredStatic; - Event: JQuery.EventStatic; + Event: JQuery.EventStatic; /** * Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize * CSS property naming, or create custom properties. @@ -62,7 +63,8 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery.cssHooks/ }\` * @since 1.4.3 */ - cssHooks: JQuery.PlainObject>; + // Set to HTMLElement to minimize breaks but should probably be Element. + cssHooks: JQuery.PlainObject>; /** * An object containing all CSS properties that may be used without a unit. The .css() method uses this * object to see if it may append px to unitless values. @@ -71,14 +73,16 @@ interface JQueryStatic { * @since 1.4.3 */ cssNumber: JQuery.PlainObject; - readonly fn: JQuery; + // Set to HTMLElement to minimize breaks but should probably be Element. + readonly fn: JQuery; fx: { /** * The rate (in milliseconds) at which animations fire. * * @see \`{@link https://api.jquery.com/jQuery.fx.interval/ }\` * @since 1.4.3 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. See \`{@link https://api.jquery.com/jQuery.fx.interval/ }\`. */ interval: number; /** @@ -96,7 +100,7 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery.ready/ }\` * @since 1.8 */ - ready: JQuery.Thenable>; + ready: JQuery.Thenable; /** * A collection of properties that represent the presence of different browser features or bugs. * Intended for jQuery's internal use; specific properties may be removed when they are no longer @@ -106,10 +110,15 @@ interface JQueryStatic { * * @see \`{@link https://api.jquery.com/jQuery.support/ }\` * @since 1.3 - * @deprecated 1.9 + * + * @deprecated Deprecated since 1.9. See \`{@link https://api.jquery.com/jQuery.support/ }\`. */ support: JQuery.PlainObject; - valHooks: JQuery.PlainObject>; + // Set to HTMLElement to minimize breaks but should probably be Element. + valHooks: JQuery.PlainObject>; + // HACK: This is the factory function returned when importing jQuery without a DOM. Declaring it separately breaks using the type parameter on JQueryStatic. + // HACK: The discriminator parameter handles the edge case of passing a Window object to JQueryStatic. It doesn't actually exist on the factory function. + (window: Window, discriminator: boolean): JQueryStatic; /** * Creates DOM elements on the fly from the provided string of raw HTML. * @@ -121,7 +130,8 @@ interface JQueryStatic { * @since 1.0 * @since 1.4 */ - (html: JQuery.htmlString, ownerDocument_attributes: Document | JQuery.PlainObject): JQuery; + // tslint:disable-next-line:no-unnecessary-generics + (html: JQuery.htmlString, ownerDocument_attributes?: Document | JQuery.PlainObject): JQuery; /** * Accepts a string containing a CSS selector which is then used to match a set of elements. * @@ -130,17 +140,15 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery/ }\` * @since 1.0 */ - (selector: JQuery.Selector, context: Element | Document | JQuery | undefined): JQuery; - // HACK: This is the factory function returned when importing jQuery without a DOM. Declaring it separately breaks using the type parameter on JQueryStatic. - // HACK: The discriminator parameter handles the edge case of passing a Window object to JQueryStatic. It doesn't actually exist on the factory function. - (window: Window, discriminator: boolean): JQueryStatic; + // tslint:disable-next-line:no-unnecessary-generics + (selector: JQuery.Selector, context?: Element | Document | JQuery): JQuery; /** * Return a collection of matched elements either found in the DOM based on passed argument(s) or created * by passing an HTML string. * * @param element_elementArray A DOM element to wrap in a jQuery object. * An array containing a set of DOM elements to wrap in a jQuery object. - * @see {@link https://api.jquery.com/jQuery/} + * @see \`{@link https://api.jquery.com/jQuery/ }\` * @since 1.0 */ (element_elementArray: T | ArrayLike): JQuery; @@ -149,39 +157,35 @@ interface JQueryStatic { * by passing an HTML string. * * @param selection An existing jQuery object to clone. - * @see {@link https://api.jquery.com/jQuery/} + * @see \`{@link https://api.jquery.com/jQuery/ }\` * @since 1.0 */ (selection: JQuery): JQuery; /** - * Accepts a string containing a CSS selector which is then used to match a set of elements. - * - * Creates DOM elements on the fly from the provided string of raw HTML. - * * Binds a function to be executed when the DOM has finished loading. * - * @param selector_object_callback A string containing a selector expression - * A string of HTML to create on the fly. Note that this parses HTML, not XML. - * The function to execute when the DOM is ready. + * @param callback The function to execute when the DOM is ready. * @see \`{@link https://api.jquery.com/jQuery/ }\` * @since 1.0 */ - (selector_object_callback: JQuery.Selector | JQuery.htmlString | ((this: Document, $: JQueryStatic) => void)): JQuery; // tslint:disable-line:unified-signatures + // tslint:disable-next-line:no-unnecessary-generics unified-signatures + (callback: ((this: Document, $: JQueryStatic) => void)): JQuery; /** * Return a collection of matched elements either found in the DOM based on passed argument(s) or created by passing an HTML string. * * @param object A plain object to wrap in a jQuery object. - * @see {@link https://api.jquery.com/jQuery/} + * @see \`{@link https://api.jquery.com/jQuery/ }\` * @since 1.0 */ (object: T): JQuery; /** * Returns an empty jQuery set. * - * @see {@link https://api.jquery.com/jQuery/} + * @see \`{@link https://api.jquery.com/jQuery/ }\` * @since 1.4 */ - (): JQuery; + // tslint:disable-next-line:no-unnecessary-generics + (): JQuery; /** * A multi-purpose callbacks list object that provides a powerful way to manage callback lists. * @@ -189,6 +193,7 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery.Callbacks/ }\` * @since 1.7 */ + // tslint:disable-next-line:ban-types no-unnecessary-generics Callbacks(flags?: string): JQuery.Callbacks; /** * Perform an asynchronous HTTP (Ajax) request. @@ -248,7 +253,7 @@ interface JQueryStatic { ajaxTransport(dataType: string, handler: (options: JQuery.AjaxSettings, originalOptions: JQuery.AjaxSettings, jqXHR: JQuery.jqXHR) => JQuery.Transport | void): void; /** - * @deprecated 3.3 + * @deprecated Deprecated since 3.3. Internal. See \`{@link https://github.com/jquery/jquery/issues/3384 }\`. */ camelCase(value: string): string; /** @@ -588,7 +593,8 @@ interface JQueryStatic { * @param hold Indicates whether the ready hold is being requested or released * @see \`{@link https://api.jquery.com/jQuery.holdReady/ }\` * @since 1.6 - * @deprecated 3.2 + * + * @deprecated Deprecated since 3.2. See \`{@link https://github.com/jquery/jquery/issues/3288 }\`. */ holdReady(hold: boolean): void; /** @@ -615,7 +621,8 @@ interface JQueryStatic { * @param obj Object to test whether or not it is an array. * @see \`{@link https://api.jquery.com/jQuery.isArray/ }\` * @since 1.3 - * @deprecated 3.2 + * + * @deprecated Deprecated since 3.2. Use \`{@link Array.isArray }\`. */ isArray(obj: any): obj is any[]; /** @@ -632,8 +639,10 @@ interface JQueryStatic { * @param obj Object to test whether or not it is a function. * @see \`{@link https://api.jquery.com/jQuery.isFunction/ }\` * @since 1.2 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use `typeof x === "function"`. */ + // tslint:disable-next-line:ban-types isFunction(obj: any): obj is Function; /** * Determines whether its argument represents a JavaScript number. @@ -641,7 +650,8 @@ interface JQueryStatic { * @param value The value to be tested. * @see \`{@link https://api.jquery.com/jQuery.isNumeric/ }\` * @since 1.7 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Internal. See \`{@link https://github.com/jquery/jquery/issues/2960 }\`. */ isNumeric(value: any): value is number; /** @@ -658,7 +668,8 @@ interface JQueryStatic { * @param obj Object to test whether or not it is a window. * @see \`{@link https://api.jquery.com/jQuery.isWindow/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Internal. See \`{@link https://github.com/jquery/jquery/issues/3629 }\`. */ isWindow(obj: any): obj is Window; /** @@ -729,7 +740,8 @@ interface JQueryStatic { * * @see \`{@link https://api.jquery.com/jQuery.now/ }\` * @since 1.4.3 - * @deprecated 3.3 Use Date.now(). + * + * @deprecated Deprecated since 3.3. Use \`{@link Date.now }\`. */ now(): number; /** @@ -770,7 +782,8 @@ interface JQueryStatic { * @param json The JSON string to parse. * @see \`{@link https://api.jquery.com/jQuery.parseJSON/ }\` * @since 1.4.1 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JSON.parse }\`. */ parseJSON(json: string): any; /** @@ -850,7 +863,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (a: A, b: B, c: C, d: D, e: E, f: F, g: G) => TReturn, @@ -863,7 +877,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (a: A, b: B, c: C, d: D, e: E, f: F) => TReturn, @@ -876,7 +891,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (a: A, b: B, c: C, d: D, e: E) => TReturn, @@ -889,7 +905,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (a: A, b: B, c: C, d: D) => TReturn, @@ -902,7 +919,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (a: A, b: B, c: C) => TReturn, @@ -915,7 +933,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (a: A, b: B) => TReturn, @@ -929,7 +948,8 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4` * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (a: A) => TReturn, @@ -942,7 +962,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: () => TReturn, context: null | undefined): () => TReturn; @@ -958,7 +979,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (t: T) => TReturn, @@ -1080,7 +1109,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (t: T, u: U) => TReturn, @@ -1202,7 +1239,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (t: T, u: U, v: V) => TReturn, @@ -1324,7 +1369,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (t: T, u: U, v: V, w: W) => TReturn, @@ -1446,7 +1499,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (t: T, u: U, v: V, w: W, x: X) => TReturn, @@ -1568,7 +1629,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (t: T, u: U, v: V, w: W, x: X, y: Y) => TReturn, @@ -1690,7 +1759,8 @@ interface JQueryStatic { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @param context The object to which the context (this) of the function should be set. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (t: T, u: U, v: V, w: W, x: X, y: Y, z: Z, ...args: any[]) => TReturn, @@ -1815,7 +1892,8 @@ interface JQueryStatic { * @param additionalArguments Any number of arguments to be passed to the function referenced in the function argument. * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.9 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (...args: any[]) => TReturn, context: null | undefined, @@ -1839,7 +1917,8 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4` * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: () => TReturn, @@ -1962,7 +2048,8 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(fn: (...args: any[]) => TReturn, @@ -2953,7 +3096,8 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery.proxy/ }\` * @since 1.4 * @since 1.6 - * @deprecated 3.3 Use Function#bind. + * + * @deprecated Deprecated since 3.3. Use \`{@link Function.bind }\`. */ proxy(context: TContext, name: keyof TContext, @@ -3000,7 +3144,7 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery.speed/ }\` * @since 1.1 */ - speed(duration: JQuery.Duration, easing: string, complete: (this: TElement) => void): JQuery.EffectsOptions; + speed(duration: JQuery.Duration, easing: string, complete: (this: TElement) => void): JQuery.EffectsOptions; /** * Creates an object containing a set of properties ready to be used in the definition of custom animations. * @@ -3011,8 +3155,8 @@ interface JQueryStatic { * @since 1.0 * @since 1.1 */ - speed(duration: JQuery.Duration, - easing_complete: string | ((this: TElement) => void)): JQuery.EffectsOptions; + speed(duration: JQuery.Duration, + easing_complete: string | ((this: TElement) => void)): JQuery.EffectsOptions; /** * Creates an object containing a set of properties ready to be used in the definition of custom animations. * @@ -3022,7 +3166,7 @@ interface JQueryStatic { * @since 1.0 * @since 1.1 */ - speed(duration_complete_settings?: JQuery.Duration | ((this: TElement) => void) | JQuery.SpeedSettings): JQuery.EffectsOptions; + speed(duration_complete_settings?: JQuery.Duration | ((this: TElement) => void) | JQuery.SpeedSettings): JQuery.EffectsOptions; /** * Remove the whitespace from the beginning and end of a string. * @@ -3037,17 +3181,19 @@ interface JQueryStatic { * @param obj Object to get the internal JavaScript [[Class]] of. * @see \`{@link https://api.jquery.com/jQuery.type/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. See \`{@link https://github.com/jquery/jquery/issues/3605 }`. */ type(obj: any): 'array' | 'boolean' | 'date' | 'error' | 'function' | 'null' | 'number' | 'object' | 'regexp' | 'string' | 'symbol' | 'undefined'; /** - * Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on + * @description Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on * arrays of DOM elements, not strings or numbers. * * @param array The Array of DOM elements. * @see \`{@link https://api.jquery.com/jQuery.unique/ }\` * @since 1.1.3 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQueryStatic.uniqueSort }`. */ unique(array: T[]): T[]; /** @@ -3068,10 +3214,10 @@ interface JQueryStatic { * @since 1.5 */ when - (deferredT: JQuery.Promise | JQuery.Thenable | TR1, - deferredU: JQuery.Promise | JQuery.Thenable | UR1, - deferredV: JQuery.Promise | JQuery.Thenable | VR1): JQuery.Promise3( + deferredT: JQuery.Promise | JQuery.Thenable | TR1, // tslint:disable-line:use-default-type-parameter + deferredU: JQuery.Promise | JQuery.Thenable | UR1, // tslint:disable-line:use-default-type-parameter + deferredV: JQuery.Promise | JQuery.Thenable | VR1): JQuery.Promise3; /** @@ -3082,9 +3228,9 @@ interface JQueryStatic { * @since 1.5 */ when - (deferredT: JQuery.Promise | JQuery.Thenable | TR1, - deferredU: JQuery.Promise | JQuery.Thenable | UR1): JQuery.Promise2( + deferredT: JQuery.Promise | JQuery.Thenable | TR1, // tslint:disable-line:use-default-type-parameter + deferredU: JQuery.Promise | JQuery.Thenable | UR1): JQuery.Promise2; /** * Provides a way to execute callback functions based on zero or more Thenable objects, usually @@ -3095,9 +3241,9 @@ interface JQueryStatic { */ when - (deferredT: JQuery.Promise3 | - JQuery.Promise2): JQuery.Promise3; + TR3 = never, TJ3 = never>( + deferredT: JQuery.Promise3 | + JQuery.Promise2): JQuery.Promise3; /** * Provides a way to execute callback functions based on zero or more Thenable objects, usually * Deferred objects that represent asynchronous events. @@ -3105,7 +3251,7 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery.when/ }\` * @since 1.5 */ - when(deferred: JQuery.Promise | JQuery.Thenable | TR1): JQuery.Promise; + when(deferred: JQuery.Promise | JQuery.Thenable | TR1): JQuery.Promise; // tslint:disable-line:use-default-type-parameter /** * Provides a way to execute callback functions based on zero or more Thenable objects, usually * Deferred objects that represent asynchronous events. @@ -3114,7 +3260,7 @@ interface JQueryStatic { * @see \`{@link https://api.jquery.com/jQuery.when/ }\` * @since 1.5 */ - when(...deferreds: Array | JQuery.Thenable | TR1>): JQuery.Promise; + when(...deferreds: Array | JQuery.Thenable | TR1>): JQuery.Promise; // tslint:disable-line:use-default-type-parameter /** * Provides a way to execute callback functions based on zero or more Thenable objects, usually * Deferred objects that represent asynchronous events. @@ -3390,7 +3536,8 @@ interface JQuery extends Iterable { * @see \`{@link https://api.jquery.com/bind/ }\` * @since 1.0 * @since 1.4.3 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.on }\`. */ bind(eventType: string, eventData: TData, @@ -3405,7 +3552,8 @@ interface JQuery extends Iterable { * @see \`{@link https://api.jquery.com/bind/ }\` * @since 1.0 * @since 1.4.3 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.on }\`. */ bind(eventType: string, handler: JQuery.EventHandler | JQuery.EventHandlerBase> | false | null | undefined): this; @@ -3415,7 +3563,8 @@ interface JQuery extends Iterable { * @param events An object containing one or more DOM event types and functions to execute for them. * @see \`{@link https://api.jquery.com/bind/ }\` * @since 1.4 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.on }\`. */ bind(events: JQuery.PlainObject | JQuery.EventHandlerBase> | false>): this; /** @@ -3425,7 +3574,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/blur/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ blur(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -3435,7 +3585,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/blur/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ blur(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -3445,7 +3596,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/change/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ change(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -3455,7 +3607,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/change/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ change(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -3481,7 +3634,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/click/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ click(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -3491,7 +3645,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/click/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ click(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -3543,7 +3698,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/contextmenu/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ contextmenu(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -3553,7 +3709,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/contextmenu/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ contextmenu(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -3644,7 +3801,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/dblclick/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ dblclick(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -3654,7 +3812,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/dblclick/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ dblclick(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -3677,7 +3836,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/delegate/ }\` * @since 1.4.2 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.on }\`. */ delegate(selector: JQuery.Selector, eventType: string, @@ -3693,7 +3853,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/delegate/ }\` * @since 1.4.2 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.on }\`. */ delegate(selector: JQuery.Selector, eventType: string, @@ -3706,7 +3867,8 @@ interface JQuery extends Iterable { * @param events A plain object of one or more event types and functions to execute for them. * @see \`{@link https://api.jquery.com/delegate/ }\` * @since 1.4.3 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.on }\`. */ delegate(selector: JQuery.Selector, events: JQuery.PlainObject | JQuery.EventHandlerBase> | false>): this; @@ -3933,7 +4095,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/focus/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ focus(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -3943,7 +4106,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/focus/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ focus(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -3953,7 +4117,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/focusin/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ focusin(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -3963,7 +4128,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/focusin/ }\` * @since 1.4 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ focusin(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -3973,7 +4139,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/focusout/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ focusout(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -3983,7 +4150,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/focusout/ }\` * @since 1.4 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ focusout(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4079,6 +4247,7 @@ interface JQuery extends Iterable { * @since 1.4 */ // HACK: The type parameter T is not used but ensures the 'event' callback parameter is typed correctly. + // tslint:disable-next-line:no-unnecessary-generics hover(handlerInOut: JQuery.EventHandler | JQuery.EventHandlerBase> | false, handlerOut?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4190,7 +4359,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/keydown/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ keydown(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -4200,7 +4370,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/keydown/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ keydown(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4210,7 +4381,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/keypress/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ keypress(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -4220,7 +4392,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/keypress/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ keypress(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4230,7 +4403,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/keyup/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ keyup(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -4240,7 +4414,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/keyup/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ keyup(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4289,7 +4464,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mousedown/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mousedown(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -4299,7 +4475,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mousedown/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mousedown(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4309,7 +4486,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mouseenter/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mouseenter(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -4319,7 +4497,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mouseenter/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mouseenter(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4329,7 +4508,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mouseleave/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mouseleave(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -4339,7 +4519,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mouseleave/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mouseleave(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4349,7 +4530,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mousemove/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mousemove(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -4359,7 +4541,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mousemove/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mousemove(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4369,7 +4552,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mouseout/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mouseout(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -4379,7 +4563,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mouseout/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mouseout(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4389,7 +4574,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mouseover/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mouseover(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -4399,7 +4585,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mouseover/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mouseover(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4409,7 +4596,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mouseup/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mouseup(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -4419,7 +4607,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/mouseup/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ mouseup(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -4556,10 +4745,10 @@ interface JQuery extends Iterable { * @see \`{@link https://api.jquery.com/on/ }\` * @since 1.7 */ - on(events: string, - selector: JQuery.Selector | null, - data: TData, - handler: ((event: JQueryEventObject) => void)): this; // tslint:disable-line:unified-signatures + on(events: string, + selector: JQuery.Selector | null, + data: any, + handler: ((event: JQueryEventObject) => void)): this; // tslint:disable-line:unified-signatures /** * Attach an event handler function for one or more events to the selected elements. * @@ -4585,8 +4774,8 @@ interface JQuery extends Iterable { * @since 1.7 */ on(events: string, - selector: JQuery.Selector, - handler: ((event: JQueryEventObject) => void)): this; // tslint:disable-line:unified-signatures + selector: JQuery.Selector, + handler: ((event: JQueryEventObject) => void)): this; // tslint:disable-line:unified-signatures /** * Attach an event handler function for one or more events to the selected elements. * @@ -4608,9 +4797,9 @@ interface JQuery extends Iterable { * @see \`{@link https://api.jquery.com/on/ }\` * @since 1.7 */ - on(events: string, - data: TData, - handler: ((event: JQueryEventObject) => void)): this; // tslint:disable-line:unified-signatures + on(events: string, + data: any, // tslint:disable-line:unified-signatures + handler: ((event: JQueryEventObject) => void)): this; /** * Attach an event handler function for one or more events to the selected elements. * @@ -4631,7 +4820,7 @@ interface JQuery extends Iterable { * @since 1.7 */ on(events: string, - handler: ((event: JQueryEventObject) => void)): this; // tslint:disable-line:unified-signatures + handler: ((event: JQueryEventObject) => void)): this; // tslint:disable-line:unified-signatures /** * Attach an event handler function for one or more events to the selected elements. * @@ -5021,9 +5210,10 @@ interface JQuery extends Iterable { * @param handler A function to execute after the DOM is ready. * @see \`{@link https://api.jquery.com/ready/ }\` * @since 1.0 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use `jQuery(function() { })`. */ - ready(handler: ($: JQueryStatic) => void): this; + ready(handler: ($: JQueryStatic) => void): this; /** * Remove the set of matched elements from the DOM. * @@ -5097,7 +5287,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/resize/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ resize(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -5107,7 +5298,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/resize/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ resize(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -5117,7 +5309,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/scroll/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ scroll(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -5127,7 +5320,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/scroll/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ scroll(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -5168,7 +5362,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/select/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ select(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -5178,7 +5373,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/select/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ select(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -5370,7 +5566,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/submit/ }\` * @since 1.4.3 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ submit(eventData: TData, handler: JQuery.EventHandler | JQuery.EventHandlerBase>): this; @@ -5380,7 +5577,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/submit/ }\` * @since 1.0 - * @deprecated 3.3 + * + * @deprecated Deprecated since 3.3. Use \`{@link JQuery.on }\` or \`{@link JQuery.trigger }\`. */ submit(handler?: JQuery.EventHandler | JQuery.EventHandlerBase> | false): this; /** @@ -5464,7 +5662,8 @@ interface JQuery extends Iterable { * @param state A boolean value to determine whether the class should be added or removed. * @see \`{@link https://api.jquery.com/toggleClass/ }\` * @since 1.4 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. See \`{@link https://github.com/jquery/jquery/pull/2618 }\`. */ toggleClass(state?: boolean): this; /** @@ -5497,7 +5696,8 @@ interface JQuery extends Iterable { * @see \`{@link https://api.jquery.com/unbind/ }\` * @since 1.0 * @since 1.4.3 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.off }\`. */ unbind(event: string, handler: JQuery.EventHandlerBase> | false): this; /** @@ -5507,7 +5707,8 @@ interface JQuery extends Iterable { * A jQuery.Event object. * @see \`{@link https://api.jquery.com/unbind/ }\` * @since 1.0 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.off }\`. */ unbind(event?: string | JQuery.Event): this; /** @@ -5519,7 +5720,8 @@ interface JQuery extends Iterable { * @param handler A function to execute each time the event is triggered. * @see \`{@link https://api.jquery.com/undelegate/ }\` * @since 1.4.2 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.off }\`. */ undelegate(selector: JQuery.Selector, eventType: string, handler: JQuery.EventHandlerBase> | false): this; /** @@ -5532,7 +5734,8 @@ interface JQuery extends Iterable { * @see \`{@link https://api.jquery.com/undelegate/ }\` * @since 1.4.2 * @since 1.4.3 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.off }\`. */ undelegate(selector: JQuery.Selector, eventTypes: string | JQuery.PlainObject> | false>): this; /** @@ -5543,7 +5746,8 @@ interface JQuery extends Iterable { * @see \`{@link https://api.jquery.com/undelegate/ }\` * @since 1.4.2 * @since 1.6 - * @deprecated 3.0 + * + * @deprecated Deprecated since 3.0. Use \`{@link JQuery.off }\`. */ undelegate(namespace?: string): this; /** @@ -5639,6 +5843,7 @@ interface JQuery extends Iterable { } // ES5 compatibility +// tslint:disable-next-line:no-empty-interface interface Iterable { } declare namespace JQuery { @@ -5707,7 +5912,7 @@ declare namespace JQuery { type TextStatus = SuccessTextStatus | ErrorTextStatus; interface SuccessCallback { - (this: TContext, data: any, textStatus: SuccessTextStatus, jqXHR: JQuery.jqXHR): void; + (this: TContext, data: any, textStatus: SuccessTextStatus, jqXHR: jqXHR): void; } interface ErrorCallback { @@ -5758,7 +5963,7 @@ declare namespace JQuery { * "timeout", "abort", or "parsererror"). As of jQuery 1.5, the complete setting can accept an array of * functions. Each function will be called in turn. This is an Ajax Event. */ - complete?: TypeOrArray>; + complete?: TypeOrArray>; /** * An object of string/regular-expression pairs that determine how jQuery will parse the response, * given its content type. @@ -5847,7 +6052,7 @@ declare namespace JQuery { * 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: * This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event. */ - error?: TypeOrArray>; + error?: TypeOrArray>; /** * Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to * prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to @@ -5933,7 +6138,7 @@ declare namespace JQuery { * XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each * function will be called in turn. This is an Ajax Event. */ - success?: TypeOrArray>; + success?: TypeOrArray>; /** * Set a timeout (in milliseconds) for the request. A value of 0 means there will be no timeout. This * will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the @@ -6429,19 +6634,10 @@ declare namespace JQuery { } namespace jqXHR { - /** - * @deprecated - */ interface DoneCallback> extends Deferred.Callback3 { } - /** - * @deprecated - */ interface FailCallback extends Deferred.Callback3 { } - /** - * @deprecated - */ interface AlwaysCallback> extends Deferred.Callback3 { } } @@ -6449,6 +6645,7 @@ declare namespace JQuery { // region Callbacks + // tslint:disable-next-line:ban-types interface Callbacks { /** * Add a callback or a collection of callbacks to a callback list. @@ -6568,13 +6765,13 @@ declare namespace JQuery { * @returns A Promise for the completion of which ever callback is executed. */ then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: any) => TResult2 | PromiseLike) | null): JQuery._Promise; + onrejected?: ((reason: any) => TResult2 | PromiseLike) | null): _Promise; /** * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of the callback. */ - catch(onrejected?: ((reason: any) => TResult | PromiseLike) | null): JQuery._Promise; + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | null): _Promise; } // Type parameter guide @@ -6597,12 +6794,11 @@ declare namespace JQuery { * pipe, progress, state and promise) to prevent users from changing the state of the Deferred. * * @see \`{@link http://api.jquery.com/Types/#Promise }\` - * @deprecated Experimental. Avoid referncing this type directly in your code. */ interface PromiseBase extends JQuery._Promise, PromiseLike { + SR, SJ, SN> extends _Promise, PromiseLike { /** * Add handlers to be called when the Deferred object is either resolved or rejected. * @@ -6678,7 +6874,8 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link then JQuery.PromiseBase.then }\`. */ pipe - (doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, - failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | AJF, - progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, + failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | AJF, + progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -6716,7 +6913,8 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link then JQuery.PromiseBase.then }\`. */ pipe - (doneFilter: null, - failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | AJF, - progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: null, + failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | AJF, + progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -6747,7 +6945,8 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link then JQuery.PromiseBase.then }\`. */ pipe - (doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, - failFilter: null, - progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, + failFilter: null, + progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -6778,18 +6977,19 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link then JQuery.PromiseBase.then }\`. */ pipe - (doneFilter: null, - failFilter: null, - progressFilter?: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: null, + failFilter: null, + progressFilter?: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -6802,7 +7002,8 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link then JQuery.PromiseBase.then }\`. */ pipe - (doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, - failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | AJF, - progressFilter?: null): PromiseBase( + doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, + failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | AJF, + progressFilter?: null): PromiseBase; @@ -6833,18 +7034,19 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link then JQuery.PromiseBase.then }\`. */ pipe - (doneFilter: null, - failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | AJF, - progressFilter?: null): PromiseBase( + doneFilter: null, + failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | AJF, + progressFilter?: null): PromiseBase; @@ -6857,18 +7059,19 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link then JQuery.PromiseBase.then }\`. */ pipe - (doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, - failFilter?: null, - progressFilter?: null): PromiseBase( + doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, + failFilter?: null, + progressFilter?: null): PromiseBase; @@ -6897,19 +7100,19 @@ declare namespace JQuery { ARP = never, AJP = never, ANP = never, BRP = never, BJP = never, BNP = never, CRP = never, CJP = never, CNP = never, - RRP = never, RJP = never, RNP = never> - (doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, - failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | ARF, - progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, + failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | ARF, + progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -6929,16 +7132,16 @@ declare namespace JQuery { ARP = never, AJP = never, ANP = never, BRP = never, BJP = never, BNP = never, CRP = never, CJP = never, CNP = never, - RRP = never, RJP = never, RNP = never> - (doneFilter: null, - failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | ARF, - progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: null, + failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | ARF, + progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -6958,16 +7161,16 @@ declare namespace JQuery { ARP = never, AJP = never, ANP = never, BRP = never, BJP = never, BNP = never, CRP = never, CJP = never, CNP = never, - RRP = never, RJP = never, RNP = never> - (doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, - failFilter: null, - progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, + failFilter: null, + progressFilter: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -6983,13 +7186,13 @@ declare namespace JQuery { then - (doneFilter: null, - failFilter: null, - progressFilter?: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: null, + failFilter: null, + progressFilter?: (t: TN, u: UN, v: VN, ...s: SN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -7009,16 +7212,16 @@ declare namespace JQuery { ARF = never, AJF = never, ANF = never, BRF = never, BJF = never, BNF = never, CRF = never, CJF = never, CNF = never, - RRF = never, RJF = never, RNF = never> - (doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, - failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | ARF, - progressFilter?: null): PromiseBase( + doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, + failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | ARF, + progressFilter?: null): PromiseBase; @@ -7034,13 +7237,13 @@ declare namespace JQuery { then - (doneFilter: null, - failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | ARF, - progressFilter?: null): PromiseBase( + doneFilter: null, + failFilter: (t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | ARF, + progressFilter?: null): PromiseBase; @@ -7056,13 +7259,13 @@ declare namespace JQuery { then - (doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, - failFilter?: null, - progressFilter?: null): PromiseBase( + doneFilter: (t: TR, u: UR, v: VR, ...s: SR[]) => PromiseBase | Thenable | ARD, + failFilter?: null, + progressFilter?: null): PromiseBase; @@ -7079,11 +7282,11 @@ declare namespace JQuery { catch - (failFilter?: ((t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | ARF) | null): PromiseBase( + failFilter?: ((t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase | Thenable | ARF) | null): PromiseBase; @@ -7128,7 +7331,7 @@ declare namespace JQuery { interface DeferredStatic { // https://jquery.com/upgrade-guide/3.0/#callback-exit exceptionHook: any; - (beforeStart?: (this: JQuery.Deferred, deferred: JQuery.Deferred) => void): JQuery.Deferred; + (beforeStart?: (this: Deferred, deferred: Deferred) => void): Deferred; } interface Deferred { @@ -7232,14 +7435,14 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.promise/ }\` * @since 1.5 */ - promise(target: TTarget): JQuery.Promise & TTarget; + promise(target: TTarget): Promise & TTarget; /** * Return a Deferred's Promise object. * * @see \`{@link https://api.jquery.com/deferred.promise/ }\` * @since 1.5 */ - promise(): JQuery.Promise; + promise(): Promise; /** * Determine the current state of a Deferred object. * @@ -7259,7 +7462,8 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link JQuery.Deferred.then }\`. */ pipe - (doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, - failFilter: (...t: TJ[]) => PromiseBase | Thenable | AJF, - progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, + failFilter: (...t: TJ[]) => PromiseBase | Thenable | AJF, + progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -7297,7 +7501,8 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link JQuery.Deferred.then }\`. */ pipe - (doneFilter: null, - failFilter: (...t: TJ[]) => PromiseBase | Thenable | AJF, - progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: null, + failFilter: (...t: TJ[]) => PromiseBase | Thenable | AJF, + progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -7328,7 +7533,8 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link JQuery.Deferred.then }\`. */ pipe - (doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, - failFilter: null, - progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, + failFilter: null, + progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -7359,18 +7565,19 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link JQuery.Deferred.then }\`. */ pipe - (doneFilter: null, - failFilter: null, - progressFilter?: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: null, + failFilter: null, + progressFilter?: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -7383,7 +7590,8 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link JQuery.Deferred.then }\`. */ pipe - (doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, - failFilter: (...t: TJ[]) => PromiseBase | Thenable | AJF, - progressFilter?: null): PromiseBase( + doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, + failFilter: (...t: TJ[]) => PromiseBase | Thenable | AJF, + progressFilter?: null): PromiseBase; @@ -7414,18 +7622,19 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link JQuery.Deferred.then }\`. */ pipe - (doneFilter: null, - failFilter: (...t: TJ[]) => PromiseBase | Thenable | AJF, - progressFilter?: null): PromiseBase( + doneFilter: null, + failFilter: (...t: TJ[]) => PromiseBase | Thenable | AJF, + progressFilter?: null): PromiseBase; @@ -7438,18 +7647,19 @@ declare namespace JQuery { * @see \`{@link https://api.jquery.com/deferred.pipe/ }\` * @since 1.6 * @since 1.7 - * @deprecated 1.8 + * + * @deprecated Deprecated since 1.8. Use \`{@link JQuery.Deferred.then }\`. */ pipe - (doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, - failFilter?: null, - progressFilter?: null): PromiseBase( + doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, + failFilter?: null, + progressFilter?: null): PromiseBase; @@ -7478,19 +7688,19 @@ declare namespace JQuery { ARP = never, AJP = never, ANP = never, BRP = never, BJP = never, BNP = never, CRP = never, CJP = never, CNP = never, - RRP = never, RJP = never, RNP = never> - (doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, - failFilter: (...t: TJ[]) => PromiseBase | Thenable | ARF, - progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, + failFilter: (...t: TJ[]) => PromiseBase | Thenable | ARF, + progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -7510,16 +7720,16 @@ declare namespace JQuery { ARP = never, AJP = never, ANP = never, BRP = never, BJP = never, BNP = never, CRP = never, CJP = never, CNP = never, - RRP = never, RJP = never, RNP = never> - (doneFilter: null, - failFilter: (...t: TJ[]) => PromiseBase | Thenable | ARF, - progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: null, + failFilter: (...t: TJ[]) => PromiseBase | Thenable | ARF, + progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -7539,16 +7749,16 @@ declare namespace JQuery { ARP = never, AJP = never, ANP = never, BRP = never, BJP = never, BNP = never, CRP = never, CJP = never, CNP = never, - RRP = never, RJP = never, RNP = never> - (doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, - failFilter: null, - progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, + failFilter: null, + progressFilter: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -7564,13 +7774,13 @@ declare namespace JQuery { then - (doneFilter: null, - failFilter: null, - progressFilter?: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase( + doneFilter: null, + failFilter: null, + progressFilter?: (...t: TN[]) => PromiseBase | Thenable | ANP): PromiseBase; @@ -7590,16 +7800,16 @@ declare namespace JQuery { ARF = never, AJF = never, ANF = never, BRF = never, BJF = never, BNF = never, CRF = never, CJF = never, CNF = never, - RRF = never, RJF = never, RNF = never> - (doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, - failFilter: (...t: TJ[]) => PromiseBase | Thenable | ARF, - progressFilter?: null): PromiseBase( + doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, + failFilter: (...t: TJ[]) => PromiseBase | Thenable | ARF, + progressFilter?: null): PromiseBase; @@ -7615,13 +7825,13 @@ declare namespace JQuery { then - (doneFilter: null, - failFilter: (...t: TJ[]) => PromiseBase | Thenable | ARF, - progressFilter?: null): PromiseBase( + doneFilter: null, + failFilter: (...t: TJ[]) => PromiseBase | Thenable | ARF, + progressFilter?: null): PromiseBase; @@ -7637,13 +7847,13 @@ declare namespace JQuery { then - (doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, - failFilter?: null, - progressFilter?: null): PromiseBase( + doneFilter: (...t: TR[]) => PromiseBase | Thenable | ARD, + failFilter?: null, + progressFilter?: null): PromiseBase; @@ -7660,11 +7870,11 @@ declare namespace JQuery { catch - (failFilter?: ((...t: TJ[]) => PromiseBase | Thenable | ARF) | null): PromiseBase( + failFilter?: ((...t: TJ[]) => PromiseBase | Thenable | ARF) | null): PromiseBase; @@ -7682,22 +7892,22 @@ declare namespace JQuery { } /** - * @deprecated + * @deprecated Use \`{@link JQuery.Deferred.Callback }\`. */ interface DoneCallback extends Callback { } /** - * @deprecated + * @deprecated Use \`{@link JQuery.Deferred.Callback }\`. */ interface FailCallback extends Callback { } /** - * @deprecated + * @deprecated Use \`{@link JQuery.Deferred.Callback }\`. */ interface AlwaysCallback extends Callback { } /** - * @deprecated + * @deprecated Use \`{@link JQuery.Deferred.Callback }\`. */ interface ProgressCallback extends Callback { } } @@ -7722,7 +7932,7 @@ declare namespace JQuery { * A function to be called when the animation on an element completes or stops without completing (its * Promise object is either resolved or rejected). */ - always?(this: TElement, animation: JQuery.Promise, jumpedToEnd: boolean): void; + always?(this: TElement, animation: Promise, jumpedToEnd: boolean): void; /** * A function that is called once the animation on an element is complete. */ @@ -7730,7 +7940,7 @@ declare namespace JQuery { /** * A function to be called when the animation on an element completes (its Promise object is resolved). */ - done?(this: TElement, animation: JQuery.Promise, jumpedToEnd: boolean): void; + done?(this: TElement, animation: Promise, jumpedToEnd: boolean): void; /** * A string or number determining how long the animation will run. */ @@ -7742,12 +7952,12 @@ declare namespace JQuery { /** * A function to be called when the animation on an element fails to complete (its Promise object is rejected). */ - fail?(this: TElement, animation: JQuery.Promise, jumpedToEnd: boolean): void; + fail?(this: TElement, animation: Promise, jumpedToEnd: boolean): void; /** * A function to be called after each step of the animation, only once per animated element regardless * of the number of animated properties. */ - progress?(this: TElement, animation: JQuery.Promise, progress: number, remainingMs: number): void; + progress?(this: TElement, animation: Promise, progress: number, remainingMs: number): void; /** * A Boolean indicating whether to place the animation in the effects queue. If false, the animation * will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case @@ -7763,7 +7973,7 @@ declare namespace JQuery { /** * A function to call when the animation on an element begins. */ - start?(this: TElement, animation: JQuery.Promise): void; + start?(this: TElement, animation: Promise): void; /** * A function to be called for each animated property of each animated element. This function provides * an opportunity to modify the Tween object to change the value of the property before it is set. @@ -7803,7 +8013,7 @@ declare namespace JQuery { } interface AnimationHook { - (fx: JQuery.Tween): void; + (fx: Tween): void; } // endregion @@ -7815,11 +8025,15 @@ declare namespace JQuery { // This should be a class but doesn't work correctly under the JQuery namespace. Event should be an inner class of jQuery. // Static members - interface EventStatic { - (event: string, properties?: T): JQuery.Event & T; - (properties: T): JQuery.Event & T; - new (event: string, properties?: T): JQuery.Event & T; - new (properties: T): JQuery.Event & T; + interface EventStatic { + // tslint:disable-next-line:no-unnecessary-generics + (event: string, properties?: T): Event & T; + // tslint:disable-next-line:no-unnecessary-generics + (properties: T): Event & T; + // tslint:disable-next-line:no-unnecessary-generics + new (event: string, properties?: T): Event & T; + // tslint:disable-next-line:no-unnecessary-generics + new (properties: T): Event & T; } // Instance members @@ -7974,7 +8188,7 @@ declare namespace JQuery { // endregion - interface EventHandler extends EventHandlerBase> { } + interface EventHandler extends EventHandlerBase> { } interface EventHandlerBase { // Extra parameters can be passed from trigger() @@ -7982,6 +8196,7 @@ declare namespace JQuery { } // Provided for convenience for use with jQuery.Event.which + // tslint:disable-next-line:no-const-enum const enum Mouse { None = 0, Left = 1, @@ -7990,6 +8205,7 @@ declare namespace JQuery { } // Provided for convenience for use with jQuery.Event.which + // tslint:disable-next-line:no-const-enum const enum Key { Backspace = 8, Tab = 9, @@ -8126,33 +8342,40 @@ declare namespace JQuery { // region Legacy types -interface JQueryCallback extends JQuery.Callbacks { } +// tslint:disable-next-line:no-empty-interface +interface JQueryCallback extends JQuery.Callbacks { } interface JQueryDeferred extends JQuery.Deferred { } -interface JQueryEventConstructor extends JQuery.Event { } +// tslint:disable-next-line:no-empty-interface +interface JQueryEventConstructor extends JQuery.EventStatic { } interface JQueryDeferred extends JQuery.Deferred { } +// tslint:disable-next-line:no-empty-interface interface JQueryAjaxSettings extends JQuery.AjaxSettings { } interface JQueryAnimationOptions extends JQuery.EffectsOptions { } +// tslint:disable-next-line:no-empty-interface interface JQueryCoordinates extends JQuery.Coordinates { } interface JQueryGenericPromise extends JQuery.Thenable { } +// tslint:disable-next-line:no-empty-interface interface JQueryXHR extends JQuery.jqXHR { } interface JQueryPromise extends JQuery.Promise { } +// tslint:disable-next-line:no-empty-interface interface JQuerySerializeArrayElement extends JQuery.NameValuePair { } /** - * @deprecated 1.9 + * @deprecated Deprecated since 1.9. See \`{@link https://api.jquery.com/jQuery.support/ }\`. */ +// tslint:disable-next-line:no-empty-interface interface JQuerySupport extends JQuery.PlainObject { } // Legacy types that are not represented in the current type definitions are marked deprecated. /** - * @deprecated + * @deprecated Use \`{@link JQuery.Deferred.Callback }\` or \`{@link JQuery.Deferred.CallbackBase }\`. */ interface JQueryPromiseCallback { (value?: T, ...args: any[]): void; } /** - * @deprecated + * @deprecated Use \`{@link JQueryStatic.param JQueryStatic['param']}\`. */ interface JQueryParam { /** @@ -8164,7 +8387,7 @@ interface JQueryParam { (obj: any, traditional?: boolean): string; } /** - * @deprecated + * @deprecated Use \`{@link JQuery.Event }\`. */ interface BaseJQueryEventObject extends Event { /** @@ -8259,7 +8482,7 @@ interface BaseJQueryEventObject extends Event { metaKey: boolean; } /** - * @deprecated + * @deprecated Use \`{@link JQuery.Event }\`. */ interface JQueryInputEventObject extends BaseJQueryEventObject { altKey: boolean; @@ -8268,7 +8491,7 @@ interface JQueryInputEventObject extends BaseJQueryEventObject { shiftKey: boolean; } /** - * @deprecated + * @deprecated Use \`{@link JQuery.Event }\`. */ interface JQueryMouseEventObject extends JQueryInputEventObject { button: number; @@ -8282,7 +8505,7 @@ interface JQueryMouseEventObject extends JQueryInputEventObject { screenY: number; } /** - * @deprecated + * @deprecated Use \`{@link JQuery.Event }\`. */ interface JQueryKeyEventObject extends JQueryInputEventObject { char: any; @@ -8291,7 +8514,7 @@ interface JQueryKeyEventObject extends JQueryInputEventObject { keyCode: number; } /** - * @deprecated + * @deprecated Use \`{@link JQuery.Event }\`. */ interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject { } /** @@ -8302,13 +8525,13 @@ interface JQueryPromiseOperator { ...callbacksN: Array>>): JQueryPromise; } /** - * @deprecated + * @deprecated Internal. See \`{@link https://github.com/jquery/api.jquery.com/issues/912 }\`. */ interface JQueryEasingFunction { (percent: number): number; } /** - * @deprecated + * @deprecated Internal. See \`{@link https://github.com/jquery/api.jquery.com/issues/912 }\`. */ interface JQueryEasingFunctions { [name: string]: JQueryEasingFunction; diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index f0d1ce5ef8..c569758fb0 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -1,8 +1,4 @@ function JQueryStatic() { - function type_assertion() { - const $Canvas = $ as JQueryStatic; - } - function type_annotation() { const jq: JQueryStatic = $; } @@ -21,6 +17,9 @@ function JQueryStatic() { } }); + // $ExpectType JQuery + $('

'); + // $ExpectType JQuery $('span', new HTMLElement()); @@ -33,63 +32,74 @@ function JQueryStatic() { // $ExpectType JQuery $('span'); - // $ExpectType JQuery - $('

'); + // $ExpectType JQuery + $('.mysvgline'); - // $ExpectType JQuery - $(new HTMLElement()); + // $ExpectType JQuery + $(new HTMLParagraphElement()); - // $ExpectType JQuery - $([new HTMLElement()]); + // $ExpectType JQuery + $([new HTMLParagraphElement()]); // $ExpectType JQuery<{ foo: string; hello: string; }> $({ foo: 'bar', hello: 'world' }); - // $ExpectType JQuery - $($('p')); + // $ExpectType JQuery + $($(document.createElementNS("http://www.w3.org/2000/svg", "svg"))); // $ExpectType JQuery $(function($) { // $ExpectType Document this; - // $ExpectType JQueryStatic + // $ExpectType JQueryStatic + $; + }); + + // $ExpectType JQuery + $(function($) { + // $ExpectType Document + this; + // $ExpectType JQueryStatic $; }); // $ExpectType JQuery $(); + // $ExpectType JQuery + $(); + // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19597#issuecomment-378218432 function issue_19597_378218432() { - let myDiv = $(document.createElement('div')); + const myDiv = $(document.createElement('div')); // $ExpectType JQuery myDiv; myDiv.on('click', (evt) => { - let target = evt.target; + const target = evt.target; // $ExpectType HTMLDivElement target; }); - let myDiv1 = $(document.createElement('div')); + const myDiv1 = $(document.createElement('div')); - let myForcedDiv: JQuery = $(document.createElement('div')) as any; + const myForcedDiv: JQuery = $(document.createElement('div')) as any; myForcedDiv.on('click', (evt) => { - let target = evt.target; // HTMLDivElement + const target = evt.target; // HTMLDivElement // $ExpectType HTMLDivElement target; }); - let myDoc = $(document); + const myDoc = $(document); // $ExpectType JQuery myDoc; myDoc.on('click', (evt) => { - let target = evt.target; + const target = evt.target; // $ExpectType Document target; }); - let myDocForced: JQuery = $(document); - let myWindow = $(window); + const myDocForced: JQuery = $(document); + const myWindow = $(window); // $ExpectType JQuery myWindow; - let myWindowForced: JQuery = $(window); + const myWindowForced: JQuery = $(window); // $ExpectType JQuery myWindowForced; } @@ -101,7 +111,7 @@ function JQueryStatic() { } function Event() { - // $ExpectType EventStatic + // $ExpectType EventStatic $.Event; } @@ -138,7 +148,7 @@ function JQueryStatic() { } function ready() { - // $ExpectType Thenable> + // $ExpectType Thenable $.ready; } @@ -734,7 +744,7 @@ function JQueryStatic() { function map() { // $ExpectType number[] - $.map([1, 2, 3], function (elementOfArray, indexInArray) { + $.map([1, 2, 3], function(elementOfArray, indexInArray) { // $ExpectType Window this; // $ExpectType number @@ -746,7 +756,7 @@ function JQueryStatic() { }); // $ExpectType number[] - $.map([1, 2, 3], function (elementOfArray, indexInArray) { + $.map([1, 2, 3], function(elementOfArray, indexInArray) { // $ExpectType Window this; // $ExpectType number @@ -758,7 +768,7 @@ function JQueryStatic() { }); // $ExpectType (number | null)[] - $.map([1, 2, 3], function (elementOfArray, indexInArray) { + $.map([1, 2, 3], function(elementOfArray, indexInArray) { // $ExpectType Window this; // $ExpectType number @@ -770,7 +780,7 @@ function JQueryStatic() { }); // $ExpectType (number | undefined)[] - $.map([1, 2, 3], function (elementOfArray, indexInArray) { + $.map([1, 2, 3], function(elementOfArray, indexInArray) { // $ExpectType Window this; // $ExpectType number @@ -785,7 +795,7 @@ function JQueryStatic() { $.map({ myProp: true, name: 'Rogers', - }, function (propertyOfObject, key) { + }, function(propertyOfObject, key) { // $ExpectType Window this; // $ExpectType string | boolean @@ -805,7 +815,7 @@ function JQueryStatic() { $.map({ myProp: true, name: 'Rogers', - }, function (propertyOfObject, key) { + }, function(propertyOfObject, key) { // $ExpectType Window this; // $ExpectType string | boolean @@ -821,7 +831,7 @@ function JQueryStatic() { myProp: true, name: 'Rogers', anotherProp: 70, - }, function (propertyOfObject, key) { + }, function(propertyOfObject, key) { // $ExpectType Window this; // $ExpectType string | number | boolean @@ -844,7 +854,7 @@ function JQueryStatic() { myProp: true, name: 'Rogers', anotherProp: 70, - }, function (propertyOfObject, key) { + }, function(propertyOfObject, key) { // $ExpectType Window this; // $ExpectType string | number | boolean @@ -869,10 +879,10 @@ function JQueryStatic() { } function noConflict() { - // $ExpectType JQueryStatic + // $ExpectType JQueryStatic $.noConflict(true); - // $ExpectType JQueryStatic + // $ExpectType JQueryStatic $.noConflict(); } @@ -2157,9 +2167,8 @@ function JQueryStatic() { } function JQuery() { - function type_assertion() { - const $el = $(document.createElement('canvas')); - const $canvas = $el as JQuery; + function type_annotation() { + const $canvas: JQuery = $(document.createElement('canvas')); } function iterable() { @@ -5344,7 +5353,7 @@ function JQuery() { function ready() { // $ExpectType JQuery $('p').ready(($) => { - // $ExpectType JQueryStatic + // $ExpectType JQueryStatic $; }); } @@ -7078,6 +7087,7 @@ function JQuery_Promise3() { interface I8 { kind: 'I8'; } interface I9 { kind: 'I9'; } + // tslint:disable-next-line:ban-types const p: JQuery.Promise3 = {} as any; const p1: JQuery.Promise3 = {} as any; const p2: JQuery.Promise3 = {} as any; @@ -7188,7 +7198,7 @@ function JQuery_Promise3() { p.then(() => { return $.ready; }).then((a) => { - a; // $ExpectType JQueryStatic + a; // $ExpectType JQueryStatic }); p.then(() => { @@ -7218,7 +7228,7 @@ function JQuery_Promise3() { p.then(null, () => { return $.ready; }).then((a) => { - a; // $ExpectType JQueryStatic + a; // $ExpectType JQueryStatic }); p.then(null, () => { @@ -7455,7 +7465,7 @@ function JQuery_Promise3() { }); // $ExpectType PromiseBase, never, SuccessTextStatus, ErrorTextStatus, never, jqXHR, string, never, never, never, never> a; - const b: JQuery.Promise3, never, JQuery.Ajax.SuccessTextStatus, JQuery.Ajax.ErrorTextStatus, never, JQuery.jqXHR, string, never> = a; + const b: JQuery.Promise3 = a; } // $ExpectType PromiseBase @@ -7476,6 +7486,7 @@ function JQuery_Promise3() { } async function testAsync(p: JQuery.Promise3): Promise { + // tslint:disable-next-line:await-promise const s: string = await p; return s; } @@ -7574,7 +7585,7 @@ function JQuery_Promise2(p: JQuery.Promise2 { return $.ready; }).then((a) => { - a; // $ExpectType JQueryStatic + a; // $ExpectType JQueryStatic }); p.then(() => { @@ -7601,7 +7612,7 @@ function JQuery_Promise2(p: JQuery.Promise2 { return $.ready; }).then((a) => { - a; // $ExpectType JQueryStatic + a; // $ExpectType JQueryStatic }); p.then(null, () => { @@ -7620,6 +7631,7 @@ function JQuery_Promise2(p: JQuery.Promise2): Promise { + // tslint:disable-next-line:await-promise const s: string = await p; return s; } @@ -7701,7 +7713,7 @@ function JQuery_Promise(p: JQuery.Promise) { p.then(() => { return $.ready; }).then((a) => { - a; // $ExpectType JQueryStatic + a; // $ExpectType JQueryStatic }); p.then(() => { @@ -7725,7 +7737,7 @@ function JQuery_Promise(p: JQuery.Promise) { p.then(null, () => { return $.ready; }).then((a) => { - a; // $ExpectType JQueryStatic + a; // $ExpectType JQueryStatic }); p.then(null, () => { diff --git a/types/jquery/test/jquery-no-window-module-tests.ts b/types/jquery/test/jquery-no-window-module-tests.ts index 2f2de4cc98..783031a672 100644 --- a/types/jquery/test/jquery-no-window-module-tests.ts +++ b/types/jquery/test/jquery-no-window-module-tests.ts @@ -1,5 +1,5 @@ import jQueryFactory = require('jquery'); const jq = jQueryFactory(window, true); -// $ExpectType JQueryStatic +// $ExpectType JQueryStatic jq; diff --git a/types/jquery/test/jquery-slim-no-window-module-tests.ts b/types/jquery/test/jquery-slim-no-window-module-tests.ts index 2e104af0eb..16793e0d2c 100644 --- a/types/jquery/test/jquery-slim-no-window-module-tests.ts +++ b/types/jquery/test/jquery-slim-no-window-module-tests.ts @@ -1,5 +1,5 @@ import jQueryFactory = require('jquery/dist/jquery.slim'); const jq = jQueryFactory(window, true); -// $ExpectType JQueryStatic +// $ExpectType JQueryStatic jq; diff --git a/types/jquery/test/jquery-window-module-tests.ts b/types/jquery/test/jquery-window-module-tests.ts index 72cb44c5aa..1d554f0861 100644 --- a/types/jquery/test/jquery-window-module-tests.ts +++ b/types/jquery/test/jquery-window-module-tests.ts @@ -3,16 +3,3 @@ import jq = require('jquery'); const $window = jq(window); // $ExpectType JQuery $window; - -class CanvasLayersDirective { - private readonly $renderingCanvas: JQuery; - private readonly $offscreenCanvas: JQuery; - - constructor(elementRef: { nativeElement: any; }) { - // This type assertion results in an error when exporting 'typeof factory & JQueryStatic' where - // 'factory' is jQuery's factory function. - const $Canvas = $ as JQueryStatic; - this.$renderingCanvas = $Canvas(elementRef.nativeElement); - this.$offscreenCanvas = $Canvas(document.createElement('canvas')); - } -} diff --git a/types/jquery/tslint.json b/types/jquery/tslint.json index d1d7bd0a0a..1d12f59138 100644 --- a/types/jquery/tslint.json +++ b/types/jquery/tslint.json @@ -1,24 +1,16 @@ { "extends": "dtslint/dt.json", "rules": { - // All are TODOs - "await-promise": false, - "ban-types": false, "callable-types": false, "interface-name": false, "no-any-union": false, + "no-declare-current-package": false, + + "ban-types": false, "no-arg": false, "no-boolean-literal-compare": false, - "no-const-enum": false, - "no-declare-current-package": false, - "no-empty-interface": false, - "no-misused-new": false, "no-object-literal-type-assertion": false, - "no-redundant-jsdoc-2": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, "no-unnecessary-type-assertion": false, - "no-var": false, "no-var-keyword": false, "object-literal-key-quotes": false, "object-literal-shorthand": false, @@ -29,9 +21,7 @@ "prefer-for-of": false, "prefer-switch": false, "prefer-template": false, - "space-before-function-paren": false, "space-within-parens": false, - "triple-equals": false, - "use-default-type-parameter": false + "triple-equals": false } } diff --git a/types/jsdom/index.d.ts b/types/jsdom/index.d.ts index 5ccdd33a65..cfb54fa25f 100644 --- a/types/jsdom/index.d.ts +++ b/types/jsdom/index.d.ts @@ -7,7 +7,7 @@ /// import { EventEmitter } from 'events'; -import { ElementLocation } from 'parse5'; +import { MarkupData } from 'parse5'; import * as tough from 'tough-cookie'; import { Script } from 'vm'; @@ -32,7 +32,7 @@ export class JSDOM { /** * The nodeLocation() method will find where a DOM node is within the source document, returning the parse5 location info for the node. */ - nodeLocation(node: Node): ElementLocation | null; + nodeLocation(node: Node): MarkupData.ElementLocation | null; /** * The built-in vm module of Node.js allows you to create Script instances, diff --git a/types/jsdom/package.json b/types/jsdom/package.json index c208056015..ef0b8c56fc 100644 --- a/types/jsdom/package.json +++ b/types/jsdom/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "parse5": "^3.0.2" + "parse5": "^4.0.0" } } diff --git a/types/jsdom/tsconfig.json b/types/jsdom/tsconfig.json index fe7f9dd41f..d75878188a 100644 --- a/types/jsdom/tsconfig.json +++ b/types/jsdom/tsconfig.json @@ -15,10 +15,13 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "paths": { + "parse5": [ "parse5/v4" ] + } }, "files": [ "index.d.ts", "jsdom-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/lingui__core/formats.d.ts b/types/lingui__core/formats.d.ts new file mode 100644 index 0000000000..841f6404e8 --- /dev/null +++ b/types/lingui__core/formats.d.ts @@ -0,0 +1,2 @@ +export function date(language: string, format?: Intl.DateTimeFormatOptions): (value: Date) => string; +export function number(language: string, format?: Intl.NumberFormatOptions): (value: number) => string; diff --git a/types/lingui__core/i18n.d.ts b/types/lingui__core/i18n.d.ts new file mode 100644 index 0000000000..49f663a6a8 --- /dev/null +++ b/types/lingui__core/i18n.d.ts @@ -0,0 +1,69 @@ +import { SelectProps, PluralProps } from "./select"; + +// In flowtype, MessageOptions is declared as exact type +export interface MessageOptions { + defaults?: string; + formats?: object; +} + +export interface LanguageData { + plurals?: (n: number, pluralType?: "cardinal" | "ordinal") => string; +} + +export interface Messages { + [key: string]: string | ((context: (name: string, type?: string, format?: any) => string) => (string | string[])); +} + +export interface Catalog { + messages: Messages; + languageData?: LanguageData; +} + +export interface Catalogs { + [key: string]: Catalog; +} + +export interface setupI18nProps { + language?: string; + catalogs?: Catalogs; + development?: object; +} + +export class I18n { + t(strings: TemplateStringsArray, ...values: any[]): string; + + t(id: string): (strings: TemplateStringsArray, ...values: any[]) => string; + + select(config: SelectProps): string; + + select(id: string, config: SelectProps): string; + + plural(config: PluralProps): string; + + plural(id: string, config: PluralProps): string; + + selectOrdinal(config: PluralProps): string; + + selectOrdinal(id: string, config: PluralProps): string; + + constructor(); + + availableLanguages: string[]; + language: string; + messages: Messages; + languageData: LanguageData; + + load(catalogs: Catalogs): void; + + activate(language: string): void; + + use(language: string): I18n; + + _(id: string, values?: object, messageOptions?: MessageOptions): string; + + pluralForm(n: number, pluralType?: "cardinal" | "ordinal"): string; +} + +export function setupI18n(params?: setupI18nProps): I18n; + +export const i18n: I18n; diff --git a/types/lingui__core/index.d.ts b/types/lingui__core/index.d.ts new file mode 100644 index 0000000000..c0aa933bee --- /dev/null +++ b/types/lingui__core/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for @lingui/core 2.1 +// Project: https://lingui.github.io/js-lingui/ +// Definitions by: Jeow Li Huan +// Definitions: https://github.com/huan086/lingui-typings + +export { + i18n, + setupI18n, + Catalog, + Catalogs, + MessageOptions, + LanguageData, + I18n +} from './i18n'; + +export { + date, + number +} from './formats'; + +export function i18nMark(id: string): string; diff --git a/types/lingui__core/lingui__core-tests.ts b/types/lingui__core/lingui__core-tests.ts new file mode 100644 index 0000000000..799bc5812b --- /dev/null +++ b/types/lingui__core/lingui__core-tests.ts @@ -0,0 +1,89 @@ +import { + i18n, + setupI18n, + Catalog, + Catalogs, + MessageOptions, + LanguageData, + I18n, + date, + number, + i18nMark +} from '@lingui/core'; + +const age = 12; +const templateResult: string = i18n.t`${age} years old`; +const templateIdResult: string = i18n.t('templateId')`${age} years old`; +const translateResult: string = i18n._('age', { age }, { defaults: '{age} years old' }); + +const count = 42; + +const pluralResult: string = i18n.plural({ + value: count, + 0: 'no books', + one: '# book', + other: '# books' +}); +const pluralIdResult: string = i18n.plural('pluralId', { + value: count, + 0: 'no books', + one: '# book', + other: '# books' +}); + +const selectOrdinalResult: string = i18n.selectOrdinal({ + value: count, + 0: 'Zeroth book', + one: '#st book', + two: '#nd book', + few: '#rd book', + other: '#th book' +}); +const selectOrdinalIdResult: string = i18n.selectOrdinal('selectOrdinalId', { + value: count, + 0: 'Zeroth book', + one: '#st book', + two: '#nd book', + few: '#rd book', + other: '#th book' +}); + +const gender = 'female'; +const numOfGuests = 2; +const host = 'Amy'; +const guest = 'Bob'; +const selectResult = i18n.select({ + value: gender, + female: i18n.plural({ + value: numOfGuests, + offset: 1, + 0: i18n.t`${host} does not give a party.`, + 1: i18n.t`${host} invites ${guest} to her party.`, + 2: i18n.t`${host} invites ${guest} and one other person to her party.`, + other: i18n.t`${host} invites ${guest} and # other people to her party.` + }), + male: 'male', + other: 'other' +}); + +const selectIdResult = i18n.select('selectId', { + value: gender, + female: 'female', + male: 'male', + other: 'other' +}); + +const catalog: Catalog = { + messages: { + age(a) { + return [a('age'), 'años de edad']; + } + } +}; +const catalogs: Catalogs = { es: catalog }; +const setupResult: I18n = setupI18n({ catalogs, language: 'es' }); + +const formattedDate: string = date('en', { timeZone: 'UTC' })(new Date()); +const formattedNumber: string = number('en', { style: 'currency', currency: 'EUR' })(1234.56); + +const mark: string = i18nMark('mark'); diff --git a/types/lingui__core/select.d.ts b/types/lingui__core/select.d.ts new file mode 100644 index 0000000000..6a2eb51db9 --- /dev/null +++ b/types/lingui__core/select.d.ts @@ -0,0 +1,20 @@ +export interface PluralForms { + zero?: string; + one?: string; + two?: string; + few?: string; + many?: string; + other: string; + [exact: number]: string; +} + +export interface PluralProps extends PluralForms { + value: number; + offset?: number; +} + +export interface SelectProps { + value: string; + other: string; + [selectForm: string]: string; +} diff --git a/types/lingui__core/tsconfig.json b/types/lingui__core/tsconfig.json new file mode 100644 index 0000000000..e01d974c46 --- /dev/null +++ b/types/lingui__core/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@lingui/core": [ + "lingui__core" + ] + } + }, + "files": [ + "index.d.ts", + "lingui__core-tests.ts" + ] +} diff --git a/types/lingui__core/tslint.json b/types/lingui__core/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/lingui__core/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/lingui__react/I18nProvider.d.ts b/types/lingui__react/I18nProvider.d.ts new file mode 100644 index 0000000000..9eb0158fac --- /dev/null +++ b/types/lingui__react/I18nProvider.d.ts @@ -0,0 +1,14 @@ +import { Component, ReactNode } from 'react'; +import { I18n, Catalogs } from '@lingui/core'; + +// tslint:disable-next-line:interface-name +export interface I18nProviderProps { + children?: ReactNode; + language: string; + catalogs?: Catalogs; + i18n?: I18n; + + defaultRender?: ReactNode; +} + +export default class I18nProvider extends Component { } diff --git a/types/lingui__react/Render.d.ts b/types/lingui__react/Render.d.ts new file mode 100644 index 0000000000..d9ccf003c0 --- /dev/null +++ b/types/lingui__react/Render.d.ts @@ -0,0 +1,6 @@ +import { ReactNode } from 'react'; + +export interface RenderProps { + render?: ReactNode; + className?: string; +} diff --git a/types/lingui__react/Select.d.ts b/types/lingui__react/Select.d.ts new file mode 100644 index 0000000000..044d4bf473 --- /dev/null +++ b/types/lingui__react/Select.d.ts @@ -0,0 +1,26 @@ +import { Component, ReactNode } from 'react'; +import { RenderProps } from './Render'; + +export interface PluralPropsWithoutI18n extends RenderProps { + id?: string; + value: number | string; + offset?: number | string; + zero?: ReactNode; + one?: ReactNode; + two?: ReactNode; + few?: ReactNode; + many?: ReactNode; + other: ReactNode; + [exact: string]: ReactNode; +} + +export interface SelectPropsWithoutI18n extends RenderProps { + id?: string; + value: string; + other: ReactNode; + [exact: string]: ReactNode; +} + +export class Select extends Component { } +export class Plural extends Component { } +export class SelectOrdinal extends Component { } diff --git a/types/lingui__react/Trans.d.ts b/types/lingui__react/Trans.d.ts new file mode 100644 index 0000000000..c1834b770d --- /dev/null +++ b/types/lingui__react/Trans.d.ts @@ -0,0 +1,13 @@ +import { Component, ReactElement, ReactNode } from 'react'; +import { RenderProps } from './Render'; + +export interface TransPropsWithoutI18n extends RenderProps { + id?: string; + defaults?: string; + values?: object; + formats?: object; + components?: ReadonlyArray>; + children?: ReactNode; +} + +export default class Trans extends Component { } diff --git a/types/lingui__react/createFormat.d.ts b/types/lingui__react/createFormat.d.ts new file mode 100644 index 0000000000..49bebb079e --- /dev/null +++ b/types/lingui__react/createFormat.d.ts @@ -0,0 +1,6 @@ +import { RenderProps } from './Render'; + +export interface FormatPropsWithoutI18n extends RenderProps { + value: V; + format?: FormatOptions; +} diff --git a/types/lingui__react/index.d.ts b/types/lingui__react/index.d.ts new file mode 100644 index 0000000000..1fbe1e5c05 --- /dev/null +++ b/types/lingui__react/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for @lingui/react 2.1 +// Project: https://lingui.github.io/js-lingui/ +// Definitions by: Jeow Li Huan +// Definitions: https://github.com/huan086/lingui-typings +// TypeScript Version: 2.8 + +import { ComponentClass } from 'react'; + +import { FormatPropsWithoutI18n } from './createFormat'; + +export { default as withI18n, withI18nProps } from './withI18n'; + +export { default as I18nProvider } from './I18nProvider'; +export { default as Trans } from './Trans'; +export { Plural, Select, SelectOrdinal } from './Select'; + +export const DateFormat: ComponentClass>; +export const NumberFormat: ComponentClass>; + +export function i18nMark(id: string): string; diff --git a/types/lingui__react/lingui__react-tests.tsx b/types/lingui__react/lingui__react-tests.tsx new file mode 100644 index 0000000000..3fc8cebebb --- /dev/null +++ b/types/lingui__react/lingui__react-tests.tsx @@ -0,0 +1,102 @@ +import * as React from 'react'; +import { Catalog, Catalogs, I18n } from '@lingui/core'; +import { + withI18n, + I18nProvider, + Trans, + Plural, + Select, + SelectOrdinal, + DateFormat, + NumberFormat, + i18nMark +} from '@lingui/react'; + +const catalog: Catalog = { + messages: { + ageId(a) { + return [a('age'), 'años de edad']; + } + } +}; +const catalogs: Catalogs = { es: catalog }; + +interface LocalizeAttributeBaseProps { + i18n: I18n; + age: number; +} + +const LocalizeAttributeBase = (props: LocalizeAttributeBaseProps) => { + const { i18n, age } = props; + return ( + Attributes + ); +}; + +const LocalizeAttribute = withI18n()(LocalizeAttributeBase); +const LocalizeOptionAttribute = withI18n({ update: true, withRef: true, withHash: true })(LocalizeAttributeBase); + +const App = () => { + const name = 'Ken'; + const numBooks = 58; + const gender = 'male'; + const price = 21.35; + const lastLogin = new Date(); + return ( + + + + Name {name} in Trans. + Name {name} in Trans with id. + {name} has no books} + one={{name} has # book} + other={{name} has # books} + _999999="Just a string" + /> + {name} has no books} + one={{name} has # book} + other={{name} has # books} + _999999="Just a string" + /> + {name} and his friends} + female={{name} and her friends} + other={{name} and their friends} + _999999="Just a string" + /> + No books from {name}} + one={#st book from {name}} + two={#nd book from {name}} + other={#th book from {name}} + _999999="Just a string" + /> + No books from {name}} + one={#st book from {name}} + two={#nd book from {name}} + other={#th book from {name}} + _999999="Just a string" + /> + Last login on . + + Price of book: . + + + ); +}; + +const mark: string = i18nMark('mark'); diff --git a/types/lingui__react/tsconfig.json b/types/lingui__react/tsconfig.json new file mode 100644 index 0000000000..3b53ee659c --- /dev/null +++ b/types/lingui__react/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@lingui/core": [ + "lingui__core" + ], + "@lingui/react": [ + "lingui__react" + ] + } + }, + "files": [ + "index.d.ts", + "lingui__react-tests.tsx" + ] +} diff --git a/types/lingui__react/tslint.json b/types/lingui__react/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/lingui__react/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/lingui__react/withI18n.d.ts b/types/lingui__react/withI18n.d.ts new file mode 100644 index 0000000000..00595ee2d5 --- /dev/null +++ b/types/lingui__react/withI18n.d.ts @@ -0,0 +1,18 @@ +import { ComponentClass, StatelessComponent } from 'react'; +import { I18n } from '@lingui/core'; +import { withI18nProps } from './withI18n'; + +export type ComponentConstructor

= ComponentClass

| StatelessComponent

; + +export interface withI18nOptions { + update?: boolean; + withRef?: boolean; + withHash?: boolean; +} + +export interface withI18nProps { + i18n: I18n; +} + +export default function withI18n(options?: withI18nOptions): +

(WrappedComponent: ComponentConstructor

) => ComponentClass>>; diff --git a/types/moment-shortformat/index.d.ts b/types/moment-shortformat/index.d.ts new file mode 100644 index 0000000000..d5125aac49 --- /dev/null +++ b/types/moment-shortformat/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for moment-shortformat 2.1 +// Project: https://github.com/researchgate/moment-shortformat#readme +// Definitions by: whatasoda +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace moment; + +import moment = require('moment'); + +export = moment; + +declare module 'moment' { + interface Moment { + short(withoutPreOrSuffix?: boolean, now?: Moment): string; + } +} diff --git a/types/moment-shortformat/moment-shortformat-tests.ts b/types/moment-shortformat/moment-shortformat-tests.ts new file mode 100644 index 0000000000..84f754a750 --- /dev/null +++ b/types/moment-shortformat/moment-shortformat-tests.ts @@ -0,0 +1,20 @@ +import moment = require('moment'); +import 'moment-shortformat'; + +let formatted: string; +/*~ Formats time relative to current time. */ +formatted = moment(moment().valueOf() + (36e5 * 5)).short(); // 'in 5h' +formatted = moment(moment().valueOf() - (36e5 * 5)).short(); // '5h ago' +formatted = moment(moment().valueOf() + (36e5 * 5)).short(true); // '5h' +formatted = moment(moment().valueOf() - (36e5 * 5)).short(true); // '5h' + +/*~ Times greater than 1 week are converted to dates like Mar 7, + *~ or if the year of the date does not match the current year + *~ it is convert to Mar 7, 2031 + */ +formatted = moment(moment().valueOf() + 6048e5).short(); // 'Mar 7' + +/*~ Using a different "now" */ +formatted = moment(moment().valueOf() + (36e5 * 5)).short( + false, moment(moment().valueOf() + (36e5 * 3)) +); // 'in 2h' diff --git a/types/moment-shortformat/tsconfig.json b/types/moment-shortformat/tsconfig.json new file mode 100644 index 0000000000..96fd6c6524 --- /dev/null +++ b/types/moment-shortformat/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "moment-shortformat-tests.ts" + ] +} diff --git a/types/moment-shortformat/tslint.json b/types/moment-shortformat/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/moment-shortformat/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 17176079ca..d67c143da1 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -2276,6 +2276,12 @@ declare module "mongoose" { /** Adds a collation. */ collation(options: CollationOptions): this; + /** + * Appends a new $count operator to this aggregate pipeline. + * @param countName name of the count field + */ + count(countName: string): this; + /** * Sets the cursor option option for the aggregation query (ignored for < 2.6.0). * Note the different syntax below: .exec() returns a cursor object, and no callback diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index 90259483f2..796ae086e3 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -1200,6 +1200,7 @@ aggregate.allowDiskUse(true).allowDiskUse(false, []); aggregate.append({ $project: { field: 1 }}, { $limit: 2 }); aggregate.append([{ $match: { daw: 'Logic Audio X' }} ]); aggregate.collation({ locale: 'en_US', strength: 1 }); +aggregate.count('countName'); aggregate.cursor({ batchSize: 1000 }).exec().each(cb); aggregate.exec().then(cb).catch(cb); aggregate.option({foo: 'bar'}).exec(); diff --git a/types/mozilla-readability/tsconfig.json b/types/mozilla-readability/tsconfig.json index 6ec688cf2f..9679936061 100644 --- a/types/mozilla-readability/tsconfig.json +++ b/types/mozilla-readability/tsconfig.json @@ -15,10 +15,13 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "paths": { + "parse5": [ "parse5/v4" ] + } }, "files": [ "index.d.ts", "mozilla-readability-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/named-routes/index.d.ts b/types/named-routes/index.d.ts new file mode 100644 index 0000000000..b983ba1911 --- /dev/null +++ b/types/named-routes/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for named-routes 2.0 +// Project: https://github.com/alubbe/named-routes#readme +// Definitions by: Philipp Katz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import * as express from 'express'; + +declare module 'express-serve-static-core' { + interface Application { + namedRoutes: NamedRouter; + } + // tslint:disable-next-line interface-name + interface IRouterMatcher { + (path: PathParams, name: string, ...handlers: RequestHandler[]): T; + (path: PathParams, name: string, ...handlers: RequestHandlerParams[]): T; + } +} + +interface RouterOptions { + caseSensitive: boolean; +} + +interface RouteOptions { + name: string; + recursiveWildcard: boolean; + caseSensitive: boolean; + wildcardInPairs: boolean; +} + +interface RouteParams { + [ key: string ]: string | string[] | number | number[] | boolean | boolean[] | null; +} + +declare class NamedRouter { + constructor(options?: Partial); + match(req: express.Request): boolean | object; + add(method: string, path: string, callbacks: express.RequestHandler | express.RequestHandler[], options?: Partial): void; + build(name: string, params?: RouteParams, method?: string): string; + registerAppHelpers(app: express.Express): NamedRouter; + param(name: string, callback: express.RequestHandler): NamedRouter; + param(callback: express.RequestHandler): NamedRouter; + dispatch(req: express.Request, res?: express.Response, next?: express.NextFunction): void; + extendExpress(app: express.Express | express.Router): NamedRouter; +} + +export = NamedRouter; diff --git a/types/named-routes/named-routes-tests.ts b/types/named-routes/named-routes-tests.ts new file mode 100644 index 0000000000..9b424a2c45 --- /dev/null +++ b/types/named-routes/named-routes-tests.ts @@ -0,0 +1,35 @@ +import NamedRouter = require('named-routes'); +import * as express from 'express'; +const app = express(); + +// constructor and `RouterOptions` +let router = new NamedRouter(); +router = new NamedRouter({ caseSensitive: true }); + +router.extendExpress(app); // $ExpectType NamedRouter +router.registerAppHelpers(app); // $ExpectType NamedRouter +app.get('/path/:id', 'foo', () => {}); // $ExpectType Express +app.namedRoutes.build('foo', { id: 1 }); // $ExpectType string + +const expressRouter = express.Router(); +router.extendExpress(expressRouter); // $ExpectType NamedRouter +expressRouter.post('/path/:id', 'foo', () => {}); // $ExpectType Router + +// `RouteOptions` +router.add('get', '/path/:id', () => {}); // $ExpectType void +router.add('get', '/path/:id', () => {}, { name: 'foo' }); // $ExpectType void +router.add('get', '/path/:id', () => {}, { name: 'foo', recursiveWildcard: true }); // $ExpectType void +router.add('get', '/path/:id', () => {}, { name: 'foo', caseSensitive: true }); // $ExpectType void +router.add('get', '/path/:id', () => {}, { name: 'foo', wildcardInPairs: true }); // $ExpectType void + +// `RouteParams` +router.build('foo', { string: 'a' }); // $ExpectType string +router.build('foo', { stringArray: [ 'a', 'b' ] }); // $ExpectType string +router.build('foo', { number: 1 }); // $ExpectType string +router.build('foo', { numberArray: [ 1, 2 ] }); // $ExpectType string +router.build('foo', { boolean: true }); // $ExpectType string +router.build('foo', { booleanArray: [ true, false ] }); // $ExpectType string +router.build('foo', { null: null }); // $ExpectType string + +const req: express.Request = {} as any; +router.dispatch(req); // $ExpectType void diff --git a/types/named-routes/tsconfig.json b/types/named-routes/tsconfig.json new file mode 100644 index 0000000000..28060f592f --- /dev/null +++ b/types/named-routes/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "named-routes-tests.ts" + ] +} diff --git a/types/named-routes/tslint.json b/types/named-routes/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/named-routes/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/new-relic-browser/index.d.ts b/types/new-relic-browser/index.d.ts index 0064ee4ad2..6d9fc22fdc 100644 --- a/types/new-relic-browser/index.d.ts +++ b/types/new-relic-browser/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Rene Hamburger , Piotr Kubisa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare const newrelic: NewRelic.Browser; - declare namespace NewRelic { interface Browser { /** @@ -186,7 +184,7 @@ declare namespace NewRelic { * Adds a custom SPA attribute only to the current interaction in New Relic Browser. * * @param key Used as the attribute name on the BrowserInteraction event. - * @param Used as the attribute value on the BrowserInteraction event. This can be a + * @param value Used as the attribute value on the BrowserInteraction event. This can be a * string, number, boolean, or object. If it is an object, New Relic serializes it to a JSON string. * @returns This method returns the same API object created by interaction(). * @see https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api/spa-set-attribute @@ -205,3 +203,6 @@ declare namespace NewRelic { setName(name: string, trigger?: string): BrowserInteraction; } } + +declare const api: NewRelic.Browser; +export = api; diff --git a/types/new-relic-browser/new-relic-browser-tests.ts b/types/new-relic-browser/new-relic-browser-tests.ts index b9f75b142d..86ce781e18 100644 --- a/types/new-relic-browser/new-relic-browser-tests.ts +++ b/types/new-relic-browser/new-relic-browser-tests.ts @@ -1,3 +1,5 @@ +import newrelic = require("new-relic-browser"); + // The following tests are largely taken straight from the examples at https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api // --- NewRelic.Browser methods ---------------------------------------------- diff --git a/types/node-ssdp/index.d.ts b/types/node-ssdp/index.d.ts new file mode 100644 index 0000000000..3ae4da7643 --- /dev/null +++ b/types/node-ssdp/index.d.ts @@ -0,0 +1,159 @@ +// Type definitions for node-ssdp 3.3 +// Project: https://github.com/diversario/node-ssdp#readme +// Definitions by: Olivia Trewin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as events from 'events'; +import * as dgram from 'dgram'; + +export interface SsdpHeaders { + /** + * Available while handling an SSDP response. A URL where the service description can be found. + */ + LOCATION?: string; + ST?: string; + /** + * Available while handling an SSDP response. The Unique Service Name (USN) of the responding device. + */ + USN?: string; + [key: string]: string | number | boolean | null | undefined | symbol; +} + +export interface SsdpOptions { + /** + * SSDP signature + * @default 'node.js/NODE_VERSION UPnP/1.1 node-ssdp/PACKAGE_VERSION' + */ + ssdpSig?: string; + /** + * SSDP multicast group + * @default '239.255.255.250' + */ + ssdpIp?: string; + /** + * Multicast TTL + * @default 4 + */ + ssdpTtl?: number; + /** + * SSDP port + * @default 1900 + */ + ssdpPort?: number; + /** Path to SSDP description file */ + description?: string; + /** Additional headers */ + headers?: SsdpHeaders; + /** A logger function to use instead of the default. The first argument to the function can contain a format string. */ + customLogger?: (format: string, ...args: any[]) => void; +} + +export interface ClientOptions extends SsdpOptions { + /** List of interfaces to explicitly bind. By default, bind to all available interfaces. */ + interfaces?: string[]; + /** Bind sockets to each discovered interface explicitly instead of relying on the system. Might help with issues with multiple NICs. */ + explicitSocketBind?: boolean; + /** + * When true socket.bind() will reuse the address, even if another process has already bound a socket on it. + * @default true + */ + reuseAddr?: boolean; +} + +export interface ServiceDescriptionLocation { + /** + * Location protocol. + * @default 'http://' + */ + protocol?: string; + /** + * Location port. + */ + port: number; + /** + * Location path. + */ + path: string; +} + +export interface ServerOptions extends ClientOptions { + /** + * URL pointing to description of your service, or a function that returns that URL. + * For cases where there are multiple network interfaces or the IP of the host isn't known in advance, + * it's possible to specify location as an object. Host will be set to the IP of the responding interface. + */ + location?: string | ServiceDescriptionLocation; + /** + * SSDP Unique Device Name + * @default 'uuid:f40c2981-7329-40b7-8b04-27f187aecfb5' + */ + udn?: string; + /** + * Allow wildcards in M-SEARCH packets (non-standard) + * @default false + */ + allowWildcards?: boolean; + /** + * When true the SSDP server will not advertise the root device (i.e. the bare UDN). In some scenarios, this advertisement is not needed. + * @default false + */ + suppressRootDeviceAdvertisements?: boolean; + /** + * Interval at which to send out advertisement (ms) + * @default 10000 + */ + adInterval?: number; + /** + * Packet TTL + * @default 1800 + */ + ttl?: number; +} + +export abstract class Base extends events.EventEmitter { + constructor(opts?: SsdpOptions); + + addUSN(device: string): void; +} + +export class Client extends Base { + constructor(opts?: ClientOptions); + + /** + * Start the listener for multicast notifications from SSDP devices + * @param cb callback to socket.bind + * @returns promise when socket.bind is ready + */ + start(cb?: (error: Error) => void): Promise; + /** + * Close UDP socket. + */ + stop(): void; + search(serviceType: string): void | Promise; + + on(event: 'response', listener: (headers: SsdpHeaders, statusCode: number, rinfo: dgram.RemoteInfo) => void): this; + once(event: 'response', listener: (headers: SsdpHeaders, statusCode: number, rinfo: dgram.RemoteInfo) => void): this; + emit(event: 'response', headers: SsdpHeaders, statusCode: number, rinfo: dgram.RemoteInfo): boolean; +} + +export class Server extends Base { + constructor(opts?: ServerOptions); + + /** + * Binds UDP socket to an interface/port and starts advertising. + * @param cb callback to socket.bind + * @returns promise when socket.bind is ready + */ + start(cb?: (error: Error) => void): void | Promise; + /** + * Advertise shutdown and close UDP socket. + */ + stop(): void; + advertise(alive?: boolean): void; + + on(event: 'advertise-alive' | 'advertise-bye', listener: (headers: SsdpHeaders) => void): this; + once(event: 'advertise-alive' | 'advertise-bye', listener: (headers: SsdpHeaders) => void): this; + emit(event: 'advertise-alive' | 'advertise-bye', headers: SsdpHeaders): boolean; +} diff --git a/types/node-ssdp/node-ssdp-tests.ts b/types/node-ssdp/node-ssdp-tests.ts new file mode 100644 index 0000000000..dbd2536e78 --- /dev/null +++ b/types/node-ssdp/node-ssdp-tests.ts @@ -0,0 +1,73 @@ +import { Client, Server } from 'node-ssdp'; + +// Taken from https://github.com/diversario/node-ssdp#usage---client + +const client = new Client({ + interfaces: [], + customLogger: format => {}, + explicitSocketBind: true, + reuseAddr: true, + ssdpPort: 0, + description: '', + headers: { + key: 'value' + }, + ssdpIp: '', + ssdpSig: '', + ssdpTtl: 0 +}); + +client.on('response', (headers, statusCode, rinfo) => { + console.log('Got a response to an m-search.'); +}); + +// search for a service type +client.search('urn:schemas-upnp-org:service:ContentDirectory:1'); + +// Or get a list of all services on the network + +client.search('ssdp:all'); + +const server = new Server({ + interfaces: [], + customLogger: format => {}, + explicitSocketBind: true, + reuseAddr: true, + ssdpPort: 0, + location: { + protocol: 'http://', + path: '', + port: 80 + }, + suppressRootDeviceAdvertisements: true, + adInterval: 0, + allowWildcards: false, + description: '', + headers: { + key: 'value' + }, + ssdpIp: '', + ssdpSig: '', + ssdpTtl: 0, + ttl: 0, + udn: '' +}); + +// Taken from https://github.com/diversario/node-ssdp#usage---server + +server.addUSN('upnp:rootdevice'); +server.addUSN('urn:schemas-upnp-org:device:MediaServer:1'); +server.addUSN('urn:schemas-upnp-org:service:ContentDirectory:1'); +server.addUSN('urn:schemas-upnp-org:service:ConnectionManager:1'); + +server.on('advertise-alive', (headers) => { + // Expire old devices from your cache. + // Register advertising device somewhere (as designated in http headers heads) +}); + +server.on('advertise-bye', (headers) => { + // Remove specified device from cache. +}); + +// start the server +server.start(); diff --git a/types/node-ssdp/tsconfig.json b/types/node-ssdp/tsconfig.json new file mode 100644 index 0000000000..a85ee0905f --- /dev/null +++ b/types/node-ssdp/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-ssdp-tests.ts" + ] +} diff --git a/types/node-ssdp/tslint.json b/types/node-ssdp/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/node-ssdp/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/nodegit/repository.d.ts b/types/nodegit/repository.d.ts index b94d7bd626..71a6497585 100644 --- a/types/nodegit/repository.d.ts +++ b/types/nodegit/repository.d.ts @@ -136,7 +136,7 @@ export class Repository { /** * Instantiate a new revision walker for browsing the Repository"s history. See also Commit.prototype.history() */ - createRevWalk(string: string | Oid): Revwalk; + createRevWalk(): Revwalk; /** * Retrieve the master branch commit. */ diff --git a/types/nodemailer/lib/json-transport.d.ts b/types/nodemailer/lib/json-transport.d.ts index f6792f4402..239decbdb6 100644 --- a/types/nodemailer/lib/json-transport.d.ts +++ b/types/nodemailer/lib/json-transport.d.ts @@ -15,6 +15,7 @@ declare namespace JSONTransport { interface Options extends MailOptions, TransportOptions { jsonTransport: true; + skipEncoding?: boolean; } interface SentMessageInfo { diff --git a/types/nodemailer/lib/mailer/index.d.ts b/types/nodemailer/lib/mailer/index.d.ts index f9d36d7efb..00cf40839c 100644 --- a/types/nodemailer/lib/mailer/index.d.ts +++ b/types/nodemailer/lib/mailer/index.d.ts @@ -165,7 +165,7 @@ declare class Mail extends EventEmitter { verify(callback: (err: Error | null, success: true) => void): void; verify(): Promise; - use(step: string, plugin: Mail.PluginFunction): void; // TODO Plugin? + use(step: string, plugin: Mail.PluginFunction): this; /** Sends an email using the preselected transport object */ sendMail(mailOptions: Mail.Options, callback: (err: Error | null, info: SentMessageInfo) => void): void; diff --git a/types/nodemailer/nodemailer-tests.ts b/types/nodemailer/nodemailer-tests.ts index 6f045df08b..140b351c6b 100644 --- a/types/nodemailer/nodemailer-tests.ts +++ b/types/nodemailer/nodemailer-tests.ts @@ -832,7 +832,8 @@ function stream_buffer_unix_newlines_test() { function json_test() { const transporter = nodemailer.createTransport({ - jsonTransport: true + jsonTransport: true, + skipEncoding: true }); transporter.sendMail({ from: 'sender@example.com', diff --git a/types/nuka-carousel/index.d.ts b/types/nuka-carousel/index.d.ts index b06403e703..5481ae8b83 100644 --- a/types/nuka-carousel/index.d.ts +++ b/types/nuka-carousel/index.d.ts @@ -64,7 +64,7 @@ export interface SlideRenderControlProps { goToSlide: (index: number) => void; } -export type RenderControl = (props: SlideRenderControlProps) => JSX.Element; +export type RenderControl = (props: SlideRenderControlProps) => JSX.Element | null; export interface CarouselProps { /** diff --git a/types/nuka-carousel/nuka-carousel-tests.tsx b/types/nuka-carousel/nuka-carousel-tests.tsx index 03df5e6251..6ca021542c 100644 --- a/types/nuka-carousel/nuka-carousel-tests.tsx +++ b/types/nuka-carousel/nuka-carousel-tests.tsx @@ -25,7 +25,7 @@ const props: CarouselProps = { renderCenterCenterControls: () =>