mirror of
https://github.com/FullScreenShenanigans/ScenePlayr.git
synced 2026-08-12 02:18:34 -07:00
(v0.5.3) Bumped gulp-shenanigans to 0.5.20
This commit is contained in:
+5
-3
@@ -1,8 +1,10 @@
|
||||
docs/**
|
||||
lib/**
|
||||
src/**/*.css
|
||||
src/**/*.d.ts
|
||||
src/**/*.js*
|
||||
~src/main.js
|
||||
test/**/*.js
|
||||
test/index.html
|
||||
test/utils/**
|
||||
!test/utils/mocks.ts
|
||||
test/**/*.d.ts
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
A stateful cutscene runner for jumping between scenes and their routines.
|
||||
|
||||
|
||||
|
||||
## Build Process
|
||||
|
||||
ScenePlayr uses [Gulp](http://gulpjs.com/) to automate building, which requires [Node.js](http://node.js.org).
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "sceneplayr",
|
||||
"description": "A stateful cutscene runner for jumping between scenes and their routines.",
|
||||
"version": "0.5.2",
|
||||
"version": "0.5.3",
|
||||
"author": {
|
||||
"name": "Josh Goldberg",
|
||||
"email": "joshuakgoldberg@outlook.com"
|
||||
@@ -15,6 +15,6 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"gulp-shenanigans": "^0.5.11"
|
||||
"gulp-shenanigans": "^0.5.20"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
"package": {
|
||||
"description": "A stateful cutscene runner for jumping between scenes and their routines.",
|
||||
"name": "ScenePlayr",
|
||||
"version": "0.5.2"
|
||||
"version": "0.5.3"
|
||||
}
|
||||
}
|
||||
|
||||
+20
-18
@@ -37,39 +37,41 @@ export interface IRoutine {
|
||||
(settings: ICutsceneSettings, ...args: any[]): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Miscellaneous settings for a cutscene.
|
||||
*/
|
||||
export interface IPartialCutsceneSettings {
|
||||
[i: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persistent settings kept throughout a cutscene.
|
||||
*/
|
||||
export interface ICutsceneSettings {
|
||||
export interface ICutsceneSettings extends IPartialCutsceneSettings {
|
||||
/**
|
||||
* A reference to the parent cutscene.
|
||||
* The currently playing cutscene.
|
||||
*/
|
||||
cutscene: ICutscene;
|
||||
cutscene?: ICutscene;
|
||||
|
||||
/**
|
||||
* The name of the parent cutscene.
|
||||
*/
|
||||
cutsceneName: string;
|
||||
cutsceneName?: string;
|
||||
|
||||
/**
|
||||
* The currently playing routine.
|
||||
*/
|
||||
routine: IRoutine;
|
||||
routine?: IRoutine;
|
||||
|
||||
/**
|
||||
* The name of the current playing routine.
|
||||
*/
|
||||
routineName: string;
|
||||
routineName?: string;
|
||||
|
||||
/**
|
||||
* Arguments passed to the currents playing routines.
|
||||
* Arguments passed to the currently playing routine.
|
||||
*/
|
||||
routineArguments: any[];
|
||||
|
||||
/**
|
||||
* Miscellaneous settings for the cutscene.
|
||||
*/
|
||||
[i: string]: any;
|
||||
routineArguments?: any[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,24 +106,24 @@ export interface IScenePlayr {
|
||||
/**
|
||||
* @returns The currently playing cutscene.
|
||||
*/
|
||||
getCutscene(): ICutscene;
|
||||
getCutscene(): ICutscene | undefined;
|
||||
|
||||
/**
|
||||
* @returns The cutscene referred to by the given name.
|
||||
*/
|
||||
getOtherCutscene(name: string): ICutscene;
|
||||
getOtherCutscene(name: string): ICutscene | undefined;
|
||||
|
||||
/**
|
||||
* @returns The currently playing routine.
|
||||
*/
|
||||
getRoutine(): IRoutine;
|
||||
getRoutine(): IRoutine | undefined;
|
||||
|
||||
/**
|
||||
* @param name The name of a routine to return.
|
||||
* @returns The routine within the current cutscene referred to
|
||||
* by the given name.
|
||||
*/
|
||||
getOtherRoutine(name: string): IRoutine;
|
||||
getOtherRoutine(name: string): IRoutine | undefined;
|
||||
|
||||
/**
|
||||
* @returns The scope routines are run in, if not this.
|
||||
@@ -131,7 +133,7 @@ export interface IScenePlayr {
|
||||
/**
|
||||
* @returns The name of the currently playing cutscene.
|
||||
*/
|
||||
getCutsceneName(): string;
|
||||
getCutsceneName(): string | undefined;
|
||||
|
||||
/**
|
||||
* @returns The settings used by the current cutscene.
|
||||
|
||||
+22
-20
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
ICutscene, ICutscenes, ICutsceneSettings, IRoutine, IScenePlayr, IScenePlayrSettings
|
||||
ICutscene, ICutscenes, ICutsceneSettings, IPartialCutsceneSettings,
|
||||
IRoutine, IScenePlayr, IScenePlayrSettings
|
||||
} from "./IScenePlayr";
|
||||
|
||||
/**
|
||||
@@ -14,17 +15,17 @@ export class ScenePlayr implements IScenePlayr {
|
||||
/**
|
||||
* The currently playing cutscene.
|
||||
*/
|
||||
private cutscene: ICutscene;
|
||||
private cutscene?: ICutscene;
|
||||
|
||||
/**
|
||||
* The currently playing routine within the current cutscene.
|
||||
*/
|
||||
private routine: IRoutine;
|
||||
private routine?: IRoutine;
|
||||
|
||||
/**
|
||||
* The name of the current cutscene.
|
||||
*/
|
||||
private cutsceneName: string;
|
||||
private cutsceneName?: string;
|
||||
|
||||
/**
|
||||
* Persistent settings for the current cutscene, passed to each routine.
|
||||
@@ -44,7 +45,7 @@ export class ScenePlayr implements IScenePlayr {
|
||||
/**
|
||||
* Initializes a new instance of the ScenePlayr class.
|
||||
*
|
||||
* @param [settings] Settings to be used for initialization.
|
||||
* @param settings Settings to be used for initialization.
|
||||
*/
|
||||
public constructor(settings: IScenePlayrSettings = {}) {
|
||||
this.cutscenes = settings.cutscenes || {};
|
||||
@@ -62,21 +63,21 @@ export class ScenePlayr implements IScenePlayr {
|
||||
/**
|
||||
* @returns The currently playing cutscene.
|
||||
*/
|
||||
public getCutscene(): ICutscene {
|
||||
public getCutscene(): ICutscene | undefined {
|
||||
return this.cutscene;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns The cutscene referred to by the given name.
|
||||
*/
|
||||
public getOtherCutscene(name: string): ICutscene {
|
||||
public getOtherCutscene(name: string): ICutscene | undefined {
|
||||
return this.cutscenes[name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns The currently playing routine.
|
||||
*/
|
||||
public getRoutine(): IRoutine {
|
||||
public getRoutine(): IRoutine | undefined {
|
||||
return this.routine;
|
||||
}
|
||||
|
||||
@@ -85,7 +86,11 @@ export class ScenePlayr implements IScenePlayr {
|
||||
* @returns The routine within the current cutscene referred to
|
||||
* by the given name.
|
||||
*/
|
||||
public getOtherRoutine(name: string): IRoutine {
|
||||
public getOtherRoutine(name: string): IRoutine | undefined {
|
||||
if (!this.cutscene) {
|
||||
throw new Error("No cutscene is currently playing.");
|
||||
}
|
||||
|
||||
return this.cutscene.routines[name];
|
||||
}
|
||||
|
||||
@@ -99,7 +104,7 @@ export class ScenePlayr implements IScenePlayr {
|
||||
/**
|
||||
* @returns The name of the currently playing cutscene.
|
||||
*/
|
||||
public getCutsceneName(): string {
|
||||
public getCutsceneName(): string | undefined {
|
||||
return this.cutsceneName;
|
||||
}
|
||||
|
||||
@@ -126,10 +131,10 @@ export class ScenePlayr implements IScenePlayr {
|
||||
* cutscene specifies a firstRoutine, it's started.
|
||||
*
|
||||
* @param name The name of the cutscene to play.
|
||||
* @param [settings] Additional settings to be kept persistently
|
||||
* @param settings Additional settings to be kept persistently
|
||||
* throughout the cutscene.
|
||||
*/
|
||||
public startCutscene(name: string, settings: any = {}, args?: any): void {
|
||||
public startCutscene(name: string, settings: IPartialCutsceneSettings = {}, args?: any): void {
|
||||
if (!name) {
|
||||
throw new Error("No name given to ScenePlayr.playScene.");
|
||||
}
|
||||
@@ -138,12 +143,10 @@ export class ScenePlayr implements IScenePlayr {
|
||||
this.stopCutscene();
|
||||
}
|
||||
|
||||
this.cutscene = this.cutscenes[name];
|
||||
this.cutsceneName = name;
|
||||
this.cutsceneSettings = settings || {};
|
||||
this.cutsceneSettings = settings as ICutsceneSettings;
|
||||
|
||||
this.cutsceneSettings.cutscene = this.cutscene;
|
||||
this.cutsceneSettings.cutsceneName = name;
|
||||
this.cutscene = this.cutsceneSettings.cutscene = this.cutscenes[name];
|
||||
this.cutsceneName = this.cutsceneSettings!.cutsceneName = name;
|
||||
|
||||
this.cutsceneArguments.push(this.cutsceneSettings);
|
||||
|
||||
@@ -161,7 +164,7 @@ export class ScenePlayr implements IScenePlayr {
|
||||
* @param args Arguments for the firstRoutine, if it exists.
|
||||
*/
|
||||
public bindCutscene(name: string, settings: any = {}, args?: any): () => void {
|
||||
return this.startCutscene.bind(this, name, args);
|
||||
return (): void => this.startCutscene(name, settings, args);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +174,7 @@ export class ScenePlayr implements IScenePlayr {
|
||||
this.routine = undefined;
|
||||
this.cutscene = undefined;
|
||||
this.cutsceneName = undefined;
|
||||
this.cutsceneSettings = undefined;
|
||||
this.cutsceneSettings = {};
|
||||
this.cutsceneArguments.pop();
|
||||
}
|
||||
|
||||
@@ -186,7 +189,6 @@ export class ScenePlayr implements IScenePlayr {
|
||||
if (!this.cutscene) {
|
||||
throw new Error("No cutscene is currently playing.");
|
||||
}
|
||||
|
||||
if (!this.cutscene.routines[name]) {
|
||||
throw new Error(`The '${this.cutsceneName}' cutscene does not contain a '${name}' routine.`);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/// <reference path="../../node_modules/@types/chai/index.d.ts" />
|
||||
/// <reference path="../../node_modules/@types/mocha/index.d.ts" />
|
||||
/// <reference path="../../lib/ScenePlayr.d.ts" />
|
||||
/// <reference path="../utils/MochaLoader.ts" />
|
||||
/// <reference path="../utils/mocks.ts" />
|
||||
import { mochaLoader } from "../main";
|
||||
|
||||
mochaLoader.addTest("_", (): void => { });
|
||||
mochaLoader.it("_", (): void => { });
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<!-- This file was auto-generated by gulp-shenanigans -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>ScenePlayr Tests</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
|
||||
<!-- Dependencies: Begin -->
|
||||
<script type="text/javascript">
|
||||
window.testDependencies = [
|
||||
|
||||
];
|
||||
</Script>
|
||||
<!-- Dependencies: End -->
|
||||
|
||||
<!-- Externals: Begin -->
|
||||
|
||||
<!-- Externals: End -->
|
||||
|
||||
<!-- Tests: Begin -->
|
||||
<script type="text/javascript">
|
||||
window.testPaths = [
|
||||
"main",
|
||||
"ScenePlayr/_",
|
||||
"utils/fakes",
|
||||
"utils/MochaLoader"
|
||||
];
|
||||
</script>
|
||||
<!-- Tests: End -->
|
||||
|
||||
<script src="../node_modules/chai/chai.js" type="text/javascript"></script>
|
||||
<script src="../node_modules/mocha/mocha.js" type="text/javascript"></script>
|
||||
<script data-main="main.js" src="../node_modules/requirejs/require.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,59 @@
|
||||
/* This file was auto-generated by gulp-shenanigans */
|
||||
|
||||
import { MochaLoader } from "./utils/MochaLoader";
|
||||
|
||||
declare var requirejs: any;
|
||||
declare var testDependencies: string[];
|
||||
declare var testPaths: string[];
|
||||
|
||||
export const mochaLoader: MochaLoader = new MochaLoader(mocha);
|
||||
|
||||
/**
|
||||
* Informs RequireJS of the file location for a test dependency.
|
||||
*
|
||||
* @param testDependencies Modules depended upon for tests.
|
||||
*/
|
||||
function redirectTestDependencies(dependencies: string[]): void {
|
||||
for (const dependency of dependencies) {
|
||||
requirejs.config({
|
||||
paths: {
|
||||
[dependency.toLowerCase() + "/lib"]: `../node_modules/${dependency}/src`
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively loads test paths under mocha loader.
|
||||
*
|
||||
* @param loadingPaths Test paths to load.
|
||||
* @param i Which index test path to load.
|
||||
* @param onComplete A callback for when loading is done.
|
||||
*/
|
||||
function loadTestPaths(loadingPaths: string[], i: number, onComplete: () => void): void {
|
||||
"use strict";
|
||||
|
||||
if (i >= loadingPaths.length) {
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
mochaLoader.setTestPath(loadingPaths[i]);
|
||||
requirejs(
|
||||
[loadingPaths[i]],
|
||||
(): void => {
|
||||
loadTestPaths(loadingPaths, i + 1, onComplete);
|
||||
});
|
||||
}
|
||||
|
||||
((): void => {
|
||||
redirectTestDependencies(testDependencies);
|
||||
|
||||
loadTestPaths(
|
||||
testPaths,
|
||||
0,
|
||||
(): void => {
|
||||
mochaLoader.describeTests();
|
||||
mochaLoader.run();
|
||||
});
|
||||
})();
|
||||
+15
-7
@@ -1,11 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es3",
|
||||
"declaration": false
|
||||
"declaration": true,
|
||||
"module": "amd",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"outDir": "..",
|
||||
"rootDir": "..",
|
||||
"strictNullChecks": true,
|
||||
"target": "es3"
|
||||
},
|
||||
"files": [
|
||||
"utils/mocks.ts",
|
||||
"utils/MochaLoader.ts",
|
||||
"ScenePlayr/_.ts"
|
||||
"include": [
|
||||
"./**/*.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/* This file was auto-generated by gulp-shenanigans */
|
||||
/// <reference path="../../node_modules/@types/chai/index.d.ts" />
|
||||
/// <reference path="../../node_modules/@types/mocha/index.d.ts" />
|
||||
|
||||
/**
|
||||
* Grouping of mocha describe() tests.
|
||||
*/
|
||||
interface ITestHierarchy {
|
||||
/**
|
||||
* Hierarchical children within this describe() group.
|
||||
*/
|
||||
children: {
|
||||
[i: string]: ITestHierarchy;
|
||||
};
|
||||
|
||||
/**
|
||||
* Tests run in this describe().
|
||||
*/
|
||||
tests: {
|
||||
[i: string]: (done: Function) => void;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines mocha tests into their describe() groups.
|
||||
*/
|
||||
export class MochaLoader {
|
||||
/**
|
||||
* The underlying mocha instance.
|
||||
*/
|
||||
private mocha: Mocha;
|
||||
|
||||
/**
|
||||
* Root grouping of test hierarchies.
|
||||
*/
|
||||
private testHierarchy: ITestHierarchy = {
|
||||
children: {},
|
||||
tests: {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Mocha describe() path for the next test to be added.
|
||||
*/
|
||||
private currentTestPath: string[];
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the MochaLoader class.
|
||||
*
|
||||
* @param mocha The underlying mocha instance.
|
||||
*/
|
||||
public constructor(mocha: Mocha) {
|
||||
this.mocha = mocha;
|
||||
this.mocha.setup("bdd");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current test path.
|
||||
*
|
||||
* @param rawPath A new current test path.
|
||||
*/
|
||||
public setTestPath(rawPath: string): void {
|
||||
this.currentTestPath = rawPath.split("/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new test under the current test path.
|
||||
*
|
||||
* @param testName The name of the test.
|
||||
* @param test A new test.
|
||||
*/
|
||||
public it(testName: string, test: (done: Function) => void): void {
|
||||
if (!this.currentTestPath) {
|
||||
throw new Error(`No test path defined before adding test '${testName}'.`);
|
||||
}
|
||||
|
||||
let testHierarchy: ITestHierarchy = this.testHierarchy;
|
||||
|
||||
for (const part of this.currentTestPath) {
|
||||
if (!testHierarchy.children[part]) {
|
||||
testHierarchy = testHierarchy.children[part] = {
|
||||
children: {},
|
||||
tests: {}
|
||||
};
|
||||
} else {
|
||||
testHierarchy = testHierarchy.children[part];
|
||||
}
|
||||
}
|
||||
|
||||
testHierarchy.tests[testName] = test;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the tests' describe() hierarchy.
|
||||
*/
|
||||
public describeTests(): void {
|
||||
this.describeTestHierarchy(this.testHierarchy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs tests using mocha.
|
||||
*/
|
||||
public run(): void {
|
||||
this.mocha.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively describes a test hierarchy and its children hierarchies.
|
||||
*
|
||||
* @param testHierarchy A test hierarchy to describe.
|
||||
*/
|
||||
private describeTestHierarchy(testHierarchy: ITestHierarchy): void {
|
||||
for (const testName in testHierarchy.tests) {
|
||||
if (testName in testHierarchy.tests) {
|
||||
it(testName, testHierarchy.tests[testName]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const childName in testHierarchy.children) {
|
||||
if (childName in testHierarchy.children) {
|
||||
describe(childName, (): void => this.describeTestHierarchy(testHierarchy.children[childName]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { IScenePlayr, IScenePlayrSettings } from "../../src/IScenePlayr";
|
||||
import { ScenePlayr } from "../../src/ScenePlayr";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export function mockScenePlayr(settings?: IScenePlayrSettings): IScenePlayr {
|
||||
return new ScenePlayr(settings);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
/// <reference path="../../lib/ScenePlayr.d.ts" />
|
||||
|
||||
const mocks = {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
mockScenePlayr: (settings?: ScenePlayr.IScenePlayrSettings): ScenePlayr.IScenePlayr => {
|
||||
return new ScenePlayr.ScenePlayr(settings);
|
||||
}
|
||||
};
|
||||
+11
-7
@@ -1,13 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "amd",
|
||||
"target": "es3",
|
||||
"noImplicitAny": true,
|
||||
"declaration": true,
|
||||
"outDir": "dist"
|
||||
"module": "amd",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "es3"
|
||||
},
|
||||
"files": [
|
||||
"src/IScenePlayr.ts",
|
||||
"src/ScenePlayr.ts"
|
||||
"include": [
|
||||
"./src/**/*.ts"
|
||||
]
|
||||
}
|
||||
|
||||
-11
@@ -15,7 +15,6 @@
|
||||
"interface-name": [true, "always-prefix"],
|
||||
"jsdoc-format": true,
|
||||
"label-position": true,
|
||||
"label-undefined": true,
|
||||
"max-line-length": [true, 140],
|
||||
"member-access": true,
|
||||
"member-ordering": [
|
||||
@@ -38,9 +37,7 @@
|
||||
"trace"
|
||||
],
|
||||
"no-construct": true,
|
||||
"no-constructor-vars": true,
|
||||
"no-debugger": true,
|
||||
"no-duplicate-key": true,
|
||||
"no-duplicate-variable": true,
|
||||
"no-empty": true,
|
||||
"no-eval": true,
|
||||
@@ -50,14 +47,11 @@
|
||||
"no-string-literal": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-trailing-whitespace": true,
|
||||
"no-unreachable": true,
|
||||
"no-unsafe-finally": true,
|
||||
"no-unused-expression": true,
|
||||
"no-unused-variable": true,
|
||||
"no-unused-new": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-var-keyword": true,
|
||||
"no-var-requires": true,
|
||||
"one-line": [
|
||||
true,
|
||||
"check-catch",
|
||||
@@ -92,11 +86,6 @@
|
||||
}
|
||||
],
|
||||
"use-isnan": true,
|
||||
"use-strict": [
|
||||
true,
|
||||
"check-module",
|
||||
"check-function"
|
||||
],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
|
||||
Reference in New Issue
Block a user