neon 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jshintrc +3 -0
- package/CHANGELOG.markdown +20 -1
- package/LICENSE +21 -0
- package/README.markdown +8 -4
- package/bower.json +23 -0
- package/license.txt +9 -0
- package/neon.js +201 -186
- package/package.json +18 -9
- package/stdlib/bubbling_support.js +32 -0
- package/stdlib/custom_event.js +54 -0
- package/stdlib/custom_event_support.js +195 -0
- package/stdlib/index.js +7 -0
- package/stdlib/node_support.js +123 -0
- package/stdlib/widget.js +340 -0
- package/test/neon_stdlib_browser.html +15 -0
- package/test/neon_stdlib_test.js +84 -0
- package/test/neon_test.js +1 -7
- /package/test/{browser.html → neon_browser.html} +0 -0
package/.jshintrc
ADDED
package/CHANGELOG.markdown
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
2.0.0 (2014-02-15)
|
|
2
|
+
|
|
3
|
+
- Requiring now adds Class, Module, Interface to global scope (neon)
|
|
4
|
+
- You can now require the stdlib with require('neon/stdlib')
|
|
5
|
+
- Requiring now adds CustomEvent, CustomEventSupport, NodeSupport
|
|
6
|
+
and BubblingSupport to the global scope (stdlib)
|
|
7
|
+
- Major version bump because it's not compatible with 1.x (The other
|
|
8
|
+
was loaded in a namespace)
|
|
9
|
+
|
|
10
|
+
1.1.0 (2014-01-29)
|
|
11
|
+
|
|
12
|
+
- Added stdlib, consisting on:
|
|
13
|
+
- NodeSupport
|
|
14
|
+
- CustomEvent and CustomEventSupport
|
|
15
|
+
- BubblingSupport
|
|
16
|
+
- Added tests for stdlib
|
|
17
|
+
- Moved files to /lib
|
|
18
|
+
|
|
1
19
|
1.0.0 (2012-06-23)
|
|
2
20
|
|
|
3
|
-
Cleaned up and packed Neon library, used already in production.
|
|
21
|
+
- Cleaned up and packed Neon library, used already in production.
|
|
22
|
+
Added usage files, improved documentation.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Freshout.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.markdown
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# Neon
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## JavaScript DSL for Classical Inheritance
|
|
4
4
|
|
|
5
5
|
This files provides a DSL for the following design patterns:
|
|
6
6
|
|
|
@@ -13,7 +13,11 @@ Neon packs a DSL for Class creation, that helps in making programs following an
|
|
|
13
13
|
The philosophy is that it should not try to emulate other languages, so it preserves the JavaScript good parts,
|
|
14
14
|
but with a nicer syntax to create classes that ensure interfaces and include reusable functionality as modules.
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
## Why another Class System?
|
|
17
|
+
|
|
18
|
+
As the web applications are getting more complex these times, backend and frontend engineers work has fusioned, and they need to be able to establish a common language. It was created for people coming from OOP languages like Ruby to Javascript.
|
|
19
|
+
|
|
20
|
+
### Usage
|
|
17
21
|
|
|
18
22
|
Interface('Editable')({
|
|
19
23
|
constructor : ['x'],
|
|
@@ -48,7 +52,7 @@ but with a nicer syntax to create classes that ensure interfaces and include reu
|
|
|
48
52
|
}
|
|
49
53
|
});
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
## License
|
|
52
56
|
|
|
53
57
|
Copyright (c) 2009 Fernando Trasviña
|
|
54
58
|
|
package/bower.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "neon",
|
|
3
|
+
"main": "neon.js",
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"homepage": "https://github.com/azendal/neon",
|
|
6
|
+
"authors": [
|
|
7
|
+
"Fernando Trasviña <fernando@freshout.us>"
|
|
8
|
+
],
|
|
9
|
+
"description": "JavaScript DSL for Classical Inheritance",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"DSL",
|
|
12
|
+
"class",
|
|
13
|
+
"inheritance"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"ignore": [
|
|
17
|
+
"**/.*",
|
|
18
|
+
"node_modules",
|
|
19
|
+
"bower_components",
|
|
20
|
+
"test",
|
|
21
|
+
"tests"
|
|
22
|
+
]
|
|
23
|
+
}
|
package/license.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2009-2017 Fernando Trasvina
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/neon.js
CHANGED
|
@@ -1,219 +1,234 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* neon.js v1.0.0 http://github.com/azendal/neon
|
|
3
|
-
*
|
|
4
|
-
* Class DSL
|
|
5
|
-
* This files provides a dsl for the following design patterns:
|
|
6
|
-
* inheritance, interface, module.
|
|
7
|
-
*
|
|
8
|
-
* It also provides a dsl for class creation.
|
|
9
|
-
*
|
|
10
|
-
* The philosophy is that it should not try to emulate other languages,
|
|
11
|
-
* and it preserves the javascript good parts, but with a nicer syntax to
|
|
12
|
-
* create classes that ensure interfaces and include reusable functionality as modules.
|
|
13
|
-
*
|
|
14
|
-
* Author: Fernando Trasviña
|
|
15
|
-
*
|
|
16
|
-
* Usage:
|
|
17
|
-
* Interface('Editable')({
|
|
18
|
-
* constructor : ['x'],
|
|
19
|
-
* prototype : ['x']
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* Module('Composition')({
|
|
23
|
-
* y : 5,
|
|
24
|
-
* prototype : {
|
|
25
|
-
* z : 3
|
|
26
|
-
* }
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* Module('Other')({
|
|
30
|
-
* a : 5,
|
|
31
|
-
* prototype : {
|
|
32
|
-
* b : 3
|
|
33
|
-
* }
|
|
34
|
-
* });
|
|
35
|
-
*
|
|
36
|
-
* Class('Overlay').inherits(Widget).ensures(Editable).includes(Composition, Other)({
|
|
37
|
-
* html : '<div></div>',
|
|
38
|
-
* prototype : {
|
|
39
|
-
* init : function (element){
|
|
40
|
-
* if(!element){
|
|
41
|
-
* element = document.createElement('div');
|
|
42
|
-
* element.innerHTML = 'hello';
|
|
43
|
-
* document.body.appendChild(element);
|
|
44
|
-
* }
|
|
45
|
-
* },
|
|
46
|
-
* b : 5
|
|
47
|
-
* }
|
|
48
|
-
* });
|
|
49
|
-
*/
|
|
50
|
-
(function(global) {
|
|
51
|
-
|
|
52
|
-
var Neon = {};
|
|
53
|
-
|
|
54
|
-
Neon.Interface = function Interface(nameOrNameSpace, name) {
|
|
55
|
-
var nameSpace, interfaceName, factory;
|
|
56
|
-
nameSpace = (nameOrNameSpace && name) ? nameOrNameSpace : this;
|
|
57
|
-
interfaceName = (nameOrNameSpace && name) ? name :
|
|
58
|
-
(nameOrNameSpace) ? nameOrNameSpace : 'interface' + Math.random().toString();
|
|
59
|
-
factory = function(definition) {
|
|
60
|
-
definition.isInterface = true;
|
|
61
|
-
definition.name = interfaceName;
|
|
62
|
-
nameSpace[interfaceName] = definition;
|
|
63
|
-
return nameSpace[interfaceName];
|
|
64
|
-
};
|
|
65
|
-
return factory;
|
|
66
|
-
};
|
|
67
1
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
2
|
+
if (typeof global === "undefined") {
|
|
3
|
+
global = window;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
global.Interface = function Interface(nameOrNameSpace, name) {
|
|
7
|
+
var nameSpace, interfaceName, factory;
|
|
8
|
+
nameSpace = (nameOrNameSpace && name) ? nameOrNameSpace : this;
|
|
9
|
+
interfaceName = (nameOrNameSpace && name) ? name :
|
|
10
|
+
(nameOrNameSpace) ? nameOrNameSpace : 'interface' + Math.random().toString();
|
|
11
|
+
factory = function(definition) {
|
|
12
|
+
definition.isInterface = true;
|
|
13
|
+
definition.name = interfaceName;
|
|
14
|
+
nameSpace[interfaceName] = definition;
|
|
15
|
+
return nameSpace[interfaceName];
|
|
79
16
|
};
|
|
17
|
+
return factory;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
global.Module = function Module(nameOrNameSpace, name) {
|
|
21
|
+
var nameSpace, moduleName, factory, newModule;
|
|
22
|
+
|
|
23
|
+
nameSpace = (nameOrNameSpace && name) ? nameOrNameSpace : this;
|
|
24
|
+
moduleName = (nameOrNameSpace && name) ? name :
|
|
25
|
+
(nameOrNameSpace) ? nameOrNameSpace : 'module' + Math.random().toString();
|
|
26
|
+
|
|
27
|
+
newModule = {
|
|
28
|
+
moduleName : moduleName,
|
|
29
|
+
prototype : {},
|
|
30
|
+
__includedModules : [],
|
|
31
|
+
include : function(module) {
|
|
32
|
+
var property;
|
|
33
|
+
for (property in module) {
|
|
34
|
+
if (module.hasOwnProperty(property)
|
|
35
|
+
&& property !== 'prototype'
|
|
36
|
+
&& property !== 'isModule'
|
|
37
|
+
&& property !== '__includedModules'
|
|
38
|
+
&& property !== 'include'
|
|
39
|
+
&& property !== 'moduleName') {
|
|
40
|
+
newModule[property] = module[property];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (module.hasOwnProperty('prototype') && module.prototype) {
|
|
45
|
+
for (property in module.prototype) {
|
|
46
|
+
if (module.prototype.hasOwnProperty(property)) {
|
|
47
|
+
newModule.prototype[property] = module.prototype[property];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
module.prototype = {};
|
|
53
|
+
}
|
|
80
54
|
|
|
81
|
-
|
|
82
|
-
var nameSpace, newClass, classFactory;
|
|
83
|
-
nameSpace = (classNameOrNameSpace && className) ? classNameOrNameSpace : this;
|
|
84
|
-
className = (classNameOrNameSpace && className) ? className :
|
|
85
|
-
(classNameOrNameSpace) ? classNameOrNameSpace : 'class' + Math.random().toString();
|
|
55
|
+
this.__includedModules.push(module);
|
|
86
56
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
factory = function(definition){
|
|
62
|
+
var property;
|
|
63
|
+
|
|
64
|
+
newModule.isModule = true;
|
|
65
|
+
|
|
66
|
+
for (property in definition) {
|
|
67
|
+
if (definition.hasOwnProperty(property)
|
|
68
|
+
&& property !== 'prototype'
|
|
69
|
+
&& property !== 'isModule'
|
|
70
|
+
&& property !== '__includedModules'
|
|
71
|
+
&& property !== 'include'
|
|
72
|
+
&& property !== 'moduleName') {
|
|
73
|
+
newModule[property] = definition[property];
|
|
90
74
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
newClass.include = function(module) {
|
|
98
|
-
var property;
|
|
99
|
-
for (property in module) {
|
|
100
|
-
if (module.hasOwnProperty(property)
|
|
101
|
-
&& property != 'prototype'
|
|
102
|
-
&& property != 'constructor'
|
|
103
|
-
&& property != 'isModule'
|
|
104
|
-
&& property != 'superClass') {
|
|
105
|
-
newClass[property] = module[property];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (definition.hasOwnProperty('prototype') && definition.prototype) {
|
|
78
|
+
for (property in definition.prototype) {
|
|
79
|
+
if (definition.prototype.hasOwnProperty(property)) {
|
|
80
|
+
newModule.prototype[property] = definition.prototype[property];
|
|
106
81
|
}
|
|
107
82
|
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
nameSpace[moduleName] = newModule;
|
|
86
|
+
|
|
87
|
+
return nameSpace[moduleName];
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
factory.includes = function () {
|
|
91
|
+
for(var i = 0; i < arguments.length; i++){
|
|
92
|
+
newModule.include(arguments[i]);
|
|
93
|
+
}
|
|
94
|
+
return factory;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return factory;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
global.Class = function Class(classNameOrNameSpace, className) {
|
|
101
|
+
var nameSpace, newClass, classFactory;
|
|
102
|
+
nameSpace = (classNameOrNameSpace && className) ? classNameOrNameSpace : global;
|
|
103
|
+
className = (classNameOrNameSpace && className) ? className :
|
|
104
|
+
(classNameOrNameSpace) ? classNameOrNameSpace : 'class' + Math.random().toString();
|
|
105
|
+
|
|
106
|
+
newClass = function() {
|
|
107
|
+
if (this.init) {
|
|
108
|
+
this.init.apply(this, arguments);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
newClass.__descendants = [];
|
|
113
|
+
newClass.__implementedInterfaces = [];
|
|
114
|
+
newClass.__includedModules = [];
|
|
115
|
+
newClass.className = className;
|
|
116
|
+
newClass.include = function(module) {
|
|
117
|
+
var property;
|
|
118
|
+
for (property in module) {
|
|
119
|
+
if (module.hasOwnProperty(property)
|
|
120
|
+
&& property != 'prototype'
|
|
121
|
+
&& property != 'constructor'
|
|
122
|
+
&& property != 'isModule'
|
|
123
|
+
&& property != 'superClass'
|
|
124
|
+
&& property != 'include') {
|
|
125
|
+
newClass[property] = module[property];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
108
128
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
129
|
+
if (module.hasOwnProperty('prototype') && module.prototype) {
|
|
130
|
+
for (property in module.prototype) {
|
|
131
|
+
if (module.prototype.hasOwnProperty(property)) {
|
|
132
|
+
newClass.prototype[property] = module.prototype[property];
|
|
114
133
|
}
|
|
115
|
-
} else {
|
|
116
|
-
module.prototype = {};
|
|
117
134
|
}
|
|
135
|
+
} else {
|
|
136
|
+
module.prototype = {};
|
|
137
|
+
}
|
|
118
138
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
139
|
+
newClass.__includedModules.push(module);
|
|
140
|
+
return this;
|
|
141
|
+
};
|
|
122
142
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
143
|
+
classFactory = function(classDefinition) {
|
|
144
|
+
var i, il, j, jl, property, classPrototype = classDefinition.prototype;
|
|
145
|
+
if (classPrototype) {
|
|
146
|
+
for (property in classPrototype) {
|
|
147
|
+
if (classPrototype.hasOwnProperty(property)) {
|
|
148
|
+
newClass.prototype[property] = classPrototype[property];
|
|
130
149
|
}
|
|
131
|
-
delete classDefinition.prototype;
|
|
132
150
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
151
|
+
delete classDefinition.prototype;
|
|
152
|
+
}
|
|
153
|
+
for (property in classDefinition) {
|
|
154
|
+
if (classDefinition.hasOwnProperty(property)) {
|
|
155
|
+
newClass[property] = classDefinition[property];
|
|
137
156
|
}
|
|
157
|
+
}
|
|
138
158
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
159
|
+
for (i = 0, il = newClass.__implementedInterfaces.length; i < il; i++) {
|
|
160
|
+
for (j = 0, jl = newClass.__implementedInterfaces[i].constructor.length; j < jl; j++) {
|
|
161
|
+
if (!newClass[ newClass.__implementedInterfaces[i].constructor[j] ]) {
|
|
162
|
+
console.log('must implement static ' + newClass.__implementedInterfaces[i].name);
|
|
163
|
+
break;
|
|
145
164
|
}
|
|
165
|
+
}
|
|
146
166
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
167
|
+
if (newClass.__implementedInterfaces[i].hasOwnProperty('prototype')
|
|
168
|
+
&& newClass.__implementedInterfaces[i].prototype) {
|
|
169
|
+
for (j = 0, jl = newClass.__implementedInterfaces[i].prototype.length; j < jl; j++) {
|
|
170
|
+
if (!newClass.prototype[newClass.__implementedInterfaces[i].prototype[j]]) {
|
|
171
|
+
console.log('must implement prototype ' + newClass.__implementedInterfaces[i].name);
|
|
172
|
+
break;
|
|
154
173
|
}
|
|
155
174
|
}
|
|
156
175
|
}
|
|
176
|
+
}
|
|
157
177
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var i, inheritedClass;
|
|
164
|
-
newClass.superClass = superClass;
|
|
165
|
-
if (superClass.hasOwnProperty('__descendants')) {
|
|
166
|
-
superClass.__descendants.push(newClass);
|
|
167
|
-
}
|
|
168
|
-
inheritedClass = function() {
|
|
169
|
-
};
|
|
170
|
-
inheritedClass.prototype = superClass.prototype;
|
|
171
|
-
newClass.prototype = new inheritedClass();
|
|
172
|
-
newClass.prototype.constructor = newClass;
|
|
173
|
-
|
|
174
|
-
for (i in superClass) {
|
|
175
|
-
if (superClass.hasOwnProperty(i)
|
|
176
|
-
&& i != 'prototype'
|
|
177
|
-
&& i !== 'className'
|
|
178
|
-
&& i !== 'superClass'
|
|
179
|
-
&& i !== 'include'
|
|
180
|
-
&& i != '__descendants') {
|
|
181
|
-
newClass[i] = superClass[i];
|
|
182
|
-
}
|
|
178
|
+
try {
|
|
179
|
+
if (Li && Li.ObjectSpy && Li.Spy) {
|
|
180
|
+
newClass.__objectSpy = new Li.ObjectSpy();
|
|
181
|
+
newClass.__objectSpy.spy(newClass);
|
|
182
|
+
newClass.__objectSpy.spy(newClass.prototype);
|
|
183
183
|
}
|
|
184
|
+
} catch (error) {}
|
|
184
185
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
nameSpace[className] = newClass;
|
|
187
|
+
return newClass;
|
|
188
|
+
};
|
|
188
189
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
classFactory.inherits = function(superClass) {
|
|
191
|
+
var i, inheritedClass;
|
|
192
|
+
newClass.superClass = superClass;
|
|
193
|
+
if (superClass.hasOwnProperty('__descendants')) {
|
|
194
|
+
superClass.__descendants.push(newClass);
|
|
195
|
+
}
|
|
196
|
+
inheritedClass = function() {
|
|
195
197
|
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
inheritedClass.prototype = superClass.prototype;
|
|
199
|
+
newClass.prototype = new inheritedClass();
|
|
200
|
+
newClass.prototype.constructor = newClass;
|
|
201
|
+
|
|
202
|
+
for (i in superClass) {
|
|
203
|
+
if (superClass.hasOwnProperty(i)
|
|
204
|
+
&& i != 'prototype'
|
|
205
|
+
&& i !== 'className'
|
|
206
|
+
&& i !== 'superClass'
|
|
207
|
+
&& i !== 'include'
|
|
208
|
+
&& i != '__descendants') {
|
|
209
|
+
newClass[i] = superClass[i];
|
|
200
210
|
}
|
|
201
|
-
|
|
202
|
-
};
|
|
211
|
+
}
|
|
203
212
|
|
|
204
|
-
|
|
213
|
+
delete this.inherits;
|
|
214
|
+
return this;
|
|
215
|
+
};
|
|
205
216
|
|
|
217
|
+
classFactory.ensures = function(interfaces) {
|
|
218
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
219
|
+
newClass.__implementedInterfaces.push(arguments[i]);
|
|
220
|
+
}
|
|
221
|
+
delete this.ensures;
|
|
222
|
+
return classFactory;
|
|
206
223
|
};
|
|
207
224
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
global.Module = Neon.Module;
|
|
215
|
-
global.Interface = Neon.Interface;
|
|
216
|
-
}
|
|
225
|
+
classFactory.includes = function() {
|
|
226
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
227
|
+
newClass.include(arguments[i]);
|
|
228
|
+
}
|
|
229
|
+
return classFactory;
|
|
230
|
+
};
|
|
217
231
|
|
|
218
|
-
|
|
232
|
+
return classFactory;
|
|
219
233
|
|
|
234
|
+
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
"name": "neon",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Javascript DSL for Classical Inheritance",
|
|
5
|
+
"main": "./neon",
|
|
6
|
+
"directories": {
|
|
7
|
+
"lib": "./lib"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/azendal/neon.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"class",
|
|
15
|
+
"prototype",
|
|
16
|
+
"inheritance",
|
|
17
|
+
"oop"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Module('BubblingSupport')({
|
|
2
|
+
dispatch : function (type, data) {
|
|
3
|
+
data = data || {};
|
|
4
|
+
var event = NeCustomEventSupport.prototype.dispatch.call(this, type, data);
|
|
5
|
+
if (event.isPropagationStopped === false) {
|
|
6
|
+
if (this.parent && this.parent.dispatch) {
|
|
7
|
+
data.target = event.target;
|
|
8
|
+
data.currentTarget = this.parent;
|
|
9
|
+
this.parent.dispatch(event.type, data);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return event;
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
prototype : {
|
|
16
|
+
dispatch : function (type, data) {
|
|
17
|
+
data = data || {};
|
|
18
|
+
|
|
19
|
+
var event = NeCustomEventSupport.prototype.dispatch.call(this, type, data);
|
|
20
|
+
|
|
21
|
+
if (event.isPropagationStopped === false && event.bubbles === true) {
|
|
22
|
+
if (this.parent && this.parent.dispatch) {
|
|
23
|
+
data.target = event.target;
|
|
24
|
+
data.currentTarget = this.parent;
|
|
25
|
+
this.parent.dispatch(event.type, data);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return event;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated CustomEvent is deprecated and will be removed on February 1st, 2026. Use NeCustomEvent instead.
|
|
3
|
+
*/
|
|
4
|
+
Class('NeCustomEvent')({
|
|
5
|
+
prototype : {
|
|
6
|
+
bubbles : true,
|
|
7
|
+
cancelable : true,
|
|
8
|
+
currentTarget : null,
|
|
9
|
+
timeStamp : 0,
|
|
10
|
+
target : null,
|
|
11
|
+
type : '',
|
|
12
|
+
isPropagationStopped : false,
|
|
13
|
+
isDefaultPrevented : false,
|
|
14
|
+
isImmediatePropagationStopped : false,
|
|
15
|
+
areImmediateHandlersPrevented : false,
|
|
16
|
+
init : function init(type, data) {
|
|
17
|
+
this.type = type;
|
|
18
|
+
if (typeof data !== 'undefined') {
|
|
19
|
+
for(var property in data) {
|
|
20
|
+
if (data.hasOwnProperty(property)) {
|
|
21
|
+
this[property] = data[property];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
stopPropagation : function stopPropagation() {
|
|
27
|
+
this.isPropagationStopped = true;
|
|
28
|
+
},
|
|
29
|
+
preventDefault : function preventDefault() {
|
|
30
|
+
this.isDefaultPrevented = true;
|
|
31
|
+
},
|
|
32
|
+
stopImmediatePropagation : function stopImmediatePropagation() {
|
|
33
|
+
this.preventImmediateHandlers();
|
|
34
|
+
this.stopPropagation();
|
|
35
|
+
},
|
|
36
|
+
preventImmediateHandlers : function preventImmediateHandlers() {
|
|
37
|
+
this.areImmediateHandlersPrevented = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (typeof window !== 'undefined') {
|
|
44
|
+
window.CustomEvent = new Proxy(NeCustomEvent, {
|
|
45
|
+
construct(target, args) {
|
|
46
|
+
console.warn('DEPRECATION NOTICE: CustomEvent is deprecated and will be removed on February 1st, 2026. Use NeCustomEvent instead.');
|
|
47
|
+
return new target(...args);
|
|
48
|
+
},
|
|
49
|
+
get(target, prop, receiver) {
|
|
50
|
+
console.warn('DEPRECATION NOTICE: CustomEvent is deprecated and will be removed on February 1st, 2026. Use NeCustomEvent instead.');
|
|
51
|
+
return Reflect.get(target, prop, receiver);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|