New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mapscreatr

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapscreatr - npm Package Compare versions

Comparing version 0.7.5 to 0.7.6

.github/ISSUE_TEMPLATE.md

6

.vscode/settings.json
{
"editor.tabSize": 4,
"editor.trimAutoWhitespace": true,
"files.exclude": {
"**/*.d.ts": true,
"**/*.js.map": true,
"**/*.js": { "when": "$(basename).ts" },
"**/*?.js": { "when": "$(basename).tsx" }
},
"tslint.alwaysShowRuleFailuresAsWarnings": true,

@@ -5,0 +11,0 @@ "tslint.autoFixOnSave": true,

613

dist/MapsCreatr.js

@@ -1,612 +0,1 @@

define(function() { return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Basic storage container for a single Thing to be stored in an Area.
*/
var PreThing = /** @class */ (function () {
/**
* Initializes a new PreThing.
*
* @param thing The Thing, freshly created by ObjectMaker.make.
* @param reference The creation Object instruction used to create the Thing.
*/
function PreThing(thing, reference, objectMaker) {
this.thing = thing;
this.title = thing.title;
this.reference = reference;
this.spawned = false;
this.left = reference.x || 0;
this.top = reference.y || 0;
// tslint:disable
this.right = this.left + (reference.width || objectMaker.getPrototypeOf(this.title).width);
this.bottom = this.top + (reference.height || objectMaker.getPrototypeOf(this.title).height);
// tslint:enable
if (reference.position) {
this.position = reference.position;
}
}
return PreThing;
}());
exports.PreThing = PreThing;
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(2), __webpack_require__(0)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, MapsCreatr_1, PreThing_1) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(MapsCreatr_1);
__export(PreThing_1);
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, exports, __webpack_require__(0)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (require, exports, PreThing_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Storage container and lazy loader for GameStartr maps.
*/
var MapsCreatr = /** @class */ (function () {
/**
* Initializes a new instance of the MapsCreatr class.
*
* @param settings Settings to be used for initialization.
*/
function MapsCreatr(settings) {
if (!settings) {
throw new Error("No settings object given to MapsCreatr.");
}
if (!settings.objectMaker) {
throw new Error("No ObjectMakr given to MapsCreatr.");
}
this.objectMaker = settings.objectMaker;
this.groupTypes = settings.groupTypes || [];
this.macros = settings.macros || {};
this.entrances = settings.entrances;
this.requireEntrance = !!settings.requireEntrance;
this.mapsRaw = {};
this.maps = {};
if (settings.maps) {
this.storeMaps(settings.maps);
}
}
/**
* @returns The internal ObjectMakr.
*/
MapsCreatr.prototype.getObjectMaker = function () {
return this.objectMaker;
};
/**
* @returns The allowed group types.
*/
MapsCreatr.prototype.getGroupTypes = function () {
return this.groupTypes;
};
/**
* @returns The allowed macro Functions.
*/
MapsCreatr.prototype.getMacros = function () {
return this.macros;
};
/**
* @returns Whether Locations must have an entrance Function.
*/
MapsCreatr.prototype.getRequireEntrance = function () {
return this.requireEntrance;
};
/**
* @returns The Object storing raw maps, keyed by name.
*/
MapsCreatr.prototype.getMapsRaw = function () {
return this.mapsRaw;
};
/**
* @returns The Object storing maps, keyed by name.
*/
MapsCreatr.prototype.getMaps = function () {
return this.maps;
};
/**
* @param name A key to find the map under.
* @returns The raw map keyed by the given name.
*/
MapsCreatr.prototype.getMapRaw = function (name) {
var mapRaw = this.mapsRaw[name];
if (!mapRaw) {
throw new Error("No map found under '" + name + "'.");
}
return mapRaw;
};
/**
* Getter for a map under the maps container. If the map has not yet been
* initialized that is done here as lazy loading.
*
* @param name A key to find the map under.
* @returns The parsed map keyed by the given name.
*/
MapsCreatr.prototype.getMap = function (name) {
if (!{}.hasOwnProperty.call(this.maps, name)) {
throw new Error("No map found under '" + name + "'.");
}
var map = this.maps[name];
if (!map.initialized) {
this.initializeMap(map);
}
return map;
};
/**
* Creates and stores a set of new maps based on the key/value pairs in a
* given Object. These will be stored as maps by their string keys via
* this.storeMap.
*
* @param maps Raw maps keyed by their storage key.
*/
MapsCreatr.prototype.storeMaps = function (maps) {
for (var i in maps) {
if ({}.hasOwnProperty.call(maps, i)) {
this.storeMap(i, maps[i]);
}
}
};
/**
* Creates and stores a new map. The internal ObjectMaker factory is used to
* auto-generate it based on a given settings object. The actual loading of
* Areas and Locations is deferred to this.getMap.
*
* @param name A name under which the map should be stored.
* @param mapRaw A raw map to be stored.
* @returns A Map object created by the internal ObjectMakr using the raw map.
*/
MapsCreatr.prototype.storeMap = function (name, mapRaw) {
var map = this.objectMaker.make("Map", mapRaw);
this.mapsRaw[name] = mapRaw;
this.maps[name] = map;
return map;
};
/**
* Given a Area, this processes and returns the PreThings that are to
* inhabit the Area per its creation instructions.
*
* @returns A container with the parsed PreThings.
*/
MapsCreatr.prototype.getPreThings = function (area) {
var map = area.map;
var creation = area.creation;
var prethings = this.createObjectFromStringArray(this.groupTypes);
area.collections = {};
for (var _i = 0, creation_1 = creation; _i < creation_1.length; _i++) {
var instruction = creation_1[_i];
this.analyzePreSwitch(instruction, prethings, area, map);
}
return this.processPreThingsArrays(prethings);
};
/**
* PreThing switcher: Given a JSON representation of a PreThing, this
* determines what to do with it. It may be a location setter (to switch the
* x- and y- location offset), a macro (to repeat some number of actions),
* or a raw PreThing.
*
* @param reference A JSON mapping of some number of PreThings.
* @param preThings The PreThing containers within the Area.
* @param area The Area to be populated.
* @param map The Map containing the Area.
* @returns The results of analyzePreMacro or analyzePreThing.
*/
MapsCreatr.prototype.analyzePreSwitch = function (reference, prethings, area, map) {
// Case: macro
if (reference.macro) {
return this.analyzePreMacro(reference, prethings, area, map);
}
// Case: default (a regular PreThing)
return this.analyzePreThing(reference, prethings, area, map);
};
/**
* PreThing case: Macro instruction. This calls the macro on the same input,
* captures the output, and recursively repeats the analyzePreSwitch driver
* function on the output(s).
*
* @param reference A JSON mapping of some number of PreThings.
* @param preThings The PreThing containers within the Area.
* @param area The Area to be populated.
* @param map The Map containing the Area.
*/
MapsCreatr.prototype.analyzePreMacro = function (reference, prethings, area, map) {
if (!{}.hasOwnProperty.call(this.macros, reference.macro)) {
throw new Error("A non-existent macro is referenced: '" + reference.macro + "'.");
}
var macro = this.macros[reference.macro];
var outputs = macro(reference, prethings, area, map);
// If there is any output, recurse on all components of it, Array or not
if (outputs) {
if (outputs instanceof Array) {
for (var _i = 0, outputs_1 = outputs; _i < outputs_1.length; _i++) {
var instruction = outputs_1[_i];
this.analyzePreSwitch(instruction, prethings, area, map);
}
}
else {
this.analyzePreSwitch(outputs, prethings, area, map);
}
}
return outputs;
};
/**
* Macro case: PreThing instruction. This creates a PreThing from the
* given reference and adds it to its respective group in PreThings (based
* on the PreThing's [keyGroupType] variable).
*
* @param reference A JSON mapping of some number of PreThings.
* @param preThings The PreThing containers within the Area.
* @param area The Area to be populated by these PreThings.
* @param map The Map containing the Area.
*/
MapsCreatr.prototype.analyzePreThing = function (reference, prethings, area, map) {
var title = reference.thing;
if (!this.objectMaker.hasClass(title)) {
throw new Error("A non-existent Thing type is referenced: '" + title + "'.");
}
var prething = new PreThing_1.PreThing(this.objectMaker.make(title, reference), reference, this.objectMaker);
var thing = prething.thing;
if (!prething.thing.groupType) {
throw new Error("A Thing of title '" + title + "' does not contain a groupType.");
}
if (this.groupTypes.indexOf(prething.thing.groupType) === -1) {
throw new Error("A Thing of title '" + title + "' contains an unknown groupType: '" + prething.thing.groupType + ".");
}
prethings[prething.thing.groupType].push(prething);
if (!thing.noBoundaryStretch && area.boundaries) {
this.stretchAreaBoundaries(prething, area);
}
// If a Thing is an entrance, then the entrance's location must know the Thing.
if (thing.entrance !== undefined) {
if (typeof map.locations[thing.entrance] !== "undefined") {
if (typeof map.locations[thing.entrance].xloc === "undefined") {
map.locations[thing.entrance].xloc = prething.left;
}
if (typeof map.locations[thing.entrance].yloc === "undefined") {
map.locations[thing.entrance].yloc = prething.top;
}
map.locations[thing.entrance].entrance = prething.thing;
}
}
if (reference.collectionName && area.collections) {
this.ensureThingCollection(thing, reference.collectionName, reference.collectionKey, area);
}
return prething;
};
/**
* Parses the Areas and Locations in a map to make it ready for use.
*
* @param map A map to be initialized.
*/
MapsCreatr.prototype.initializeMap = function (map) {
// Set the one-to-many Map->Area relationships within the Map
this.setMapAreas(map);
// Set the one-to-many Area->Location relationships within the Map
this.setMapLocations(map);
map.initialized = true;
};
/**
* Converts the raw area settings in a Map into Area objects.
*
* @param map A map whose areas should be parsed.
*/
MapsCreatr.prototype.setMapAreas = function (map) {
var areasRaw = map.areas;
var locationsRaw = map.locations;
// The parsed containers should be the same types as the originals
var areasParsed = new areasRaw.constructor();
var locationsParsed = new locationsRaw.constructor();
// Parse all the Area objects (works for both Arrays and Objects)
for (var i in areasRaw) {
if (!areasRaw.hasOwnProperty(i)) {
continue;
}
var area = this.objectMaker.make("Area", areasRaw[i]);
areasParsed[i] = area;
area.map = map;
area.name = i;
area.boundaries = {
bottom: 0,
left: 0,
right: 0,
top: 0,
};
}
// Parse all the Location objects (works for both Arrays and Objects)
for (var i in locationsRaw) {
if (!locationsRaw.hasOwnProperty(i)) {
continue;
}
var location_1 = this.objectMaker.make("Location", locationsRaw[i]);
locationsParsed[i] = location_1;
location_1.entryRaw = locationsRaw[i].entry;
location_1.name = i;
location_1.area = locationsRaw[i].area || 0;
if (this.requireEntrance) {
if (location_1.entryRaw === undefined || !{}.hasOwnProperty.call(this.entrances, location_1.entryRaw)) {
throw new Error("Location " + i + " has unknown entry string: '" + location_1.entryRaw + "'.");
}
}
if (this.entrances && location_1.entryRaw) {
location_1.entry = this.entrances[location_1.entryRaw];
}
else if (location_1.entry && location_1.entry.constructor === String) {
location_1.entry = this.entrances[String(location_1.entry)];
}
}
map.areas = areasParsed;
map.locations = locationsParsed;
};
/**
* Converts the raw location settings in a Map into Location objects.
*
* @param map A map whose locations should be parsed.
*/
MapsCreatr.prototype.setMapLocations = function (map) {
// The parsed container should be the same type as the original
var locationsRaw = map.locations;
var locationsParsed = new locationsRaw.constructor();
// Parse all the keys in locationsRaw (works for both Arrays and Objects)
for (var i in locationsRaw) {
if (!locationsRaw.hasOwnProperty(i)) {
continue;
}
var location_2 = this.objectMaker.make("Location", locationsRaw[i]);
locationsParsed[i] = location_2;
// The area should be an object reference, under the Map's areas
location_2.area = map.areas[locationsRaw[i].area || 0];
if (!locationsParsed[i].area) {
throw new Error("Location '" + i + "'' references an invalid area: '" + locationsRaw[i].area + "'.");
}
}
// Store the output object in the Map, and keep the old settings for the
// Sake of debugging / user interest
map.locations = locationsParsed;
};
/**
* "Stretches" an Area's boundaries based on a PreThing. For each direction,
* if the PreThing has a more extreme version of it (higher top, etc.), the
* boundary is updated.
*
* @param prething The PreThing stretching the Area's boundaries.
* @param area An Area containing the PreThing.
*/
MapsCreatr.prototype.stretchAreaBoundaries = function (prething, area) {
var boundaries = area.boundaries;
boundaries.top = Math.min(prething.top, boundaries.top);
boundaries.right = Math.max(prething.right, boundaries.right);
boundaries.bottom = Math.max(prething.bottom, boundaries.bottom);
boundaries.left = Math.min(prething.left, boundaries.left);
};
/**
* Adds a Thing to the specified collection in the Map's Area. If the collection
* doesn't exist yet, it's created.
*
* @param thing The thing that has specified a collection.
* @param collectionName The name of the collection.
* @param collectionKey The key under which the collection should store
* the Thing.
* @param area The Area containing the collection.
*/
MapsCreatr.prototype.ensureThingCollection = function (thing, collectionName, collectionKey, area) {
var collection = area.collections[collectionName];
if (!collection) {
collection = area.collections[collectionName] = {};
}
thing.collection = collection;
collection[collectionKey] = thing;
};
/**
* Creates an Object wrapper around a PreThings Object with versions of each
* child PreThing[] sorted by xloc and yloc, in increasing and decreasing order.
*
* @param prethings A raw container of PreThings.
* @returns A PreThing wrapper with the keys "xInc", "xDec", "yInc", and "yDec".
*/
MapsCreatr.prototype.processPreThingsArrays = function (prethings) {
var _this = this;
var output = {};
var _loop_1 = function (i) {
var children = prethings[i];
var array = {
push: function (prething) {
_this.addArraySorted(array.xInc, prething, _this.sortPreThingsXInc);
_this.addArraySorted(array.xDec, prething, _this.sortPreThingsXDec);
_this.addArraySorted(array.yInc, prething, _this.sortPreThingsYInc);
_this.addArraySorted(array.yDec, prething, _this.sortPreThingsYDec);
},
xDec: this_1.getArraySorted(children, this_1.sortPreThingsXDec),
xInc: this_1.getArraySorted(children, this_1.sortPreThingsXInc),
yDec: this_1.getArraySorted(children, this_1.sortPreThingsYDec),
yInc: this_1.getArraySorted(children, this_1.sortPreThingsYInc),
};
output[i] = array;
};
var this_1 = this;
for (var i in prethings) {
_loop_1(i);
}
return output;
};
/**
* Creates an Object pre-populated with one key for each of the Strings in
* the input Array, each pointing to a new Array.
*
* @param array An Array listing the keys to be made into an Object.
* @returns An Object with the keys listed in the Array.
*/
MapsCreatr.prototype.createObjectFromStringArray = function (array) {
var output = {};
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
var member = array_1[_i];
output[member] = [];
}
return output;
};
/**
* Returns a shallow copy of an Array, in sorted order based on a given
* sorter Function.
*
* @param array An Array to be sorted.
* @param sorter A standard sorter Function.
* @returns A copy of the original Array, sorted.
*/
MapsCreatr.prototype.getArraySorted = function (array, sorter) {
var copy = array.slice();
copy.sort(sorter);
return copy;
};
/**
* Adds an element into an Array using a binary search with a sorter Function.
*
* @param array An Array to insert the element into.
* @param element An element to insert into the Array.
* @param sorter A standard sorter Function.
*/
MapsCreatr.prototype.addArraySorted = function (array, element, sorter) {
var lower = 0;
var upper = array.length;
while (lower !== upper) {
var index = ((lower + upper) / 2) | 0;
// Case: element is less than the index
if (sorter(element, array[index]) < 0) {
upper = index;
}
else {
// Case: element is higher than the index
lower = index + 1;
}
}
if (lower === upper) {
array.splice(lower, 0, element);
return;
}
};
/**
* Sorter for PreThings that results in increasing horizontal order.
*
* @param a A PreThing.
* @param b A PreThing.
*/
MapsCreatr.prototype.sortPreThingsXInc = function (a, b) {
return a.left === b.left ? a.top - b.top : a.left - b.left;
};
/**
* Sorter for PreThings that results in decreasing horizontal order.
*
* @param a A PreThing.
* @param b A PreThing.
*/
MapsCreatr.prototype.sortPreThingsXDec = function (a, b) {
return b.right === a.right ? b.bottom - a.bottom : b.right - a.right;
};
/**
* Sorter for PreThings that results in increasing vertical order.
*
* @param a A PreThing.
* @param b A PreThing.
*/
MapsCreatr.prototype.sortPreThingsYInc = function (a, b) {
return a.top === b.top ? a.left - b.left : a.top - b.top;
};
/**
* Sorter for PreThings that results in decreasing vertical order.
*
* @param a A PreThing.
* @param b A PreThing.
*/
MapsCreatr.prototype.sortPreThingsYDec = function (a, b) {
return b.bottom === a.bottom ? b.right - a.right : b.bottom - a.bottom;
};
return MapsCreatr;
}());
exports.MapsCreatr = MapsCreatr;
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
/***/ })
/******/ ])});;
define(function(){return function(t){var r={};function e(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}return e.m=t,e.c=r,e.d=function(t,r,o){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var n in t)e.d(o,n,function(r){return t[r]}.bind(null,n));return o},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=1)}([function(t,r,e){var o;void 0===(o=function(t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var e=function(){return function(t,r,e){this.thing=t,this.title=t.title,this.reference=r,this.spawned=!1,this.left=r.x||0,this.top=r.y||0,this.right=this.left+(r.width||e.getPrototypeOf(this.title).width),this.bottom=this.top+(r.height||e.getPrototypeOf(this.title).height),r.position&&(this.position=r.position)}}();r.PreThing=e}.apply(r,[e,r]))||(t.exports=o)},function(t,r,e){var o,n;o=[e,r,e(2),e(0)],void 0===(n=function(t,r,e,o){"use strict";function n(t){for(var e in t)r.hasOwnProperty(e)||(r[e]=t[e])}Object.defineProperty(r,"__esModule",{value:!0}),n(e),n(o)}.apply(r,o))||(t.exports=n)},function(t,r,e){var o,n;o=[e,r,e(0)],void 0===(n=function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function t(t){if(!t)throw new Error("No settings object given to MapsCreatr.");if(!t.objectMaker)throw new Error("No ObjectMakr given to MapsCreatr.");this.objectMaker=t.objectMaker,this.groupTypes=t.groupTypes||[],this.macros=t.macros||{},this.entrances=t.entrances,this.requireEntrance=!!t.requireEntrance,this.mapsRaw={},this.maps={},t.maps&&this.storeMaps(t.maps)}return t.prototype.getObjectMaker=function(){return this.objectMaker},t.prototype.getGroupTypes=function(){return this.groupTypes},t.prototype.getMacros=function(){return this.macros},t.prototype.getRequireEntrance=function(){return this.requireEntrance},t.prototype.getMapsRaw=function(){return this.mapsRaw},t.prototype.getMaps=function(){return this.maps},t.prototype.getMapRaw=function(t){var r=this.mapsRaw[t];if(!r)throw new Error("No map found under '"+t+"'.");return r},t.prototype.getMap=function(t){if(!{}.hasOwnProperty.call(this.maps,t))throw new Error("No map found under '"+t+"'.");var r=this.maps[t];return r.initialized||this.initializeMap(r),r},t.prototype.storeMaps=function(t){for(var r in t)({}).hasOwnProperty.call(t,r)&&this.storeMap(r,t[r])},t.prototype.storeMap=function(t,r){var e=this.objectMaker.make("Map",r);return this.mapsRaw[t]=r,this.maps[t]=e,e},t.prototype.getPreThings=function(t){var r=t.map,e=t.creation,o=this.createObjectFromStringArray(this.groupTypes);t.collections={};for(var n=0,i=e;n<i.length;n++){var a=i[n];this.analyzePreSwitch(a,o,t,r)}return this.processPreThingsArrays(o)},t.prototype.analyzePreSwitch=function(t,r,e,o){return t.macro?this.analyzePreMacro(t,r,e,o):this.analyzePreThing(t,r,e,o)},t.prototype.analyzePreMacro=function(t,r,e,o){if(!{}.hasOwnProperty.call(this.macros,t.macro))throw new Error("A non-existent macro is referenced: '"+t.macro+"'.");var n=(0,this.macros[t.macro])(t,r,e,o);if(n)if(n instanceof Array)for(var i=0,a=n;i<a.length;i++){var s=a[i];this.analyzePreSwitch(s,r,e,o)}else this.analyzePreSwitch(n,r,e,o);return n},t.prototype.analyzePreThing=function(t,r,o,n){var i=t.thing;if(!this.objectMaker.hasClass(i))throw new Error("A non-existent Thing type is referenced: '"+i+"'.");var a=new e.PreThing(this.objectMaker.make(i,t),t,this.objectMaker),s=a.thing;if(!a.thing.groupType)throw new Error("A Thing of title '"+i+"' does not contain a groupType.");if(-1===this.groupTypes.indexOf(a.thing.groupType))throw new Error("A Thing of title '"+i+"' contains an unknown groupType: '"+a.thing.groupType+".");return r[a.thing.groupType].push(a),!s.noBoundaryStretch&&o.boundaries&&this.stretchAreaBoundaries(a,o),void 0!==s.entrance&&void 0!==n.locations[s.entrance]&&(void 0===n.locations[s.entrance].xloc&&(n.locations[s.entrance].xloc=a.left),void 0===n.locations[s.entrance].yloc&&(n.locations[s.entrance].yloc=a.top),n.locations[s.entrance].entrance=a.thing),t.collectionName&&o.collections&&this.ensureThingCollection(s,t.collectionName,t.collectionKey,o),a},t.prototype.initializeMap=function(t){this.setMapAreas(t),this.setMapLocations(t),t.initialized=!0},t.prototype.setMapAreas=function(t){var r=t.areas,e=t.locations,o=new r.constructor,n=new e.constructor;for(var i in r)if(r.hasOwnProperty(i)){var a=this.objectMaker.make("Area",r[i]);o[i]=a,a.map=t,a.name=i,a.boundaries={bottom:0,left:0,right:0,top:0}}for(var i in e)if(e.hasOwnProperty(i)){var s=this.objectMaker.make("Location",e[i]);if(n[i]=s,s.entryRaw=e[i].entry,s.name=i,s.area=e[i].area||0,this.requireEntrance&&(void 0===s.entryRaw||!{}.hasOwnProperty.call(this.entrances,s.entryRaw)))throw new Error("Location "+i+" has unknown entry string: '"+s.entryRaw+"'.");this.entrances&&s.entryRaw?s.entry=this.entrances[s.entryRaw]:s.entry&&s.entry.constructor===String&&(s.entry=this.entrances[String(s.entry)])}t.areas=o,t.locations=n},t.prototype.setMapLocations=function(t){var r=t.locations,e=new r.constructor;for(var o in r)if(r.hasOwnProperty(o)){var n=this.objectMaker.make("Location",r[o]);if(e[o]=n,n.area=t.areas[r[o].area||0],!e[o].area)throw new Error("Location '"+o+"'' references an invalid area: '"+r[o].area+"'.")}t.locations=e},t.prototype.stretchAreaBoundaries=function(t,r){var e=r.boundaries;e.top=Math.min(t.top,e.top),e.right=Math.max(t.right,e.right),e.bottom=Math.max(t.bottom,e.bottom),e.left=Math.min(t.left,e.left)},t.prototype.ensureThingCollection=function(t,r,e,o){var n=o.collections[r];n||(n=o.collections[r]={}),t.collection=n,n[e]=t},t.prototype.processPreThingsArrays=function(t){var r=this,e={},o=function(o){var i=t[o],a={push:function(t){r.addArraySorted(a.xInc,t,r.sortPreThingsXInc),r.addArraySorted(a.xDec,t,r.sortPreThingsXDec),r.addArraySorted(a.yInc,t,r.sortPreThingsYInc),r.addArraySorted(a.yDec,t,r.sortPreThingsYDec)},xDec:n.getArraySorted(i,n.sortPreThingsXDec),xInc:n.getArraySorted(i,n.sortPreThingsXInc),yDec:n.getArraySorted(i,n.sortPreThingsYDec),yInc:n.getArraySorted(i,n.sortPreThingsYInc)};e[o]=a},n=this;for(var i in t)o(i);return e},t.prototype.createObjectFromStringArray=function(t){for(var r={},e=0,o=t;e<o.length;e++){r[o[e]]=[]}return r},t.prototype.getArraySorted=function(t,r){var e=t.slice();return e.sort(r),e},t.prototype.addArraySorted=function(t,r,e){for(var o=0,n=t.length;o!==n;){var i=(o+n)/2|0;e(r,t[i])<0?n=i:o=i+1}o!==n||t.splice(o,0,r)},t.prototype.sortPreThingsXInc=function(t,r){return t.left===r.left?t.top-r.top:t.left-r.left},t.prototype.sortPreThingsXDec=function(t,r){return r.right===t.right?r.bottom-t.bottom:r.right-t.right},t.prototype.sortPreThingsYInc=function(t,r){return t.top===r.top?t.left-r.left:t.top-r.top},t.prototype.sortPreThingsYDec=function(t,r){return r.bottom===t.bottom?r.right-t.right:r.bottom-t.bottom},t}();r.MapsCreatr=o}.apply(r,o))||(t.exports=n)}])});

@@ -11,28 +11,34 @@ {

"dependencies": {
"itemsholdr": "^0.7.4",
"objectmakr": "^0.7.4"
"itemsholdr": "^0.7.8",
"objectmakr": "^0.7.5"
},
"description": "Storage container and lazy loader for GameStartr maps.",
"devDependencies": {
"@types/chai": "^4.0.4",
"@types/lolex": "^2.1.1",
"@types/mocha": "^2.2.46",
"@types/sinon": "^4.1.3",
"@types/sinon-chai": "^2.7.29",
"chai": "^4.1.2",
"glob": "^7.1.2",
"lolex": "^2.3.0",
"@types/chai": "^4.1.7",
"@types/lodash": "^4.14.123",
"@types/lolex": "^3.1.1",
"@types/mocha": "^5.2.6",
"@types/sinon": "^7.0.11",
"@types/sinon-chai": "^3.2.2",
"chai": "^4.2.0",
"concurrently": "^4.1.0",
"glob": "^7.1.3",
"istanbul": "^0.4.5",
"lolex": "^3.1.0",
"mkdirp": "^0.5.1",
"mocha": "^4.0.1",
"mocha-headless-chrome": "^1.8.1",
"requirejs": "^2.3.5",
"mocha": "^6.1.3",
"mocha-headless-chrome": "^2.0.2",
"npm-check-updates": "^3.1.7",
"requirejs": "^2.3.6",
"run-for-every-file": "^1.1.0",
"shenanigans-manager": "^0.2.20",
"sinon": "^4.1.5",
"sinon-chai": "^2.14.0",
"tslint": "5.9.1",
"tsutils": "^2.17.0",
"typedoc": "^0.9.0",
"typescript": "^2.6.2",
"webpack": "^3.10.0"
"shenanigans-manager": "^0.2.36",
"sinon": "^7.3.1",
"sinon-chai": "^3.3.0",
"tslint": "5.15.0",
"tsutils": "^3.10.0",
"typedoc": "^0.14.2",
"typescript": "^3.4.3",
"watch": "^1.0.2",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.0"
},

@@ -51,5 +57,7 @@ "license": "MIT",

"init": "npm install && npm run setup && npm run verify",
"setup": "npm run setup:copy && npm run setup:package && npm run setup:readme",
"ncu": "ncu -u",
"setup": "npm run setup:dirs && npm run setup:copy && npm run setup:package && npm run setup:readme",
"setup:copy": "npm run setup:copy:default",
"setup:copy:default": "run-for-every-file --dot --src \"node_modules/shenanigans-manager/setup/default/\" --file \"**/*\" --run \"mustache package.json {{src-file}} {{file}}\" --dest \".\" --only-files",
"setup:dirs": "shenanigans-manager ensure-dirs-exist",
"setup:package": "shenanigans-manager hydrate-package-json",

@@ -60,3 +68,9 @@ "setup:readme": "shenanigans-manager hydrate-readme",

"src:tslint": "tslint -c tslint.json -p tsconfig.json -t stylish",
"src:tslint:fix": "tslint -c tslint.json --fix -p tsconfig.json -t stylish",
"test": "npm run test:setup && npm run test:run",
"test:coverage": "npm run test:coverage:generate-html && npm run test:coverage:instrument && npm run test:coverage:run && npm run test:coverage:report",
"test:coverage:generate-html": "shenanigans-manager generate-test-html --source instrumented",
"test:coverage:instrument": "istanbul instrument src -o instrumented",
"test:coverage:report": "istanbul report html",
"test:coverage:run": "mocha-headless-chrome --coverage coverage.json --file test/index.instrumented.html",
"test:run": "mocha-headless-chrome --file test/index.html",

@@ -69,4 +83,5 @@ "test:setup": "npm run test:setup:dir && npm run test:setup:copy && npm run test:setup:html && npm run test:setup:tsc",

"test:setup:tsc": "tsc -p test",
"verify": "npm run src && npm run test && npm run dist && npm run docs",
"watch": "tsc -p . -w"
"verify": "npm run src && npm run test && npm run dist",
"verify:coverage": "npm run src && npm run test:setup && npm run test:coverage && npm run dist",
"watch": "concurrently \"tsc -p . -w\" --raw \"chokidar src/**/*.test.t* --command \"\"npm run test:setup:html\"\" --silent\" --raw"
},

@@ -77,3 +92,3 @@ "shenanigans": {

"types": "./src/index.d.ts",
"version": "0.7.5"
}
"version": "0.7.6"
}

@@ -1,2 +0,2 @@

<!-- {{Top}} -->
<!-- Top -->
# MapsCreatr

@@ -8,5 +8,5 @@ [![Greenkeeper badge](https://badges.greenkeeper.io/FullScreenShenanigans/MapsCreatr.svg)](https://greenkeeper.io/)

Storage container and lazy loader for GameStartr maps.
<!-- {{/Top}} -->
<!-- /Top -->
<!-- {{Development}} -->
<!-- Development -->
## Development

@@ -37,3 +37,3 @@

### Running Tests
#### Running Tests

@@ -44,6 +44,9 @@ ```shell

Test files are alongside source files under `src/` and named `*.test.ts?`.
Whenever you add, remove, or rename a `*.test.ts?` file under `src/`, re-run `npm run test:setup` to regenerate the list of static test files in `test/index.html`.
Tests are written in [Mocha](https://github.com/mochajs/mocha) and [Chai](https://github.com/chaijs/chai).
Their files are written using alongside source files under `src/` and named `*.test.ts?`.
Whenever you add, remove, or rename a `*.test.t*` file under `src/`, `watch` will re-run `npm run test:setup` to regenerate the list of static test files in `test/index.html`.
You can open that file in a browser to debug through the tests.
`npm run test` will run that setup and execute tests using [Puppeteer](https://github.com/GoogleChrome/puppeteer).
<!-- {{/Development}} -->
<!-- Maps -->
<!-- /Maps -->
<!-- /Development -->

@@ -151,3 +151,3 @@ import { IObjectMakr } from "objectmakr";

*/
private initializeMap(map);
private initializeMap;
/**

@@ -158,3 +158,3 @@ * Converts the raw area settings in a Map into Area objects.

*/
private setMapAreas(map);
private setMapAreas;
/**

@@ -165,3 +165,3 @@ * Converts the raw location settings in a Map into Location objects.

*/
private setMapLocations(map);
private setMapLocations;
/**

@@ -175,3 +175,3 @@ * "Stretches" an Area's boundaries based on a PreThing. For each direction,

*/
private stretchAreaBoundaries(prething, area);
private stretchAreaBoundaries;
/**

@@ -187,3 +187,3 @@ * Adds a Thing to the specified collection in the Map's Area. If the collection

*/
private ensureThingCollection(thing, collectionName, collectionKey, area);
private ensureThingCollection;
/**

@@ -196,3 +196,3 @@ * Creates an Object wrapper around a PreThings Object with versions of each

*/
private processPreThingsArrays(prethings);
private processPreThingsArrays;
/**

@@ -205,3 +205,3 @@ * Creates an Object pre-populated with one key for each of the Strings in

*/
private createObjectFromStringArray(array);
private createObjectFromStringArray;
/**

@@ -215,3 +215,3 @@ * Returns a shallow copy of an Array, in sorted order based on a given

*/
private getArraySorted(array, sorter?);
private getArraySorted;
/**

@@ -224,3 +224,3 @@ * Adds an element into an Array using a binary search with a sorter Function.

*/
private addArraySorted(array, element, sorter);
private addArraySorted;
/**

@@ -232,3 +232,3 @@ * Sorter for PreThings that results in increasing horizontal order.

*/
private sortPreThingsXInc(a, b);
private sortPreThingsXInc;
/**

@@ -240,3 +240,3 @@ * Sorter for PreThings that results in decreasing horizontal order.

*/
private sortPreThingsXDec(a, b);
private sortPreThingsXDec;
/**

@@ -248,3 +248,3 @@ * Sorter for PreThings that results in increasing vertical order.

*/
private sortPreThingsYInc(a, b);
private sortPreThingsYInc;
/**

@@ -256,3 +256,3 @@ * Sorter for PreThings that results in decreasing vertical order.

*/
private sortPreThingsYDec(a, b);
private sortPreThingsYDec;
}

@@ -7,11 +7,15 @@ {

"jsx": "react",
"lib": ["dom", "es2015.collection", "es2015.promise", "es5"],
"lib": ["dom", "es2015"],
"module": "amd",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"pretty": true,
"strictNullChecks": true,
"strict": true,
"strictFunctionTypes": false,
"strictPropertyInitialization": false,
"target": "es5"

@@ -18,0 +22,0 @@ },

@@ -12,6 +12,2 @@ const glob = require("glob");

name: package.shenanigans.name,
sources: [
"./**/*.js",
"!./**/*.test.js",
]
}

@@ -48,2 +44,3 @@ ]

externals,
mode: "production",
output: {

@@ -53,3 +50,6 @@ filename: "[name].js",

path: path.join(__dirname, "dist"),
},
performance: {
hints: false
}
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc