Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@excaliburjs/dev-tools

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@excaliburjs/dev-tools - npm Package Compare versions

Comparing version 0.27.0 to 0.27.1

.parcel-cache/bdf2efb244bc073f

108

dev-tools.ts

@@ -5,2 +5,5 @@ import * as ex from "excalibur";

type SceneOption = { text: string, value: string };
type ArrayComparator<T> = (item: T, index: number, otherItems: T[]) => boolean
export class DevTool {

@@ -170,2 +173,5 @@ public pane: Pane

this._buildTimersTab();
// Update scene ui
this._buildSceneUI();
}

@@ -195,39 +201,4 @@

let currentSceneName = '';
let scenes: { text: string, value: string }[] = []
for (let key in this.engine.scenes) {
if (this.engine.currentScene === this.engine.scenes[key]) {
currentSceneName = key;
}
scenes.push({ text: key, value: key })
}
this._buildSceneUI();
let numberEntitiesBlade: BladeApi<any>;
const scenePicker = this.pane.addBlade({
view: 'list',
label: 'current scene',
options: scenes,
value: currentSceneName
}) as ListApi<string>;
scenePicker.on('change', ev => {
this.engine.goToScene(ev.value);
this._installPickerSystemIfNeeded(this.engine.currentScene);
numberEntitiesBlade.dispose();
numberEntitiesBlade = this.pane.addBlade({
view: 'text',
label: 'number of entities',
value: this.engine.currentScene.world.entityManager.entities.length,
parse: v => String(v),
index: 3
});
});
numberEntitiesBlade = this.pane.addBlade({
view: 'text',
label: 'number of entities',
value: this.engine.currentScene.world.entityManager.entities.length,
parse: v => String(v),
index: 3
});
this.pointerPos = { x: 10, y: 10 };

@@ -708,2 +679,67 @@ this.pointerPosInput = this.pane.addInput(this, "pointerPos", {

}
private _scenePicker: ListApi<string>;
private _numberEntitiesBlade: BladeApi<any>;
private _previousScenes: SceneOption[] = [];
private _previousScene: ex.Scene = null;
private _areArraysEqual<T = any>(items: T[], otherItems: T[], comparator: ArrayComparator<T>) {
if(items.length !== otherItems.length) {
return false;
}
return items.every(comparator)
}
private _areScenesEqual(previousScenes: SceneOption[], scenes: SceneOption[]) {
return this._areArraysEqual(previousScenes, scenes, (item, index, otherItems) => item.value === otherItems[index].value);
}
private _buildSceneUI() {
const scenes: SceneOption[] = [];
let currentSceneName = '';
for (let key in this.engine.scenes) {
if (this.engine.currentScene === this.engine.scenes[key]) {
currentSceneName = key;
}
scenes.push({ text: key, value: key })
}
if(this._previousScene === this.engine.currentScene && this._areScenesEqual(this._previousScenes, scenes)) {
return;
}
if(this._scenePicker) {
this._scenePicker.dispose();
}
if(this._numberEntitiesBlade) {
this._numberEntitiesBlade.dispose();
}
this._scenePicker = this.pane.addBlade({
view: 'list',
label: 'current scene',
options: scenes,
value: currentSceneName,
index: 2,
}) as ListApi<string>;
this._scenePicker.on('change', ev => {
this.engine.goToScene(ev.value);
});
this._numberEntitiesBlade = this.pane.addBlade({
view: 'text',
label: 'number of entities',
value: this.engine.currentScene.world.entityManager.entities.length,
parse: v => String(v),
index: 3
});
this._installPickerSystemIfNeeded(this.engine.currentScene);
this._previousScene = this.engine.currentScene;
this._previousScenes = scenes;
}
}

@@ -56,2 +56,9 @@ import * as ex from "excalibur";

private _buildDebugSettingsTab;
private _scenePicker;
private _numberEntitiesBlade;
private _previousScenes;
private _previousScene;
private _areArraysEqual;
private _areScenesEqual;
private _buildSceneUI;
}

@@ -1,4 +0,12 @@

import { Actor, Color, DisplayMode, Engine, vec, CollisionType, Vector, Scene, Label, Font, FontUnit, Text, ParticleEmitter, Timer } from "excalibur";
import { Actor, Color, DisplayMode, Engine, vec, CollisionType, Vector, Scene, Label, Font, FontUnit, Text, ParticleEmitter, Timer, Input, Random } from "excalibur";
import { DevTool } from "./dev-tools";
const rand = new Random(1234)
const fontOptions = {
family: 'Times New Roman',
size: 30,
unit: FontUnit.Px
};
const game = new Engine({

@@ -47,7 +55,3 @@ width: 800,

text: "Yo it's text",
font: new Font({
family: 'Times New Roman',
size: 30,
unit: FontUnit.Px
}),
font: new Font(fontOptions),
});

@@ -131,2 +135,43 @@ const label = new Actor({

const dynamicSceneKey = 'dynamic scene';
const createDynamicScene = () => {
if(dynamicSceneKey in game.scenes) {
game.removeScene(dynamicSceneKey);
}
const dynamicScene = new Scene();
for (let index = 0; index < rand.integer(1, 5); index++) {
const label = new Actor({
pos: vec(10, 30 + (index * 30)),
anchor: vec(0, 0),
});
const text = new Text({
text: `Dynamically added scene with varying entities ${index} 👋`,
font: new Font({ ...fontOptions, size: 18 }),
color: Color.Orange,
});
label.graphics.use(text);
dynamicScene.add(label);
}
game.addScene(dynamicSceneKey, dynamicScene);
};
game.input.keyboard.on("press", (evt: Input.KeyEvent) => {
switch(evt.key) {
// Add a dynamic scene, without activating it. This should still be reflected in dev tools
case Input.Keys.N:
createDynamicScene();
break;
// Add a dynamic scene and activate it
case Input.Keys.A:
createDynamicScene();
game.goToScene(dynamicSceneKey);
break;
}
});
const devtool = new DevTool(game);
{
"name": "@excaliburjs/dev-tools",
"version": "0.27.0",
"version": "0.27.1",
"description": "Excalibur Debug Tools",

@@ -5,0 +5,0 @@ "source": "./dev-tools.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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