Merge branch 'master' into patch-4

This commit is contained in:
Bradley Ayers
2018-03-22 09:36:01 +11:00
committed by GitHub
56 changed files with 2963 additions and 2068 deletions

View File

@@ -1,4 +1,6 @@
/// <reference types="node" />
/// <reference types="lodash" />
/// <reference types="benchmark" />
declare namespace adone {
const _null: symbol;
@@ -104,4 +106,8 @@ declare namespace adone {
export const expect: assertion.I.ExpectFunction;
export const std: typeof nodestd;
export const lodash: _.LoDashStatic;
export const benchmark: typeof tbenchmark;
}

5
types/adone/benchmark.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
import Benchmark = require("benchmark");
export { Benchmark };
export as namespace tbenchmark;

View File

@@ -1158,37 +1158,35 @@ declare namespace adone {
*/
function watch(paths: string | string[], options?: I.Watcher.ConstructorOptions): Watcher;
namespace is {
/**
* Returns true if the given path refers to a file
*/
function file(path: string): Promise<boolean>;
/**
* Returns true if the given path refers to a file
*/
function isFile(path: string): Promise<boolean>;
/**
* Returns true if the given path refers to a file
*/
function fileSync(path: string): boolean;
/**
* Returns true if the given path refers to a file
*/
function isFileSync(path: string): boolean;
/**
* Returns true if the given path refers to a direcotry
*/
function directory(path: string): Promise<boolean>;
/**
* Returns true if the given path refers to a direcotry
*/
function isDirectory(path: string): Promise<boolean>;
/**
* Returns true if the given path refers to a direcotry
*/
function directorySync(path: string): boolean;
/**
* Returns true if the given path refers to a direcotry
*/
function isDirectorySync(path: string): boolean;
/**
* Returns true if the given path refers to an executable file
*/
function executable(path: string): Promise<boolean>;
/**
* Returns true if the given path refers to an executable file
*/
function isExecutable(path: string): Promise<boolean>;
/**
* Returns true if the given path refers to an executable file
*/
function executableSync(path: string): boolean;
}
/**
* Returns true if the given path refers to an executable file
*/
function isExecutableSync(path: string): boolean;
namespace I.Which {
interface Options {
@@ -1920,5 +1918,19 @@ declare namespace adone {
* Creates a new TailWatcher instance with the given arguments
*/
function watchTail(filename: string, options?: I.TailWatcher.ConstructorOptions): TailWatcher;
namespace I {
interface WriteFileAtomicOptions {
chown?: {
gid?: number;
uid?: number;
};
encoding?: string | null;
fsync?: boolean;
mode?: number;
}
}
function writeFileAtomic(filename: string, data: Buffer | string | Uint8Array, options?: I.WriteFileAtomicOptions): Promise<void>;
}
}

View File

@@ -676,5 +676,9 @@ declare namespace adone {
export function emitter(obj: any): obj is event.Emitter;
export function asyncEmitter(obj: any): obj is event.AsyncEmitter;
export const openbsd: boolean;
export const aix: boolean;
}
}

View File

@@ -602,13 +602,12 @@ namespace fsTests {
}
namespace isTests {
const { is } = fs;
is.file("hello").then((x: boolean) => {});
{ const a: boolean = is.fileSync("hello"); }
is.directory("hello").then((x: boolean) => {});
{ const a: boolean = is.directorySync("hello"); }
is.executable("hello").then((x: boolean) => {});
{ const a: boolean = is.executableSync("hello"); }
fs.isFile("hello").then((x: boolean) => {});
{ const a: boolean = fs.isFileSync("hello"); }
fs.isDirectory("hello").then((x: boolean) => {});
{ const a: boolean = fs.isDirectorySync("hello"); }
fs.isExecutable("hello").then((x: boolean) => {});
{ const a: boolean = fs.isExecutableSync("hello"); }
}
namespace whichTests {
@@ -944,4 +943,17 @@ namespace fsTests {
fs.watchTail("file", { separator: /\n/ });
fs.watchTail("file", { useWatchFile: true });
}
namespace writeFileAtomicTests {
fs.writeFileAtomic("a", "b").then(() => {});
fs.writeFileAtomic("a", Buffer.from("b")).then(() => {});
fs.writeFileAtomic("a", new Uint8Array(10)).then(() => {});
fs.writeFileAtomic("a", "a", {}).then(() => {});
fs.writeFileAtomic("a", "a", { chown: {} }).then(() => {});
fs.writeFileAtomic("a", "a", { chown: { gid: 0 } }).then(() => {});
fs.writeFileAtomic("a", "a", { chown: { uid: 0 } }).then(() => {});
fs.writeFileAtomic("a", "a", { encoding: "utf8" }).then(() => {});
fs.writeFileAtomic("a", "a", { fsync: false }).then(() => {});
fs.writeFileAtomic("a", "a", { mode: 0o666 }).then(() => {});
}
}

View File

@@ -336,6 +336,8 @@ namespace isTests {
{ const a: boolean = is.freebsd; }
{ const a: boolean = is.darwin; }
{ const a: boolean = is.sunos; }
{ const a: boolean = is.openbsd; }
{ const a: boolean = is.aix; }
{ const a: boolean = is.uppercase("abc"); }
{ const a: boolean = is.lowercase("abc"); }
{ const a: boolean = is.digits("012"); }

View File

@@ -54,4 +54,15 @@ namespace AdoneRootTests {
obj = adone.package;
{ const a: typeof adone.assertion.assert = adone.assert; }
{ const a: typeof adone.assertion.expect = adone.expect; }
namespace lodashTests {
adone.lodash.get({}, "a");
adone.lodash.defaults({}, {});
adone.lodash.zip([]);
}
namespace benchmarkTests {
const b = new adone.benchmark.Benchmark.Suite();
b.add(() => {}).add("", () => {}).run();
}
}

View File

@@ -22,6 +22,7 @@
"files": [
"adone-tests.ts",
"adone.d.ts",
"benchmark.d.ts",
"glosses/archives.d.ts",
"glosses/assertion.d.ts",
"glosses/collections/array_set.d.ts",

19
types/cleave.js/options/creditCard.d.ts vendored Normal file
View File

@@ -0,0 +1,19 @@
import Cleave = require("../");
// Credit Card Options
export type CreditCardType =
| "amex"
| "dankort"
| "diners"
| "discover"
| "instapayment"
| "jcb"
| "maestro"
| "mastercard"
| "uatp"
| "unknown"
| "unionPay"
| "mir"
| "visa";
export type CreditCardTypeChangeHandler = (this: Cleave, type: CreditCardType) => void;

View File

@@ -1,19 +1,4 @@
// Credit Card Options
export type CreditCardType =
| "amex"
| "dankort"
| "diners"
| "discover"
| "instapayment"
| "jcb"
| "maestro"
| "mastercard"
| "uatp"
| "unknown"
| "unionPay"
| "mir"
| "visa";
export type CreditCardTypeChangeHandler = (owner: HTMLInputElement, type: CreditCardType) => void;
import { CreditCardTypeChangeHandler } from "./creditCard";
export interface CleaveOptions {
creditCard?: boolean;

View File

@@ -21,7 +21,8 @@
"files": [
"cleave.js-tests.tsx",
"index.d.ts",
"options.d.ts",
"options/creditCard.d.ts",
"options/index.d.ts",
"react/index.d.ts"
]
}

View File

@@ -1,5 +1,5 @@
/*!
* Dynamsoft WebTwain PDF Addon
* Based on Dynamsoft WebTwain JavaScript Intellisense
* Product: Dynamsoft Web Twain
* Web Site: http://www.dynamsoft.com
*
@@ -25,7 +25,7 @@ interface PDF {
* The function to call when the download succeeds. Please refer to the function prototype OnSuccess.
* @param {function} optionalAsyncFailureFunc optional.
* The function to call when the download fails. Please refer to the function prototype OnFailure.
* @return {bool}
* @return {boolean}
*/
Download(remoteFile: string,
optionalAsyncSuccessFunc?: () => void,
@@ -35,7 +35,7 @@ interface PDF {
* Input the password to decrypt PDF files using PDF Rasterizer add-on.
* @method Dynamsoft.WebTwain#SetPassword
* @param {string} password Specifies the PDF password.
* @return {bool}
* @return {boolean}
*/
SetPassword(password: string): boolean;
@@ -43,7 +43,7 @@ interface PDF {
* Set the image convert mode for PDF Rasterizer in Dynamic Web TWAIN.
* @method Dynamsoft.WebTwain#SetConvertMode
* @param {EnumDWT_ConverMode} convertMode Specifies the image convert mode.
* @return {bool}
* @return {boolean}
*/
SetConvertMode(convertMode: EnumDWT_ConverMode): boolean;
@@ -51,7 +51,7 @@ interface PDF {
* Set the output resolution for the PDF Rasterizer in Dynamic Web TWAIN.
* @method Dynamsoft.WebTwain#ReadRect
* @param {float} fResolution Specifies the resolution for convert image from PDF file.
* @return {bool}
* @return {boolean}
*/
SetResolution(fResolution: number): boolean;
@@ -59,7 +59,7 @@ interface PDF {
* Judges whether the local PDF is text-based or not.
* @method Dynamsoft.WebTwain#ReadRect
* @param {string} localFile specifies the local path of the target PDF.
* @return {bool}
* @return {boolean}
*/
IsTextBasedPDF(localFile: string): boolean;
}
@@ -69,5 +69,5 @@ interface WebTwainAddon {
}
interface WebTwain {
Addon: WebTwainAddon;
Addon: WebTwainAddon;
}

3678
types/dwt/index.d.ts vendored

File diff suppressed because it is too large Load Diff

View File

@@ -56,6 +56,11 @@ export class GraphQLError extends Error {
* The original error thrown from a field resolver during execution.
*/
originalError?: Error;
/**
* Extension fields to add to the formatted error.
*/
extensions?: { [key: string]: any } | undefined;
constructor(
message: string,
@@ -64,5 +69,6 @@ export class GraphQLError extends Error {
positions?: number[],
path?: Array<string | number>,
originalError?: Error,
extensions?: { [key: string]: any },
);
}

View File

@@ -11,6 +11,7 @@
// Jamie Mason <https://github.com/JamieMason>
// Douglas Duteil <https://github.com/douglasduteil>
// Ahn <https://github.com/AhnpGit>
// Josh Goldberg <https://github.com/joshuakgoldberg>
// Bradley Ayers <https://github.com/bradleyayers>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -202,6 +203,10 @@ declare namespace jest {
type Lifecycle = (fn: ProvidesCallback, timeout?: number) => any;
interface FunctionLike {
readonly name: string;
}
/**
* Creates a test closure
*/
@@ -223,7 +228,8 @@ declare namespace jest {
}
interface Describe {
(name: string, fn: EmptyFunction): void;
// tslint:disable-next-line ban-types
(name: number | string | Function | FunctionLike, fn: EmptyFunction): void;
only: Describe;
skip: Describe;
}

View File

@@ -10,6 +10,10 @@ declare const $: any;
// Tests based on the Jest website
jest.unmock('../sum');
class TestClass { }
describe(TestClass, () => { });
describe('sum', () => {
it('adds 1 + 2 to equal 3', () => {
const sum: (a: number, b: number) => number = require('../sum');

13
types/joi/index.d.ts vendored
View File

@@ -165,6 +165,11 @@ export interface IPOptions {
cidr?: string
}
export interface StringRegexOptions {
name?: string;
invert?: boolean;
}
export interface JoiObject {
isJoi: boolean;
}
@@ -552,9 +557,13 @@ export interface StringSchema extends AnySchema {
/**
* Defines a regular expression rule.
* @param pattern - a regular expression object the string value must match against.
* @param name - optional name for patterns (useful with multiple patterns). Defaults to 'required'.
* @param options - optional, can be:
* Name for patterns (useful with multiple patterns). Defaults to 'required'.
* An optional configuration object with the following supported properties:
* name - optional pattern name.
* invert - optional boolean flag. Defaults to false behavior. If specified as true, the provided pattern will be disallowed instead of required.
*/
regex(pattern: RegExp, name?: string): this;
regex(pattern: RegExp, options?: string | StringRegexOptions): this;
/**
* Replace characters matching the given pattern with the specified replacement string where:

View File

@@ -135,6 +135,13 @@ refOpts = { contextPrefix: str };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
let stringRegexOpts: Joi.StringRegexOptions = null;
stringRegexOpts = { name: str };
stringRegexOpts = { invert: bool };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
let validErr: Joi.ValidationError = null;
let validErrItem: Joi.ValidationErrorItem;
let validErrFunc: Joi.ValidationErrorFunction;
@@ -764,6 +771,7 @@ strSchema = strSchema.length(ref);
strSchema = strSchema.length(ref, str);
strSchema = strSchema.regex(exp);
strSchema = strSchema.regex(exp, str);
strSchema = strSchema.regex(exp, stringRegexOpts);
strSchema = strSchema.replace(exp, str);
strSchema = strSchema.replace(str, str);
strSchema = strSchema.alphanum();

View File

@@ -236,7 +236,7 @@ declare namespace Fancytree {
/** Outer element of single nodes */
span: HTMLElement;
/** Outer element of single nodes for table extension */
tr: HTMLElement;
tr: HTMLTableRowElement;
//#endregion
//#region Methods

View File

@@ -3,6 +3,7 @@
// Definitions by: William Johnston <https://github.com/wjohnsto>
// Kacper Polak <https://github.com/kacepe>
// Krittanan Pingclasai <https://github.com/kpping>
// James Munro <https://github.com/jdmunro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
@@ -240,6 +241,11 @@ export interface QueryOptions {
*/
sql: string;
/**
* Values for template query
*/
values?: any;
/**
* Every operation takes an optional inactivity timeout option. This allows you to specify appropriate timeouts for
* operations. It is important to note that these timeouts are not part of the MySQL protocol, and rather timeout

View File

@@ -423,6 +423,9 @@ connection.query({
}
});
connection.query({sql: '...', values: ['test']}, (err: Error, results: any) => {
});
connection = mysql.createConnection("mysql://localhost/test?flags=-FOUND_ROWS");
connection = mysql.createConnection({debug: true});
connection = mysql.createConnection({debug: ['ComQueryPacket', 'RowDataPacket']});

70
types/node/index.d.ts vendored
View File

@@ -1,4 +1,4 @@
// Type definitions for Node.js 9.4.x
// Type definitions for Node.js 9.6.x
// Project: http://nodejs.org/
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>
// DefinitelyTyped <https://github.com/DefinitelyTyped/DefinitelyTyped>
@@ -19,6 +19,7 @@
// Alberto Schiabel <https://github.com/jkomyno>
// Klaus Meinhardt <https://github.com/ajafff>
// Huw <https://github.com/hoo29>
// Nicolas Even <https://github.com/n-e>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/** inspector module types */
@@ -1768,6 +1769,7 @@ declare module "https" {
export class Agent extends http.Agent {
constructor(options?: AgentOptions);
options: AgentOptions;
}
export class Server extends tls.Server {
@@ -5575,18 +5577,18 @@ declare module "util" {
export function callbackify<T1, T2, T3, T4, T5, T6, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
export function promisify<TResult>(fn: (callback: (err: Error, result: TResult) => void) => void): () => Promise<TResult>;
export function promisify(fn: (callback: (err: Error) => void) => void): () => Promise<void>;
export function promisify<T1, TResult>(fn: (arg1: T1, callback: (err: Error, result: TResult) => void) => void): (arg1: T1) => Promise<TResult>;
export function promisify<T1>(fn: (arg1: T1, callback: (err: Error) => void) => void): (arg1: T1) => Promise<void>;
export function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
export function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
export function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
export function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
export function promisify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
export function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
export function promisify<T1, T2, T3, T4, T5, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
export function promisify<T1, T2, T3, T4, T5>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
export function promisify<TResult>(fn: (callback: (err: Error | null, result: TResult) => void) => void): () => Promise<TResult>;
export function promisify(fn: (callback: (err: Error | null) => void) => void): () => Promise<void>;
export function promisify<T1, TResult>(fn: (arg1: T1, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1) => Promise<TResult>;
export function promisify<T1>(fn: (arg1: T1, callback: (err: Error | null) => void) => void): (arg1: T1) => Promise<void>;
export function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
export function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
export function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
export function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
export function promisify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
export function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
export function promisify<T1, T2, T3, T4, T5, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
export function promisify<T1, T2, T3, T4, T5>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
export function promisify(fn: Function): Function;
export namespace promisify {
const custom: symbol;
@@ -6080,6 +6082,23 @@ declare module "async_hooks" {
*/
export function createHook(options: HookCallbacks): AsyncHook;
export interface AsyncResourceOptions {
/**
* The ID of the execution context that created this async event.
* Default: `executionAsyncId()`
*/
triggerAsyncId?: number;
/**
* Disables automatic `emitDestroy` when the object is garbage collected.
* This usually does not need to be set (even if `emitDestroy` is called
* manually), unless the resource's `asyncId` is retrieved and the
* sensitive API's `emitDestroy` is called with it.
* Default: `false`
*/
requireManualDestroy?: boolean;
}
/**
* The class AsyncResource was designed to be extended by the embedder's async resources.
* Using this users can easily trigger the lifetime events of their own resources.
@@ -6089,21 +6108,38 @@ declare module "async_hooks" {
* AsyncResource() is meant to be extended. Instantiating a
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
* async_hook.executionAsyncId() is used.
* @param type the name of this async resource type
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
* @param type The type of async event.
* @param triggerAsyncId The ID of the execution context that created
* this async event (default: `executionAsyncId()`), or an
* AsyncResourceOptions object (since 9.3)
*/
constructor(type: string, triggerAsyncId?: number)
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
/**
* Call AsyncHooks before callbacks.
* @deprecated since 9.6 - Use asyncResource.runInAsyncScope() instead.
*/
emitBefore(): void;
/**
* Call AsyncHooks after callbacks
* Call AsyncHooks after callbacks.
* @deprecated since 9.6 - Use asyncResource.runInAsyncScope() instead.
*/
emitAfter(): void;
/**
* Call the provided function with the provided arguments in the
* execution context of the async resource. This will establish the
* context, trigger the AsyncHooks before callbacks, call the function,
* trigger the AsyncHooks after callbacks, and then restore the original
* execution context.
* @param fn The function to call in the execution context of this
* async resource.
* @param thisArg The receiver to be used for the function call.
* @param args Optional arguments to pass to the function.
*/
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
/**
* Call AsyncHooks destroy callbacks.
*/

View File

@@ -1497,6 +1497,8 @@ namespace https_tests {
https.request('http://www.example.com/xyz');
https.globalAgent.options.ca = [];
{
const server = new https.Server();
@@ -3333,13 +3335,23 @@ namespace async_hooks_tests {
const tId: number = this.triggerAsyncId();
}
run() {
this.emitBefore();
this.emitAfter();
this.runInAsyncScope(() => {});
this.runInAsyncScope(Array.prototype.find, [], () => true);
}
destroy() {
this.emitDestroy();
}
}
// check AsyncResource constructor options.
new async_hooks.AsyncResource('');
new async_hooks.AsyncResource('', 0);
new async_hooks.AsyncResource('', {});
new async_hooks.AsyncResource('', { triggerAsyncId: 0 });
new async_hooks.AsyncResource('', {
triggerAsyncId: 0,
requireManualDestroy: true
});
}
////////////////////////////////////////////////////

View File

@@ -1081,7 +1081,9 @@ declare module "https" {
secureProtocol?: string;
}
export interface Agent extends http.Agent { }
export interface Agent extends http.Agent {
options?: AgentOptions;
}
export interface AgentOptions extends http.AgentOptions {
pfx?: any;

View File

@@ -561,6 +561,8 @@ namespace https_tests {
});
https.request('http://www.example.com/xyz');
https.globalAgent.options.ca = [];
}
////////////////////////////////////////////////////

View File

@@ -1468,7 +1468,9 @@ declare module "https" {
secureProtocol?: string;
}
export interface Agent extends http.Agent { }
export interface Agent extends http.Agent {
options?: AgentOptions;
}
export interface AgentOptions extends http.AgentOptions {
pfx?: any;

View File

@@ -1015,6 +1015,8 @@ namespace https_tests {
});
https.request('http://www.example.com/xyz');
https.globalAgent.options.ca = [];
}
////////////////////////////////////////////////////

View File

@@ -1528,7 +1528,9 @@ declare module "https" {
secureProtocol?: string;
}
export interface Agent extends http.Agent { }
export interface Agent extends http.Agent {
options?: AgentOptions;
}
export interface AgentOptions extends http.AgentOptions {
pfx?: any;

View File

@@ -1093,6 +1093,8 @@ namespace https_tests {
});
https.request('http://www.example.com/xyz');
https.globalAgent.options.ca = [];
}
////////////////////////////////////////////////////

View File

@@ -1,4 +1,4 @@
// Type definitions for Node.js 8.9.x
// Type definitions for Node.js 8.10.x
// Project: http://nodejs.org/
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>
// DefinitelyTyped <https://github.com/DefinitelyTyped/DefinitelyTyped>
@@ -18,6 +18,7 @@
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
// Alberto Schiabel <https://github.com/jkomyno>
// Huw <https://github.com/hoo29>
// Nicolas Even <https://github.com/n-e>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
@@ -1757,6 +1758,7 @@ declare module "https" {
export class Agent extends http.Agent {
constructor(options?: AgentOptions);
options: AgentOptions;
}
export class Server extends tls.Server {
@@ -5545,18 +5547,18 @@ declare module "util" {
export function callbackify<T1, T2, T3, T4, T5, T6, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
export function promisify<TResult>(fn: (callback: (err: Error, result: TResult) => void) => void): () => Promise<TResult>;
export function promisify(fn: (callback: (err: Error) => void) => void): () => Promise<void>;
export function promisify<T1, TResult>(fn: (arg1: T1, callback: (err: Error, result: TResult) => void) => void): (arg1: T1) => Promise<TResult>;
export function promisify<T1>(fn: (arg1: T1, callback: (err: Error) => void) => void): (arg1: T1) => Promise<void>;
export function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
export function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
export function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
export function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
export function promisify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
export function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
export function promisify<T1, T2, T3, T4, T5, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
export function promisify<T1, T2, T3, T4, T5>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
export function promisify<TResult>(fn: (callback: (err: Error | null, result: TResult) => void) => void): () => Promise<TResult>;
export function promisify(fn: (callback: (err: Error | null) => void) => void): () => Promise<void>;
export function promisify<T1, TResult>(fn: (arg1: T1, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1) => Promise<TResult>;
export function promisify<T1>(fn: (arg1: T1, callback: (err: Error | null) => void) => void): (arg1: T1) => Promise<void>;
export function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
export function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
export function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
export function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
export function promisify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
export function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
export function promisify<T1, T2, T3, T4, T5, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
export function promisify<T1, T2, T3, T4, T5>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
export function promisify(fn: Function): Function;
export namespace promisify {
const custom: symbol;
@@ -6052,6 +6054,23 @@ declare module "async_hooks" {
*/
export function createHook(options: HookCallbacks): AsyncHook;
export interface AsyncResourceOptions {
/**
* The ID of the execution context that created this async event.
* Default: `executionAsyncId()`
*/
triggerAsyncId?: number;
/**
* Disables automatic `emitDestroy` when the object is garbage collected.
* This usually does not need to be set (even if `emitDestroy` is called
* manually), unless the resource's `asyncId` is retrieved and the
* sensitive API's `emitDestroy` is called with it.
* Default: `false`
*/
requireManualDestroy?: boolean;
}
/**
* The class AsyncResource was designed to be extended by the embedder's async resources.
* Using this users can easily trigger the lifetime events of their own resources.
@@ -6061,10 +6080,12 @@ declare module "async_hooks" {
* AsyncResource() is meant to be extended. Instantiating a
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
* async_hook.executionAsyncId() is used.
* @param type the name of this async resource type
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
* @param type The type of async event.
* @param triggerAsyncId The ID of the execution context that created
* this async event (default: `executionAsyncId()`), or an
* AsyncResourceOptions object (since 8.10)
*/
constructor(type: string, triggerAsyncId?: number)
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
/**
* Call AsyncHooks before callbacks.

View File

@@ -1471,6 +1471,8 @@ namespace https_tests {
https.request('http://www.example.com/xyz');
https.globalAgent.options.ca = [];
{
const server = new https.Server();
@@ -3304,6 +3306,16 @@ namespace async_hooks_tests {
this.emitDestroy();
}
}
// check AsyncResource constructor options.
new async_hooks.AsyncResource('');
new async_hooks.AsyncResource('', 0);
new async_hooks.AsyncResource('', {});
new async_hooks.AsyncResource('', { triggerAsyncId: 0 });
new async_hooks.AsyncResource('', {
triggerAsyncId: 0,
requireManualDestroy: true
});
}
////////////////////////////////////////////////////

View File

@@ -5,7 +5,7 @@ export interface AccordionProps {
/**
* An array of sections passed to the render methods
*/
sections: string[];
sections: any[];
/**
* A function that should return a renderable representing the header

View File

@@ -1,6 +1,7 @@
// Type definitions for react-native-collapsible 0.8
// Project: https://github.com/oblador/react-native-collapsible
// Definitions by: Kyle Roach <https://github.com/iRoachie>
// Umidbek Karimov <https://github.com/umidbekkarimov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6

View File

@@ -36,3 +36,27 @@ class AccordianTest extends React.Component<any, any> {
);
}
}
class AccordionComplexTest extends React.Component<any, any> {
_renderHeader() {
return (
<View />
);
}
_renderContent() {
return (
<View />
);
}
render() {
return (
<Accordion
sections={[{icon: 'foo', title: 'Section 1'}, {icon: 'bar', title: 'Section 2'}, {icon: 'baz', title: 'Section 3'}]}
renderHeader={this._renderHeader}
renderContent={this._renderContent}
/>
);
}
}

View File

@@ -2,6 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"dom",
"es6"
],
"noImplicitAny": true,
@@ -22,4 +23,4 @@
"Accordion.d.ts",
"react-native-collapsible-tests.tsx"
]
}
}

View File

@@ -47,7 +47,7 @@ export namespace ReactStripeElements {
className?: string;
elementRef?(): void;
elementRef?(ref: any): void;
onChange?(event: ElementChangeResponse): void;

View File

@@ -129,7 +129,7 @@ export type GridCellRangeProps = {
scrollTop: number,
deferredMeasurementCache: CellMeasurerCache,
horizontalOffsetAdjustment: number,
parent: Grid | List | Table,
parent: typeof Grid | typeof List | typeof Table,
styleCache: Map<React.CSSProperties>,
verticalOffsetAdjustment: number,
visibleColumnIndices: VisibleCellRange,

View File

@@ -114,7 +114,7 @@ export class AutoSizerExample extends PureComponent<any, any> {
}
}
import { } from 'react'
import { CellMeasurer, CellMeasurerCache } from 'react-virtualized'
import { CellMeasurer, CellMeasurerCache, ListRowProps } from 'react-virtualized'
export class DynamicHeightList extends PureComponent<any> {
@@ -148,7 +148,7 @@ export class DynamicHeightList extends PureComponent<any> {
)
}
_rowRenderer({ index, isScrolling, key, parent, style }) {
_rowRenderer({ index, isScrolling, key, parent, style }: ListRowProps) {
const { getClassName, list } = this.props
const datum = list.get(index % list.size)
@@ -1835,3 +1835,114 @@ export class WindowScrollerExample extends PureComponent<{}, any> {
this.context.setScrollingCustomElement(event.target.checked)
}
}
import { GridCellProps, GridCellRangeProps } from 'react-virtualized'
export class GridCellRangeRendererExample extends PureComponent<{}, any> {
constructor(props) {
super(props)
this.state = {
columnWidth: 75,
columnCount: 50,
height: 300,
rowHeight: 40,
rowCount: 100
}
this._cellRangeRenderer = this._cellRangeRenderer.bind(this)
}
render() {
const {
columnCount,
columnWidth,
height,
rowHeight,
rowCount
} = this.state
return (
<Grid
cellRangeRenderer={this._cellRangeRenderer}
cellRenderer={(props: GridCellProps): React.ReactNode => (
<div key={props.key} style={props.style}>
I'm a table cell
</div>
)}
columnCount={columnCount}
columnWidth={columnWidth}
height={height}
rowCount={rowCount}
rowHeight={rowHeight}
width={columnWidth}
/>
)
}
_cellRangeRenderer({
cellCache, // Temporary cell cache used while scrolling
cellRenderer, // Cell renderer prop supplied to Grid
columnSizeAndPositionManager, // @see CellSizeAndPositionManager,
columnStartIndex, // Index of first column (inclusive) to render
columnStopIndex, // Index of last column (inclusive) to render
horizontalOffsetAdjustment, // Horizontal pixel offset (required for scaling)
isScrolling, // The Grid is currently being scrolled
rowSizeAndPositionManager, // @see CellSizeAndPositionManager,
rowStartIndex, // Index of first column (inclusive) to render
rowStopIndex, // Index of last column (inclusive) to render
scrollLeft, // Current horizontal scroll offset of Grid
scrollTop, // Current vertical scroll offset of Grid
styleCache, // Temporary style (size & position) cache used while scrolling
verticalOffsetAdjustment, // Vertical pixel offset (required for scaling)
parent,
visibleColumnIndices,
visibleRowIndices,
}: GridCellRangeProps): React.ReactNode[] {
const renderedCells: React.ReactNode[] = []
const style: React.CSSProperties = {}
for (let rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
// This contains :offset (top) and :size (height) information for the cell
const rowDatum = rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex)
for (let columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) {
// This contains :offset (left) and :size (width) information for the cell
const columnDatum = columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex)
// Be sure to adjust cell position in case the total set of cells is too large to be supported by the browser natively.
// In this case, Grid will shift cells as a user scrolls to increase cell density.
const left = columnDatum.offset + horizontalOffsetAdjustment
const top = rowDatum.offset + verticalOffsetAdjustment
// The rest of the information you need to render the cell are contained in the data.
// Be sure to provide unique :key attributes.
const key = `${rowIndex}-${columnIndex}`
const height = rowDatum.size
const width = columnDatum.size
const isVisible =
columnIndex >= visibleColumnIndices.start &&
columnIndex <= visibleColumnIndices.stop &&
rowIndex >= visibleRowIndices.start &&
rowIndex <= visibleRowIndices.stop
// Now render your cell and additional UI as you see fit.
// Add all rendered children to the :renderedCells Array.
const gridCellProps: GridCellProps = {
columnIndex,
isScrolling,
isVisible,
key,
parent,
rowIndex,
style,
}
renderedCells.push(cellRenderer(gridCellProps))
}
}
return renderedCells
}
}

View File

@@ -53,6 +53,7 @@ declare const FIND_MY_CONSTRUCTION_SITES: 114;
declare const FIND_HOSTILE_CONSTRUCTION_SITES: 115;
declare const FIND_MINERALS: 116;
declare const FIND_NUKES: 117;
declare const FIND_TOMBSTONES: 118;
declare const TOP: 1;
declare const TOP_RIGHT: 2;
@@ -246,7 +247,7 @@ declare const RESOURCE_CATALYZED_KEANIUM_ALKALIDE: "XKHO2";
declare const RESOURCE_CATALYZED_LEMERGIUM_ACID: "XLH2O";
declare const RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE: "XLHO2";
declare const RESOURCE_CATALYZED_ZYNTHIUM_ACID: "XZH2O";
declare const RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE: "ZXHO2";
declare const RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE: "XZHO2";
declare const RESOURCE_CATALYZED_GHODIUM_ACID: "XGH2O";
declare const RESOURCE_CATALYZED_GHODIUM_ALKALIDE: "XGHO2";
declare const RESOURCES_ALL: ResourceConstant[];
@@ -627,11 +628,14 @@ declare const LOOK_FLAGS: "flag";
declare const LOOK_CONSTRUCTION_SITES: "constructionSite";
declare const LOOK_NUKES: "nuke";
declare const LOOK_TERRAIN: "terrain";
declare const LOOK_TOMBSTONES: 'tombstone';
declare const ORDER_SELL: "sell";
declare const ORDER_BUY: "buy";
declare const SYSTEM_USERNAME: string;
declare const TOMBSTONE_DECAY_PER_PART: 5;
/**
* A site of a structure which is currently under construction.
*/
@@ -1190,6 +1194,31 @@ interface CPU {
* @memberof CPU
*/
setShardLimits(limits: CPUShardLimits): OK | ERR_BUSY | ERR_INVALID_ARGS;
/**
* Use this method to get heap statistics for your virtual machine.
*
* This method will be undefined if you are not using IVM.
*
* The return value is almost identical to the Node.js function v8.getHeapStatistics().
* This function returns one additional property: externally_allocated_size which is the total amount of currently
* allocated memory which is not included in the v8 heap but counts against this isolate's memory limit.
* ArrayBuffer instances over a certain size are externally allocated and will be counted here.
*/
getHeapStatistics?(): HeapStatistics;
}
interface HeapStatistics {
total_heap_size: number;
total_heap_size_executable: number;
total_physical_size: number;
total_available_size: number;
used_heap_size: number;
heap_size_limit: number;
malloced_memory: number;
peak_malloced_memory: number;
does_zap_garbage: 0 | 1;
externally_allocated_size: number;
}
/**
@@ -1250,6 +1279,7 @@ interface AllLookAtTypes {
source: Source;
structure: Structure;
terrain: Terrain;
tombstone: Tombstone;
}
type LookAtTypes = Partial<AllLookAtTypes>;
@@ -1280,7 +1310,7 @@ type LookForAtAreaResultWithPos<T, K extends keyof LookAtTypes = keyof LookAtTyp
type LookForAtAreaResultArray<T, K extends keyof LookAtTypes = keyof LookAtTypes> = Array<LookForAtAreaResultWithPos<T, K>>;
interface FindTypes {
[key: number]: RoomPosition | Creep | Source | Resource | Structure | Flag | ConstructionSite | Mineral | Nuke;
[key: number]: RoomPosition | Creep | Source | Resource | Structure | Flag | ConstructionSite | Mineral | Nuke | Tombstone;
1: RoomPosition; // FIND_EXIT_TOP
3: RoomPosition; // FIND_EXIT_RIGHT
5: RoomPosition; // FIND_EXIT_BOTTOM
@@ -1303,6 +1333,7 @@ interface FindTypes {
115: ConstructionSite; // FIND_HOSTILE_CONSTRUCTION_SITES
116: Mineral; // FIND_MINERALS
117: Nuke; // FIND_NUKES
118: Tombstone; // FIND_TOMBSTONES
}
interface FindPathOpts {
@@ -1531,7 +1562,8 @@ type FindConstant =
FIND_MY_CONSTRUCTION_SITES |
FIND_HOSTILE_CONSTRUCTION_SITES |
FIND_MINERALS |
FIND_NUKES;
FIND_NUKES |
FIND_TOMBSTONES;
type FIND_EXIT_TOP = 1;
type FIND_EXIT_RIGHT = 3;
@@ -1556,6 +1588,7 @@ type FIND_MY_CONSTRUCTION_SITES = 114;
type FIND_HOSTILE_CONSTRUCTION_SITES = 115;
type FIND_MINERALS = 116;
type FIND_NUKES = 117;
type FIND_TOMBSTONES = 118;
type FilterOptions<T extends FindConstant> = string | FilterFunction<T> | { filter: FilterFunction<T> };
@@ -1594,7 +1627,8 @@ type LookConstant =
LOOK_FLAGS |
LOOK_CONSTRUCTION_SITES |
LOOK_NUKES |
LOOK_TERRAIN;
LOOK_TERRAIN |
LOOK_TOMBSTONES;
type LOOK_CONSTRUCTION_SITES = "constructionSite";
type LOOK_CREEPS = "creep";
@@ -1606,6 +1640,7 @@ type LOOK_RESOURCES = "resource";
type LOOK_SOURCES = "source";
type LOOK_STRUCTURES = "structure";
type LOOK_TERRAIN = "terrain";
type LOOK_TOMBSTONES = "tombstone";
// Direction Constants
@@ -1844,9 +1879,11 @@ type RESOURCE_CATALYZED_KEANIUM_ALKALIDE = "XKHO2";
type RESOURCE_CATALYZED_LEMERGIUM_ACID = "XLH2O";
type RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE = "XLHO2";
type RESOURCE_CATALYZED_ZYNTHIUM_ACID = "XZH2O";
type RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE = "ZXHO2";
type RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE = "XZHO2";
type RESOURCE_CATALYZED_GHODIUM_ACID = "XGH2O";
type RESOURCE_CATALYZED_GHODIUM_ALKALIDE = "XGHO2";
type TOMBSTONE_DECAY_PER_PART = 5;
/**
* The options that can be accepted by `findRoute()` and friends.
*/
@@ -3078,11 +3115,8 @@ interface StructureSpawn extends OwnedStructure<STRUCTURE_SPAWN> {
name: string;
/**
* If the spawn is in process of spawning a new creep, this object will contain the new creeps information, or null otherwise.
* @param name The name of a new creep.
* @param needTime Time needed in total to complete the spawning.
* @param remainingTime Remaining time to go.
*/
spawning: { name: string, needTime: number, remainingTime: number };
spawning: Spawning | null;
/**
* Check if a creep can be created.
@@ -3180,11 +3214,56 @@ interface StructureSpawn extends OwnedStructure<STRUCTURE_SPAWN> {
}
interface StructureSpawnConstructor extends _Constructor<StructureSpawn>, _ConstructorById<StructureSpawn> {
Spawning: SpawningConstructor;
}
declare const StructureSpawn: StructureSpawnConstructor;
declare const Spawn: StructureSpawnConstructor; // legacy alias
// declare type Spawn = StructureSpawn;
interface Spawning {
readonly prototype: Spawning;
/**
* An array with the spawn directions
* @see http://docs.screeps.com/api/#StructureSpawn.Spawning.setDirections
*/
directions: DirectionConstant[];
/**
* The name of the creep
*/
name: string;
/**
* Time needed in total to complete the spawning.
*/
needTime: number;
/**
* Remaining time to go.
*/
remainingTime: number;
/**
* A link to the spawn
*/
spawn: StructureSpawn;
/**
* Cancel spawning immediately. Energy spent on spawning is not returned.
*/
cancel(): ScreepsReturnCode & (OK | ERR_NOT_OWNER);
/**
* Set desired directions where the creep should move when spawned.
* @param directions An array with the spawn directions
*/
setDirections(directions: DirectionConstant[]): ScreepsReturnCode & (OK | ERR_NOT_OWNER | ERR_INVALID_ARGS);
}
interface SpawningConstructor extends _Constructor<Spawning>, _ConstructorById<Spawning> {
}
/**
* Parent object for structure classes
*/
@@ -3642,7 +3721,7 @@ interface StructureLab extends OwnedStructure<STRUCTURE_LAB> {
/**
* The type of minerals containing in the lab. Labs can contain only one mineral type at the same time.
*/
mineralType: MineralConstant;
mineralType: _ResourceConstantSansEnergy | undefined;
/**
* The total amount of minerals the lab can contain.
*/
@@ -3819,3 +3898,17 @@ type AnyStructure =
StructurePortal |
StructureRoad |
StructureWall;
interface Tombstone extends RoomObject {
/** The tick that the creep died. */
deathTime: number;
store: StoreDefinition;
/** How many ticks until this tombstone decays */
ticksToDecay: number;
/** The creep that died to create this tombstone */
creep: Creep;
}
interface TombstoneConstructor extends _Constructor<Tombstone>, _ConstructorById<Tombstone> {
}
declare const Tombstone: TombstoneConstructor;

View File

@@ -43,6 +43,21 @@ interface CreepMemory {
{
for (const i in Game.spawns) {
Game.spawns[i].createCreep(body);
// Test StructureSpawn.Spawning
let creep: Spawning | null = Game.spawns[i].spawning;
if (creep) {
const name: string = creep.name;
const needTime: number = creep.needTime;
const remainingTime: number = creep.remainingTime;
const creepSpawn: StructureSpawn = creep.spawn;
const cancelStatus: OK | ERR_NOT_OWNER = creep.cancel();
const setDirectionStatus: OK | ERR_NOT_OWNER | ERR_INVALID_ARGS = creep.setDirections([TOP, BOTTOM, LEFT, RIGHT]);
}
creep = new StructureSpawn.Spawning("");
creep = StructureSpawn.Spawning("");
}
}
@@ -275,11 +290,12 @@ interface CreepMemory {
{
const pfCreep = Game.creeps.John;
const goals = pfCreep.room.find(FIND_SOURCES).map((source) => {
// We can't actually walk on sources-- set `range` to 1
// so we path next to it.
return { pos: source.pos, range: 1 };
});
const goals = pfCreep.room.find(FIND_SOURCES)
.map((source) => {
// We can't actually walk on sources-- set `range` to 1
// so we path next to it.
return { pos: source.pos, range: 1 };
});
const ret = PathFinder.search(
pfCreep.pos, goals,
@@ -299,22 +315,24 @@ interface CreepMemory {
}
const costs = new PathFinder.CostMatrix();
curRoom.find(FIND_STRUCTURES).forEach((struct) => {
if (struct.structureType === STRUCTURE_ROAD) {
// Favor roads over plain tiles
costs.set(struct.pos.x, struct.pos.y, 1);
} else if (struct.structureType !== STRUCTURE_CONTAINER &&
(struct.structureType !== STRUCTURE_RAMPART ||
!(struct as OwnedStructure).my)) {
// Can't walk through non-walkable buildings
costs.set(struct.pos.x, struct.pos.y, 0xff);
}
});
curRoom.find(FIND_STRUCTURES)
.forEach((struct) => {
if (struct.structureType === STRUCTURE_ROAD) {
// Favor roads over plain tiles
costs.set(struct.pos.x, struct.pos.y, 1);
} else if (struct.structureType !== STRUCTURE_CONTAINER &&
(struct.structureType !== STRUCTURE_RAMPART ||
!(struct as OwnedStructure).my)) {
// Can't walk through non-walkable buildings
costs.set(struct.pos.x, struct.pos.y, 0xff);
}
});
// Avoid creeps in the room
curRoom.find(FIND_CREEPS).forEach((thisCreep) => {
costs.set(thisCreep.pos.x, thisCreep.pos.y, 0xff);
});
curRoom.find(FIND_CREEPS)
.forEach((thisCreep) => {
costs.set(thisCreep.pos.x, thisCreep.pos.y, 0xff);
});
return costs;
},
@@ -504,7 +522,8 @@ interface CreepMemory {
const from = Game.rooms.myRoom.find(FIND_STRUCTURES, (s) => (s.structureType === STRUCTURE_CONTAINER || s.structureType === STRUCTURE_STORAGE) && s.store.energy > 0)[0];
const to = from.pos.findClosestByPath(FIND_MY_STRUCTURES, {filter: (s) => (s.structureType === STRUCTURE_SPAWN || s.structureType === STRUCTURE_EXTENSION) && s.energy < s.energyCapacity});
Game.rooms.myRoom.find(FIND_MY_STRUCTURES, (s) => s.structureType === STRUCTURE_RAMPART).forEach((r) => r.notifyWhenAttacked(false));
Game.rooms.myRoom.find(FIND_MY_STRUCTURES, (s) => s.structureType === STRUCTURE_RAMPART)
.forEach((r) => r.notifyWhenAttacked(false));
}
{
@@ -515,3 +534,18 @@ interface CreepMemory {
BOOSTS[creep.body[0].type];
}
{
const tombstone = room.find(FIND_TOMBSTONES)[0];
tombstone.creep.my;
tombstone.store.energy;
}
{
if (Game.cpu.hasOwnProperty('getHeapStatistics')) {
const heap = Game.cpu.getHeapStatistics!();
heap.total_heap_size;
}
}

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/vitalets/sinon-chrome
// Definitions by: Tim Perry <https://github.com/pimterry>
// CRIMX <https://github.com/crimx>
// kobanyan <https://github.com/kobanyan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
@@ -37,6 +38,8 @@ declare namespace SinonChrome {
*/
export function reset(): void;
export function registerPlugin(plugin: {}): void;
export var csi: Sinon.SinonSpy;
export var loadTimes: Sinon.SinonSpy;
}
@@ -353,6 +356,27 @@ declare namespace SinonChrome.permissions {
export var request: SinonChromeStub;
}
declare namespace SinonChrome.plugins {
export interface Translations {
[key: string]: {
message: string;
description?: string;
placeholders?: {
[key: string]: {
content: string;
example?: string;
};
};
};
}
export class I18nPlugin {
constructor(translations?: Translations);
}
export class CookiePlugin {
constructor(state?: Array<chrome.cookies.Cookie>);
}
}
declare namespace SinonChrome.power {
export var releaseKeepAwake: SinonChromeStub;
export var requestKeepAwake: SinonChromeStub;

View File

@@ -32,3 +32,50 @@ var id: string = chromeStub.runtime.id;
chromeStub.proxy.settings.set({value: { }, scope: 'regular'});
chromeStub.proxy.settings.onChange.trigger();
chromeStub.registerPlugin(new chromeStub.plugins.I18nPlugin({
one: {
message: 'Hi!'
},
two: {
message: 'Hi $first_name$ $last_name$!',
placeholders: {
first_name: {
content: '$1'
},
last_name: {
content: '$2'
}
}
}
}));
chromeStub.registerPlugin(new chromeStub.plugins.CookiePlugin());
chromeStub.registerPlugin(new chromeStub.plugins.CookiePlugin(
[
{
domain: '.domain.com',
expirationDate: 1511612273,
hostOnly: false,
httpOnly: false,
name: 'COOKIE_NAME',
path: '/data',
secure: false,
session: false,
storeId: '0',
value: 'COOKIE_VALUE'
},
{
domain: 'other-domain.com',
hostOnly: false,
httpOnly: false,
name: 'other-cookie',
path: '/',
secure: false,
session: true,
storeId: '0',
value: '123'
}
]
));

View File

@@ -136,16 +136,19 @@ declare namespace Snap {
export interface Element {
add(el:Snap.Element):Snap.Element;
add(el:Snap.Set):Snap.Element;
addClass(value:string):Snap.Element;
after(el:Snap.Element):Snap.Element;
align(el: Snap.Element, way: string):Snap.Element;
animate(animation:any):Snap.Element;
animate(attrs:{[attr:string]:string|number|boolean|any},duration:number,easing?:(num: number)=> number,callback?:()=>void):Snap.Element;
append(el:Snap.Element):Snap.Element;
append(el:Snap.Set):Snap.Element;
appendTo(el:Snap.Element):Snap.Element;
asPX(attr:string,value?:string):number; //TODO: check what is really returned
attr(param:string):string;
attr(params:{[attr:string]:string|number|boolean|any}):Snap.Element;
attr(param: "viewBox"): BBox;
attr(param: string): string;
attr(params:{[attr:string]:string|number|boolean|BBox|any}):Snap.Element;
before(el:Snap.Element):Snap.Element;
children(): Snap.Element[];
clone():Snap.Element;
@@ -284,12 +287,14 @@ declare namespace Snap {
rect(x:number,y:number,width:number,height:number,rx?:number,ry?:number):Snap.Element;
text(x:number,y:number,text:string|number):Snap.Element;
text(x:number,y:number,text:Array<string|number>):Snap.Element;
symbol(vbx:number,vby:number,vbw:number,vbh:number):Snap.Element;
}
export interface Set {
animate(attrs:{[attr:string]:string|number|boolean|any},duration:number,easing?:(num:number)=>number,callback?:()=>void):Snap.Element;
animate(...params:Array<{attrs:any,duration:number,easing:(num:number)=>number,callback?:()=>void}>):Snap.Element;
attr(params: {[attr:string]:string|number|boolean|any}): Snap.Element;
attr(params: {[attr:string]:string|number|boolean|BBox|any}): Snap.Element;
attr(param: "viewBox"): BBox;
attr(param: string): string;
bind(attr: string, callback: Function): Snap.Set;
bind(attr:string,element:Snap.Element):Snap.Set;

View File

@@ -125,6 +125,19 @@ function tester6() {
console.log(!path.isPointInsideBBox(b3, 50, 50));
}
function tester7() {
var paper = Snap(600, 800);
Snap.load("http://snapsvg.io/assets/images/logo.svg", (fragment: Snap.Fragment) => {
// viewBox retrieveal
let fragmentViewBox = fragment.select("svg").attr("viewBox");
let symbol = paper.symbol(fragmentViewBox.x, fragmentViewBox.y, fragmentViewBox.width, fragmentViewBox.height);
symbol.add(fragment.selectAll("svg *"));
symbol.toDefs();
});
}
//$(function () {
// tester1();
//});
@@ -134,3 +147,4 @@ function tester6() {
//tester4();
//tester5();
//tester6();
//tester7();

View File

@@ -1,4 +1,4 @@
// Type definitions for three.js 0.89
// Type definitions for three.js 0.91
// Project: https://threejs.org
// Definitions by: Kon <http://phyzkit.net/>, Satoru Kimura <https://github.com/gyohk>, Florent Poujol <https://github.com/florentpoujol>, SereznoKot <https://github.com/SereznoKot>, HouChunlei <https://github.com/omni360>, Ivo <https://github.com/ivoisbelongtous>, David Asmuth <https://github.com/piranha771>, Brandon Roberge, Qinsi ZHU <https://github.com/qszhusightp>, Toshiya Nakakura <https://github.com/nakakura>, Poul Kjeldager Sørensen <https://github.com/s093294>, Stefan Profanter <https://github.com/Pro>, Edmund Fokschaner <https://github.com/efokschaner>, Roelof Jooste <https://github.com/PsychoSTS>, Daniel Hritzkiv <https://github.com/dhritzkiv>, Apurva Ojas <https://github.com/apurvaojas>
// Definitions: https://github.com//DefinitelyTyped

View File

@@ -91,57 +91,62 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
test( "center", function() {
var a = new THREE.Box2( zero2.clone(), zero2.clone() );
var center = new THREE.Vector2();
ok( a.getCenter().equals( zero2 ), "Passed!" );
ok( a.getCenter(center).equals( zero2 ), "Passed!" );
a = new THREE.Box2( zero2, one2 );
var midpoint = one2.clone().multiplyScalar( 0.5 );
ok( a.getCenter().equals( midpoint ), "Passed!" );
ok( a.getCenter(center).equals( midpoint ), "Passed!" );
});
test( "size", function() {
var a = new THREE.Box2( zero2.clone(), zero2.clone() );
var size = new THREE.Vector2();
ok( a.getSize().equals( zero2 ), "Passed!" );
ok( a.getSize(size).equals( zero2 ), "Passed!" );
a = new THREE.Box2( zero2.clone(), one2.clone() );
ok( a.getSize().equals( one2 ), "Passed!" );
ok( a.getSize(size).equals( one2 ), "Passed!" );
});
test( "expandByPoint", function() {
var a = new THREE.Box2( zero2.clone(), zero2.clone() );
var size = new THREE.Vector2();
a.expandByPoint( zero2 );
ok( a.getSize().equals( zero2 ), "Passed!" );
ok( a.getSize(size).equals( zero2 ), "Passed!" );
a.expandByPoint( one2 );
ok( a.getSize().equals( one2 ), "Passed!" );
ok( a.getSize(size).equals( one2 ), "Passed!" );
a.expandByPoint( one2.clone().negate() );
ok( a.getSize().equals( one2.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter().equals( zero2 ), "Passed!" );
ok( a.getSize(size).equals( one2.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter(new THREE.Vector2()).equals( zero2 ), "Passed!" );
});
test( "expandByVector", function() {
var a = new THREE.Box2( zero2.clone(), zero2.clone() );
var size = new THREE.Vector2();
a.expandByVector( zero2 );
ok( a.getSize().equals( zero2 ), "Passed!" );
ok( a.getSize(size).equals( zero2 ), "Passed!" );
a.expandByVector( one2 );
ok( a.getSize().equals( one2.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter().equals( zero2 ), "Passed!" );
ok( a.getSize(size).equals( one2.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter(new THREE.Vector2()).equals( zero2 ), "Passed!" );
});
test( "expandByScalar", function() {
var a = new THREE.Box2( zero2.clone(), zero2.clone() );
var size = new THREE.Vector2();
a.expandByScalar( 0 );
ok( a.getSize().equals( zero2 ), "Passed!" );
ok( a.getSize(size).equals( zero2 ), "Passed!" );
a.expandByScalar( 1 );
ok( a.getSize().equals( one2.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter().equals( zero2 ), "Passed!" );
ok( a.getSize(size).equals( one2.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter(new THREE.Vector2()).equals( zero2 ), "Passed!" );
});
test( "containsPoint", function() {
@@ -185,16 +190,17 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
test( "clampPoint", function() {
var a = new THREE.Box2( zero2.clone(), zero2.clone() );
var b = new THREE.Box2( one2.clone().negate(), one2.clone() );
var target = new THREE.Vector2();
ok( a.clampPoint( new THREE.Vector2( 0, 0 ) ).equals( new THREE.Vector2( 0, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector2( 1, 1 ) ).equals( new THREE.Vector2( 0, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector2( -1, -1 ) ).equals( new THREE.Vector2( 0, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector2( 0, 0 ), target ).equals( new THREE.Vector2( 0, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector2( 1, 1 ), target ).equals( new THREE.Vector2( 0, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector2( -1, -1 ), target ).equals( new THREE.Vector2( 0, 0 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector2( 2, 2 ) ).equals( new THREE.Vector2( 1, 1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector2( 1, 1 ) ).equals( new THREE.Vector2( 1, 1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector2( 0, 0 ) ).equals( new THREE.Vector2( 0, 0 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector2( -1, -1 ) ).equals( new THREE.Vector2( -1, -1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector2( -2, -2 ) ).equals( new THREE.Vector2( -1, -1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector2( 2, 2 ), target ).equals( new THREE.Vector2( 1, 1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector2( 1, 1 ), target ).equals( new THREE.Vector2( 1, 1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector2( 0, 0 ), target ).equals( new THREE.Vector2( 0, 0 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector2( -1, -1 ), target ).equals( new THREE.Vector2( -1, -1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector2( -2, -2 ), target ).equals( new THREE.Vector2( -1, -1 ) ), "Passed!" );
});
test( "distanceToPoint", function() {
@@ -332,57 +338,62 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
test( "center", function() {
var a = new THREE.Box3( zero3.clone(), zero3.clone() );
var center = new THREE.Vector3();
ok( a.getCenter().equals( zero3 ), "Passed!" );
ok( a.getCenter(center).equals( zero3 ), "Passed!" );
a = new THREE.Box3( zero3.clone(), one3.clone() );
var midpoint = one3.clone().multiplyScalar( 0.5 );
ok( a.getCenter().equals( midpoint ), "Passed!" );
ok( a.getCenter(center).equals( midpoint ), "Passed!" );
});
test( "size", function() {
var a = new THREE.Box3( zero3.clone(), zero3.clone() );
var size = new THREE.Vector3();
ok( a.getSize().equals( zero3 ), "Passed!" );
ok( a.getSize(size).equals( zero3 ), "Passed!" );
a = new THREE.Box3( zero3.clone(), one3.clone() );
ok( a.getSize().equals( one3 ), "Passed!" );
ok( a.getSize(size).equals( one3 ), "Passed!" );
});
test( "expandByPoint", function() {
var a = new THREE.Box3( zero3.clone(), zero3.clone() );
var size = new THREE.Vector3();
a.expandByPoint( zero3 );
ok( a.getSize().equals( zero3 ), "Passed!" );
ok( a.getSize(size).equals( zero3 ), "Passed!" );
a.expandByPoint( one3 );
ok( a.getSize().equals( one3 ), "Passed!" );
ok( a.getSize(size).equals( one3 ), "Passed!" );
a.expandByPoint( one3.clone().negate() );
ok( a.getSize().equals( one3.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter().equals( zero3 ), "Passed!" );
ok( a.getSize(size).equals( one3.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter(new THREE.Vector3()).equals( zero3 ), "Passed!" );
});
test( "expandByVector", function() {
var a = new THREE.Box3( zero3.clone(), zero3.clone() );
var size = new THREE.Vector3();
a.expandByVector( zero3 );
ok( a.getSize().equals( zero3 ), "Passed!" );
ok( a.getSize(size).equals( zero3 ), "Passed!" );
a.expandByVector( one3 );
ok( a.getSize().equals( one3.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter().equals( zero3 ), "Passed!" );
ok( a.getSize(size).equals( one3.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter(new THREE.Vector3()).equals( zero3 ), "Passed!" );
});
test( "expandByScalar", function() {
var a = new THREE.Box3( zero3.clone(), zero3.clone() );
var size = new THREE.Vector3();
a.expandByScalar( 0 );
ok( a.getSize().equals( zero3 ), "Passed!" );
ok( a.getSize(size).equals( zero3 ), "Passed!" );
a.expandByScalar( 1 );
ok( a.getSize().equals( one3.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter().equals( zero3 ), "Passed!" );
ok( a.getSize(size).equals( one3.clone().multiplyScalar( 2 ) ), "Passed!" );
ok( a.getCenter(new THREE.Vector3()).equals( zero3 ), "Passed!" );
});
test( "containsPoint", function() {
@@ -426,16 +437,17 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
test( "clampPoint", function() {
var a = new THREE.Box3( zero3.clone(), zero3.clone() );
var b = new THREE.Box3( one3.clone().negate(), one3.clone() );
var target = new THREE.Vector3();
ok( a.clampPoint( new THREE.Vector3( 0, 0, 0 ) ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector3( 1, 1, 1 ) ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector3( -1, -1, -1 ) ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector3( 0, 0, 0 ), target ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector3( 1, 1, 1 ), target ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector3( -1, -1, -1 ), target ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector3( 2, 2, 2 ) ).equals( new THREE.Vector3( 1, 1, 1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector3( 1, 1, 1 ) ).equals( new THREE.Vector3( 1, 1, 1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector3( 0, 0, 0 ) ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector3( -1, -1, -1 ) ).equals( new THREE.Vector3( -1, -1, -1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector3( -2, -2, -2 ) ).equals( new THREE.Vector3( -1, -1, -1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector3( 2, 2, 2 ), target ).equals( new THREE.Vector3( 1, 1, 1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector3( 1, 1, 1 ), target ).equals( new THREE.Vector3( 1, 1, 1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector3( 0, 0, 0 ), target ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector3( -1, -1, -1 ), target ).equals( new THREE.Vector3( -1, -1, -1 ) ), "Passed!" );
ok( b.clampPoint( new THREE.Vector3( -2, -2, -2 ), target ).equals( new THREE.Vector3( -1, -1, -1 ) ), "Passed!" );
});
test( "distanceToPoint", function() {
@@ -491,10 +503,11 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
var a = new THREE.Box3( zero3.clone(), zero3.clone() );
var b = new THREE.Box3( zero3.clone(), one3.clone() );
var c = new THREE.Box3( one3.clone().negate(), one3.clone() );
var target = new THREE.Sphere();
ok( a.getBoundingSphere().equals( new THREE.Sphere( zero3, 0 ) ), "Passed!" );
ok( b.getBoundingSphere().equals( new THREE.Sphere( one3.clone().multiplyScalar( 0.5 ), Math.sqrt( 3 ) * 0.5 ) ), "Passed!" );
ok( c.getBoundingSphere().equals( new THREE.Sphere( zero3, Math.sqrt( 12 ) * 0.5 ) ), "Passed!" );
ok( a.getBoundingSphere( target ).equals( new THREE.Sphere( zero3, 0 ) ), "Passed!" );
ok( b.getBoundingSphere( target ).equals( new THREE.Sphere( one3.clone().multiplyScalar( 0.5 ), Math.sqrt( 3 ) * 0.5 ) ), "Passed!" );
ok( c.getBoundingSphere( target ).equals( new THREE.Sphere( zero3, Math.sqrt( 12 ) * 0.5 ) ), "Passed!" );
});
test( "intersect", function() {
@@ -1080,34 +1093,36 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
test( "at", function() {
var a = new THREE.Line3( one3.clone(), new THREE.Vector3( 1, 1, 2 ) );
var target = new THREE.Vector3();
ok( a.at( -1 ).distanceTo( new THREE.Vector3( 1, 1, 0 ) ) < 0.0001, "Passed!" );
ok( a.at( 0 ).distanceTo( one3.clone() ) < 0.0001, "Passed!" );
ok( a.at( 1 ).distanceTo( new THREE.Vector3( 1, 1, 2 ) ) < 0.0001, "Passed!" );
ok( a.at( 2 ).distanceTo( new THREE.Vector3( 1, 1, 3 ) ) < 0.0001, "Passed!" );
ok( a.at( -1, target ).distanceTo( new THREE.Vector3( 1, 1, 0 ) ) < 0.0001, "Passed!" );
ok( a.at( 0, target ).distanceTo( one3.clone() ) < 0.0001, "Passed!" );
ok( a.at( 1, target ).distanceTo( new THREE.Vector3( 1, 1, 2 ) ) < 0.0001, "Passed!" );
ok( a.at( 2, target ).distanceTo( new THREE.Vector3( 1, 1, 3 ) ) < 0.0001, "Passed!" );
});
test( "closestPointToPoint/closestPointToPointParameter", function() {
var a = new THREE.Line3( one3.clone(), new THREE.Vector3( 1, 1, 2 ) );
var target = new THREE.Vector3();
// nearby the ray
ok( a.closestPointToPointParameter( zero3.clone(), true ) == 0, "Passed!" );
var b1 = a.closestPointToPoint( zero3.clone(), true );
var b1 = a.closestPointToPoint( zero3.clone(), true, target );
ok( b1.distanceTo( new THREE.Vector3( 1, 1, 1 ) ) < 0.0001, "Passed!" );
// nearby the ray
ok( a.closestPointToPointParameter( zero3.clone(), false ) == -1, "Passed!" );
var b2 = a.closestPointToPoint( zero3.clone(), false );
var b2 = a.closestPointToPoint( zero3.clone(), false, target );
ok( b2.distanceTo( new THREE.Vector3( 1, 1, 0 ) ) < 0.0001, "Passed!" );
// nearby the ray
ok( a.closestPointToPointParameter( new THREE.Vector3( 1, 1, 5 ), true ) == 1, "Passed!" );
var b = a.closestPointToPoint( new THREE.Vector3( 1, 1, 5 ), true );
var b = a.closestPointToPoint( new THREE.Vector3( 1, 1, 5 ), true, target );
ok( b.distanceTo( new THREE.Vector3( 1, 1, 2 ) ) < 0.0001, "Passed!" );
// exactly on the ray
ok( a.closestPointToPointParameter( one3.clone(), true ) == 0, "Passed!" );
var c = a.closestPointToPoint( one3.clone(), true );
var c = a.closestPointToPoint( one3.clone(), true, target );
ok( c.distanceTo( one3.clone() ) < 0.0001, "Passed!" );
});
@@ -1752,7 +1767,7 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
var a = new THREE.Plane( new THREE.Vector3( 2, 0, 0 ), -2 );
a.normalize();
ok( a.distanceToPoint( a.projectPoint( zero3.clone() ) ) === 0, "Passed!" );
ok( a.distanceToPoint( a.projectPoint( zero3.clone(), new THREE.Vector3() ) ) === 0, "Passed!" );
ok( a.distanceToPoint( new THREE.Vector3( 4, 0, 0 ) ) === 3, "Passed!" );
});
@@ -1771,54 +1786,57 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
test( "isInterestionLine/intersectLine", function() {
var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
var target = new THREE.Vector3();
var l1 = new THREE.Line3( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) );
ok( a.intersectsLine( l1 ), "Passed!" );
ok( a.intersectLine( l1 ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( a.intersectLine( l1, target ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), -3 );
ok( a.intersectsLine( l1 ), "Passed!" );
ok( a.intersectLine( l1 ).equals( new THREE.Vector3( 3, 0, 0 ) ), "Passed!" );
ok( a.intersectLine( l1, target ).equals( new THREE.Vector3( 3, 0, 0 ) ), "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), -11 );
ok( ! a.intersectsLine( l1 ), "Passed!" );
ok( a.intersectLine( l1 ) === undefined, "Passed!" );
ok( a.intersectLine( l1, target ) === undefined, "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 11 );
ok( ! a.intersectsLine( l1 ), "Passed!" );
ok( a.intersectLine( l1 ) === undefined, "Passed!" );
ok( a.intersectLine( l1, target ) === undefined, "Passed!" );
});
test( "projectPoint", function() {
var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
var target = new THREE.Vector3();
ok( a.projectPoint( new THREE.Vector3( 10, 0, 0 ) ).equals( zero3 ), "Passed!" );
ok( a.projectPoint( new THREE.Vector3( -10, 0, 0 ) ).equals( zero3 ), "Passed!" );
ok( a.projectPoint( new THREE.Vector3( 10, 0, 0 ), target ).equals( zero3 ), "Passed!" );
ok( a.projectPoint( new THREE.Vector3( -10, 0, 0 ), target ).equals( zero3 ), "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 0, 1, 0 ), -1 );
ok( a.projectPoint( new THREE.Vector3( 0, 0, 0 ) ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
ok( a.projectPoint( new THREE.Vector3( 0, 1, 0 ) ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
ok( a.projectPoint( new THREE.Vector3( 0, 0, 0 ), target ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
ok( a.projectPoint( new THREE.Vector3( 0, 1, 0 ), target ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
});
test( "orthoPoint", function() {
var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
var target = new THREE.Vector3();
ok( a.orthoPoint( new THREE.Vector3( 10, 0, 0 ) ).equals( new THREE.Vector3( 10, 0, 0 ) ), "Passed!" );
ok( a.orthoPoint( new THREE.Vector3( -10, 0, 0 ) ).equals( new THREE.Vector3( -10, 0, 0 ) ), "Passed!" );
ok( a.orthoPoint( new THREE.Vector3( 10, 0, 0 ), target ).equals( new THREE.Vector3( 10, 0, 0 ) ), "Passed!" );
ok( a.orthoPoint( new THREE.Vector3( -10, 0, 0 ), target ).equals( new THREE.Vector3( -10, 0, 0 ) ), "Passed!" );
});
test( "coplanarPoint", function() {
var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
ok( a.distanceToPoint( a.coplanarPoint() ) === 0, "Passed!" );
ok( a.distanceToPoint( a.coplanarPoint( new THREE.Vector3() ) ) === 0, "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 0, 1, 0 ), -1 );
ok( a.distanceToPoint( a.coplanarPoint() ) === 0, "Passed!" );
ok( a.distanceToPoint( a.coplanarPoint( new THREE.Vector3() ) ) === 0, "Passed!" );
});
test( "applyMatrix4/translate", function() {
@@ -2080,10 +2098,11 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
test( "at", function() {
var a = new THREE.Ray( one3.clone(), new THREE.Vector3( 0, 0, 1 ) );
var target = new THREE.Vector3();
ok( a.at( 0 ).equals( one3 ), "Passed!" );
ok( a.at( -1 ).equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" );
ok( a.at( 1 ).equals( new THREE.Vector3( 1, 1, 2 ) ), "Passed!" );
ok( a.at( 0, target ).equals( one3 ), "Passed!" );
ok( a.at( -1, target ).equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" );
ok( a.at( 1, target ).equals( new THREE.Vector3( 1, 1, 2 ) ), "Passed!" );
});
test( "recast/clone", function() {
@@ -2106,17 +2125,18 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
test( "closestPointToPoint", function() {
var a = new THREE.Ray( one3.clone(), new THREE.Vector3( 0, 0, 1 ) );
var target = new THREE.Vector3();
// behind the ray
var b = a.closestPointToPoint( zero3 );
var b = a.closestPointToPoint( zero3, target );
ok( b.equals( one3 ), "Passed!" );
// front of the ray
var c = a.closestPointToPoint( new THREE.Vector3( 0, 0, 50 ) );
var c = a.closestPointToPoint( new THREE.Vector3( 0, 0, 50 ), target );
ok( c.equals( new THREE.Vector3( 1, 1, 50 ) ), "Passed!" );
// exactly on the ray
var d = a.closestPointToPoint( one3 );
var d = a.closestPointToPoint( one3, target );
ok( d.equals( one3 ), "Passed!" );
});
@@ -2159,34 +2179,35 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
var a0 = new THREE.Ray( zero3.clone(), new THREE.Vector3( 0, 0, -1 ) );
// ray a1 origin located at ( 1, 1, 1 ) and points left in negative-x direction
var a1 = new THREE.Ray( one3.clone(), new THREE.Vector3( -1, 0, 0 ) );
var target = new THREE.Vector3();
// sphere (radius of 2) located behind ray a0, should result in null
var b = new THREE.Sphere( new THREE.Vector3( 0, 0, 3 ), 2 );
ok( a0.intersectSphere( b ) === null, "Passed!" );
ok( a0.intersectSphere( b, target ) === null, "Passed!" );
// sphere (radius of 2) located in front of, but too far right of ray a0, should result in null
var b = new THREE.Sphere( new THREE.Vector3( 3, 0, -1 ), 2 );
ok( a0.intersectSphere( b ) === null, "Passed!" );
ok( a0.intersectSphere( b, target ) === null, "Passed!" );
// sphere (radius of 2) located below ray a1, should result in null
var b = new THREE.Sphere( new THREE.Vector3( 1, -2, 1 ), 2 );
ok( a1.intersectSphere( b ) === null, "Passed!" );
ok( a1.intersectSphere( b, target ) === null, "Passed!" );
// sphere (radius of 1) located to the left of ray a1, should result in intersection at 0, 1, 1
var b = new THREE.Sphere( new THREE.Vector3( -1, 1, 1 ), 1 );
ok( a1.intersectSphere( b ).distanceTo( new THREE.Vector3( 0, 1, 1 ) ) < TOL, "Passed!" );
ok( a1.intersectSphere( b, target ).distanceTo( new THREE.Vector3( 0, 1, 1 ) ) < TOL, "Passed!" );
// sphere (radius of 1) located in front of ray a0, should result in intersection at 0, 0, -1
var b = new THREE.Sphere( new THREE.Vector3( 0, 0, -2 ), 1 );
ok( a0.intersectSphere( b ).distanceTo( new THREE.Vector3( 0, 0, -1 ) ) < TOL, "Passed!" );
ok( a0.intersectSphere( b, target ).distanceTo( new THREE.Vector3( 0, 0, -1 ) ) < TOL, "Passed!" );
// sphere (radius of 2) located in front & right of ray a0, should result in intersection at 0, 0, -1, or left-most edge of sphere
var b = new THREE.Sphere( new THREE.Vector3( 2, 0, -1 ), 2 );
ok( a0.intersectSphere( b ).distanceTo( new THREE.Vector3( 0, 0, -1 ) ) < TOL, "Passed!" );
ok( a0.intersectSphere( b, target ).distanceTo( new THREE.Vector3( 0, 0, -1 ) ) < TOL, "Passed!" );
// same situation as above, but move the sphere a fraction more to the right, and ray a0 should now just miss
var b = new THREE.Sphere( new THREE.Vector3( 2.01, 0, -1 ), 2 );
ok( a0.intersectSphere( b ) === null, "Passed!" );
ok( a0.intersectSphere( b, target ) === null, "Passed!" );
// following tests are for situations where the ray origin is inside the sphere
@@ -2194,19 +2215,19 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
// is behind ray a0. Therefore, second exit point on back of sphere will be returned: 0, 0, -1
// thus keeping the intersection point always in front of the ray.
var b = new THREE.Sphere( zero3.clone(), 1 );
ok( a0.intersectSphere( b ).distanceTo( new THREE.Vector3( 0, 0, -1 ) ) < TOL, "Passed!" );
ok( a0.intersectSphere( b, target ).distanceTo( new THREE.Vector3( 0, 0, -1 ) ) < TOL, "Passed!" );
// sphere (radius of 4) center located behind ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 5,
// is behind ray a0. Therefore, second exit point on back of sphere will be returned: 0, 0, -3
// thus keeping the intersection point always in front of the ray.
var b = new THREE.Sphere( new THREE.Vector3( 0, 0, 1 ), 4 );
ok( a0.intersectSphere( b ).distanceTo( new THREE.Vector3( 0, 0, -3 ) ) < TOL, "Passed!" );
ok( a0.intersectSphere( b, target ).distanceTo( new THREE.Vector3( 0, 0, -3 ) ) < TOL, "Passed!" );
// sphere (radius of 4) center located in front of ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 3,
// is behind ray a0. Therefore, second exit point on back of sphere will be returned: 0, 0, -5
// thus keeping the intersection point always in front of the ray.
var b = new THREE.Sphere( new THREE.Vector3( 0, 0, -1 ), 4 );
ok( a0.intersectSphere( b ).distanceTo( new THREE.Vector3( 0, 0, -5 ) ) < TOL, "Passed!" );
ok( a0.intersectSphere( b, target ).distanceTo( new THREE.Vector3( 0, 0, -5 ) ) < TOL, "Passed!" );
});
@@ -2236,26 +2257,27 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
test( "intersectPlane", function() {
var a = new THREE.Ray( one3.clone(), new THREE.Vector3( 0, 0, 1 ) );
var target = new THREE.Vector3();
// parallel plane behind
var b = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), new THREE.Vector3( 1, 1, -1 ) );
ok( a.intersectPlane( b ) === null, "Passed!" );
ok( a.intersectPlane( b, target ) === null, "Passed!" );
// parallel plane coincident with origin
var c = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), new THREE.Vector3( 1, 1, 0 ) );
ok( a.intersectPlane( c ) === null, "Passed!" );
ok( a.intersectPlane( c, target ) === null, "Passed!" );
// parallel plane infront
var d = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), new THREE.Vector3( 1, 1, 1 ) );
ok( a.intersectPlane( d ).equals( a.origin ), "Passed!" );
ok( a.intersectPlane( d, target ).equals( a.origin ), "Passed!" );
// perpendical ray that overlaps exactly
var e = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 1, 0, 0 ), one3 );
ok( a.intersectPlane( e ).equals( a.origin ), "Passed!" );
ok( a.intersectPlane( e, target ).equals( a.origin ), "Passed!" );
// perpendical ray that doesn't overlap
var f = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 1, 0, 0 ), zero3 );
ok( a.intersectPlane( f ) === null, "Passed!" );
ok( a.intersectPlane( f, target ) === null, "Passed!" );
});
@@ -2324,36 +2346,37 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
var TOL = 0.0001;
var box = new THREE.Box3( new THREE.Vector3( -1, -1, -1 ), new THREE.Vector3( 1, 1, 1 ) );
var target = new THREE.Vector3();
var a = new THREE.Ray( new THREE.Vector3( -2, 0, 0 ), new THREE.Vector3( 1, 0, 0) );
//ray should intersect box at -1,0,0
ok( a.intersectsBox(box) === true, "Passed!" );
ok( a.intersectBox(box).distanceTo( new THREE.Vector3( -1, 0, 0 ) ) < TOL, "Passed!" );
ok( a.intersectBox(box, target).distanceTo( new THREE.Vector3( -1, 0, 0 ) ) < TOL, "Passed!" );
var b = new THREE.Ray( new THREE.Vector3( -2, 0, 0 ), new THREE.Vector3( -1, 0, 0) );
//ray is point away from box, it should not intersect
ok( b.intersectsBox(box) === false, "Passed!" );
ok( b.intersectBox(box) === null, "Passed!" );
ok( b.intersectBox(box, target) === null, "Passed!" );
var c = new THREE.Ray( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 1, 0, 0) );
// ray is inside box, should return exit point
ok( c.intersectsBox(box) === true, "Passed!" );
ok( c.intersectBox(box).distanceTo( new THREE.Vector3( 1, 0, 0 ) ) < TOL, "Passed!" );
ok( c.intersectBox(box, target).distanceTo( new THREE.Vector3( 1, 0, 0 ) ) < TOL, "Passed!" );
var d = new THREE.Ray( new THREE.Vector3( 0, 2, 1 ), new THREE.Vector3( 0, -1, -1).normalize() );
//tilted ray should intersect box at 0,1,0
ok( d.intersectsBox(box) === true, "Passed!" );
ok( d.intersectBox(box).distanceTo( new THREE.Vector3( 0, 1, 0 ) ) < TOL, "Passed!" );
ok( d.intersectBox(box, target).distanceTo( new THREE.Vector3( 0, 1, 0 ) ) < TOL, "Passed!" );
var e = new THREE.Ray( new THREE.Vector3( 1, -2, 1 ), new THREE.Vector3( 0, 1, 0).normalize() );
//handle case where ray is coplanar with one of the boxes side - box in front of ray
ok( e.intersectsBox(box) === true, "Passed!" );
ok( e.intersectBox(box).distanceTo( new THREE.Vector3( 1, -1, 1 ) ) < TOL, "Passed!" );
ok( e.intersectBox(box, target).distanceTo( new THREE.Vector3( 1, -1, 1 ) ) < TOL, "Passed!" );
var f = new THREE.Ray( new THREE.Vector3( 1, -2, 0 ), new THREE.Vector3( 0, -1, 0).normalize() );
//handle case where ray is coplanar with one of the boxes side - box behind ray
ok( f.intersectsBox(box) === false, "Passed!" );
ok( f.intersectBox(box) == null, "Passed!" );
ok( f.intersectBox(box, target) == null, "Passed!" );
});
@@ -2425,18 +2448,20 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
test( "clampPoint", function() {
var a = new THREE.Sphere( one3.clone(), 1 );
var target = new THREE.Vector3();
ok( a.clampPoint( new THREE.Vector3( 1, 1, 3 ) ).equals( new THREE.Vector3( 1, 1, 2 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector3( 1, 1, -3 ) ).equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector3( 1, 1, 3 ), target ).equals( new THREE.Vector3( 1, 1, 2 ) ), "Passed!" );
ok( a.clampPoint( new THREE.Vector3( 1, 1, -3 ), target ).equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" );
});
test( "getBoundingBox", function() {
var a = new THREE.Sphere( one3.clone(), 1 );
var target = new THREE.Box3();
ok( a.getBoundingBox().equals( new THREE.Box3( zero3, two3 ) ), "Passed!" );
ok( a.getBoundingBox( target ).equals( new THREE.Box3( zero3, two3 ) ), "Passed!" );
a.set( zero3, 0 )
ok( a.getBoundingBox().equals( new THREE.Box3( zero3, zero3 ) ), "Passed!" );
ok( a.getBoundingBox( target ).equals( new THREE.Box3( zero3, zero3 ) ), "Passed!" );
});
test( "applyMatrix4", function() {
@@ -2444,7 +2469,7 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
var m = new THREE.Matrix4().makeTranslation( 1, -2, 1 );
ok( a.clone().applyMatrix4( m ).getBoundingBox().equals( a.getBoundingBox().applyMatrix4( m ) ), "Passed!" );
ok( a.clone().applyMatrix4( m ).getBoundingBox( new THREE.Box3() ).equals( a.getBoundingBox( new THREE.Box3() ).applyMatrix4( m ) ), "Passed!" );
});
test( "translate", function() {
@@ -2505,88 +2530,92 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
});
test( "area", function() {
test( "getArea", function() {
var a = new THREE.Triangle();
ok( a.area() == 0, "Passed!" );
ok( a.getArea() == 0, "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ) );
ok( a.area() == 0.5, "Passed!" );
ok( a.getArea() == 0.5, "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 2, 0, 0 ), new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, 2 ) );
ok( a.area() == 2, "Passed!" );
ok( a.getArea() == 2, "Passed!" );
// colinear triangle.
a = new THREE.Triangle( new THREE.Vector3( 2, 0, 0 ), new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 3, 0, 0 ) );
ok( a.area() == 0, "Passed!" );
ok( a.getArea() == 0, "Passed!" );
});
test( "midpoint", function() {
test( "getMidpoint", function() {
var a = new THREE.Triangle();
var target = new THREE.Vector3();
ok( a.midpoint().equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( a.getMidpoint( target ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ) );
ok( a.midpoint().equals( new THREE.Vector3( 1/3, 1/3, 0 ) ), "Passed!" );
ok( a.getMidpoint( target ).equals( new THREE.Vector3( 1/3, 1/3, 0 ) ), "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 2, 0, 0 ), new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, 2 ) );
ok( a.midpoint().equals( new THREE.Vector3( 2/3, 0, 2/3 ) ), "Passed!" );
ok( a.getMidpoint( target ).equals( new THREE.Vector3( 2/3, 0, 2/3 ) ), "Passed!" );
});
test( "normal", function() {
test( "getNormal", function() {
var a = new THREE.Triangle();
var target = new THREE.Vector3();
ok( a.normal().equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( a.getNormal( target ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ) );
ok( a.normal().equals( new THREE.Vector3( 0, 0, 1 ) ), "Passed!" );
ok( a.getNormal( target ).equals( new THREE.Vector3( 0, 0, 1 ) ), "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 2, 0, 0 ), new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, 2 ) );
ok( a.normal().equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
ok( a.getNormal( target ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
});
test( "plane", function() {
test( "getPlane", function() {
var a = new THREE.Triangle();
var target = new THREE.Vector3();
// artificial normal is created in this case.
ok( a.plane().distanceToPoint( a.a ) == 0, "Passed!" );
ok( a.plane().distanceToPoint( a.b ) == 0, "Passed!" );
ok( a.plane().distanceToPoint( a.c ) == 0, "Passed!" );
ok( a.plane().normal.equals( a.normal() ), "Passed!" );
ok( a.getPlane( target ).distanceToPoint( a.a ) == 0, "Passed!" );
ok( a.getPlane( target ).distanceToPoint( a.b ) == 0, "Passed!" );
ok( a.getPlane( target ).distanceToPoint( a.c ) == 0, "Passed!" );
ok( a.getPlane( target ).normal.equals( a.getNormal( new THREE.Vector3() ) ), "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ) );
ok( a.plane().distanceToPoint( a.a ) == 0, "Passed!" );
ok( a.plane().distanceToPoint( a.b ) == 0, "Passed!" );
ok( a.plane().distanceToPoint( a.c ) == 0, "Passed!" );
ok( a.plane().normal.equals( a.normal() ), "Passed!" );
ok( a.getPlane( target ).distanceToPoint( a.a ) == 0, "Passed!" );
ok( a.getPlane( target ).distanceToPoint( a.b ) == 0, "Passed!" );
ok( a.getPlane( target ).distanceToPoint( a.c ) == 0, "Passed!" );
ok( a.getPlane( target ).normal.equals( a.getNormal( new THREE.Vector3() ) ), "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 2, 0, 0 ), new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, 2 ) );
ok( a.plane().distanceToPoint( a.a ) == 0, "Passed!" );
ok( a.plane().distanceToPoint( a.b ) == 0, "Passed!" );
ok( a.plane().distanceToPoint( a.c ) == 0, "Passed!" );
ok( a.plane().normal.clone().normalize().equals( a.normal() ), "Passed!" );
ok( a.getPlane( target ).distanceToPoint( a.a ) == 0, "Passed!" );
ok( a.getPlane( target ).distanceToPoint( a.b ) == 0, "Passed!" );
ok( a.getPlane( target ).distanceToPoint( a.c ) == 0, "Passed!" );
ok( a.getPlane( target ).normal.clone().normalize().equals( a.getNormal( new THREE.Vector3() ) ), "Passed!" );
});
test( "barycoordFromPoint", function() {
test( "getBarycoord", function() {
var a = new THREE.Triangle();
var target = new THREE.Vector3();
var bad = new THREE.Vector3( -2, -1, -1 );
ok( a.barycoordFromPoint( a.a ).equals( bad ), "Passed!" );
ok( a.barycoordFromPoint( a.b ).equals( bad ), "Passed!" );
ok( a.barycoordFromPoint( a.c ).equals( bad ), "Passed!" );
ok( a.getBarycoord( a.a, target ).equals( bad ), "Passed!" );
ok( a.getBarycoord( a.b, target ).equals( bad ), "Passed!" );
ok( a.getBarycoord( a.c, target ).equals( bad ), "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ) );
ok( a.barycoordFromPoint( a.a ).equals( new THREE.Vector3( 1, 0, 0 ) ), "Passed!" );
ok( a.barycoordFromPoint( a.b ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
ok( a.barycoordFromPoint( a.c ).equals( new THREE.Vector3( 0, 0, 1 ) ), "Passed!" );
ok( a.barycoordFromPoint( a.midpoint() ).distanceTo( new THREE.Vector3( 1/3, 1/3, 1/3 ) ) < 0.0001, "Passed!" );
ok( a.getBarycoord( a.a, target ).equals( new THREE.Vector3( 1, 0, 0 ) ), "Passed!" );
ok( a.getBarycoord( a.b, target ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
ok( a.getBarycoord( a.c, target ).equals( new THREE.Vector3( 0, 0, 1 ) ), "Passed!" );
ok( a.getBarycoord( a.getMidpoint( new THREE.Vector3() ), target ).distanceTo( new THREE.Vector3( 1/3, 1/3, 1/3 ) ) < 0.0001, "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 2, 0, 0 ), new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, 2 ) );
ok( a.barycoordFromPoint( a.a ).equals( new THREE.Vector3( 1, 0, 0 ) ), "Passed!" );
ok( a.barycoordFromPoint( a.b ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
ok( a.barycoordFromPoint( a.c ).equals( new THREE.Vector3( 0, 0, 1 ) ), "Passed!" );
ok( a.barycoordFromPoint( a.midpoint() ).distanceTo( new THREE.Vector3( 1/3, 1/3, 1/3 ) ) < 0.0001, "Passed!" );
ok( a.getBarycoord( a.a, target ).equals( new THREE.Vector3( 1, 0, 0 ) ), "Passed!" );
ok( a.getBarycoord( a.b, target ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
ok( a.getBarycoord( a.c, target ).equals( new THREE.Vector3( 0, 0, 1 ) ), "Passed!" );
ok( a.getBarycoord( a.getMidpoint( new THREE.Vector3() ), target ).distanceTo( new THREE.Vector3( 1/3, 1/3, 1/3 ) ) < 0.0001, "Passed!" );
});
test( "containsPoint", function() {
@@ -2600,14 +2629,14 @@ declare function equal<T>(a: T, b: T, desc?: string): void;
ok( a.containsPoint( a.a ), "Passed!" );
ok( a.containsPoint( a.b ), "Passed!" );
ok( a.containsPoint( a.c ), "Passed!" );
ok( a.containsPoint( a.midpoint() ), "Passed!" );
ok( a.containsPoint( a.getMidpoint( new THREE.Vector3() ) ), "Passed!" );
ok( ! a.containsPoint( new THREE.Vector3( -1, -1, -1 ) ), "Passed!" );
a = new THREE.Triangle( new THREE.Vector3( 2, 0, 0 ), new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, 2 ) );
ok( a.containsPoint( a.a ), "Passed!" );
ok( a.containsPoint( a.b ), "Passed!" );
ok( a.containsPoint( a.c ), "Passed!" );
ok( a.containsPoint( a.midpoint() ), "Passed!" );
ok( a.containsPoint( a.getMidpoint( new THREE.Vector3() ) ), "Passed!" );
ok( ! a.containsPoint( new THREE.Vector3( -1, -1, -1 ) ), "Passed!" );
});

View File

@@ -448,7 +448,7 @@ export class Camera extends Object3D {
*/
projectionMatrix: Matrix4;
getWorldDirection(optionalTarget?: Vector3): Vector3;
getWorldDirection(target: Vector3): Vector3;
}
@@ -687,7 +687,6 @@ export class BufferAttribute {
copyAt(index1: number, attribute: BufferAttribute, index2: number): BufferAttribute;
copyArray(array: ArrayLike<number>): BufferAttribute;
copyColorsArray(colors: {r: number, g: number, b: number}[]): BufferAttribute;
copyIndicesArray(indices: {a: number, b: number, c: number}[]): BufferAttribute;
copyVector2sArray(vectors: {x: number, y: number}[]): BufferAttribute;
copyVector3sArray(vectors: {x: number, y: number, z: number}[]): BufferAttribute;
copyVector4sArray(vectors: {x: number, y: number, z: number, w: number}[]): BufferAttribute;
@@ -868,7 +867,7 @@ export class BufferGeometry extends EventDispatcher {
scale(x: number, y: number, z: number): BufferGeometry;
lookAt(v: Vector3): void;
center(): Vector3;
center(): BufferGeometry;
setFromObject(object: Object3D): BufferGeometry;
setFromPoints(points: Vector3[]): BufferGeometry;
@@ -1343,7 +1342,7 @@ export class Geometry extends EventDispatcher {
fromBufferGeometry(geometry: BufferGeometry): Geometry;
center(): Vector3;
center(): Geometry;
normalize(): Geometry;
@@ -1368,8 +1367,6 @@ export class Geometry extends EventDispatcher {
*/
computeMorphNormals(): void;
computeLineDistances(): void;
/**
* Computes bounding box of the geometry, updating {@link Geometry.boundingBox} attribute.
*/
@@ -1782,11 +1779,10 @@ export class Object3D extends EventDispatcher {
getObjectByProperty( name: string, value: string ): Object3D;
getWorldPosition(optionalTarget?: Vector3): Vector3;
getWorldQuaternion(optionalTarget?: Quaternion): Quaternion;
getWorldRotation(optionalTarget?: Euler): Euler;
getWorldScale(optionalTarget?: Vector3): Vector3;
getWorldDirection(optionalTarget?: Vector3): Vector3;
getWorldPosition(target: Vector3): Vector3;
getWorldQuaternion(target: Quaternion): Quaternion;
getWorldScale(target: Vector3): Vector3;
getWorldDirection(target: Vector3): Vector3;
raycast(raycaster: Raycaster, intersects: any): void;
@@ -3088,8 +3084,8 @@ export class Box2 {
copy(box: this): this;
makeEmpty(): Box2;
isEmpty(): boolean;
getCenter(optionalTarget?: Vector2): Vector2;
getSize(optionalTarget?: Vector2): Vector2;
getCenter(target: Vector2): Vector2;
getSize(target: Vector2): Vector2;
expandByPoint(point: Vector2): Box2;
expandByVector(vector: Vector2): Box2;
expandByScalar(scalar: number): Box2;
@@ -3097,7 +3093,7 @@ export class Box2 {
containsBox(box: Box2): boolean;
getParameter(point: Vector2): Vector2;
intersectsBox(box: Box2): boolean;
clampPoint(point: Vector2, optionalTarget?: Vector2): Vector2;
clampPoint(point: Vector2, target: Vector2): Vector2;
distanceToPoint(point: Vector2): number;
intersect(box: Box2): Box2;
union(box: Box2): Box2;
@@ -3128,8 +3124,8 @@ export class Box3 {
copy(box: this): this;
makeEmpty(): Box3;
isEmpty(): boolean;
getCenter(optionalTarget?: Vector3): Vector3;
getSize(optionalTarget?: Vector3): Vector3;
getCenter(target: Vector3): Vector3;
getSize(target: Vector3): Vector3;
expandByPoint(point: Vector3): Box3;
expandByVector(vector: Vector3): Box3;
expandByScalar(scalar: number): Box3;
@@ -3140,9 +3136,9 @@ export class Box3 {
intersectsBox(box: Box3): boolean;
intersectsSphere(sphere: Sphere): boolean;
intersectsPlane(plane: Plane): boolean;
clampPoint(point: Vector3, optionalTarget?: Vector3): Vector3;
clampPoint(point: Vector3, target: Vector3): Vector3;
distanceToPoint(point: Vector3): number;
getBoundingSphere(optionalTarget?: Sphere): Sphere;
getBoundingSphere(target: Sphere): Sphere;
intersect(box: Box3): Box3;
union(box: Box3): Box3;
applyMatrix4(matrix: Matrix4): Box3;
@@ -3499,13 +3495,13 @@ export class Line3 {
set(start?: Vector3, end?: Vector3): Line3;
clone(): this;
copy(line: this): this;
getCenter(optionalTarget?: Vector3): Vector3;
delta(optionalTarget?: Vector3): Vector3;
getCenter(target: Vector3): Vector3;
delta(target: Vector3): Vector3;
distanceSq(): number;
distance(): number;
at(t: number, optionalTarget?: Vector3): Vector3;
at(t: number, target: Vector3): Vector3;
closestPointToPointParameter(point: Vector3, clampToLine?: boolean): number;
closestPointToPoint(point: Vector3, clampToLine?: boolean, optionalTarget?: Vector3): Vector3;
closestPointToPoint(point: Vector3, clampToLine: boolean, target: Vector3): Vector3;
applyMatrix4(matrix: Matrix4): Line3;
equals(line: Line3): boolean;
}
@@ -3943,12 +3939,12 @@ export class Plane {
negate(): Plane;
distanceToPoint(point: Vector3): number;
distanceToSphere(sphere: Sphere): number;
projectPoint(point: Vector3, optionalTarget?: Vector3): Vector3;
orthoPoint(point: Vector3, optionalTarget?: Vector3): Vector3;
intersectLine(line: Line3, optionalTarget?: Vector3): Vector3;
projectPoint(point: Vector3, target: Vector3): Vector3;
orthoPoint(point: Vector3, target: Vector3): Vector3;
intersectLine(line: Line3, target: Vector3): Vector3;
intersectsLine(line: Line3): boolean;
intersectsBox(box: Box3): boolean;
coplanarPoint(optionalTarget?: boolean): Vector3;
coplanarPoint(target: Vector3): Vector3;
applyMatrix4(matrix: Matrix4, optionalNormalMatrix?: Matrix3): Plane;
translate(offset: Vector3): Plane;
equals(plane: Plane): boolean;
@@ -4106,21 +4102,21 @@ export class Ray {
set(origin: Vector3, direction: Vector3): Ray;
clone(): this;
copy(ray: this): this;
at(t: number, optionalTarget?: Vector3): Vector3;
at(t: number, target: Vector3): Vector3;
lookAt(v: Vector3): Vector3;
recast(t: number): Ray;
closestPointToPoint(point: Vector3, optionalTarget?: Vector3): Vector3;
closestPointToPoint(point: Vector3, target: Vector3): Vector3;
distanceToPoint(point: Vector3): number;
distanceSqToPoint(point: Vector3): number;
distanceSqToSegment(v0: Vector3, v1: Vector3, optionalPointOnRay?: Vector3, optionalPointOnSegment?: Vector3): number;
intersectSphere(sphere: Sphere, optionalTarget?: Vector3): Vector3;
intersectSphere(sphere: Sphere, target: Vector3): Vector3;
intersectsSphere(sphere: Sphere): boolean;
distanceToPlane(plane: Plane): number;
intersectPlane(plane: Plane, optionalTarget?: Vector3): Vector3;
intersectPlane(plane: Plane, target: Vector3): Vector3;
intersectsPlane(plane: Plane): boolean;
intersectBox(box: Box3, optionalTarget?: Vector3): Vector3;
intersectBox(box: Box3, target: Vector3): Vector3;
intersectsBox(box: Box3): boolean;
intersectTriangle(a: Vector3, b: Vector3, c: Vector3, backfaceCulling: boolean, optionalTarget?: Vector3): Vector3;
intersectTriangle(a: Vector3, b: Vector3, c: Vector3, backfaceCulling: boolean, target: Vector3): Vector3;
applyMatrix4(matrix4: Matrix4): Ray;
equals(ray: Ray): boolean;
@@ -4156,8 +4152,8 @@ export class Sphere {
intersectsSphere(sphere: Sphere): boolean;
intersectsBox(box: Box3): boolean;
intersectsPlane(plane: Plane): boolean;
clampPoint(point: Vector3, optionalTarget?: Vector3): Vector3;
getBoundingBox(optionalTarget?: Box3): Box3;
clampPoint(point: Vector3, target: Vector3): Vector3;
getBoundingBox(target: Box3): Box3;
applyMatrix4(matrix: Matrix4): Sphere;
translate(offset: Vector3): Sphere;
equals(sphere: Sphere): boolean;
@@ -4180,17 +4176,17 @@ export class Triangle {
setFromPointsAndIndices(points: Vector3[], i0: number, i1: number, i2: number): Triangle;
clone(): this;
copy(triangle: this): this;
area(): number;
midpoint(optionalTarget?: Vector3): Vector3;
normal(optionalTarget?: Vector3): Vector3;
plane(optionalTarget?: Vector3): Plane;
barycoordFromPoint(point: Vector3, optionalTarget?: Vector3): Vector3;
getArea(): number;
getMidpoint(target: Vector3): Vector3;
getNormal(target: Vector3): Vector3;
getPlane(target: Vector3): Plane;
getBarycoord(point: Vector3, target: Vector3): Vector3;
containsPoint(point: Vector3): boolean;
closestPointToPoint(point: Vector3, optionalTarget?: Vector3): Vector3;
closestPointToPoint(point: Vector3, target: Vector3): Vector3;
equals(triangle: Triangle): boolean;
static normal(a: Vector3, b: Vector3, c: Vector3, optionalTarget?: Vector3): Vector3;
static barycoordFromPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3, optionalTarget: Vector3): Vector3;
static getNormal(a: Vector3, b: Vector3, c: Vector3, target: Vector3): Vector3;
static getBarycoord(point: Vector3, a: Vector3, b: Vector3, c: Vector3, target: Vector3): Vector3;
static containsPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3): boolean;
}
@@ -5285,7 +5281,6 @@ export class WebGLRenderer implements Renderer {
};
render: {
calls: number;
vertices: number;
faces: number;
points: number;
};
@@ -5399,13 +5394,6 @@ export class WebGLRenderer implements Renderer {
*/
render(scene: Scene, camera: Camera, renderTarget?: RenderTarget, forceClear?: boolean): void;
/**
* Used for setting the gl frontFace, cullFace states in the GPU, thus enabling/disabling face culling when rendering.
* If cullFace is false, culling will be disabled.
* @param cullFace "back", "front", "front_and_back", or false.
* @param frontFace "ccw" or "cw
*/
setFaceCulling(cullFace?: CullFace, frontFace?: FrontFaceDirection): void;
/**
* @deprecated
*/
@@ -5648,12 +5636,15 @@ export let ShaderChunk: {
lightmap_fragment: string;
lightmap_pars_fragment: string;
lights_lambert_vertex: string;
lights_pars: string;
lights_pars_begin: string;
lights_pars_map: string;
lights_phong_fragment: string;
lights_phong_pars_fragment: string;
lights_physical_fragment: string;
lights_physical_pars_fragment: string;
lights_template: string;
lights_fragment_begin: string;
lights_fragment_maps: string;
lights_fragment_end: string;
logdepthbuf_fragment: string;
logdepthbuf_pars_fragment: string;
logdepthbuf_pars_vertex: string;
@@ -5677,7 +5668,8 @@ export let ShaderChunk: {
morphtarget_vertex: string;
normal_flip: string;
normal_frag: string;
normal_fragment: string;
normal_fragment_begin: string;
normal_fragment_maps: string;
normal_vert: string;
normalmap_pars_fragment: string;
packing: string;
@@ -6034,8 +6026,6 @@ export class WebGLShadowMap {
autoUpdate: boolean;
needsUpdate: boolean;
type: ShadowMapType;
renderReverseSided: boolean;
renderSingleSided: boolean;
render(scene: Scene, camera: Camera): void;

View File

@@ -0,0 +1,48 @@
// Type definitions for uglifyjs-webpack-plugin 1.1
// Project: https://github.com/webpack-contrib/uglifyjs-webpack-plugin
// Definitions by: Rene Vajkay <https://github.com/vajkayrene>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { Plugin } from 'webpack';
export = UglifyJsPlugin;
declare class UglifyJsPlugin extends Plugin {
constructor(options?: UglifyJsPlugin.UglifyJsPluginOptions);
}
declare namespace UglifyJsPlugin {
interface UglifyJsPluginOptions {
test?: RegExp | RegExp[];
include?: RegExp | RegExp[];
exclude?: RegExp | RegExp[];
cache?: boolean | string;
parallel?: boolean | number;
sourceMap?: boolean;
uglifyOptions?: UglifyJsOptions;
extractComments?: boolean | RegExp | ((node: object, comment: string) => boolean) | ExtractCommentsOptions;
warningsFilter?: (source: string) => boolean;
}
interface UglifyJsOptions {
ie8?: boolean;
ecma?: number;
parse?: object;
mangle?: boolean | object;
output?: object;
compress?: boolean | object;
warnings?: boolean;
toplevel?: boolean;
nameCache?: object;
keep_classnames?: boolean;
keep_fnames?: boolean;
safari10?: boolean;
}
interface ExtractCommentsOptions {
condition?: RegExp | ((node: object, comment: string) => boolean);
filename?: string | ((originalFileName: string) => string);
banner?: boolean | string | ((fileName: string) => string);
}
}

View File

@@ -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",
"uglifyjs-webpack-plugin-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -0,0 +1,18 @@
import * as webpack from "webpack";
import * as UglifyjsWebpackPlugin from "uglifyjs-webpack-plugin";
const compiler = webpack({
plugins: [
new UglifyjsWebpackPlugin(),
],
});
const compilerOptions = webpack({
plugins: [
new UglifyjsWebpackPlugin({
cache: false,
parallel: true,
sourceMap: true,
}),
],
});

View File

@@ -13,6 +13,7 @@ declare namespace uri {
absoluteTo(path: URI): URI;
addFragment(fragment: string): URI;
addQuery(qry: string): URI;
addQuery(qry: string, value:any): URI;
addQuery(qry: Object): URI;
addSearch(qry: string): URI;
addSearch(key: string, value:any): URI;

View File

@@ -32,6 +32,12 @@ URI('').setQuery('foo', 'bar');
URI('').setQuery({ foo: 'bar' });
URI('').setSearch('foo', 'bar');
URI('').setSearch({ foo: 'bar' });
URI('http://example.org/foo/hello.html').addQuery('foo');
URI('http://example.org/foo/hello.html').addQuery('foo', 'bar');
URI('http://example.org/foo/hello.html').addQuery({ foo: 'bar' });
URI('http://example.org/foo/hello.html').addSearch('foo');
URI('http://example.org/foo/hello.html').addSearch('foo', 'bar');
URI('http://example.org/foo/hello.html').addSearch({ foo: 'bar' });
var uri: uri.URI = $('a').uri();

View File

@@ -464,8 +464,8 @@ declare namespace WebdriverIO {
run(): Promise<any>;
}
class ErrorHandler {
constructor(type: string, msg: string | number);
class ErrorHandler extends Error {
constructor(type: string, msg: string | number, details?: string);
}
function multiremote(options: MultiRemoteOptions): Client<void>;

View File

@@ -551,7 +551,7 @@ declare namespace webpack {
/** Give chunks created a name (chunks with equal name are merged) */
name?: boolean | string | ((...args: any[]) => any);
/** Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) */
cacheGroups?: false | string | ((...args: any[]) => any) | RegExp | CacheGroupsOptions;
cacheGroups?: false | string | ((...args: any[]) => any) | RegExp | { [key: string]: CacheGroupsOptions };
}
interface RuntimeChunkOptions {
/** The name or name factory for the runtime chunks. */

View File

@@ -582,6 +582,22 @@ configuration = {
}
};
configuration = {
mode: "production",
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
chunks: "initial",
test: "node_modules",
name: "vendor",
enforce: true
}
}
}
},
};
plugin = new webpack.SplitChunksPlugin({ chunks: "async", minChunks: 2 });
class SingleEntryDependency extends webpack.compilation.Dependency {}