diff --git a/CHANGELOG.MD b/CHANGELOG.MD
index 15d3cc9f0..8407d57a5 100644
--- a/CHANGELOG.MD
+++ b/CHANGELOG.MD
@@ -1,5 +1,19 @@
# Change Log
+## v3.60.0 - Apr 16, 2023
+
+* Fixes labels of the Size section in the Inspector view.
+* Scene compiler: fixes class-field declaration.
+* Scene compiler: fixes nested prefab varname resolution.
+* Improves folder icons.
+* Adds command for enable/disable pixel art rendering mode.
+* New game objects support: NineSlice and ThreeSlice.
+* Removes Parent section.
+* Supports the new ScriptNode object.
+* Updates the app icon.
+* Updates to Phaser 3.60.
+* Updates allInOne built-in templates to support Phaser 3.60 and script nodes.
+
## v3.36.2 - Dec 14, 2022
* Get latest update from Core:
diff --git a/design/blender-mono/custom/nineslice/dark/3slice.png b/design/blender-mono/custom/nineslice/dark/3slice.png
new file mode 100644
index 000000000..29eb8687a
Binary files /dev/null and b/design/blender-mono/custom/nineslice/dark/3slice.png differ
diff --git a/design/blender-mono/custom/nineslice/dark/3slice@2x.png b/design/blender-mono/custom/nineslice/dark/3slice@2x.png
new file mode 100644
index 000000000..d60f64cb2
Binary files /dev/null and b/design/blender-mono/custom/nineslice/dark/3slice@2x.png differ
diff --git a/design/blender-mono/custom/nineslice/dark/9slice.png b/design/blender-mono/custom/nineslice/dark/9slice.png
new file mode 100644
index 000000000..91be9336d
Binary files /dev/null and b/design/blender-mono/custom/nineslice/dark/9slice.png differ
diff --git a/design/blender-mono/custom/nineslice/dark/9slice@2x.png b/design/blender-mono/custom/nineslice/dark/9slice@2x.png
new file mode 100644
index 000000000..7a314516e
Binary files /dev/null and b/design/blender-mono/custom/nineslice/dark/9slice@2x.png differ
diff --git a/design/blender-mono/custom/nineslice/light/3slice.png b/design/blender-mono/custom/nineslice/light/3slice.png
new file mode 100644
index 000000000..b7d2c2f06
Binary files /dev/null and b/design/blender-mono/custom/nineslice/light/3slice.png differ
diff --git a/design/blender-mono/custom/nineslice/light/3slice@2x.png b/design/blender-mono/custom/nineslice/light/3slice@2x.png
new file mode 100644
index 000000000..c7df8adf1
Binary files /dev/null and b/design/blender-mono/custom/nineslice/light/3slice@2x.png differ
diff --git a/design/blender-mono/custom/nineslice/light/9slice.png b/design/blender-mono/custom/nineslice/light/9slice.png
new file mode 100644
index 000000000..5dd748809
Binary files /dev/null and b/design/blender-mono/custom/nineslice/light/9slice.png differ
diff --git a/design/blender-mono/custom/nineslice/light/9slice@2x.png b/design/blender-mono/custom/nineslice/light/9slice@2x.png
new file mode 100644
index 000000000..896514625
Binary files /dev/null and b/design/blender-mono/custom/nineslice/light/9slice@2x.png differ
diff --git a/design/blender-mono/custom/nineslice/nineslice.svg b/design/blender-mono/custom/nineslice/nineslice.svg
new file mode 100644
index 000000000..55cf72d2d
--- /dev/null
+++ b/design/blender-mono/custom/nineslice/nineslice.svg
@@ -0,0 +1,7101 @@
+
+
+
+
diff --git a/design/logo-icons/1024.png b/design/logo-icons/1024.png
new file mode 100644
index 000000000..1e4046695
Binary files /dev/null and b/design/logo-icons/1024.png differ
diff --git a/design/logo-icons/128.png b/design/logo-icons/128.png
index 97895c2ff..72b41a151 100644
Binary files a/design/logo-icons/128.png and b/design/logo-icons/128.png differ
diff --git a/design/logo-icons/256.png b/design/logo-icons/256.png
index 3a2f17a7c..b8d34a418 100644
Binary files a/design/logo-icons/256.png and b/design/logo-icons/256.png differ
diff --git a/design/logo-icons/32.png b/design/logo-icons/32.png
index 252a6c1a7..1d0bb3eac 100644
Binary files a/design/logo-icons/32.png and b/design/logo-icons/32.png differ
diff --git a/design/logo-icons/48.png b/design/logo-icons/48.png
index 4f9c5bc1c..924c8c54a 100644
Binary files a/design/logo-icons/48.png and b/design/logo-icons/48.png differ
diff --git a/design/logo-icons/512.png b/design/logo-icons/512.png
new file mode 100644
index 000000000..a435efb9e
Binary files /dev/null and b/design/logo-icons/512.png differ
diff --git a/design/logo-icons/64.png b/design/logo-icons/64.png
index 8bd53ff0e..313bef195 100644
Binary files a/design/logo-icons/64.png and b/design/logo-icons/64.png differ
diff --git a/design/logo-icons/build-icons.sh b/design/logo-icons/build-icons.sh
new file mode 100755
index 000000000..16bfb1420
--- /dev/null
+++ b/design/logo-icons/build-icons.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# optipng *.png
+
+convert 16.png 32.png 48.png 256.png icon.ico
+
+rm -Rf icon.iconset
+mkdir icon.iconset
+
+cp 16.png icon.iconset/icon_16x16.png
+
+cp 32.png icon.iconset/icon_16x16@2x.png
+cp 32.png icon.iconset/icon_32x32.png
+
+cp 64.png icon.iconset/icon_32x32@2x.png
+cp 64.png icon.iconset/icon_64x64.png
+
+cp 128.png icon.iconset/icon_64x64@2x.png
+cp 128.png icon.iconset/icon_128x128.png
+
+cp 512.png icon.iconset/icon_64x64@2x.png
+cp 512.png icon.iconset/icon_512x512.png
+
+cp 1024.png icon.iconset/icon_512x512@2x.png
+
+iconutil -c icns icon.iconset/
+
+rm -R icon.iconset
\ No newline at end of file
diff --git a/design/logo-icons/dark-128.png b/design/logo-icons/dark-128.png
new file mode 100644
index 000000000..6cd0f2c47
Binary files /dev/null and b/design/logo-icons/dark-128.png differ
diff --git a/design/logo-icons/drawing.svg b/design/logo-icons/drawing.svg
new file mode 100644
index 000000000..50b5703a8
--- /dev/null
+++ b/design/logo-icons/drawing.svg
@@ -0,0 +1,3810 @@
+
+
+
+
diff --git a/design/logo-icons/icon.icns b/design/logo-icons/icon.icns
new file mode 100644
index 000000000..bb659a08d
Binary files /dev/null and b/design/logo-icons/icon.icns differ
diff --git a/design/logo-icons/icon.ico b/design/logo-icons/icon.ico
new file mode 100644
index 000000000..1433166fa
Binary files /dev/null and b/design/logo-icons/icon.ico differ
diff --git a/design/logo-icons/logo.png b/design/logo-icons/logo.png
deleted file mode 100644
index cd15a158e..000000000
Binary files a/design/logo-icons/logo.png and /dev/null differ
diff --git a/scripts/make-all-help-files.js b/scripts/make-all-help-files.js
index 6333b40b9..019f6ea36 100755
--- a/scripts/make-all-help-files.js
+++ b/scripts/make-all-help-files.js
@@ -120,6 +120,12 @@ utils.makeHelpFile([
"Phaser.GameObjects.TileSprite.tileScaleY",
"Phaser.GameObjects.TileSprite.setTileScale",
+ "Phaser.GameObjects.NineSlice",
+ "Phaser.GameObjects.NineSlice.leftWidth",
+ "Phaser.GameObjects.NineSlice.rightWidth",
+ "Phaser.GameObjects.NineSlice.topHeight",
+ "Phaser.GameObjects.NineSlice.bottomHeight",
+
"Phaser.GameObjects.GameObject.parentContainer",
"Phaser.GameObjects.Text",
diff --git a/source/editor/package.json b/source/editor/package.json
index 6c03739d0..1ae4da1de 100644
--- a/source/editor/package.json
+++ b/source/editor/package.json
@@ -7,7 +7,7 @@
"start": "tsc -b -w",
"build": "tsc -b",
"clean": "tsc -b -clean",
- "editor-dev": "PhaserEditor2D -editor . -project \"$PHASEREDITOR_DEMO_PROJECT\" -dev -disable-plugins phasereditor2d.code"
+ "editor-dev": "PhaserEditor2D -editor . -project \"$PHASEREDITOR_DEMO_PROJECT\" -dev"
},
"devDependencies": {
"tslint": "^6.1.3",
diff --git a/source/editor/plugins/colibri/icons/dark/folder.png b/source/editor/plugins/colibri/icons/dark/folder.png
index 1cdad53eb..3369e8bc8 100644
Binary files a/source/editor/plugins/colibri/icons/dark/folder.png and b/source/editor/plugins/colibri/icons/dark/folder.png differ
diff --git a/source/editor/plugins/colibri/icons/dark/folder@2x.png b/source/editor/plugins/colibri/icons/dark/folder@2x.png
index 5874a3aa5..4f7dfcda5 100644
Binary files a/source/editor/plugins/colibri/icons/dark/folder@2x.png and b/source/editor/plugins/colibri/icons/dark/folder@2x.png differ
diff --git a/source/editor/plugins/colibri/icons/light/folder.png b/source/editor/plugins/colibri/icons/light/folder.png
index 16298ccde..ba371ec09 100644
Binary files a/source/editor/plugins/colibri/icons/light/folder.png and b/source/editor/plugins/colibri/icons/light/folder.png differ
diff --git a/source/editor/plugins/colibri/icons/light/folder@2x.png b/source/editor/plugins/colibri/icons/light/folder@2x.png
index 1e58be1a2..63dc667b5 100644
Binary files a/source/editor/plugins/colibri/icons/light/folder@2x.png and b/source/editor/plugins/colibri/icons/light/folder@2x.png differ
diff --git a/source/editor/plugins/colibri/src/ui/controls/viewers/GridTreeViewerRenderer.ts b/source/editor/plugins/colibri/src/ui/controls/viewers/GridTreeViewerRenderer.ts
index b1c84a1d6..67c3f27a1 100644
--- a/source/editor/plugins/colibri/src/ui/controls/viewers/GridTreeViewerRenderer.ts
+++ b/source/editor/plugins/colibri/src/ui/controls/viewers/GridTreeViewerRenderer.ts
@@ -458,15 +458,25 @@ namespace colibri.ui.controls.viewers {
this.prepareContextForText(args);
- const label = args.viewer.getLabelProvider().getLabel(args.obj);
+ const labelProvider = args.viewer.getLabelProvider();
+ const styledLabelProvider = args.viewer.getStyledLabelProvider();
- const trim = this.trimLabel(ctx, label, args.w - 10);
+ const label = labelProvider.getLabel(args.obj);
- const x2 = Math.max(x, x + args.w / 2 - trim.textWidth / 2);
+ const trimLabel = this.trimLabel(ctx, label, args.w - 10);
+
+ const x2 = Math.max(x, x + args.w / 2 - trimLabel.textWidth / 2);
const y2 = args.y + args.h - 5;
- ctx.fillText(trim.text, x2, y2);
+ if (styledLabelProvider && !selected) {
+
+ this.renderStyledLabel(args, x2, y2, styledLabelProvider, trimLabel.text.length);
+
+ } else {
+
+ ctx.fillText(trimLabel.text, x2, y2);
+ }
ctx.restore();
diff --git a/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewerRenderer.ts b/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewerRenderer.ts
index d6731d82e..b9fb12acd 100644
--- a/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewerRenderer.ts
+++ b/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewerRenderer.ts
@@ -288,7 +288,7 @@ namespace colibri.ui.controls.viewers {
args.canvasContext.fillText(label, x, y);
}
- protected renderStyledLabel(args: RenderCellArgs, x: number, y: number, styledProvider: IStyledLabelProvider) {
+ protected renderStyledLabel(args: RenderCellArgs, x: number, y: number, styledProvider: IStyledLabelProvider, maxLength = -1) {
const dark = controls.Controls.getTheme().dark;
@@ -300,15 +300,31 @@ namespace colibri.ui.controls.viewers {
ctx.save();
+ let len = 0;
+
for (const part of parts) {
ctx.fillStyle = part.color;
- ctx.fillText(part.text, cursor, y);
+ let text = part.text;
+
+ if (maxLength > 0 && len + part.text.length > maxLength) {
+
+ text = text.substring(0, maxLength - len - 2) + "..";
+ }
+
+ ctx.fillText(text, cursor, y);
- const width = this.measureText(args, part.text);
+ const width = this.measureText(args, text);
cursor += width;
+
+ len += text.length;
+
+ if (maxLength > 0 && len >= maxLength) {
+
+ break;
+ }
}
ctx.restore();
diff --git a/source/editor/plugins/phasereditor2d.animations/data/phaser-docs.json b/source/editor/plugins/phasereditor2d.animations/data/phaser-docs.json
index 59505f419..71c70a048 100644
--- a/source/editor/plugins/phasereditor2d.animations/data/phaser-docs.json
+++ b/source/editor/plugins/phasereditor2d.animations/data/phaser-docs.json
@@ -5,7 +5,7 @@
"Phaser.Types.Animations.Animation.repeat": "Number of times to repeat the animation (-1 for infinity)",
"Phaser.Types.Animations.Animation.repeatDelay": "Delay before the animation repeats. Value given in milliseconds.",
"Phaser.Types.Animations.Animation.yoyo": "Should the animation yoyo? (reverse back down to the start) before repeating?",
- "Phaser.Types.Animations.Animation.showOnStart": "Should sprite.visible = true when the animation starts to play?",
+ "Phaser.Types.Animations.Animation.showOnStart": "Should sprite.visible = true when the animation starts to play? This happens _after_ any delay, if set.",
"Phaser.Types.Animations.Animation.hideOnComplete": "Should sprite.visible = false when the animation finishes?",
"Phaser.Types.Animations.Animation.skipMissedFrames": "Skip frames if the time lags, or always advanced anyway?"
}
\ No newline at end of file
diff --git a/source/editor/plugins/phasereditor2d.files/icons/dark/project.png b/source/editor/plugins/phasereditor2d.files/icons/dark/project.png
index 1cdad53eb..3369e8bc8 100644
Binary files a/source/editor/plugins/phasereditor2d.files/icons/dark/project.png and b/source/editor/plugins/phasereditor2d.files/icons/dark/project.png differ
diff --git a/source/editor/plugins/phasereditor2d.files/icons/dark/project@2x.png b/source/editor/plugins/phasereditor2d.files/icons/dark/project@2x.png
index 5874a3aa5..4f7dfcda5 100644
Binary files a/source/editor/plugins/phasereditor2d.files/icons/dark/project@2x.png and b/source/editor/plugins/phasereditor2d.files/icons/dark/project@2x.png differ
diff --git a/source/editor/plugins/phasereditor2d.files/icons/light/project.png b/source/editor/plugins/phasereditor2d.files/icons/light/project.png
index 16298ccde..ba371ec09 100644
Binary files a/source/editor/plugins/phasereditor2d.files/icons/light/project.png and b/source/editor/plugins/phasereditor2d.files/icons/light/project.png differ
diff --git a/source/editor/plugins/phasereditor2d.files/icons/light/project@2x.png b/source/editor/plugins/phasereditor2d.files/icons/light/project@2x.png
index 1e58be1a2..63dc667b5 100644
Binary files a/source/editor/plugins/phasereditor2d.files/icons/light/project@2x.png and b/source/editor/plugins/phasereditor2d.files/icons/light/project@2x.png differ
diff --git a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts
index 20ced08d0..0b969baf3 100644
--- a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts
+++ b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts
@@ -261,7 +261,7 @@ namespace phasereditor2d.ide {
/* program entry point */
- export const VER = "3.36.2";
+ export const VER = "3.60.0";
async function main() {
diff --git a/source/editor/plugins/phasereditor2d.ide/src/core/code/CodeUtils.ts b/source/editor/plugins/phasereditor2d.ide/src/core/code/CodeUtils.ts
index 23eec3fef..4932c4e3a 100644
--- a/source/editor/plugins/phasereditor2d.ide/src/core/code/CodeUtils.ts
+++ b/source/editor/plugins/phasereditor2d.ide/src/core/code/CodeUtils.ts
@@ -15,7 +15,7 @@ namespace phasereditor2d.ide.core.code {
return "./" + importFile.getNameWithoutExtension();
}
- if (importFilePath.startsWith(parentPath)) {
+ if (importFilePath.startsWith(parentPath + "/")) {
return "./" + importFileElements.slice(parentElements.length).join("/");
}
diff --git a/source/editor/plugins/phasereditor2d.pack/src/ui/viewers/AssetPackGrouping.ts b/source/editor/plugins/phasereditor2d.pack/src/ui/viewers/AssetPackGrouping.ts
index ba2b9774c..23c0c1b8a 100644
--- a/source/editor/plugins/phasereditor2d.pack/src/ui/viewers/AssetPackGrouping.ts
+++ b/source/editor/plugins/phasereditor2d.pack/src/ui/viewers/AssetPackGrouping.ts
@@ -25,7 +25,7 @@ namespace phasereditor2d.pack.ui.viewers {
window.localStorage["phasereditor2d.scene.ui.blocks.SceneEditorBlocksProvider.assetGrouping"] = groupType;
}
- static getGroupingPreference() {
+ static getGroupingPreference(): string {
return window.localStorage["phasereditor2d.scene.ui.blocks.SceneEditorBlocksProvider.assetGrouping"]
|| AssetPackGrouping.GROUP_ASSETS_BY_TYPE;
diff --git a/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js b/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js
old mode 100755
new mode 100644
index 296df62db..abcbac12f
--- a/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js
+++ b/source/editor/plugins/phasereditor2d.phaser/scripts/phaser.js
@@ -7,22046 +7,23056 @@
exports["Phaser"] = factory();
else
root["Phaser"] = factory();
-})(this, 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, { enumerable: true, get: getter });
-/******/ }
-/******/ };
-/******/
-/******/ // define __esModule on exports
-/******/ __webpack_require__.r = function(exports) {
-/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
-/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
-/******/ }
-/******/ Object.defineProperty(exports, '__esModule', { value: true });
-/******/ };
-/******/
-/******/ // create a fake namespace object
-/******/ // mode & 1: value is a module id, require it
-/******/ // mode & 2: merge all properties of value into the ns
-/******/ // mode & 4: return value when already ns object
-/******/ // mode & 8|1: behave like require
-/******/ __webpack_require__.t = function(value, mode) {
-/******/ if(mode & 1) value = __webpack_require__(value);
-/******/ if(mode & 8) return value;
-/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
-/******/ var ns = Object.create(null);
-/******/ __webpack_require__.r(ns);
-/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
-/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
-/******/ return ns;
-/******/ };
-/******/
-/******/ // 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 = 1528);
-/******/ })
-/************************************************************************/
-/******/ ([
-/* 0 */
-/***/ (function(module, exports) {
+})(this, () => {
+return /******/ (() => { // webpackBootstrap
+/******/ var __webpack_modules__ = ({
+
+/***/ 6659:
+/***/ ((module) => {
+
+"use strict";
+
+
+var has = Object.prototype.hasOwnProperty
+ , prefix = '~';
/**
- * @author Richard Davey
- * @copyright 2020 Photon Storm Ltd.
- * @license {@link https://opensource.org/licenses/MIT|MIT License}
+ * Constructor to create a storage for our `EE` objects.
+ * An `Events` instance is a plain object whose properties are event names.
+ *
+ * @constructor
+ * @private
*/
+function Events() {}
-// Taken from klasse by mattdesl https://github.com/mattdesl/klasse
+//
+// We try to not inherit from `Object.prototype`. In some engines creating an
+// instance in this way is faster than calling `Object.create(null)` directly.
+// If `Object.create(null)` is not supported we prefix the event names with a
+// character to make sure that the built-in object properties are not
+// overridden or used as an attack vector.
+//
+if (Object.create) {
+ Events.prototype = Object.create(null);
-function hasGetterOrSetter (def)
-{
- return (!!def.get && typeof def.get === 'function') || (!!def.set && typeof def.set === 'function');
+ //
+ // This hack is needed because the `__proto__` property is still inherited in
+ // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
+ //
+ if (!new Events().__proto__) prefix = false;
}
-function getProperty (definition, k, isClassDescriptor)
-{
- // This may be a lightweight object, OR it might be a property that was defined previously.
+/**
+ * Representation of a single event listener.
+ *
+ * @param {Function} fn The listener function.
+ * @param {*} context The context to invoke the listener with.
+ * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
+ * @constructor
+ * @private
+ */
+function EE(fn, context, once) {
+ this.fn = fn;
+ this.context = context;
+ this.once = once || false;
+}
- // For simple class descriptors we can just assume its NOT previously defined.
- var def = (isClassDescriptor) ? definition[k] : Object.getOwnPropertyDescriptor(definition, k);
+/**
+ * Add a listener for a given event.
+ *
+ * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
+ * @param {(String|Symbol)} event The event name.
+ * @param {Function} fn The listener function.
+ * @param {*} context The context to invoke the listener with.
+ * @param {Boolean} once Specify if the listener is a one-time listener.
+ * @returns {EventEmitter}
+ * @private
+ */
+function addListener(emitter, event, fn, context, once) {
+ if (typeof fn !== 'function') {
+ throw new TypeError('The listener must be a function');
+ }
- if (!isClassDescriptor && def.value && typeof def.value === 'object')
- {
- def = def.value;
- }
+ var listener = new EE(fn, context || emitter, once)
+ , evt = prefix ? prefix + event : event;
- // This might be a regular property, or it may be a getter/setter the user defined in a class.
- if (def && hasGetterOrSetter(def))
- {
- if (typeof def.enumerable === 'undefined')
- {
- def.enumerable = true;
- }
+ if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
+ else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
+ else emitter._events[evt] = [emitter._events[evt], listener];
- if (typeof def.configurable === 'undefined')
- {
- def.configurable = true;
- }
+ return emitter;
+}
- return def;
- }
- else
- {
- return false;
- }
+/**
+ * Clear event by name.
+ *
+ * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
+ * @param {(String|Symbol)} evt The Event name.
+ * @private
+ */
+function clearEvent(emitter, evt) {
+ if (--emitter._eventsCount === 0) emitter._events = new Events();
+ else delete emitter._events[evt];
}
-function hasNonConfigurable (obj, k)
-{
- var prop = Object.getOwnPropertyDescriptor(obj, k);
+/**
+ * Minimal `EventEmitter` interface that is molded against the Node.js
+ * `EventEmitter` interface.
+ *
+ * @constructor
+ * @public
+ */
+function EventEmitter() {
+ this._events = new Events();
+ this._eventsCount = 0;
+}
- if (!prop)
- {
- return false;
- }
+/**
+ * Return an array listing the events for which the emitter has registered
+ * listeners.
+ *
+ * @returns {Array}
+ * @public
+ */
+EventEmitter.prototype.eventNames = function eventNames() {
+ var names = []
+ , events
+ , name;
- if (prop.value && typeof prop.value === 'object')
- {
- prop = prop.value;
- }
+ if (this._eventsCount === 0) return names;
- if (prop.configurable === false)
- {
- return true;
- }
+ for (name in (events = this._events)) {
+ if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
+ }
- return false;
-}
+ if (Object.getOwnPropertySymbols) {
+ return names.concat(Object.getOwnPropertySymbols(events));
+ }
+
+ return names;
+};
/**
- * Extends the given `myClass` object's prototype with the properties of `definition`.
+ * Return the listeners registered for a given event.
*
- * @function extend
- * @ignore
- * @param {Object} ctor The constructor object to mix into.
- * @param {Object} definition A dictionary of functions for the class.
- * @param {boolean} isClassDescriptor Is the definition a class descriptor?
- * @param {Object} [extend] The parent constructor object.
+ * @param {(String|Symbol)} event The event name.
+ * @returns {Array} The registered listeners.
+ * @public
*/
-function extend (ctor, definition, isClassDescriptor, extend)
-{
- for (var k in definition)
- {
- if (!definition.hasOwnProperty(k))
- {
- continue;
- }
-
- var def = getProperty(definition, k, isClassDescriptor);
+EventEmitter.prototype.listeners = function listeners(event) {
+ var evt = prefix ? prefix + event : event
+ , handlers = this._events[evt];
- if (def !== false)
- {
- // If Extends is used, we will check its prototype to see if the final variable exists.
+ if (!handlers) return [];
+ if (handlers.fn) return [handlers.fn];
- var parent = extend || ctor;
+ for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
+ ee[i] = handlers[i].fn;
+ }
- if (hasNonConfigurable(parent.prototype, k))
- {
- // Just skip the final property
- if (Class.ignoreFinals)
- {
- continue;
- }
+ return ee;
+};
- // We cannot re-define a property that is configurable=false.
- // So we will consider them final and throw an error. This is by
- // default so it is clear to the developer what is happening.
- // You can set ignoreFinals to true if you need to extend a class
- // which has configurable=false; it will simply not re-define final properties.
- throw new Error('cannot override final property \'' + k + '\', set Class.ignoreFinals = true to skip');
- }
+/**
+ * Return the number of listeners listening to a given event.
+ *
+ * @param {(String|Symbol)} event The event name.
+ * @returns {Number} The number of listeners.
+ * @public
+ */
+EventEmitter.prototype.listenerCount = function listenerCount(event) {
+ var evt = prefix ? prefix + event : event
+ , listeners = this._events[evt];
- Object.defineProperty(ctor.prototype, k, def);
- }
- else
- {
- ctor.prototype[k] = definition[k];
- }
- }
-}
+ if (!listeners) return 0;
+ if (listeners.fn) return 1;
+ return listeners.length;
+};
/**
- * Applies the given `mixins` to the prototype of `myClass`.
+ * Calls each of the listeners registered for a given event.
*
- * @function mixin
- * @ignore
- * @param {Object} myClass The constructor object to mix into.
- * @param {Object|Array