<commit_before>/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";

const ConcatSource = require("webpack-sources").ConcatSource;
const OriginalSource = require("webpack-sources").OriginalSource;
const PrefixSource = require("webpack-sources").PrefixSource;
const Template = require("./Template");

// require function shortcuts:
// __webpack_require__.s = the module id of the entry point
// __webpack_require__.c = the module cache
// __webpack_require__.m = the module functions
// __webpack_require__.p = the bundle public path
// __webpack_require__.i = the identity function used for harmony imports
// __webpack_require__.e = the chunk ensure function
// __webpack_require__.d = the exported propery define getter function
// __webpack_require__.o = Object.prototype.hasOwnProperty.call
// __webpack_require__.n = compatibility get default export
// __webpack_require__.h = the webpack hash
// __webpack_require__.oe = the uncatched error handler for the webpack runtime
// __webpack_require__.nc = the script nonce

module.exports = class MainTemplate extends Template {
	constructor(outputOptions) {
		super(outputOptions);
		this.plugin("startup", (source, chunk, hash) => {
			let buf = [];
			if(chunk.entryModule) {
				buf.push("// Load entry module and return exports");
				buf.push("return " + this.renderRequireFunctionForModule(hash, chunk, JSON.stringify(chunk.entryModule.id)) +
					"(" + this.requireFn + ".s = " + JSON.stringify(chunk.entryModule.id) + ");");
			}
			return this.asString(buf);
		});
		this.plugin("render", (bootstrapSource, chunk, hash, moduleTemplate, dependencyTemplates) => {
			let source = new ConcatSource();
			source.add("/******/ (function(modules) { // webpackBootstrap\n");
			source.add(new PrefixSource("/******/", bootstrapSource));
			source.add("/******/ })\n");
			source.add("/************************************************************************/\n");
			source.add("/******/ (");
			let modules = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates, "/******/ ");
			source.add(this.applyPluginsWaterfall("modules", modules, chunk, hash, moduleTemplate, dependencyTemplates));
			source.add(")");
			return source;
		});
		this.plugin("local-vars", (source, chunk, hash) => {
			return this.asString([
				source,
				"// The module cache",
				"var installedModules = {};"
			]);
		});
		this.plugin("require", (source, chunk, hash) => {
			return this.asString([
				source,
				"// Check if module is in cache",
				"if(installedModules[moduleId])",
				this.indent("return installedModules[moduleId].exports;"),
				"",
				"// Create a new module (and put it into the cache)",
				"var module = installedModules[moduleId] = {",
				this.indent(this.applyPluginsWaterfall("module-obj", "", chunk, hash, "moduleId")),
				"};",
				"",
				this.asString(outputOptions.strictModuleExceptionHandling ? [
					"// Execute the module function",
					"var threw = true;",
					"try {",
					this.indent([
						"modules[moduleId].call(module.exports, module, module.exports, " + this.renderRequireFunctionForModule(hash, chunk, "moduleId") + ");",
						"threw = false;"
					]),
					"} finally {",
					this.indent([
						"if(threw) delete installedModules[moduleId];"
					]),
					"}"
				] : [
					"// Execute the module function",
					"modules[moduleId].call(module.exports, module, module.exports, " + this.renderRequireFunctionForModule(hash, chunk, "moduleId") + ");",
				]),
				"",
				"// Flag the module as loaded",
				"module.l = true;",
				"",
				"// Return the exports of the module",
				"return module.exports;"
			]);
		});
		this.plugin("module-obj", (source, chunk, hash, varModuleId) => {
			return this.asString([
				"i: moduleId,",
				"l: false,",
				"exports: {}"
			]);
		});
		this.plugin("require-extensions", (source, chunk, hash) => {
			let buf = [];
			if(chunk.chunks.length > 0) {
				buf.push("// This file contains only the entry chunk.");
				buf.push("// The chunk loading function for additional chunks");
				buf.push(this.requireFn + ".e = function requireEnsure(chunkId) {");
				buf.push(this.indent(this.applyPluginsWaterfall("require-ensure", "throw new Error('Not chunk loading available');", chunk, hash, "chunkId")));
				buf.push("};");
			}
			buf.push("");
			buf.push("// expose the modules object (__webpack_modules__)");
			buf.push(this.requireFn + ".m = modules;");

			buf.push("");
			buf.push("// expose the module cache");
			buf.push(this.requireFn + ".c = installedModules;");

			buf.push("");
			buf.push("// identity function for calling harmony imports with the correct context");
			buf.push(this.requireFn + ".i = function(value) { return value; };");

			buf.push("");
			buf.push("// define getter function for harmony exports");
			buf.push(this.requireFn + ".d = function(exports, name, getter) {");
			buf.push(this.indent([
				"if(!" + this.requireFn + ".o(exports, name)) {",
				this.indent([
					"Object.defineProperty(exports, name, {",
					this.indent([
						"configurable: false,",
						"enumerable: true,",
						"get: getter"
					]),
					"});"
				]),
				"}"
			]));
			buf.push("};");

			buf.push("");
			buf.push("// getDefaultExport function for compatibility with non-harmony modules");
			buf.push(this.requireFn + ".n = function(module) {");
			buf.push(this.indent([
				"var getter = module && module.__esModule ?",
				this.indent([
					"function getDefault() { return module['default']; } :",
					"function getModuleExports() { return module; };"
				]),
				this.requireFn + ".d(getter, 'a', getter);",
				"return getter;"
			]));
			buf.push("};");

			buf.push("");
			buf.push("// Object.prototype.hasOwnProperty.call");
			buf.push(this.requireFn + ".o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };");

			let publicPath = this.getPublicPath({
				hash: hash
			});
			buf.push("");
			buf.push("// __webpack_public_path__");
			buf.push(this.requireFn + ".p = " + JSON.stringify(publicPath) + ";");
			return this.asString(buf);
		});

		this.requireFn = "__webpack_require__";
	}

	render(hash, chunk, moduleTemplate, dependencyTemplates) {
		let buf = [];
		buf.push(this.applyPluginsWaterfall("bootstrap", "", chunk, hash, moduleTemplate, dependencyTemplates));
		buf.push(this.applyPluginsWaterfall("local-vars", "", chunk, hash));
		buf.push("");
		buf.push("// The require function");
		buf.push("function " + this.requireFn + "(moduleId) {");
		buf.push(this.indent(this.applyPluginsWaterfall("require", "", chunk, hash)));
		buf.push("}");
		buf.push("");
		buf.push(this.asString(this.applyPluginsWaterfall("require-extensions", "", chunk, hash)));
		buf.push("");
		buf.push(this.asString(this.applyPluginsWaterfall("startup", "", chunk, hash)));
		let source = this.applyPluginsWaterfall("render", new OriginalSource(this.prefix(buf, " \t") + "\n", "webpack/bootstrap " + hash), chunk, hash, moduleTemplate, dependencyTemplates);
		if(chunk.hasEntryModule()) {
			source = this.applyPluginsWaterfall("render-with-entry", source, chunk, hash);
		}
		if(!source) throw new Error("Compiler error: MainTemplate plugin 'render' should return something");
		chunk.rendered = true;
		return new ConcatSource(source, ";");
	}

	renderRequireFunctionForModule(hash, chunk, varModuleId) {
		return this.applyPluginsWaterfall("module-require", this.requireFn, chunk, hash, varModuleId);
	}

	renderAddModule(hash, chunk, varModuleId, varModule) {
		return this.applyPluginsWaterfall("add-module", "modules[" + varModuleId + "] = " + varModule + ";", chunk, hash, varModuleId, varModule);
	}

	renderCurrentHashCode(hash, length) {
		length = length || Infinity;
		return this.applyPluginsWaterfall("current-hash", JSON.stringify(hash.substr(0, length)), length);
	}

	entryPointInChildren(chunk) {
		let checkChildren = (chunk, alreadyCheckedChunks) => {
			return chunk.chunks.some((child) => {
				if(alreadyCheckedChunks.indexOf(child) >= 0) return;
				alreadyCheckedChunks.push(child);
				return child.hasEntryModule() || checkChildren(child, alreadyCheckedChunks);
			});
		};
		return checkChildren(chunk, []);
	}

	getPublicPath(options) {
		return this.applyPluginsWaterfall("asset-path", this.outputOptions.publicPath || "", options);
	}

	updateHash(hash) {
		hash.update("maintemplate");
		hash.update("3");
		hash.update(this.outputOptions.publicPath + "");
		this.applyPlugins("hash", hash);
	}

	updateHashForChunk(hash, chunk) {
		this.updateHash(hash);
		this.applyPlugins("hash-for-chunk", hash, chunk);
	}

	useChunkHash(chunk) {
		let paths = this.applyPluginsWaterfall("global-hash-paths", []);
		return !this.applyPluginsBailResult("global-hash", chunk, paths);
	}
};
<commit_msg>use const where applicable in MainTemplate<commit_after>/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";

const ConcatSource = require("webpack-sources").ConcatSource;
const OriginalSource = require("webpack-sources").OriginalSource;
const PrefixSource = require("webpack-sources").PrefixSource;
const Template = require("./Template");

// require function shortcuts:
// __webpack_require__.s = the module id of the entry point
// __webpack_require__.c = the module cache
// __webpack_require__.m = the module functions
// __webpack_require__.p = the bundle public path
// __webpack_require__.i = the identity function used for harmony imports
// __webpack_require__.e = the chunk ensure function
// __webpack_require__.d = the exported propery define getter function
// __webpack_require__.o = Object.prototype.hasOwnProperty.call
// __webpack_require__.n = compatibility get default export
// __webpack_require__.h = the webpack hash
// __webpack_require__.oe = the uncatched error handler for the webpack runtime
// __webpack_require__.nc = the script nonce

module.exports = class MainTemplate extends Template {
	constructor(outputOptions) {
		super(outputOptions);
		this.plugin("startup", (source, chunk, hash) => {
			const buf = [];
			if(chunk.entryModule) {
				buf.push("// Load entry module and return exports");
				buf.push("return " + this.renderRequireFunctionForModule(hash, chunk, JSON.stringify(chunk.entryModule.id)) +
					"(" + this.requireFn + ".s = " + JSON.stringify(chunk.entryModule.id) + ");");
			}
			return this.asString(buf);
		});
		this.plugin("render", (bootstrapSource, chunk, hash, moduleTemplate, dependencyTemplates) => {
			const source = new ConcatSource();
			source.add("/******/ (function(modules) { // webpackBootstrap\n");
			source.add(new PrefixSource("/******/", bootstrapSource));
			source.add("/******/ })\n");
			source.add("/************************************************************************/\n");
			source.add("/******/ (");
			const modules = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates, "/******/ ");
			source.add(this.applyPluginsWaterfall("modules", modules, chunk, hash, moduleTemplate, dependencyTemplates));
			source.add(")");
			return source;
		});
		this.plugin("local-vars", (source, chunk, hash) => {
			return this.asString([
				source,
				"// The module cache",
				"var installedModules = {};"
			]);
		});
		this.plugin("require", (source, chunk, hash) => {
			return this.asString([
				source,
				"// Check if module is in cache",
				"if(installedModules[moduleId])",
				this.indent("return installedModules[moduleId].exports;"),
				"",
				"// Create a new module (and put it into the cache)",
				"var module = installedModules[moduleId] = {",
				this.indent(this.applyPluginsWaterfall("module-obj", "", chunk, hash, "moduleId")),
				"};",
				"",
				this.asString(outputOptions.strictModuleExceptionHandling ? [
					"// Execute the module function",
					"var threw = true;",
					"try {",
					this.indent([
						"modules[moduleId].call(module.exports, module, module.exports, " + this.renderRequireFunctionForModule(hash, chunk, "moduleId") + ");",
						"threw = false;"
					]),
					"} finally {",
					this.indent([
						"if(threw) delete installedModules[moduleId];"
					]),
					"}"
				] : [
					"// Execute the module function",
					"modules[moduleId].call(module.exports, module, module.exports, " + this.renderRequireFunctionForModule(hash, chunk, "moduleId") + ");",
				]),
				"",
				"// Flag the module as loaded",
				"module.l = true;",
				"",
				"// Return the exports of the module",
				"return module.exports;"
			]);
		});
		this.plugin("module-obj", (source, chunk, hash, varModuleId) => {
			return this.asString([
				"i: moduleId,",
				"l: false,",
				"exports: {}"
			]);
		});
		this.plugin("require-extensions", (source, chunk, hash) => {
			const buf = [];
			if(chunk.chunks.length > 0) {
				buf.push("// This file contains only the entry chunk.");
				buf.push("// The chunk loading function for additional chunks");
				buf.push(this.requireFn + ".e = function requireEnsure(chunkId) {");
				buf.push(this.indent(this.applyPluginsWaterfall("require-ensure", "throw new Error('Not chunk loading available');", chunk, hash, "chunkId")));
				buf.push("};");
			}
			buf.push("");
			buf.push("// expose the modules object (__webpack_modules__)");
			buf.push(this.requireFn + ".m = modules;");

			buf.push("");
			buf.push("// expose the module cache");
			buf.push(this.requireFn + ".c = installedModules;");

			buf.push("");
			buf.push("// identity function for calling harmony imports with the correct context");
			buf.push(this.requireFn + ".i = function(value) { return value; };");

			buf.push("");
			buf.push("// define getter function for harmony exports");
			buf.push(this.requireFn + ".d = function(exports, name, getter) {");
			buf.push(this.indent([
				"if(!" + this.requireFn + ".o(exports, name)) {",
				this.indent([
					"Object.defineProperty(exports, name, {",
					this.indent([
						"configurable: false,",
						"enumerable: true,",
						"get: getter"
					]),
					"});"
				]),
				"}"
			]));
			buf.push("};");

			buf.push("");
			buf.push("// getDefaultExport function for compatibility with non-harmony modules");
			buf.push(this.requireFn + ".n = function(module) {");
			buf.push(this.indent([
				"var getter = module && module.__esModule ?",
				this.indent([
					"function getDefault() { return module['default']; } :",
					"function getModuleExports() { return module; };"
				]),
				this.requireFn + ".d(getter, 'a', getter);",
				"return getter;"
			]));
			buf.push("};");

			buf.push("");
			buf.push("// Object.prototype.hasOwnProperty.call");
			buf.push(this.requireFn + ".o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };");

			const publicPath = this.getPublicPath({
				hash: hash
			});
			buf.push("");
			buf.push("// __webpack_public_path__");
			buf.push(this.requireFn + ".p = " + JSON.stringify(publicPath) + ";");
			return this.asString(buf);
		});

		this.requireFn = "__webpack_require__";
	}

	render(hash, chunk, moduleTemplate, dependencyTemplates) {
		const buf = [];
		buf.push(this.applyPluginsWaterfall("bootstrap", "", chunk, hash, moduleTemplate, dependencyTemplates));
		buf.push(this.applyPluginsWaterfall("local-vars", "", chunk, hash));
		buf.push("");
		buf.push("// The require function");
		buf.push("function " + this.requireFn + "(moduleId) {");
		buf.push(this.indent(this.applyPluginsWaterfall("require", "", chunk, hash)));
		buf.push("}");
		buf.push("");
		buf.push(this.asString(this.applyPluginsWaterfall("require-extensions", "", chunk, hash)));
		buf.push("");
		buf.push(this.asString(this.applyPluginsWaterfall("startup", "", chunk, hash)));
		let source = this.applyPluginsWaterfall("render", new OriginalSource(this.prefix(buf, " \t") + "\n", "webpack/bootstrap " + hash), chunk, hash, moduleTemplate, dependencyTemplates);
		if(chunk.hasEntryModule()) {
			source = this.applyPluginsWaterfall("render-with-entry", source, chunk, hash);
		}
		if(!source) throw new Error("Compiler error: MainTemplate plugin 'render' should return something");
		chunk.rendered = true;
		return new ConcatSource(source, ";");
	}

	renderRequireFunctionForModule(hash, chunk, varModuleId) {
		return this.applyPluginsWaterfall("module-require", this.requireFn, chunk, hash, varModuleId);
	}

	renderAddModule(hash, chunk, varModuleId, varModule) {
		return this.applyPluginsWaterfall("add-module", "modules[" + varModuleId + "] = " + varModule + ";", chunk, hash, varModuleId, varModule);
	}

	renderCurrentHashCode(hash, length) {
		length = length || Infinity;
		return this.applyPluginsWaterfall("current-hash", JSON.stringify(hash.substr(0, length)), length);
	}

	entryPointInChildren(chunk) {
		const checkChildren = (chunk, alreadyCheckedChunks) => {
			return chunk.chunks.some((child) => {
				if(alreadyCheckedChunks.indexOf(child) >= 0) return;
				alreadyCheckedChunks.push(child);
				return child.hasEntryModule() || checkChildren(child, alreadyCheckedChunks);
			});
		};
		return checkChildren(chunk, []);
	}

	getPublicPath(options) {
		return this.applyPluginsWaterfall("asset-path", this.outputOptions.publicPath || "", options);
	}

	updateHash(hash) {
		hash.update("maintemplate");
		hash.update("3");
		hash.update(this.outputOptions.publicPath + "");
		this.applyPlugins("hash", hash);
	}

	updateHashForChunk(hash, chunk) {
		this.updateHash(hash);
		this.applyPlugins("hash-for-chunk", hash, chunk);
	}

	useChunkHash(chunk) {
		const paths = this.applyPluginsWaterfall("global-hash-paths", []);
		return !this.applyPluginsBailResult("global-hash", chunk, paths);
	}
};
<|endoftext|>


<commit_before>/*
MicroManager

Handles integration to Taaspace and higher level events such as tap event.

Keep all taaspace-related stuff in MicroManager
Keep MicroRecognizer compatible with all html elements.
*/
var MicroRecognizer = require('./MicroRecognizer')
var utils = require('./utils')
var taaspace = require('taaspace')

var toRawPivot = function (mode, transformer, view) {
  // The pivot needs to be converted to [x, y]
  // on the same coordinate system as the touch points (view).
  if (mode.pivot) {
    return mode.pivot.to(view).toArray()
  }

  // Use middle of transformer as a default pivot if translation not allowed.
  if (mode.translate === false) {
    return transformer.atMid().to(view).toArray()
  }

  // Return undefined so that when rawPivot is given as a parameter
  // it looks like the parameter was not given. TODO HUH?
}

var toSpaceEvent = function (ev, view) {
  // Turn recognizer events to Taaspace compatible events.
  //
  // Parameters:
  //   ev
  //     event from MicroRecognizer
  //   view
  //     taaspace.HTMLSpaceView
  return {
    duration: ev.duration,
    totalTrans: new taaspace.InvariantTransform(ev.totaltrans, view),
    microTrans: new taaspace.InvariantTransform(ev.microtrans, view),
    totalTravel: ev.totaltravel
  }
}

var MicroManager = function (element, transformer, view, emitter, mode) {
  // Create a MicroManager
  //   var man = new MicroManager(...)
  //
  // Parameters:
  //   element
  //     HTML element to listen to
  //   transformer
  //     a taaspace.SpaceTransformer, the object to move
  //   view
  //     a taaspace.SpaceViewHTML
  //   emitter
  //     public emitter the user listens to
  //   type
  //     transformation type
  //   pivot
  //     a taaspace.InvariantVector

  var self = this

  this.mode = mode
  this.transformer = transformer
  this.view = view

  // Convert mode options for the Taaspace-agnostic MicroRecognizer
  var type = utils.convertToTransformationType(mode)
  var rawPivot = toRawPivot(this.mode, this.transformer, this.view)
  this.recognizer = new MicroRecognizer(element, type, rawPivot)

  // // We "lift" the SpaceTransformer and therefore have to remember things.
  // originalParent = null;

  this.recognizer.on('transformstart', function (event) {
    // Store original parent so we can return spacetaa onto it after gesture.
    // TODO implement so that parent does not need to change.
    //      It can be done by computing view transformation as done here
    //      but then using setGlobalTransform.
    // TODO prepare for views, so that the effective transformation on views
    //      is inverted.

    // originalParent = transformer.getParent();
    //
    // if (self.view !== self.transformer) {
    //   // Change parent to view => not dependent on how view is transformed.
    //   // This keeps transformer location the same in relation to the view.
    //   // As a goal, transforming the view with other fingers does not
    //   // move the transformer away from the gripping finger.
    //   var t = transformer.getGlobalTransform();
    //   transformer.setParent(view);
    //   transformer.setGlobalTransform(t);
    // }

    emitter.emit('transformstart', toSpaceEvent(event, self.view))
  })

  this.recognizer.on('transformmove', function (event) {
    // A safety feature to protect from invalid TouchAPI implementations.
    // Also, root space nodes (parent === null) cannot be transformed.
    // if (originalParent === null) { return }

    var spaceEvent = toSpaceEvent(event, self.view)

    // Apply to transformer
    if (self.view === self.transformer) {
      transformer.transformBy(spaceEvent.microTrans.inverse())
    } else {
      transformer.transformBy(spaceEvent.microTrans)
    }

    emitter.emit('transformmove', spaceEvent)
  })

  // Do we need handling of cancel?
  // r.on('transformcancel', function (event) {
  //  emitter.emit('transformcancel') if applicable
  //  emitter.emit('presscancel') if applicable
  // });

  this.recognizer.on('transformend', function (event) {
    // var t, spaceEvent
    //
    // if (self.mode.view === false) {
    //   // Drop back to original parent.
    //   t = transformer.getGlobalTransform();
    //   transformer.setParent(originalParent);
    //   transformer.setGlobalTransform(t);
    //   // We do not need the initial transformation and parent anymore.
    // }
    // originalParent = null;

    var spaceEvent = toSpaceEvent(event, self.view)

    emitter.emit('transformend', spaceEvent)

    if (self.mode.tap && event.totaltravel < self.mode.tapMaxTravel) {
      emitter.emit('tap', spaceEvent)
    }
  })
}

MicroManager.prototype.update = function (mode) {
  var type, rawPivot

  this.mode = mode

  type = utils.convertToTransformationType(this.mode)
  this.recognizer.setType(type)

  rawPivot = toRawPivot(this.mode, this.transformer, this.view)
  this.recognizer.setPivot(rawPivot)
}

MicroManager.prototype.destroy = function () {
  this.recognizer.destroy()
}

module.exports = MicroManager
<commit_msg>Improve comments.<commit_after>/*
MicroManager

Handles integration to Taaspace and higher level events such as tap event.

Keep all taaspace-related stuff in MicroManager
Keep MicroRecognizer compatible with all html elements.
*/
var MicroRecognizer = require('./MicroRecognizer')
var utils = require('./utils')
var taaspace = require('taaspace')

var toRawPivot = function (mode, transformer, view) {
  // The pivot needs to be converted to [x, y]
  // on the same coordinate system as the touch points (view).
  //
  if (mode.pivot) {
    return mode.pivot.to(view).toArray()
  }

  // Use middle of transformer as a default pivot if translation not allowed.
  if (mode.translate === false) {
    return transformer.atMid().to(view).toArray()
  }

  // Return undefined so that when rawPivot is given as a parameter
  // to MicroRecognizer, it looks like the parameter was not given.
}

var toSpaceEvent = function (ev, view) {
  // Turn recognizer events to Taaspace compatible events.
  //
  // Parameters:
  //   ev
  //     event from MicroRecognizer
  //   view
  //     taaspace.HTMLSpaceView
  return {
    duration: ev.duration,
    totalTrans: new taaspace.InvariantTransform(ev.totaltrans, view),
    microTrans: new taaspace.InvariantTransform(ev.microtrans, view),
    totalTravel: ev.totaltravel
  }
}

var MicroManager = function (element, transformer, view, emitter, mode) {
  // Create a MicroManager
  //   var man = new MicroManager(...)
  //
  // Parameters:
  //   element
  //     HTML element to listen to
  //   transformer
  //     a taaspace.SpaceTransformer, the object to move
  //   view
  //     a taaspace.SpaceViewHTML
  //   emitter
  //     public emitter the user listens to
  //   type
  //     transformation type
  //   pivot
  //     a taaspace.InvariantVector

  var self = this

  this.mode = mode
  this.transformer = transformer
  this.view = view

  // Convert mode options for the Taaspace-agnostic MicroRecognizer
  var type = utils.convertToTransformationType(mode)
  var rawPivot = toRawPivot(this.mode, this.transformer, this.view)
  this.recognizer = new MicroRecognizer(element, type, rawPivot)

  // // We "lift" the SpaceTransformer and therefore have to remember things.
  // originalParent = null;

  this.recognizer.on('transformstart', function (event) {
    // Store original parent so we can return spacetaa onto it after gesture.
    // TODO implement so that parent does not need to change.
    //      It can be done by computing view transformation as done here
    //      but then using setGlobalTransform.
    // TODO prepare for views, so that the effective transformation on views
    //      is inverted.

    // originalParent = transformer.getParent();
    //
    // if (self.view !== self.transformer) {
    //   // Change parent to view => not dependent on how view is transformed.
    //   // This keeps transformer location the same in relation to the view.
    //   // As a goal, transforming the view with other fingers does not
    //   // move the transformer away from the gripping finger.
    //   var t = transformer.getGlobalTransform();
    //   transformer.setParent(view);
    //   transformer.setGlobalTransform(t);
    // }

    emitter.emit('transformstart', toSpaceEvent(event, self.view))
  })

  this.recognizer.on('transformmove', function (event) {
    // A safety feature to protect from invalid TouchAPI implementations.
    // Also, root space nodes (parent === null) cannot be transformed.
    // if (originalParent === null) { return }

    var spaceEvent = toSpaceEvent(event, self.view)

    // Apply to transformer
    if (self.view === self.transformer) {
      transformer.transformBy(spaceEvent.microTrans.inverse())
    } else {
      transformer.transformBy(spaceEvent.microTrans)
    }

    emitter.emit('transformmove', spaceEvent)
  })

  // Do we need handling of cancel?
  // r.on('transformcancel', function (event) {
  //  emitter.emit('transformcancel') if applicable
  //  emitter.emit('presscancel') if applicable
  // });

  this.recognizer.on('transformend', function (event) {
    // var t, spaceEvent
    //
    // if (self.mode.view === false) {
    //   // Drop back to original parent.
    //   t = transformer.getGlobalTransform();
    //   transformer.setParent(originalParent);
    //   transformer.setGlobalTransform(t);
    //   // We do not need the initial transformation and parent anymore.
    // }
    // originalParent = null;

    var spaceEvent = toSpaceEvent(event, self.view)

    emitter.emit('transformend', spaceEvent)

    if (self.mode.tap && event.totaltravel < self.mode.tapMaxTravel) {
      emitter.emit('tap', spaceEvent)
    }
  })
}

MicroManager.prototype.update = function (mode) {
  var type, rawPivot

  this.mode = mode

  type = utils.convertToTransformationType(this.mode)
  this.recognizer.setType(type)

  rawPivot = toRawPivot(this.mode, this.transformer, this.view)
  this.recognizer.setPivot(rawPivot)
}

MicroManager.prototype.destroy = function () {
  this.recognizer.destroy()
}

module.exports = MicroManager
<|endoftext|>


<commit_before>var limp = require('../limp');
var expect = require('expect');

describe("this.parallel()", function () {
  describe("is fine with", function () {
    it("2 sync", function (done) {
      limp(
        function () {
          this.parallel()(null, "foo");
          this.parallel()(null, "bar");
        },
        function (err, a, b) {
          if (err) { return done(err); }
          expect(a).toBe("foo");
          expect(b).toBe("bar");
          done();
        }
      );
    });

    it("2 async", function (done) {
      limp(
        function () {
          _delay(10, "foo", this.parallel());
          _delay(15, "bar", this.parallel());
        },
        function (err, a, b) {
          if (err) { return done(err); }
          expect(a).toBe("foo");
          expect(b).toBe("bar");
          done();
        }
      );
    });

    it("a sync then an async", function (done) {
      limp(
        function () {
          this.parallel()(null, "foo");
          _delay(15, "bar", this.parallel());
        },
        function (err, a, b) {
          if (err) { return done(err); }
          expect(a).toBe("foo");
          expect(b).toBe("bar");
          done();
        }
      );
    });

    it("an async then a sync", function (done) {
      limp(
        function () {
          _delay(10, { derp: "hi" }, this.parallel());
          this.parallel()(null, 3.14159);
        },
        function (err, a, b) {
          if (err) { return done(err); }
          expect(a).toEqual({ derp: "hi" });
          expect(b).toEqual(3.14159);
          done();
        }
      );
    });

    it("crazy timings", function (done) {
      limp(
        function () {
          _delay(10, 1, this.parallel());
          this.parallel()(null, 2);
          _delay(15, 3, this.parallel());
          this.parallel()(null, 4);
          _delay(0, 5, this.parallel());
          _delay(5, 6, this.parallel());
          this.parallel()(null, 7);
        },
        function (err, a, b, c, d, e, f, g) {
          if (err) { return done(err); }
          expect(a).toBe(1);
          expect(b).toBe(2);
          expect(c).toBe(3);
          expect(d).toBe(4);
          expect(e).toBe(5);
          expect(f).toBe(6);
          expect(g).toBe(7);
          done();
        }
      );
    });

    it("odd arguments", function (done) {
      limp(
        function () {
          this.parallel()(null, 1);
          this.parallel()();
          this.parallel()(null, 2);
        },
        function (err, a, b, c) {
          if (err) { return done(err); }
          expect(a).toBe(1);
          expect(b).toBe(undefined);
          expect(c).toBe(2);
          done();
        }
      );
    });

    it("single errors", function (done) {
      limp(
        function () {
          this.parallel()(null, "hello");
          this.parallel()(new Error("blah"));
        },
        function (err, a, b) {
          expect(err).toExist();
          expect(err.message).toBe("blah");

          expect(a).toBe("hello");
          expect(b).toBe(undefined);

          expect(this.errors[0]).toNotExist();
          expect(this.errors[1]).toExist();
          expect(this.errors[1].message).toBe("blah");

          done();
        }
      );
    });

    it("multi errors", function (done) {
      limp(
        function () {
          this.parallel()(new Error("derp"));
          this.parallel()(new Error("blah"));
        },
        function (err, a, b) {
          expect(err).toExist();
          expect(err.message).toBe("derp");

          expect(a).toBe(undefined);
          expect(b).toBe(undefined);

          expect(this.errors[0]).toExist();
          expect(this.errors[0].message).toBe("derp");
          expect(this.errors[1]).toExist();
          expect(this.errors[1].message).toBe("blah");

          done();
        }
      );
    });
  });

  describe("will reject", function () {
    it("a cb called twice", function (done) {
      limp(
        function () {
          var cb = this.parallel();
          cb();

          expect(function () {
            cb();
          }).toThrow(/called 2 times/i);

          done();
        }
      );
    });

    it("a cb created after the step", function (done) {
      limp(
        function () {
          var self = this;
          self.parallel();
          setTimeout(function () {
            expect(function () {
              self.parallel();
            }).toThrow(/after current step/i);
            done();
          }, 10);
        }
      );
    });

    it("use after a this.rest()", function (done) {
      limp(
        function () {
          var self = this;
          self.rest();

          expect(function () {
            self.parallel();
          }).toThrow(/used after this\.rest\(\)/i);

          done();
        }
      );
    });
  });

  describe("handles exceptions", function () {

    var mocha_handler;
    before(function () {
      mocha_handler = process.listeners('uncaughtException').shift();
      process.removeListener('uncaughtException', mocha_handler);
    });

    after(function () {
      process.on('uncaughtException', mocha_handler);
    });

    it("by NOT passing them along", function (done) {

      process.once('uncaughtException', function (err) {
        expect(err).toExist();
        expect(err.message).toBe("Derp");
        done();
      });

      limp(
        function () {
          throw new Error("Derp");
        },
        function (err) {
          done(new Error("Limp passed along an exception!"));
        }
      );
    });
  });

  describe("handles values returned", function () {
    it("by not passing them along", function (done) {
      limp(
        function () {
          return 42;
        },
        function (err, a) {
          expect(err).toNotExist();
          expect(a).toNotExist();
          done();
        }
      );
    });
  });
});

function _delay(ms, data, cb) {
  setTimeout(function () {
    cb(null, data);
  }, ms);
}
<commit_msg>Fixed this.parallel() test that depended on no callbacks meaning we can continue<commit_after>var limp = require('../limp');
var expect = require('expect');

describe("this.parallel()", function () {
  describe("is fine with", function () {
    it("2 sync", function (done) {
      limp(
        function () {
          this.parallel()(null, "foo");
          this.parallel()(null, "bar");
        },
        function (err, a, b) {
          if (err) { return done(err); }
          expect(a).toBe("foo");
          expect(b).toBe("bar");
          done();
        }
      );
    });

    it("2 async", function (done) {
      limp(
        function () {
          _delay(10, "foo", this.parallel());
          _delay(15, "bar", this.parallel());
        },
        function (err, a, b) {
          if (err) { return done(err); }
          expect(a).toBe("foo");
          expect(b).toBe("bar");
          done();
        }
      );
    });

    it("a sync then an async", function (done) {
      limp(
        function () {
          this.parallel()(null, "foo");
          _delay(15, "bar", this.parallel());
        },
        function (err, a, b) {
          if (err) { return done(err); }
          expect(a).toBe("foo");
          expect(b).toBe("bar");
          done();
        }
      );
    });

    it("an async then a sync", function (done) {
      limp(
        function () {
          _delay(10, { derp: "hi" }, this.parallel());
          this.parallel()(null, 3.14159);
        },
        function (err, a, b) {
          if (err) { return done(err); }
          expect(a).toEqual({ derp: "hi" });
          expect(b).toEqual(3.14159);
          done();
        }
      );
    });

    it("crazy timings", function (done) {
      limp(
        function () {
          _delay(10, 1, this.parallel());
          this.parallel()(null, 2);
          _delay(15, 3, this.parallel());
          this.parallel()(null, 4);
          _delay(0, 5, this.parallel());
          _delay(5, 6, this.parallel());
          this.parallel()(null, 7);
        },
        function (err, a, b, c, d, e, f, g) {
          if (err) { return done(err); }
          expect(a).toBe(1);
          expect(b).toBe(2);
          expect(c).toBe(3);
          expect(d).toBe(4);
          expect(e).toBe(5);
          expect(f).toBe(6);
          expect(g).toBe(7);
          done();
        }
      );
    });

    it("odd arguments", function (done) {
      limp(
        function () {
          this.parallel()(null, 1);
          this.parallel()();
          this.parallel()(null, 2);
        },
        function (err, a, b, c) {
          if (err) { return done(err); }
          expect(a).toBe(1);
          expect(b).toBe(undefined);
          expect(c).toBe(2);
          done();
        }
      );
    });

    it("single errors", function (done) {
      limp(
        function () {
          this.parallel()(null, "hello");
          this.parallel()(new Error("blah"));
        },
        function (err, a, b) {
          expect(err).toExist();
          expect(err.message).toBe("blah");

          expect(a).toBe("hello");
          expect(b).toBe(undefined);

          expect(this.errors[0]).toNotExist();
          expect(this.errors[1]).toExist();
          expect(this.errors[1].message).toBe("blah");

          done();
        }
      );
    });

    it("multi errors", function (done) {
      limp(
        function () {
          this.parallel()(new Error("derp"));
          this.parallel()(new Error("blah"));
        },
        function (err, a, b) {
          expect(err).toExist();
          expect(err.message).toBe("derp");

          expect(a).toBe(undefined);
          expect(b).toBe(undefined);

          expect(this.errors[0]).toExist();
          expect(this.errors[0].message).toBe("derp");
          expect(this.errors[1]).toExist();
          expect(this.errors[1].message).toBe("blah");

          done();
        }
      );
    });
  });

  describe("will reject", function () {
    it("a cb called twice", function (done) {
      limp(
        function () {
          var cb = this.parallel();
          cb();

          expect(function () {
            cb();
          }).toThrow(/called 2 times/i);

          done();
        }
      );
    });

    it("a cb created after the step", function (done) {
      limp(
        function () {
          var self = this;
          self.parallel();
          setTimeout(function () {
            expect(function () {
              self.parallel();
            }).toThrow(/after current step/i);
            done();
          }, 10);
        }
      );
    });

    it("use after a this.rest()", function (done) {
      limp(
        function () {
          var self = this;
          self.rest();

          expect(function () {
            self.parallel();
          }).toThrow(/used after this\.rest\(\)/i);

          done();
        }
      );
    });
  });

  describe("handles exceptions", function () {

    var mocha_handler;
    before(function () {
      mocha_handler = process.listeners('uncaughtException').shift();
      process.removeListener('uncaughtException', mocha_handler);
    });

    after(function () {
      process.on('uncaughtException', mocha_handler);
    });

    it("by NOT passing them along", function (done) {

      process.once('uncaughtException', function (err) {
        expect(err).toExist();
        expect(err.message).toBe("Derp");
        done();
      });

      limp(
        function () {
          throw new Error("Derp");
        },
        function (err) {
          done(new Error("Limp passed along an exception!"));
        }
      );
    });
  });

  describe("handles values returned", function () {
    it("by not passing them along", function (done) {
      limp(
        function () {
          return 42;
        },
        function (err, a) {
          done(new Error("Next stage entered"));
        }
      );
      _delay(15, null, done);
    });
  });
});

function _delay(ms, data, cb) {
  setTimeout(function () {
    cb(null, data);
  }, ms);
}
<|endoftext|>


<commit_before>(function() {
  var mode = CodeMirror.getMode({tabSize: 4}, "plantuml");
  function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "plantuml", highlightFormatting: true});
  function FT(name) {
  	//console.log("FT name="+name);
  	//console.log("FT mode="+mode);
  	//console.log("FT mode.startState="+mode.startState);
  	//console.log("FT arguments="+arguments);
  	//console.log("A="+modeHighlightFormatting);
  	//console.log("test.mode="+test.mode);
  	//console.log("FT Array.prototype.slice="+Array.prototype.slice.call(arguments, 1));

  	test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1));
  }

  MT("activityDiagram_example1",
     "[keyword @startuml]",
     "",
     "[keyword title][string  Activity Diagram ]",
     "",
     "",
     "[keyword start]",
     "",
     "[def :Eat Hot Wings;]",
     "",
     "[keyword note] [keyword left]",
     "[string This is a Note...]",
     "[string Activity diagrams can begin with a Start]",
     "[string An activity is colon, some words, and a semicolon]",
     "[string Activity diagrams can end with a stop]",
     "[keyword end note]",
     "",
     "[def :Drink Homebrew;]",
     "",
     "[keyword stop]",
     "",
     "[keyword @enduml]"
  );

  MT("activityDiagram_example2",
     "[keyword @startuml]",
     "",
     "[keyword title][string  Conditional - Activity Diagram]",
     "",
     "",
     "[keyword start]",
     "",
     "[def :Eat Hot Wings;]",
     "[keyword note] [keyword right][operator :][string  This is a note to the right]",
     "",
     "[def :Drink Homebrew;]",
     "[keyword note] [keyword left][operator :][string  This is a note to the left]",
     "",
     "[keyword if] [string (Turn On The Game?)] [keyword then] [string (yes)]",
     "  [def :__Having Fun__!!!;]",
     "[keyword else] [string (no)]",
     "  [def :Not Having Fun;]",
     "[keyword endif]",
     "",
     "[def :Go To Bed;]",
     "",
     "[keyword stop]",
     "",
     "[keyword @enduml]"
  );

  MT("note_with_formatting",
    "[keyword note] [keyword right]",
    "[string This note is on several lines]",
    "[operator ....]",
    "[operator //][string This line is in italics][operator //]",
    "[operator ----]",
    "[string This one contains som HTML]",
    "[operator ====]",
    "[operator *][string This line contains a bullet]",
    "[operator ____]",
    "[operator \"\"][string This line is in code block][operator \"\"]",
    "[keyword end note]"
  );

  MT("repeat_block",
    "[keyword repeat]",
    "[def :Eat Hot Wings;]",
    "[def :Drink Homebrew;]",
    "[keyword repeat] [keyword while] [string (Still Hungry?)]"
  );

  MT("while_loop",
    "[keyword while] [string (Hungry?)]  [keyword is] [string (Yes)]",
    "    [def :Eat Hot Wings;]",
    "    [def :Drink Homebrew;]",
    "[keyword endwhile] [string (No)]"
  );

  MT("fork_join",
    "[keyword if] [string (Turn On The Game?)] [keyword then] [string (yes)]",
    "    [keyword fork]",
    "        [def :__Having Fun__!!!;]",
    "    [keyword fork] [keyword again]",
    "        [def :Scream At TV!!;]",
    "    [keyword end] [keyword fork]",
    "[keyword else] [string (no)]",
    "    [def :Not Having Fun;]",
    "    [def :Eat Poptart;]",
    "[keyword endif]"
  );

  MT("colors",
    "[keyword skinparam] [attribute backgroundColor] [atom #AAAAAA]",
    "[keyword skinparam] [keyword activity] [bracket {]",
    "  [attribute StartColor] [atom Blue]",
    "  [attribute EndColor] [atom Red]",
    "  [attribute BackgroundColor] [atom Green]",
    "  [attribute BorderColor] [atom Yellow]",
    "[bracket }]"
  );

  MT("classes_firstExample",
    "[keyword class] [def Dwelling] [bracket {]",
    "  [attribute +][builtin Int] [def Windows]",
    "  [attribute +][keyword void] [def Lock][operator ()]",
    "[bracket }]",
    "",
    "[keyword class] [def Apartment]",
    "[keyword class] [def House]",
    "[keyword class] [def Commune]"
  );

  MT("classdiagram_relationships",
    "[variable Dwelling] [operator <|-down-] [variable Apartment][operator :] [keyword Inheritance]",
    "[variable Dwelling] [operator <|-down-] [variable Commune][operator :] [keyword Inheritance]",
    "[variable Dwelling] [operator <|-down-] [variable House][operator :] [keyword Inheritance]",
    "[variable Dwelling] [string \"1\"] [operator *-up-] [string \"many\"] [variable Window][operator :] [keyword Composition]",
    "[variable Dwelling] [string \"1\"] [operator *-up-] [string \"many\"] [variable Door][operator :] [keyword Composition]"
  );

  MT("style_for_class",
    "[keyword skinparam] [keyword componentStyle] [keyword uml2]"
  );

  MT("abstract_class",
    "[keyword abstract] [keyword class] [def AbstractList] [bracket {]",
    "",
    "[bracket }]"
  );

  MT("class_with_stereotype",
    "[keyword class] [def Test] << [variable general] >> [bracket {]",
    "[bracket }]"
  );

  MT("style_on_stereotype",
    "[keyword class] [def System] << ([string S],[atom #FF7700]) [variable Singleton] >>"
  );

  MT("multiple_stereotypes",
    "[keyword class] [def Date] << ([string D],[atom orchid]) >>"
  );

  MT("content_of_class",
    "[keyword class] [def Foo1][string <Generics tag>] [bracket {]",
    "You can use",
    "several lines",
    "[operator ..]",
    "as you want",
    "and group",
    "[operator ==]",
    "things together.",
    "[operator __]",
    "You can have as many groups",
    "as you want",
    "[operator --]",
    "End of class",
    "[bracket }]"
  );

  MT("class_with_methods",
    "[keyword class] [def User] [bracket {]",
    "[operator ..][string  Simple Getter ][operator ..]",
    "[attribute +] [def getName][operator ()] [operator :] [variable String]",
    "[attribute +] [def getAddress][operator ()] [operator :] [variable Address]",
    "[operator ..][string  Some setter ][operator ..]",
    "[attribute +] [def setName][operator ()] [operator :] [variable String]",
    "[operator __][string  private data ][operator __]",
    "[attribute -][builtin int] [def age]",
    "[operator --][string  crypted ][operator --]",
    "[attribute -][variable String] [def password]",
    "[bracket }]"
  );

  MT("enum",
    "[keyword enum] [def TimeUnit] [bracket {]",
    "  [def DAYS]",
    "  [def HOURS]",
    "  [def MINUTES]",
    "[bracket }]"
  );

  MT("interface",
    "[keyword interface] [def List] [bracket {]",
    "[bracket }]"
  );

  MT("annotation",
    "[keyword annotation] [def SuppressWarnings]"
  );

  MT("class_inline_with_stereotype",
    "[keyword class] [def Object] << [variable general] >>"
  );

  MT("extension_relation",
    "[variable Object] [operator <|---] [variable ArrayList]"
  );

  MT("title with a slash",
    "[keyword title][string Properties / Methods - Class Diagram]"
  );

  MT("advanced class fields",
    "[keyword class] [def Car] [bracket {]",
    "  [operator ..][string Field Examples ][operator ..]",
    "  [attribute -][def Name][operator :] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute +][def Name][operator :] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute #][def Name][operator :] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute ~][def Name][operator :] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]"
  );

  MT("advanced class methods",
    "[keyword class] [def Car] [bracket {]",
    "  [operator ..][string Method Examples ][operator ..]",
    "  [attribute -][def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute +][def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute #][def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute ~][def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]"
  );

  MT("static class methods",
    "[keyword class] [def Car] [bracket {]",
    "  [operator ..][string Method Examples ][operator ..]",
    "  [attribute +][keyword {static}] [def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]"
  );

  MT("abstract class methods",
    "[keyword class] [def Car] [bracket {]",
    "  [operator ..][string Method Examples ][operator ..]",
    "  [attribute +][keyword {abstract}] [def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]"
  );
/*

/*

class Car
ICar ()- Car
ICar2 ()-- Car
Car -() ICar3

@enduml
*/

/*
@startuml

title Interfaces - Class Diagram

class Car
ICar ()- Car
ICar2 ()-- Car
Car -() ICar3

@enduml
*/

/*
@startuml

title Packages - Class Diagram

package Node <<[builtin Node]>> {
  class Worker1
}

package Rectangle <<[builtin Rect]>> {
  class Worker2
}

package Folder <<[builtin Folder]>> {
  class Worker3
}

package Frame <<[builtin Frame]>> {
  class Worker4
}

package Internet <<[builtin Cloud]>> {
  class Worker5
}

package Database <<[builtin Database]>> {
  class Worker6
}

@enduml
*/

})();<commit_msg>Adding remaining tests for the class diagrams<commit_after>(function() {
  var mode = CodeMirror.getMode({tabSize: 4}, "plantuml");
  function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "plantuml", highlightFormatting: true});
  function FT(name) {
  	//console.log("FT name="+name);
  	//console.log("FT mode="+mode);
  	//console.log("FT mode.startState="+mode.startState);
  	//console.log("FT arguments="+arguments);
  	//console.log("A="+modeHighlightFormatting);
  	//console.log("test.mode="+test.mode);
  	//console.log("FT Array.prototype.slice="+Array.prototype.slice.call(arguments, 1));

  	test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1));
  }

  MT("activityDiagram_example1",
     "[keyword @startuml]",
     "",
     "[keyword title][string  Activity Diagram ]",
     "",
     "",
     "[keyword start]",
     "",
     "[def :Eat Hot Wings;]",
     "",
     "[keyword note] [keyword left]",
     "[string This is a Note...]",
     "[string Activity diagrams can begin with a Start]",
     "[string An activity is colon, some words, and a semicolon]",
     "[string Activity diagrams can end with a stop]",
     "[keyword end note]",
     "",
     "[def :Drink Homebrew;]",
     "",
     "[keyword stop]",
     "",
     "[keyword @enduml]"
  );

  MT("activityDiagram_example2",
     "[keyword @startuml]",
     "",
     "[keyword title][string  Conditional - Activity Diagram]",
     "",
     "",
     "[keyword start]",
     "",
     "[def :Eat Hot Wings;]",
     "[keyword note] [keyword right][operator :][string  This is a note to the right]",
     "",
     "[def :Drink Homebrew;]",
     "[keyword note] [keyword left][operator :][string  This is a note to the left]",
     "",
     "[keyword if] [string (Turn On The Game?)] [keyword then] [string (yes)]",
     "  [def :__Having Fun__!!!;]",
     "[keyword else] [string (no)]",
     "  [def :Not Having Fun;]",
     "[keyword endif]",
     "",
     "[def :Go To Bed;]",
     "",
     "[keyword stop]",
     "",
     "[keyword @enduml]"
  );

  MT("note_with_formatting",
    "[keyword note] [keyword right]",
    "[string This note is on several lines]",
    "[operator ....]",
    "[operator //][string This line is in italics][operator //]",
    "[operator ----]",
    "[string This one contains som HTML]",
    "[operator ====]",
    "[operator *][string This line contains a bullet]",
    "[operator ____]",
    "[operator \"\"][string This line is in code block][operator \"\"]",
    "[keyword end note]"
  );

  MT("repeat_block",
    "[keyword repeat]",
    "[def :Eat Hot Wings;]",
    "[def :Drink Homebrew;]",
    "[keyword repeat] [keyword while] [string (Still Hungry?)]"
  );

  MT("while_loop",
    "[keyword while] [string (Hungry?)]  [keyword is] [string (Yes)]",
    "    [def :Eat Hot Wings;]",
    "    [def :Drink Homebrew;]",
    "[keyword endwhile] [string (No)]"
  );

  MT("fork_join",
    "[keyword if] [string (Turn On The Game?)] [keyword then] [string (yes)]",
    "    [keyword fork]",
    "        [def :__Having Fun__!!!;]",
    "    [keyword fork] [keyword again]",
    "        [def :Scream At TV!!;]",
    "    [keyword end] [keyword fork]",
    "[keyword else] [string (no)]",
    "    [def :Not Having Fun;]",
    "    [def :Eat Poptart;]",
    "[keyword endif]"
  );

  MT("colors",
    "[keyword skinparam] [attribute backgroundColor] [atom #AAAAAA]",
    "[keyword skinparam] [keyword activity] [bracket {]",
    "  [attribute StartColor] [atom Blue]",
    "  [attribute EndColor] [atom Red]",
    "  [attribute BackgroundColor] [atom Green]",
    "  [attribute BorderColor] [atom Yellow]",
    "[bracket }]"
  );

  MT("classes_firstExample",
    "[keyword class] [def Dwelling] [bracket {]",
    "  [attribute +][builtin Int] [def Windows]",
    "  [attribute +][keyword void] [def Lock][operator ()]",
    "[bracket }]",
    "",
    "[keyword class] [def Apartment]",
    "[keyword class] [def House]",
    "[keyword class] [def Commune]"
  );

  MT("classdiagram_relationships",
    "[variable Dwelling] [operator <|-down-] [variable Apartment][operator :] [keyword Inheritance]",
    "[variable Dwelling] [operator <|-down-] [variable Commune][operator :] [keyword Inheritance]",
    "[variable Dwelling] [operator <|-down-] [variable House][operator :] [keyword Inheritance]",
    "[variable Dwelling] [string \"1\"] [operator *-up-] [string \"many\"] [variable Window][operator :] [keyword Composition]",
    "[variable Dwelling] [string \"1\"] [operator *-up-] [string \"many\"] [variable Door][operator :] [keyword Composition]"
  );

  MT("style_for_class",
    "[keyword skinparam] [keyword componentStyle] [keyword uml2]"
  );

  MT("abstract_class",
    "[keyword abstract] [keyword class] [def AbstractList] [bracket {]",
    "",
    "[bracket }]"
  );

  MT("class_with_stereotype",
    "[keyword class] [def Test] << [variable general] >> [bracket {]",
    "[bracket }]"
  );

  MT("style_on_stereotype",
    "[keyword class] [def System] << ([string S],[atom #FF7700]) [variable Singleton] >>"
  );

  MT("multiple_stereotypes",
    "[keyword class] [def Date] << ([string D],[atom orchid]) >>"
  );

  MT("content_of_class",
    "[keyword class] [def Foo1][string <Generics tag>] [bracket {]",
    "You can use",
    "several lines",
    "[operator ..]",
    "as you want",
    "and group",
    "[operator ==]",
    "things together.",
    "[operator __]",
    "You can have as many groups",
    "as you want",
    "[operator --]",
    "End of class",
    "[bracket }]"
  );

  MT("class_with_methods",
    "[keyword class] [def User] [bracket {]",
    "[operator ..][string  Simple Getter ][operator ..]",
    "[attribute +] [def getName][operator ()] [operator :] [variable String]",
    "[attribute +] [def getAddress][operator ()] [operator :] [variable Address]",
    "[operator ..][string  Some setter ][operator ..]",
    "[attribute +] [def setName][operator ()] [operator :] [variable String]",
    "[operator __][string  private data ][operator __]",
    "[attribute -][builtin int] [def age]",
    "[operator --][string  crypted ][operator --]",
    "[attribute -][variable String] [def password]",
    "[bracket }]"
  );

  MT("enum",
    "[keyword enum] [def TimeUnit] [bracket {]",
    "  [def DAYS]",
    "  [def HOURS]",
    "  [def MINUTES]",
    "[bracket }]"
  );

  MT("interface",
    "[keyword interface] [def List] [bracket {]",
    "[bracket }]"
  );

  MT("annotation",
    "[keyword annotation] [def SuppressWarnings]"
  );

  MT("class_inline_with_stereotype",
    "[keyword class] [def Object] << [variable general] >>"
  );

  MT("extension_relation",
    "[variable Object] [operator <|---] [variable ArrayList]"
  );

  MT("title with a slash",
    "[keyword title][string Properties / Methods - Class Diagram]"
  );

  MT("advanced class fields",
    "[keyword class] [def Car] [bracket {]",
    "  [operator ..][string Field Examples ][operator ..]",
    "  [attribute -][def Name][operator :] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute +][def Name][operator :] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute #][def Name][operator :] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute ~][def Name][operator :] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]"
  );

  MT("advanced class methods",
    "[keyword class] [def Car] [bracket {]",
    "  [operator ..][string Method Examples ][operator ..]",
    "  [attribute -][def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute +][def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute #][def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]",
    "  [attribute ~][def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]"
  );

  MT("static class methods",
    "[keyword class] [def Car] [bracket {]",
    "  [operator ..][string Method Examples ][operator ..]",
    "  [attribute +][keyword {static}] [def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]"
  );

  MT("abstract class methods",
    "[keyword class] [def Car] [bracket {]",
    "  [operator ..][string Method Examples ][operator ..]",
    "  [attribute +][keyword {abstract}] [def Name][operator ():] [variable Type] [bracket {] [variable arg1], [variable arg2], [variable argn] [bracket }]"
  );

  MT("interfaces examples",
    "[keyword class] [def Car]",
    "[variable ICar] [operator ()-] [variable Car]",
    "[variable ICar2] [operator ()--] [variable Car]",
    "[variable Car] [operator -()] [variable ICar3]"
  );

  MT("node package",
    "[keyword package] [def Node] <<[builtin Node]>> [bracket {]",
    "    [keyword class] [def Worker1]",
    "[bracket }]"
  );

  MT("rect package",
    "[keyword package] [def Node] <<[builtin Rect]>> [bracket {]",
    "    [keyword class] [def Worker1]",
    "[bracket }]"
  );

  MT("folder package",
    "[keyword package] [def Node] <<[builtin Folder]>> [bracket {]",
    "    [keyword class] [def Worker1]",
    "[bracket }]"
  );

  MT("frame package",
    "[keyword package] [def Node] <<[builtin Frame]>> [bracket {]",
    "    [keyword class] [def Worker1]",
    "[bracket }]"
  );

  MT("cloud package",
    "[keyword package] [def Node] <<[builtin Cloud]>> [bracket {]",
    "    [keyword class] [def Worker1]",
    "[bracket }]"
  );

  MT("database package",
    "[keyword package] [def Node] <<[builtin Database]>> [bracket {]",
    "    [keyword class] [def Worker1]",
    "[bracket }]"
  );

})();<|endoftext|>


<commit_before>var test = require('tape')
  , assert = require('assert')
  , stream = require('stream')

var response = require('../lib/responses')

test('verify json response', verify_json_response)

function verify_json_response(assert) {
  var res = {}

  res.writeHead = function(status, headers) {
    assert.strictEqual(status, 200)
    assert.deepEqual(headers, {'Content-Type': 'application/json'})
  }

  res.write = function(data) {
    assert.strictEqual(data, '{"arbitrary": "data"}')
  }

  res.end = function() {
    assert.end()
  }

  response.json(null, res, 200, '{"arbitrary": "data"}')
}

test('verify unauthorized', verify_error_response)

function verify_error_response(assert) {
  var res = {}

  res.writeHead = function(status, headers) {
    assert.strictEqual(status, 401)
    assert.deepEqual(headers, {'Content-Type': 'application/json'})
  }

  res.write = function(data) {
    assert.strictEqual(data, JSON.stringify({
        error: 'unauthorized'
      , reason: 'Name or password is incorrect.'
    }))
  }

  res.end = function() {
    assert.end()
  }

  response.unauthorized(null, res)
}

test('verify not found', function(assert) {
  var res = {}

  res.writeHead = function(status, headers) {
    assert.strictEqual(status, 404)
    assert.deepEqual(headers, {'Content-Type': 'application/json'})
  }

  res.write = function(data) {
    assert.strictEqual(data, JSON.stringify({
        error: 'not_found'
      , reason: 'Document not found.'
    }))
  }

  res.end = function() {
    assert.end()
  }

  response.not_found(null, res)
})

test('verify conflict', function(assert) {
  var res = {}

  res.writeHead = function(status, headers) {
    assert.strictEqual(status, 409)
    assert.deepEqual(headers, {'Content-Type': 'application/json'})
  }

  res.write = function(data) {
    assert.strictEqual(data, JSON.stringify({
        error: 'conflict'
      , reason: 'Document update conflict.'
    }))
  }

  res.end = function() {
    assert.end()
  }

  response.conflict(null, res)
})

test('verify 500', function(assert) {
  var res = {}

  res.writeHead = function(status) {
    assert.equal(status, 500)
  }

  res.write = function(data) {
    assert.strictEqual('Something went wrong.', data)
  }

  res.end = function() {
    assert.end()
  }

  response.on_error(null, res)
})
<commit_msg>style<commit_after>var test = require('tape')

var response = require('../lib/responses')

test('verify json response', verify_json_response)

function verify_json_response(assert) {
  var res = {}

  res.writeHead = function(status, headers) {
    assert.strictEqual(status, 200)
    assert.deepEqual(headers, {'Content-Type': 'application/json'})
  }

  res.write = function(data) {
    assert.strictEqual(data, '{"arbitrary": "data"}')
  }

  res.end = function() {
    assert.end()
  }

  response.json(null, res, 200, '{"arbitrary": "data"}')
}

test('verify unauthorized', verify_error_response)

function verify_error_response(assert) {
  var res = {}

  res.writeHead = function(status, headers) {
    assert.strictEqual(status, 401)
    assert.deepEqual(headers, {'Content-Type': 'application/json'})
  }

  res.write = function(data) {
    assert.strictEqual(data, JSON.stringify({
        error: 'unauthorized'
      , reason: 'Name or password is incorrect.'
    }))
  }

  res.end = function() {
    assert.end()
  }

  response.unauthorized(null, res)
}

test('verify not found', function(assert) {
  var res = {}

  res.writeHead = function(status, headers) {
    assert.strictEqual(status, 404)
    assert.deepEqual(headers, {'Content-Type': 'application/json'})
  }

  res.write = function(data) {
    assert.strictEqual(data, JSON.stringify({
        error: 'not_found'
      , reason: 'Document not found.'
    }))
  }

  res.end = function() {
    assert.end()
  }

  response.not_found(null, res)
})

test('verify conflict', verify_conflict)

function verify_conflict(assert) {
  var res = {}

  res.writeHead = function(status, headers) {
    assert.strictEqual(status, 409)
    assert.deepEqual(headers, {'Content-Type': 'application/json'})
  }

  res.write = function(data) {
    assert.strictEqual(data, JSON.stringify({
        error: 'conflict'
      , reason: 'Document update conflict.'
    }))
  }

  res.end = function() {
    assert.end()
  }

  response.conflict(null, res)
})

test('verify 500', verify_500)

function verify_500(assert) {
  var res = {}

  res.writeHead = function(status) {
    assert.equal(status, 500)
  }

  res.write = function(data) {
    assert.strictEqual('Something went wrong.', data)
  }

  res.end = function() {
    assert.end()
  }

  response.on_error(null, res)
})
<|endoftext|>


<commit_before>module.exports = function( grunt ) {
  'use strict';
  //
  // Grunt configuration:
  //
  // https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
  //
  grunt.initConfig({

    // Project configuration
    // ---------------------

    // specify an alternate install location for Bower
    bower: {
      dir: 'app/scripts/vendor'
    },

    // Coffee to JS compilation
    coffee: {
      dist: {
        src: 'app/scripts/**/*.coffee',
        dest: 'app/scripts'
      }
    },

    // compile .scss/.sass to .css using Compass
    compass: {
      dist: {
        // http://compass-style.org/help/tutorials/configuration-reference/#configuration-properties
        options: {
          css_dir: 'temp/styles',
          sass_dir: 'app/styles',
          images_dir: 'app/images',
          javascripts_dir: 'temp/scripts',
          force: true
          force: true
        }
      }
    },

    // generate application cache manifest
    manifest:{
      dest: ''
    },

    // headless testing through PhantomJS
    mocha: {
      all: ['test/**/*.html']
    },

    // default watch configuration
    watch: {
      coffee: {
        files: '<config:coffee.dist.src>',
        tasks: 'coffee reload'
      },
      compass: {
        files: [
          'app/styles/**/*.{scss,sass}'
        ],
        tasks: 'compass reload'
      },
      reload: {
        files: [
          'app/*.html',
          'app/styles/**/*.css',
          'app/scripts/**/*.js',
          'app/images/**/*'
        ],
        tasks: 'reload'
      }
    },

    // default lint configuration, change this to match your setup:
    // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#lint-built-in-task
    lint: {
      files: [
        'Gruntfile.js',
        'app/scripts/**/*.js',
        'spec/**/*.js'
      ]
    },

    // specifying JSHint options and globals
    // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#specifying-jshint-options-and-globals
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        browser: true
      },
      globals: {
        jQuery: true
      }
    },

    // Build configuration
    // -------------------

    // the staging directory used during the process
    staging: 'temp',
    // final build output
    output: 'dist',

    mkdirs: {
      staging: 'app/'
    },

    // Below, all paths are relative to the staging directory, which is a copy
    // of the app/ directory. Any .gitignore, .ignore and .buildignore file
    // that might appear in the app/ tree are used to ignore these values
    // during the copy process.

    // concat css/**/*.css files, inline @import, output a single minified css
    css: {
      'styles/main.css': ['styles/**/*.css']
    },

    // renames JS/CSS to prepend a hash of their contents for easier
    // versioning
    rev: {
      js: 'scripts/**/*.js',
      css: 'styles/**/*.css',
      img: 'images/**'
    },

    // usemin handler should point to the file containing
    // the usemin blocks to be parsed
    'usemin-handler': {
      html: 'index.html'
    },

    // update references in HTML/CSS to revved files
    usemin: {
      html: ['**/*.html'],
      css: ['**/*.css']
    },

    // HTML minification
    html: {
      files: ['**/*.html']
    },

    // Optimizes JPGs and PNGs (with jpegtran & optipng)
    img: {
      dist: '<config:rev.img>'
    },

    // rjs configuration. You don't necessarily need to specify the typical
    // `path` configuration, the rjs task will parse these values from your
    // main module, using http://requirejs.org/docs/optimization.html#mainConfigFile
    //
    // name / out / mainConfig file should be used. You can let it blank if
    // you're using usemin-handler to parse rjs config from markup (default
    // setup)
    rjs: {
      // no minification, is done by the min task
      optimize: 'none',
      baseUrl: './scripts',
      wrap: true
    },
  });

  // Alias the `test` task to run the `mocha` task instead
  grunt.registerTask('test', 'mocha');

};
<commit_msg>Update lib/generators/chromeapp/all/templates/Gruntfile.js<commit_after>module.exports = function( grunt ) {
  'use strict';
  //
  // Grunt configuration:
  //
  // https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
  //
  grunt.initConfig({

    // Project configuration
    // ---------------------

    // specify an alternate install location for Bower
    bower: {
      dir: 'app/scripts/vendor'
    },

    // Coffee to JS compilation
    coffee: {
      dist: {
        src: 'app/scripts/**/*.coffee',
        dest: 'app/scripts'
      }
    },

    // compile .scss/.sass to .css using Compass
    compass: {
      dist: {
        // http://compass-style.org/help/tutorials/configuration-reference/#configuration-properties
        options: {
          css_dir: 'temp/styles',
          sass_dir: 'app/styles',
          images_dir: 'app/images',
          javascripts_dir: 'temp/scripts',
          force: true
        }
      }
    },

    // generate application cache manifest
    manifest:{
      dest: ''
    },

    // headless testing through PhantomJS
    mocha: {
      all: ['test/**/*.html']
    },

    // default watch configuration
    watch: {
      coffee: {
        files: '<config:coffee.dist.src>',
        tasks: 'coffee reload'
      },
      compass: {
        files: [
          'app/styles/**/*.{scss,sass}'
        ],
        tasks: 'compass reload'
      },
      reload: {
        files: [
          'app/*.html',
          'app/styles/**/*.css',
          'app/scripts/**/*.js',
          'app/images/**/*'
        ],
        tasks: 'reload'
      }
    },

    // default lint configuration, change this to match your setup:
    // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#lint-built-in-task
    lint: {
      files: [
        'Gruntfile.js',
        'app/scripts/**/*.js',
        'spec/**/*.js'
      ]
    },

    // specifying JSHint options and globals
    // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#specifying-jshint-options-and-globals
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        browser: true
      },
      globals: {
        jQuery: true
      }
    },

    // Build configuration
    // -------------------

    // the staging directory used during the process
    staging: 'temp',
    // final build output
    output: 'dist',

    mkdirs: {
      staging: 'app/'
    },

    // Below, all paths are relative to the staging directory, which is a copy
    // of the app/ directory. Any .gitignore, .ignore and .buildignore file
    // that might appear in the app/ tree are used to ignore these values
    // during the copy process.

    // concat css/**/*.css files, inline @import, output a single minified css
    css: {
      'styles/main.css': ['styles/**/*.css']
    },

    // renames JS/CSS to prepend a hash of their contents for easier
    // versioning
    rev: {
      js: 'scripts/**/*.js',
      css: 'styles/**/*.css',
      img: 'images/**'
    },

    // usemin handler should point to the file containing
    // the usemin blocks to be parsed
    'usemin-handler': {
      html: 'index.html'
    },

    // update references in HTML/CSS to revved files
    usemin: {
      html: ['**/*.html'],
      css: ['**/*.css']
    },

    // HTML minification
    html: {
      files: ['**/*.html']
    },

    // Optimizes JPGs and PNGs (with jpegtran & optipng)
    img: {
      dist: '<config:rev.img>'
    },

    // rjs configuration. You don't necessarily need to specify the typical
    // `path` configuration, the rjs task will parse these values from your
    // main module, using http://requirejs.org/docs/optimization.html#mainConfigFile
    //
    // name / out / mainConfig file should be used. You can let it blank if
    // you're using usemin-handler to parse rjs config from markup (default
    // setup)
    rjs: {
      // no minification, is done by the min task
      optimize: 'none',
      baseUrl: './scripts',
      wrap: true
    },
  });

  // Alias the `test` task to run the `mocha` task instead
  grunt.registerTask('test', 'mocha');

};
<|endoftext|>