From 8fdbbd54ffed14807498dd2c428024e937e670ea Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 25 Dec 2017 14:11:35 -0500 Subject: [PATCH] (v0.7.0) Used shenanigans-manager@0.2 instead of Gulp --- .travis.yml | 4 +- .vscode/settings.json | 7 ++++ gulpfile.js | 1 - package.json | 95 ++++++++++++++++++++++++++++++------------- src/IQuadsKeepr.ts | 24 +++++------ src/QuadsKeepr.ts | 62 ++++++++++++++-------------- src/index.ts | 2 + test/QuadsKeepr/_.ts | 3 -- test/tsconfig.json | 19 +-------- test/utils/fakes.ts | 9 ---- tsconfig.json | 12 ++++-- tslint.json | 58 +++----------------------- 12 files changed, 136 insertions(+), 160 deletions(-) create mode 100644 .vscode/settings.json delete mode 100644 gulpfile.js create mode 100644 src/index.ts delete mode 100644 test/QuadsKeepr/_.ts delete mode 100644 test/utils/fakes.ts diff --git a/.travis.yml b/.travis.yml index 0820099..902fe1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: node_js node_js: - - "7" + - "node" - "5" script: - node_modules/gulp/bin/gulp.js + npm run verify diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ff6d1a5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "editor.tabSize": 4, + "editor.trimAutoWhitespace": true, + "tslint.alwaysShowRuleFailuresAsWarnings": true, + "tslint.autoFixOnSave": true, + "typescript.tsdk": "node_modules\\typescript\\lib" +} diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 5b7a4f9..0000000 --- a/gulpfile.js +++ /dev/null @@ -1 +0,0 @@ -require("gulp-shenanigans").initialize(require("gulp")); diff --git a/package.json b/package.json index 7f3ca61..b01ccb2 100644 --- a/package.json +++ b/package.json @@ -1,29 +1,68 @@ { - "name": "quadskeepr", - "description": "Adjustable quadrant-based collision detection.", - "version": "0.6.2", - "author": { - "name": "Josh Goldberg", - "email": "joshuakgoldberg@outlook.com" - }, - "repository": { - "type": "git", - "url": "ssh://git@github.com:FullScreenShenanigans/QuadsKeepr.git" - }, - "bugs": { - "url": "https://github.com/FullScreenShenanigans/QuadsKeepr/issues" - }, - "license": "MIT", - "devDependencies": { - "gulp": "^3.9.1", - "gulp-shenanigans": "^0.6.17" - }, - "scripts": { - "gulp": "gulp", - "test": "gulp test" - }, - "shenanigans": { - "name": "QuadsKeepr" - }, - "dependencies": {} -} + "author": { + "email": "joshuakgoldberg@outlook.com", + "name": "Josh Goldberg" + }, + "browser": "./lib/index.js", + "bugs": { + "url": "https://github.com/FullScreenShenanigans/QuadsKeepr/issues" + }, + "dependencies": { + }, + "description": "Adjustable quadrant-based collision detection.", + "devDependencies": { + "@types/chai": "^4.0.4", + "@types/lolex": "^1.5.32", + "@types/mocha": "^2.2.44", + "@types/sinon": "^4.0.0", + "@types/sinon-chai": "^2.7.29", + "chai": "^4.1.2", + "glob": "^7.1.2", + "lolex": "^2.3.0", + "mocha": "^4.0.1", + "mocha-headless-chrome": "^1.7.1", + "requirejs": "^2.3.5", + "run-for-every-file": "^1.1.0", + "shenanigans-manager": "^0.2.0", + "sinon": "^4.1.2", + "sinon-chai": "^2.14.0", + "tslint": "5.8.0", + "typedoc": "^0.9.0", + "typescript": "^2.6.2", + "webpack": "^3.10.0" + }, + "license": "MIT", + "name": "quadskeepr", + "repository": { + "type": "git", + "url": "ssh://git@github.com:FullScreenShenanigans/QuadsKeepr.git" + }, + "scripts": { + "dist": "npm run dist:webpack", + "dist:webpack": "webpack --config webpack.config.js", + "docs": "npm run docs:typedoc", + "docs:typedoc": "typedoc src/ --out docs/generated", + "init": "npm install && npm run setup && npm run verify", + "setup": "npm run setup:copy && npm run setup:package", + "setup:copy": "npm run setup:copy:default", + "setup:copy:default": "run-for-every-file --dot --src \"node_modules/shenanigans-manager/setup/default/\" --file \"**/*\" --run \"mustache package.json {{src-file}} {{file}}\" --dest \".\" --only-files", + "setup:package": "shenanigans-manager hydrate-package-json", + "src": "npm run src:tsc && npm run src:tslint", + "src:tsc": "tsc -p .", + "src:tslint": "tslint -c tslint.json --exclude ./node_modules/**/*.ts* -p tsconfig.json -t stylish", + "test": "npm run test:setup && npm run test:run", + "test:run": "mocha-headless-chrome --file test/index.html", + "test:setup": "npm run test:setup:copy && npm run test:setup:html && npm run test:setup:tsc", + "test:setup:copy": "npm run test:setup:copy:default", + "test:setup:copy:default": "run-for-every-file --dot --src \"node_modules/shenanigans-manager/setup/test/\" --file \"**/*\" --run \"mustache package.json {{src-file}} ./test/{{file}}\" --dest \".\" --only-files", + "test:setup:html": "shenanigans-manager generate-test-html", + "test:setup:tsc": "tsc -p test", + "verify": "npm run src && npm run test && npm run dist && npm run docs", + "watch": "run-p \"tsc -p . -w\" \"echo sup\"" + }, + "shenanigans": { + "name": "QuadsKeepr" + }, + "types": "./src/index.d.ts", + "version": "0.7.0" +} \ No newline at end of file diff --git a/src/IQuadsKeepr.ts b/src/IQuadsKeepr.ts index 610074d..272823c 100644 --- a/src/IQuadsKeepr.ts +++ b/src/IQuadsKeepr.ts @@ -1,12 +1,10 @@ /** * Creates new Quadrants. * - * @type TThing Type of Things in the Quadrant. + * @template TThing Type of Things in the Quadrant. * @returns A new Quadrant. */ -export interface IQuadrantFactory { - (): IQuadrant; -} +export type IQuadrantFactory = () => IQuadrant; /** * Any rectangular bounding box. @@ -71,7 +69,7 @@ export interface IThing extends IBoundingBox { /** * Some collection of Thing groups, keyed by group name. * - * @type T The type of Thing. + * @template T The type of Thing. */ export interface IThingsCollection { [i: string]: T[]; @@ -90,7 +88,7 @@ export interface IThingsCounter { /** * A single cell in a grid structure containing any number of Things. * - * @type T The type of Thing. + * @template T The type of Thing. */ export interface IQuadrant extends IBoundingBox { /** @@ -107,7 +105,7 @@ export interface IQuadrant extends IBoundingBox { /** * A straight line of Quadrants, border-to-border. * - * @type T The type of Thing. + * @template T The type of Thing. */ export interface IQuadrantCollection { /** @@ -129,7 +127,7 @@ export interface IQuadrantCollection { /** * A complete row of Quadrants, border-to-border. * - * @type T The type of Thing. + * @template T The type of Thing. */ export interface IQuadrantRow extends IQuadrantCollection { /** @@ -141,7 +139,7 @@ export interface IQuadrantRow extends IQuadrantCollection { /** * A complete column of Quadrants, border-to-border. * - * @type T The type of Thing. + * @template T The type of Thing. */ export interface IQuadrantCol extends IQuadrantCollection { /** @@ -159,14 +157,12 @@ export interface IQuadrantCol extends IQuadrantCollection { * @param bottom The bottom border of the new area. * @param left The left border of the new area. */ -export interface IQuadrantChangeCallback { - (direction: string, top: number, right: number, bottom: number, left: number): void; -} +export type IQuadrantChangeCallback = (direction: string, top: number, right: number, bottom: number, left: number) => void; /** * Settings to initialize a new IQuadsKeepr. * - * @type TThing Type of Things in the Quadrants. + * @template TThing Type of Things in the Quadrants. */ export interface IQuadsKeeprSettings { /** @@ -233,7 +229,7 @@ export interface IQuadsKeeprSettings { /** * Adjustable quadrant-based collision detection. * - * @type T The type of Thing contained in the quadrants. + * @template T The type of Thing contained in the quadrants. */ export interface IQuadsKeepr { /** diff --git a/src/QuadsKeepr.ts b/src/QuadsKeepr.ts index cc75bfa..5c5f24b 100644 --- a/src/QuadsKeepr.ts +++ b/src/QuadsKeepr.ts @@ -1,12 +1,12 @@ import { IQuadrant, IQuadrantChangeCallback, IQuadrantCol, IQuadrantFactory, - IQuadrantRow, IQuadsKeepr, IQuadsKeeprSettings, IThing + IQuadrantRow, IQuadsKeepr, IQuadsKeeprSettings, IThing, } from "./IQuadsKeepr"; /** * Adjustable quadrant-based collision detection. * - * @type TThing The type of Thing contained in the quadrants. + * @template TThing The type of Thing contained in the quadrants. */ export class QuadsKeepr implements IQuadsKeepr { /** @@ -199,32 +199,32 @@ export class QuadsKeepr implements IQuadsKeepr { let top: number = this.startTop; - for (let i: number = 0; i < this.numRows; i += 1) { + for (let i = 0; i < this.numRows; i += 1) { this.quadrantRows.push({ - "left": this.startLeft, - "top": top, - "quadrants": [] + left: this.startLeft, + top, + quadrants: [], }); top += this.quadrantHeight; } let left: number = this.startLeft; - for (let j: number = 0; j < this.numCols; j += 1) { + for (let j = 0; j < this.numCols; j += 1) { this.quadrantCols.push({ - "left": left, - "top": this.startTop, - "quadrants": [] + left, + top: this.startTop, + quadrants: [], }); left += this.quadrantWidth; } top = this.startTop; - for (let i: number = 0; i < this.numRows; i += 1) { + for (let i = 0; i < this.numRows; i += 1) { left = this.startLeft; - for (let j: number = 0; j < this.numCols; j += 1) { + for (let j = 0; j < this.numCols; j += 1) { const quadrant: IQuadrant = this.createQuadrant(left, top); this.quadrantRows[i].quadrants.push(quadrant); this.quadrantCols[j].quadrants.push(quadrant); @@ -259,18 +259,18 @@ export class QuadsKeepr implements IQuadsKeepr { this.bottom += dy; this.left += dx; - for (let row: number = 0; row < this.numRows; row += 1) { + for (let row = 0; row < this.numRows; row += 1) { this.quadrantRows[row].left += dx; this.quadrantRows[row].top += dy; } - for (let col: number = 0; col < this.numCols; col += 1) { + for (let col = 0; col < this.numCols; col += 1) { this.quadrantCols[col].left += dx; this.quadrantCols[col].top += dy; } - for (let row: number = 0; row < this.numRows; row += 1) { - for (let col: number = 0; col < this.numCols; col += 1) { + for (let row = 0; row < this.numRows; row += 1) { + for (let col = 0; col < this.numCols; col += 1) { this.shiftQuadrant(this.quadrantRows[row].quadrants[col], dx, dy); } } @@ -291,7 +291,7 @@ export class QuadsKeepr implements IQuadsKeepr { this.numRows += 1; this.quadrantRows.push(row); - for (let i: number = 0; i < this.quadrantCols.length; i += 1) { + for (let i = 0; i < this.quadrantCols.length; i += 1) { this.quadrantCols[i].quadrants.push(row.quadrants[i]); } @@ -317,7 +317,7 @@ export class QuadsKeepr implements IQuadsKeepr { this.numCols += 1; this.quadrantCols.push(col); - for (let i: number = 0; i < this.quadrantRows.length; i += 1) { + for (let i = 0; i < this.quadrantRows.length; i += 1) { this.quadrantRows[i].quadrants.push(col.quadrants[i]); } @@ -386,7 +386,7 @@ export class QuadsKeepr implements IQuadsKeepr { this.numRows += 1; this.quadrantRows.unshift(row); - for (let i: number = 0; i < this.quadrantCols.length; i += 1) { + for (let i = 0; i < this.quadrantCols.length; i += 1) { this.quadrantCols[i].quadrants.unshift(row.quadrants[i]); } @@ -412,7 +412,7 @@ export class QuadsKeepr implements IQuadsKeepr { this.numCols += 1; this.quadrantCols.unshift(col); - for (let i: number = 0; i < this.quadrantRows.length; i += 1) { + for (let i = 0; i < this.quadrantRows.length; i += 1) { this.quadrantRows[i].quadrants.unshift(col.quadrants[i]); } @@ -476,8 +476,8 @@ export class QuadsKeepr implements IQuadsKeepr { * @param things The listing of Things in that group. */ public determineAllQuadrants(group: string, things: TThing[]): void { - for (let row: number = 0; row < this.numRows; row += 1) { - for (let col: number = 0; col < this.numCols; col += 1) { + for (let row = 0; row < this.numRows; row += 1) { + for (let col = 0; col < this.numCols; col += 1) { this.quadrantRows[row].quadrants[col].numthings[group] = 0; } } @@ -630,12 +630,12 @@ export class QuadsKeepr implements IQuadsKeepr { */ private createQuadrantRow(left: number = 0, top: number = 0): IQuadrantRow { const row: IQuadrantRow = { - left: left, - top: top, - quadrants: [] + left, + top, + quadrants: [], }; - for (let i: number = 0; i < this.numCols; i += 1) { + for (let i = 0; i < this.numCols; i += 1) { row.quadrants.push(this.createQuadrant(left, top)); // tslint:disable-next-line:no-parameter-reassignment left += this.quadrantWidth; @@ -653,12 +653,12 @@ export class QuadsKeepr implements IQuadsKeepr { */ private createQuadrantCol(left: number, top: number): IQuadrantCol { const col: IQuadrantCol = { - left: left, - top: top, - quadrants: [] + left, + top, + quadrants: [], }; - for (let i: number = 0; i < this.numRows; i += 1) { + for (let i = 0; i < this.numRows; i += 1) { col.quadrants.push(this.createQuadrant(left, top)); // tslint:disable-next-line:no-parameter-reassignment top += this.quadrantHeight; @@ -723,7 +723,7 @@ export class QuadsKeepr implements IQuadsKeepr { * Marks all Quadrants a Thig is contained within as changed. */ private markThingQuadrantsChanged(thing: TThing): void { - for (let i: number = 0; i < thing.numQuadrants; i += 1) { + for (let i = 0; i < thing.numQuadrants; i += 1) { thing.quadrants[i].changed = true; } } diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..18254ea --- /dev/null +++ b/src/index.ts @@ -0,0 +1,2 @@ +export * from "./IQuadsKeepr"; +export * from "./QuadsKeepr"; diff --git a/test/QuadsKeepr/_.ts b/test/QuadsKeepr/_.ts deleted file mode 100644 index c1cb46d..0000000 --- a/test/QuadsKeepr/_.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { mochaLoader } from "../main"; - -mochaLoader.it("_", (): void => { }); diff --git a/test/tsconfig.json b/test/tsconfig.json index 9a4ef9f..615249f 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,19 +1,4 @@ { - "compilerOptions": { - "declaration": true, - "lib": ["dom", "es2015.collection", "es2015.promise", "es5"], - "module": "amd", - "moduleResolution": "node", - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "strictNullChecks": true, - "target": "es5" - }, - "include": [ - "./**/*.ts" - ] + "extends": "../tsconfig.json", + "include": ["*.ts"] } diff --git a/test/utils/fakes.ts b/test/utils/fakes.ts deleted file mode 100644 index 03ed587..0000000 --- a/test/utils/fakes.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { IQuadsKeepr, IQuadsKeeprSettings, IThing } from "../../src/IQuadsKeepr"; -import { QuadsKeepr } from "../../src/QuadsKeepr"; - -/** - * - */ -export function stubQuadsKeepr(settings: IQuadsKeeprSettings): IQuadsKeepr { - return new QuadsKeepr(settings); -} diff --git a/tsconfig.json b/tsconfig.json index 09aa46a..9d9ee77 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,8 @@ { "compilerOptions": { "declaration": true, + "experimentalDecorators": true, + "jsx": "react", "lib": ["dom", "es2015.collection", "es2015.promise", "es5"], "module": "amd", "moduleResolution": "node", @@ -8,12 +10,16 @@ "noImplicitReturns": true, "noImplicitThis": true, "noFallthroughCasesInSwitch": true, - "noUnusedLocals": true, - "noUnusedParameters": true, + "pretty": true, "strictNullChecks": true, "target": "es5" }, + "exclude": [ + "dist", + "node_modules" + ], "include": [ - "./src/**/*.ts" + "./src/**/*.ts", + "./src/**/*.tsx" ] } diff --git a/tslint.json b/tslint.json index 47bc48d..6626443 100644 --- a/tslint.json +++ b/tslint.json @@ -1,56 +1,10 @@ { - "extends": "tslint:all", + "extends": "./node_modules/shenanigans-manager/setup/tslint.json", "rules": { - "array-type": [false], - "arrow-return-shorthand": [false], - "ban-types": [false], - "callable-types": [false], - "comment-format": [false], - "completed-docs": [false], - "cyclomatic-complexity": [false], - "forin": [false], - "linebreak-style": [false], - "max-file-line-count": [false], - "max-line-length": [true, 140], - "member-ordering": [ - true, - "public-before-private", - "static-before-instance", - "variables-before-functions" - ], - "newline-before-return": [false], - "no-any": [false], - "no-bitwise": [false], - "no-console": [false], - "no-default-export": [false], - "no-inferrable-types": [false], - "no-magic-numbers": [false], - "no-redundant-jsdoc": [false], - "no-non-null-assertion": [false], - "no-object-literal-type-assertion": [false], - "no-submodule-imports": [false], - "no-require-imports": false, - "no-unbound-method": [false], - "no-unsafe-any": [false], - "no-unused-variable": [false], - "no-void-expression": [false], - "number-literal-format": [false], - "object-literal-key-quotes": [false], - "object-literal-shorthand": [false], - "object-literal-sort-keys": [false], - "only-arrow-functions": [false], - "prefer-function-over-method": [false], - "prefer-method-signature": [false], - "prefer-switch": [false], - "prefer-conditional-expression": [false], - "prefer-template": [false], - "restrict-plus-operands": [false], - "space-before-function-paren": [false], - "strict-boolean-expressions": [false], - "strict-type-predicates": [false], - "switch-final-break": [false], - "trailing-comma": [false], - "typedef": [false], - "variable-name": [false] + "completed-docs": false, + "no-bitwise": false, + "no-non-null-assertion": false, + "prefer-function-over-method": false, + "strict-boolean-expressions": false } }