@safe-engine/cocos 1.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/@types/index.d.ts +61 -0
- package/@types/safex.d.ts +103 -0
- package/README.md +10 -0
- package/dist/app.d.ts +2 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +24 -0
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +77 -0
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosArmatureDisplay.js +227 -0
- package/dist/dragonbones/cocos/CocosFactory.d.ts +128 -0
- package/dist/dragonbones/cocos/CocosFactory.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosFactory.js +231 -0
- package/dist/dragonbones/cocos/CocosSlot.d.ts +49 -0
- package/dist/dragonbones/cocos/CocosSlot.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosSlot.js +385 -0
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +53 -0
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +1 -0
- package/dist/dragonbones/cocos/CocosTextureAtlasData.js +158 -0
- package/dist/dragonbones/dragonBones.d.ts +3 -0
- package/dist/dragonbones/dragonBones.d.ts.map +1 -0
- package/dist/dragonbones/dragonBones.js +4788 -0
- package/dist/dragonbones/index.d.ts +20 -0
- package/dist/dragonbones/index.d.ts.map +1 -0
- package/dist/dragonbones/index.js +112 -0
- package/dist/gworld/components/AnimationComponent.d.ts +65 -0
- package/dist/gworld/components/AnimationComponent.d.ts.map +1 -0
- package/dist/gworld/components/AnimationComponent.js +141 -0
- package/dist/gworld/components/CollideComponent.d.ts +64 -0
- package/dist/gworld/components/CollideComponent.d.ts.map +1 -0
- package/dist/gworld/components/CollideComponent.js +266 -0
- package/dist/gworld/components/EnhancedComponent.d.ts +21 -0
- package/dist/gworld/components/EnhancedComponent.d.ts.map +1 -0
- package/dist/gworld/components/EnhancedComponent.js +50 -0
- package/dist/gworld/components/GUIComponent.d.ts +62 -0
- package/dist/gworld/components/GUIComponent.d.ts.map +1 -0
- package/dist/gworld/components/GUIComponent.js +158 -0
- package/dist/gworld/components/NoRenderComponent.d.ts +36 -0
- package/dist/gworld/components/NoRenderComponent.d.ts.map +1 -0
- package/dist/gworld/components/NoRenderComponent.js +74 -0
- package/dist/gworld/components/NodeComp.d.ts +184 -0
- package/dist/gworld/components/NodeComp.d.ts.map +1 -0
- package/dist/gworld/components/NodeComp.js +425 -0
- package/dist/gworld/components/RenderComponent.d.ts +53 -0
- package/dist/gworld/components/RenderComponent.d.ts.map +1 -0
- package/dist/gworld/components/RenderComponent.js +158 -0
- package/dist/gworld/core/Scene.d.ts +5 -0
- package/dist/gworld/core/Scene.d.ts.map +1 -0
- package/dist/gworld/core/Scene.js +38 -0
- package/dist/gworld/core/decorator.d.ts +9 -0
- package/dist/gworld/core/decorator.d.ts.map +1 -0
- package/dist/gworld/core/decorator.js +43 -0
- package/dist/gworld/index.d.ts +8 -0
- package/dist/gworld/index.d.ts.map +1 -0
- package/dist/gworld/index.js +43 -0
- package/dist/gworld/systems/AnimationSystem.d.ts +7 -0
- package/dist/gworld/systems/AnimationSystem.d.ts.map +1 -0
- package/dist/gworld/systems/AnimationSystem.js +38 -0
- package/dist/gworld/systems/CollideSystem.d.ts +19 -0
- package/dist/gworld/systems/CollideSystem.d.ts.map +1 -0
- package/dist/gworld/systems/CollideSystem.js +183 -0
- package/dist/gworld/systems/GUISystem.d.ts +7 -0
- package/dist/gworld/systems/GUISystem.d.ts.map +1 -0
- package/dist/gworld/systems/GUISystem.js +147 -0
- package/dist/gworld/systems/NoRenderSystem.d.ts +7 -0
- package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -0
- package/dist/gworld/systems/NoRenderSystem.js +93 -0
- package/dist/gworld/systems/RenderSystem.d.ts +15 -0
- package/dist/gworld/systems/RenderSystem.d.ts.map +1 -0
- package/dist/gworld/systems/RenderSystem.js +115 -0
- package/dist/helper/Intersection.d.ts +6 -0
- package/dist/helper/Intersection.d.ts.map +1 -0
- package/dist/helper/Intersection.js +117 -0
- package/dist/helper/NodePool.d.ts +9 -0
- package/dist/helper/NodePool.d.ts.map +1 -0
- package/dist/helper/NodePool.js +29 -0
- package/dist/helper/action.d.ts +9 -0
- package/dist/helper/action.d.ts.map +1 -0
- package/dist/helper/action.js +34 -0
- package/dist/helper/director.d.ts +3 -0
- package/dist/helper/director.d.ts.map +1 -0
- package/dist/helper/director.js +10 -0
- package/dist/helper/html-text-parser.d.ts +30 -0
- package/dist/helper/html-text-parser.d.ts.map +1 -0
- package/dist/helper/html-text-parser.js +354 -0
- package/dist/helper/math.d.ts +4 -0
- package/dist/helper/math.d.ts.map +1 -0
- package/dist/helper/math.js +9 -0
- package/dist/helper/utils.d.ts +14 -0
- package/dist/helper/utils.d.ts.map +1 -0
- package/dist/helper/utils.js +81 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/polyfills.d.ts +54 -0
- package/dist/polyfills.d.ts.map +1 -0
- package/dist/polyfills.js +168 -0
- package/dist/spine/CCSkeleton.d.ts +2 -0
- package/dist/spine/CCSkeleton.d.ts.map +1 -0
- package/dist/spine/CCSkeleton.js +380 -0
- package/dist/spine/CCSkeletonAnimation.d.ts +16 -0
- package/dist/spine/CCSkeletonAnimation.d.ts.map +1 -0
- package/dist/spine/CCSkeletonAnimation.js +353 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +2 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -0
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +229 -0
- package/dist/spine/CCSkeletonTexture.d.ts +2 -0
- package/dist/spine/CCSkeletonTexture.d.ts.map +1 -0
- package/dist/spine/CCSkeletonTexture.js +98 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +2 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +1 -0
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +317 -0
- package/package.json +32 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-var */
|
|
3
|
+
/* eslint-disable quotes */
|
|
4
|
+
/* eslint-disable no-useless-escape */
|
|
5
|
+
/* eslint-disable prettier/prettier */
|
|
6
|
+
/****************************************************************************
|
|
7
|
+
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
8
|
+
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
9
|
+
|
|
10
|
+
https://www.cocos.com/
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated engine source code (the "Software"), a limited,
|
|
14
|
+
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
|
15
|
+
to use Cocos Creator solely to develop games on your target platforms. You shall
|
|
16
|
+
not use Cocos Creator software for developing other software or tools that's
|
|
17
|
+
used for developing games. You are not granted to publish, distribute,
|
|
18
|
+
sublicense, and/or sell copies of Cocos Creator.
|
|
19
|
+
|
|
20
|
+
The software or tools in this License Agreement are licensed, not sold.
|
|
21
|
+
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
29
|
+
THE SOFTWARE.
|
|
30
|
+
****************************************************************************/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.HtmlTextParser = void 0;
|
|
33
|
+
var eventRegx = /^(click)(\s)*=|(param)(\s)*=/;
|
|
34
|
+
var imageAttrReg = /(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
|
|
35
|
+
/**
|
|
36
|
+
* A utils class for parsing HTML texts. The parsed results will be an object array.
|
|
37
|
+
*/
|
|
38
|
+
var HtmlTextParser = function () {
|
|
39
|
+
this._parsedObject = {};
|
|
40
|
+
this._specialSymbolArray = [];
|
|
41
|
+
this._specialSymbolArray.push([/</g, '<']);
|
|
42
|
+
this._specialSymbolArray.push([/>/g, '>']);
|
|
43
|
+
this._specialSymbolArray.push([/&/g, '&']);
|
|
44
|
+
this._specialSymbolArray.push([/"/g, '"']);
|
|
45
|
+
this._specialSymbolArray.push([/'/g, "'"]);
|
|
46
|
+
this._specialSymbolArray.push([/ /g, ' ']);
|
|
47
|
+
};
|
|
48
|
+
exports.HtmlTextParser = HtmlTextParser;
|
|
49
|
+
exports.HtmlTextParser.prototype = {
|
|
50
|
+
constructor: exports.HtmlTextParser,
|
|
51
|
+
parse: function (htmlString) {
|
|
52
|
+
this._resultObjectArray = [];
|
|
53
|
+
if (!htmlString) {
|
|
54
|
+
return this._resultObjectArray;
|
|
55
|
+
}
|
|
56
|
+
this._stack = [];
|
|
57
|
+
var startIndex = 0;
|
|
58
|
+
var length = htmlString.length;
|
|
59
|
+
while (startIndex < length) {
|
|
60
|
+
var tagEndIndex = htmlString.indexOf('>', startIndex);
|
|
61
|
+
var tagBeginIndex = -1;
|
|
62
|
+
if (tagEndIndex >= 0) {
|
|
63
|
+
tagBeginIndex = htmlString.lastIndexOf('<', tagEndIndex);
|
|
64
|
+
var noTagBegin = tagBeginIndex < startIndex - 1;
|
|
65
|
+
if (noTagBegin) {
|
|
66
|
+
tagBeginIndex = htmlString.indexOf('<', tagEndIndex + 1);
|
|
67
|
+
tagEndIndex = htmlString.indexOf('>', tagBeginIndex + 1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (tagBeginIndex < 0) {
|
|
71
|
+
this._stack.pop();
|
|
72
|
+
this._processResult(htmlString.substring(startIndex));
|
|
73
|
+
startIndex = length;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
var newStr = htmlString.substring(startIndex, tagBeginIndex);
|
|
77
|
+
var tagStr = htmlString.substring(tagBeginIndex + 1, tagEndIndex);
|
|
78
|
+
if (tagStr === '')
|
|
79
|
+
newStr = htmlString.substring(startIndex, tagEndIndex + 1);
|
|
80
|
+
this._processResult(newStr);
|
|
81
|
+
if (tagEndIndex === -1) {
|
|
82
|
+
// cc.error('The HTML tag is invalid!');
|
|
83
|
+
tagEndIndex = tagBeginIndex;
|
|
84
|
+
}
|
|
85
|
+
else if (htmlString.charAt(tagBeginIndex + 1) === '/') {
|
|
86
|
+
this._stack.pop();
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this._addToStack(tagStr);
|
|
90
|
+
}
|
|
91
|
+
startIndex = tagEndIndex + 1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return this._resultObjectArray;
|
|
95
|
+
},
|
|
96
|
+
_attributeToObject: function (attribute) {
|
|
97
|
+
attribute = attribute.trim();
|
|
98
|
+
var obj = {};
|
|
99
|
+
var header = attribute.match(/^(color|size)(\s)*=/);
|
|
100
|
+
var tagName;
|
|
101
|
+
var nextSpace;
|
|
102
|
+
var eventObj;
|
|
103
|
+
var eventHanlderString;
|
|
104
|
+
if (header) {
|
|
105
|
+
tagName = header[0];
|
|
106
|
+
attribute = attribute.substring(tagName.length).trim();
|
|
107
|
+
if (attribute === '')
|
|
108
|
+
return obj;
|
|
109
|
+
//parse color
|
|
110
|
+
nextSpace = attribute.indexOf(' ');
|
|
111
|
+
switch (tagName[0]) {
|
|
112
|
+
case 'c':
|
|
113
|
+
if (nextSpace > -1) {
|
|
114
|
+
obj.color = attribute.substring(0, nextSpace).trim();
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
obj.color = attribute;
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
case 's':
|
|
121
|
+
obj.size = parseInt(attribute);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
//tag has event arguments
|
|
125
|
+
if (nextSpace > -1) {
|
|
126
|
+
eventHanlderString = attribute.substring(nextSpace + 1).trim();
|
|
127
|
+
eventObj = this._processEventHandler(eventHanlderString);
|
|
128
|
+
obj.event = eventObj;
|
|
129
|
+
}
|
|
130
|
+
return obj;
|
|
131
|
+
}
|
|
132
|
+
header = attribute.match(/^(br(\s)*\/)/);
|
|
133
|
+
if (header && header[0].length > 0) {
|
|
134
|
+
tagName = header[0].trim();
|
|
135
|
+
if (tagName.startsWith('br') && tagName[tagName.length - 1] === '/') {
|
|
136
|
+
obj.isNewLine = true;
|
|
137
|
+
this._resultObjectArray.push({ text: '', style: { newline: true } });
|
|
138
|
+
return obj;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
header = attribute.match(/^(img(\s)*src(\s)*=[^>]+\/)/);
|
|
142
|
+
if (header && header[0].length > 0) {
|
|
143
|
+
tagName = header[0].trim();
|
|
144
|
+
if (tagName.startsWith('img') && tagName[tagName.length - 1] === '/') {
|
|
145
|
+
header = attribute.match(imageAttrReg);
|
|
146
|
+
var tagValue;
|
|
147
|
+
var remainingArgument;
|
|
148
|
+
var isValidImageTag = false;
|
|
149
|
+
while (header) {
|
|
150
|
+
//skip the invalid tags at first
|
|
151
|
+
attribute = attribute.substring(attribute.indexOf(header[0]));
|
|
152
|
+
tagName = attribute.substr(0, header[0].length);
|
|
153
|
+
//remove space and = character
|
|
154
|
+
remainingArgument = attribute.substring(tagName.length).trim();
|
|
155
|
+
nextSpace = remainingArgument.indexOf(' ');
|
|
156
|
+
tagValue = nextSpace > -1 ? remainingArgument.substr(0, nextSpace) : remainingArgument;
|
|
157
|
+
tagName = tagName.replace(/[^a-zA-Z]/g, '').trim();
|
|
158
|
+
tagName = tagName.toLocaleLowerCase();
|
|
159
|
+
attribute = remainingArgument.substring(nextSpace).trim();
|
|
160
|
+
if (tagValue.endsWith('/'))
|
|
161
|
+
tagValue = tagValue.slice(0, -1);
|
|
162
|
+
if (tagName === 'src') {
|
|
163
|
+
switch (tagValue.charCodeAt(0)) {
|
|
164
|
+
case 34: // "
|
|
165
|
+
case 39: // '
|
|
166
|
+
isValidImageTag = true;
|
|
167
|
+
tagValue = tagValue.slice(1, -1);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
obj.isImage = true;
|
|
171
|
+
obj.src = tagValue;
|
|
172
|
+
}
|
|
173
|
+
else if (tagName === 'height') {
|
|
174
|
+
obj.imageHeight = parseInt(tagValue);
|
|
175
|
+
}
|
|
176
|
+
else if (tagName === 'width') {
|
|
177
|
+
obj.imageWidth = parseInt(tagValue);
|
|
178
|
+
}
|
|
179
|
+
else if (tagName === 'align') {
|
|
180
|
+
switch (tagValue.charCodeAt(0)) {
|
|
181
|
+
case 34: // "
|
|
182
|
+
case 39: // '
|
|
183
|
+
tagValue = tagValue.slice(1, -1);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
obj.imageAlign = tagValue.toLocaleLowerCase();
|
|
187
|
+
}
|
|
188
|
+
else if (tagName === 'offset') {
|
|
189
|
+
obj.imageOffset = tagValue;
|
|
190
|
+
}
|
|
191
|
+
else if (tagName === 'click') {
|
|
192
|
+
obj.event = this._processEventHandler("".concat(tagName, "=").concat(tagValue));
|
|
193
|
+
}
|
|
194
|
+
if (obj.event && tagName === 'param') {
|
|
195
|
+
obj.event.param = tagValue.replace(/^\"|\"$/g, '');
|
|
196
|
+
}
|
|
197
|
+
header = attribute.match(imageAttrReg);
|
|
198
|
+
}
|
|
199
|
+
if (isValidImageTag && obj.isImage) {
|
|
200
|
+
this._resultObjectArray.push({ text: '', style: obj });
|
|
201
|
+
}
|
|
202
|
+
return {};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
header = attribute.match(/^(outline(\s)*[^>]*)/);
|
|
206
|
+
if (header) {
|
|
207
|
+
attribute = header[0].substring('outline'.length).trim();
|
|
208
|
+
var defaultOutlineObject = { color: '#ffffff', width: 1 };
|
|
209
|
+
if (attribute) {
|
|
210
|
+
var outlineAttrReg = /(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;
|
|
211
|
+
header = attribute.match(outlineAttrReg);
|
|
212
|
+
var tagValue;
|
|
213
|
+
while (header) {
|
|
214
|
+
//skip the invalid tags at first
|
|
215
|
+
attribute = attribute.substring(attribute.indexOf(header[0]));
|
|
216
|
+
tagName = attribute.substr(0, header[0].length);
|
|
217
|
+
//remove space and = character
|
|
218
|
+
remainingArgument = attribute.substring(tagName.length).trim();
|
|
219
|
+
nextSpace = remainingArgument.indexOf(' ');
|
|
220
|
+
if (nextSpace > -1) {
|
|
221
|
+
tagValue = remainingArgument.substr(0, nextSpace);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
tagValue = remainingArgument;
|
|
225
|
+
}
|
|
226
|
+
tagName = tagName.replace(/[^a-zA-Z]/g, '').trim();
|
|
227
|
+
tagName = tagName.toLocaleLowerCase();
|
|
228
|
+
attribute = remainingArgument.substring(nextSpace).trim();
|
|
229
|
+
if (tagName === 'click') {
|
|
230
|
+
obj.event = this._processEventHandler("".concat(tagName, "=").concat(tagValue));
|
|
231
|
+
}
|
|
232
|
+
else if (tagName === 'color') {
|
|
233
|
+
defaultOutlineObject.color = tagValue;
|
|
234
|
+
}
|
|
235
|
+
else if (tagName === 'width') {
|
|
236
|
+
defaultOutlineObject.width = parseInt(tagValue);
|
|
237
|
+
}
|
|
238
|
+
if (obj.event && tagName === 'param') {
|
|
239
|
+
obj.event.param = tagValue.replace(/^\"|\"$/g, '');
|
|
240
|
+
}
|
|
241
|
+
header = attribute.match(outlineAttrReg);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
obj.outline = defaultOutlineObject;
|
|
245
|
+
}
|
|
246
|
+
header = attribute.match(/^(on|u|b|i)(\s)*/);
|
|
247
|
+
if (header && header[0].length > 0) {
|
|
248
|
+
tagName = header[0];
|
|
249
|
+
attribute = attribute.substring(tagName.length).trim();
|
|
250
|
+
switch (tagName[0]) {
|
|
251
|
+
case 'u':
|
|
252
|
+
obj.underline = true;
|
|
253
|
+
break;
|
|
254
|
+
case 'i':
|
|
255
|
+
obj.italic = true;
|
|
256
|
+
break;
|
|
257
|
+
case 'b':
|
|
258
|
+
obj.bold = true;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
if (attribute === '') {
|
|
262
|
+
return obj;
|
|
263
|
+
}
|
|
264
|
+
eventObj = this._processEventHandler(attribute);
|
|
265
|
+
obj.event = eventObj;
|
|
266
|
+
}
|
|
267
|
+
return obj;
|
|
268
|
+
},
|
|
269
|
+
_processEventHandler: function (eventString) {
|
|
270
|
+
var index = 0;
|
|
271
|
+
var obj = {};
|
|
272
|
+
var eventNames = eventString.match(eventRegx);
|
|
273
|
+
var isValidTag = false;
|
|
274
|
+
while (eventNames) {
|
|
275
|
+
var eventName = eventNames[0];
|
|
276
|
+
var eventValue = '';
|
|
277
|
+
isValidTag = false;
|
|
278
|
+
eventString = eventString.substring(eventName.length).trim();
|
|
279
|
+
if (eventString.charAt(0) === '"') {
|
|
280
|
+
index = eventString.indexOf('"', 1);
|
|
281
|
+
if (index > -1) {
|
|
282
|
+
eventValue = eventString.substring(1, index).trim();
|
|
283
|
+
isValidTag = true;
|
|
284
|
+
}
|
|
285
|
+
index++;
|
|
286
|
+
}
|
|
287
|
+
else if (eventString.charAt(0) === '\'') {
|
|
288
|
+
index = eventString.indexOf('\'', 1);
|
|
289
|
+
if (index > -1) {
|
|
290
|
+
eventValue = eventString.substring(1, index).trim();
|
|
291
|
+
isValidTag = true;
|
|
292
|
+
}
|
|
293
|
+
index++;
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
//skip the invalid attribute value
|
|
297
|
+
var match = eventString.match(/(\S)+/);
|
|
298
|
+
if (match) {
|
|
299
|
+
eventValue = match[0];
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
eventValue = '';
|
|
303
|
+
}
|
|
304
|
+
index = eventValue.length;
|
|
305
|
+
}
|
|
306
|
+
if (isValidTag) {
|
|
307
|
+
eventName = eventName.substring(0, eventName.length - 1).trim();
|
|
308
|
+
obj[eventName] = eventValue;
|
|
309
|
+
}
|
|
310
|
+
eventString = eventString.substring(index).trim();
|
|
311
|
+
eventNames = eventString.match(eventRegx);
|
|
312
|
+
}
|
|
313
|
+
return obj;
|
|
314
|
+
},
|
|
315
|
+
_addToStack: function (attribute) {
|
|
316
|
+
var obj = this._attributeToObject(attribute);
|
|
317
|
+
if (this._stack.length === 0) {
|
|
318
|
+
this._stack.push(obj);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
if (obj.isNewLine || obj.isImage) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
//for nested tags
|
|
325
|
+
var previousTagObj = this._stack[this._stack.length - 1];
|
|
326
|
+
for (var key in previousTagObj) {
|
|
327
|
+
if (!obj[key]) {
|
|
328
|
+
obj[key] = previousTagObj[key];
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
this._stack.push(obj);
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
_processResult: function (value) {
|
|
335
|
+
if (value === '') {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
value = this._escapeSpecialSymbol(value);
|
|
339
|
+
if (this._stack.length > 0) {
|
|
340
|
+
this._resultObjectArray.push({ text: value, style: this._stack[this._stack.length - 1] });
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
this._resultObjectArray.push({ text: value });
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
_escapeSpecialSymbol: function (str) {
|
|
347
|
+
for (var i = 0; i < this._specialSymbolArray.length; ++i) {
|
|
348
|
+
var key = this._specialSymbolArray[i][0];
|
|
349
|
+
var value = this._specialSymbolArray[i][1];
|
|
350
|
+
str = str.replace(key, value);
|
|
351
|
+
}
|
|
352
|
+
return str;
|
|
353
|
+
},
|
|
354
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../src/helper/math.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,UAEtE;AAED,eAAO,MAAM,gBAAgB,4BAAsB,CAAA;AACnD,eAAO,MAAM,gBAAgB,4BAAsB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.radiansToDegrees = exports.degreesToRadians = void 0;
|
|
4
|
+
exports.randomRangeInt = randomRangeInt;
|
|
5
|
+
function randomRangeInt(minInclude, maxExclude) {
|
|
6
|
+
return Math.round(Math.random() * (maxExclude - minInclude - 1)) + minInclude;
|
|
7
|
+
}
|
|
8
|
+
exports.degreesToRadians = cc.degreesToRadians;
|
|
9
|
+
exports.radiansToDegrees = cc.radiansToDegrees;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Constructor, EntityManager, EventManager, EventReceive } from 'entityx-ts';
|
|
2
|
+
import { Collider, ComponentX, NoRenderComponentX, SceneComponent } from '..';
|
|
3
|
+
export declare function registerSystem<T extends ComponentX>(component: Constructor<T>): {
|
|
4
|
+
new (): {
|
|
5
|
+
configure(event_manager: EventManager): void;
|
|
6
|
+
receive(type: string, event: EventReceive): void;
|
|
7
|
+
update(entities: EntityManager, events: EventManager, dt: number): void;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type GetProps<T> = T extends ComponentX<infer P> ? P : T extends NoRenderComponentX<infer Q> ? Q : never;
|
|
11
|
+
export declare function instantiate<T extends ComponentX>(ComponentType: Constructor<T>, data?: GetProps<T>): T;
|
|
12
|
+
export declare function loadScene<T extends SceneComponent>(ComponentType: Constructor<T>): void;
|
|
13
|
+
export declare function shouldCollider(colA: Collider, colB: Collider): any;
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/helper/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAU,MAAM,YAAY,CAAA;AAEvI,OAAO,EAAE,QAAQ,EAAiB,UAAU,EAAY,kBAAkB,EAAE,cAAc,EAAE,MAAM,IAAI,CAAA;AAGtG,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;;iCAKjD,YAAY;sBAMvB,MAAM,SAAS,YAAY;yBAmBxB,aAAa,UAAU,YAAY,MAAM,MAAM;;EAenE;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAE/G,wBAAgB,WAAW,CAAC,CAAC,SAAS,UAAU,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAOtG;AACD,wBAAgB,SAAS,CAAC,CAAC,SAAS,cAAc,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,QAKhF;AACD,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,OAQ5D"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerSystem = registerSystem;
|
|
4
|
+
exports.instantiate = instantiate;
|
|
5
|
+
exports.loadScene = loadScene;
|
|
6
|
+
exports.shouldCollider = shouldCollider;
|
|
7
|
+
var entityx_ts_1 = require("entityx-ts");
|
|
8
|
+
var __1 = require("..");
|
|
9
|
+
var gworld_1 = require("../gworld");
|
|
10
|
+
function registerSystem(component) {
|
|
11
|
+
if (gworld_1.GameWorld.Instance.systems.isRegistered("".concat(component.name, "System"))) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
var NewSystem = /** @class */ (function () {
|
|
15
|
+
function NewSystem() {
|
|
16
|
+
}
|
|
17
|
+
NewSystem.prototype.configure = function (event_manager) {
|
|
18
|
+
console.log('configure registerSystem', component.name);
|
|
19
|
+
event_manager.subscribe((0, entityx_ts_1.ComponentAddedEvent)(component), this);
|
|
20
|
+
event_manager.subscribe((0, entityx_ts_1.ComponentRemovedEvent)(component), this);
|
|
21
|
+
};
|
|
22
|
+
NewSystem.prototype.receive = function (type, event) {
|
|
23
|
+
switch (type) {
|
|
24
|
+
case (0, entityx_ts_1.ComponentAddedEvent)(component): {
|
|
25
|
+
var ett = event.entity;
|
|
26
|
+
var newComp = event.component;
|
|
27
|
+
newComp.node = ett.getComponent(__1.NodeComp);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case (0, entityx_ts_1.ComponentRemovedEvent)(component): {
|
|
31
|
+
var newComp = event.component;
|
|
32
|
+
if (newComp.destroy) {
|
|
33
|
+
newComp.destroy();
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
NewSystem.prototype.update = function (entities, events, dt) {
|
|
42
|
+
for (var _i = 0, _a = entities.entities_with_components(component); _i < _a.length; _i++) {
|
|
43
|
+
var entt = _a[_i];
|
|
44
|
+
var comp = entt.getComponent(component);
|
|
45
|
+
// console.log('comp', comp.constructor.name, typeof comp['update'] === 'function')
|
|
46
|
+
if (comp.node.active && typeof comp['update'] === 'function') {
|
|
47
|
+
comp['update'](dt);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return NewSystem;
|
|
52
|
+
}());
|
|
53
|
+
Object.defineProperty(NewSystem, 'name', { value: "".concat(component.name, "System") });
|
|
54
|
+
gworld_1.GameWorld.Instance.systems.add(NewSystem);
|
|
55
|
+
gworld_1.GameWorld.Instance.systems.configureOnce(NewSystem);
|
|
56
|
+
gworld_1.GameWorld.Instance.listUpdate.push(NewSystem);
|
|
57
|
+
return NewSystem;
|
|
58
|
+
}
|
|
59
|
+
function instantiate(ComponentType, data) {
|
|
60
|
+
var instance = new ComponentType(data);
|
|
61
|
+
instance.init(data);
|
|
62
|
+
if (!instance.render) {
|
|
63
|
+
return instance;
|
|
64
|
+
}
|
|
65
|
+
return instance.render();
|
|
66
|
+
}
|
|
67
|
+
function loadScene(ComponentType) {
|
|
68
|
+
var world = gworld_1.GameWorld.Instance;
|
|
69
|
+
world.entities.reset();
|
|
70
|
+
var instance = new ComponentType();
|
|
71
|
+
instance.render();
|
|
72
|
+
}
|
|
73
|
+
function shouldCollider(colA, colB) {
|
|
74
|
+
var groupA = colA.node.group;
|
|
75
|
+
var groupB = colB.node.group;
|
|
76
|
+
if (groupA === undefined || groupB === undefined) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
var colliderMatrix = gworld_1.GameWorld.Instance.systems.get(__1.CollideSystem).colliderMatrix;
|
|
80
|
+
return colliderMatrix[groupA][groupB];
|
|
81
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from './app';
|
|
2
|
+
export * from './dragonbones';
|
|
3
|
+
export * from './gworld';
|
|
4
|
+
export * from './gworld/components/CollideComponent';
|
|
5
|
+
export * from './gworld/components/GUIComponent';
|
|
6
|
+
export * from './gworld/components/NodeComp';
|
|
7
|
+
export * from './gworld/components/NoRenderComponent';
|
|
8
|
+
export * from './gworld/components/RenderComponent';
|
|
9
|
+
export * from './gworld/core/decorator';
|
|
10
|
+
export * from './gworld/core/Scene';
|
|
11
|
+
export * from './gworld/systems/CollideSystem';
|
|
12
|
+
export * from './helper/action';
|
|
13
|
+
export * from './helper/director';
|
|
14
|
+
export * from './helper/math';
|
|
15
|
+
export * from './helper/NodePool';
|
|
16
|
+
export * from './helper/utils';
|
|
17
|
+
export * from './polyfills';
|
|
18
|
+
export { type Touch } from './polyfills';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,sCAAsC,CAAA;AACpD,cAAc,kCAAkC,CAAA;AAChD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uCAAuC,CAAA;AACrD,cAAc,qCAAqC,CAAA;AACnD,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./app"), exports);
|
|
18
|
+
__exportStar(require("./dragonbones"), exports);
|
|
19
|
+
__exportStar(require("./gworld"), exports);
|
|
20
|
+
__exportStar(require("./gworld/components/CollideComponent"), exports);
|
|
21
|
+
__exportStar(require("./gworld/components/GUIComponent"), exports);
|
|
22
|
+
__exportStar(require("./gworld/components/NodeComp"), exports);
|
|
23
|
+
__exportStar(require("./gworld/components/NoRenderComponent"), exports);
|
|
24
|
+
__exportStar(require("./gworld/components/RenderComponent"), exports);
|
|
25
|
+
__exportStar(require("./gworld/core/decorator"), exports);
|
|
26
|
+
__exportStar(require("./gworld/core/Scene"), exports);
|
|
27
|
+
__exportStar(require("./gworld/systems/CollideSystem"), exports);
|
|
28
|
+
__exportStar(require("./helper/action"), exports);
|
|
29
|
+
__exportStar(require("./helper/director"), exports);
|
|
30
|
+
__exportStar(require("./helper/math"), exports);
|
|
31
|
+
__exportStar(require("./helper/NodePool"), exports);
|
|
32
|
+
__exportStar(require("./helper/utils"), exports);
|
|
33
|
+
__exportStar(require("./polyfills"), exports);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare class _Vec2 {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
static ZERO: any;
|
|
5
|
+
constructor(x?: number | object, y?: number);
|
|
6
|
+
equals(other: cc.Vec2): boolean;
|
|
7
|
+
add(value: cc.Point): cc.Vec2;
|
|
8
|
+
addSelf(value: cc.Point): cc.Vec2;
|
|
9
|
+
sub(value: cc.Point): cc.Vec2;
|
|
10
|
+
mul(multiply: number): cc.Vec2;
|
|
11
|
+
mulSelf(multiply: number): cc.Vec2;
|
|
12
|
+
mag(): number;
|
|
13
|
+
normalizeSelf(): cc.Vec2;
|
|
14
|
+
normalize(): cc.Vec2;
|
|
15
|
+
cross(other: Vec2): number;
|
|
16
|
+
signAngle(other: Vec2): number;
|
|
17
|
+
lengthSqr(): number;
|
|
18
|
+
dot(other: Vec2): number;
|
|
19
|
+
angle(other: Vec2): number;
|
|
20
|
+
distance(other: _Vec2): number;
|
|
21
|
+
}
|
|
22
|
+
export type Vec2 = _Vec2;
|
|
23
|
+
export declare function Vec2(x?: number, y?: number): Vec2;
|
|
24
|
+
export declare namespace Vec2 {
|
|
25
|
+
var ZERO: Readonly<_Vec2>;
|
|
26
|
+
}
|
|
27
|
+
export declare enum SpriteType {
|
|
28
|
+
SIMPLE = 0,
|
|
29
|
+
SLICED = 1,
|
|
30
|
+
TILED = 2,
|
|
31
|
+
FILLED = 3,
|
|
32
|
+
MESH = 4
|
|
33
|
+
}
|
|
34
|
+
export declare const RED: cc.Color;
|
|
35
|
+
export declare const BLACK: cc.Color;
|
|
36
|
+
export declare const WHITE: cc.Color;
|
|
37
|
+
export declare const GREEN: cc.Color;
|
|
38
|
+
export declare const BLUE: cc.Color;
|
|
39
|
+
export declare function Color4B(r: number, g: number, b: number, a: number): cc.Color;
|
|
40
|
+
export type Color4B = ReturnType<typeof Color4B>;
|
|
41
|
+
declare class _Size {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
static ZERO: any;
|
|
45
|
+
constructor(width?: number, height?: number);
|
|
46
|
+
}
|
|
47
|
+
export type Size = _Size;
|
|
48
|
+
export declare function Size(x?: number, y?: number): Size;
|
|
49
|
+
export declare class Touch extends cc.Touch {
|
|
50
|
+
getLocation: () => Vec2;
|
|
51
|
+
}
|
|
52
|
+
export declare function getWinSize(): Size;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=polyfills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyfills.d.ts","sourceRoot":"","sources":["../src/polyfills.ts"],"names":[],"mappings":"AAOA,cAAM,KAAK;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,MAAM,CAAC,IAAI,MAAA;gBACC,CAAC,GAAE,MAAM,GAAG,MAAU,EAAE,CAAC,SAAI;IAazC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI;IAIrB,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,IAAI;IAI7B,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,IAAI;IAOjC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,IAAI;IAI7B,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,EAAE,CAAC,IAAI;IAI9B,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,EAAE,CAAC,IAAI;IAOlC,GAAG,IAAI,MAAM;IAIb,aAAa,IAAI,EAAE,CAAC,IAAI;IAOxB,SAAS,IAAI,EAAE,CAAC,IAAI;IAIb,KAAK,CAAC,KAAK,EAAE,IAAI;IAGjB,SAAS,CAAC,KAAK,EAAE,IAAI;IAIrB,SAAS;IAGT,GAAG,CAAC,KAAK,EAAE,IAAI;IAGf,KAAK,CAAC,KAAK,EAAE,IAAI;IAcjB,QAAQ,CAAC,KAAK,EAAE,KAAK;CAG7B;AACD,MAAM,MAAM,IAAI,GAAG,KAAK,CAAA;AACxB,wBAAgB,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAEjD;yBAFe,IAAI;;;AAMpB,oBAAY,UAAU;IACpB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,IAAI,IAAA;CACL;AAED,eAAO,MAAM,GAAG,UAA0B,CAAA;AAC1C,eAAO,MAAM,KAAK,UAAwB,CAAA;AAC1C,eAAO,MAAM,KAAK,UAA8B,CAAA;AAChD,eAAO,MAAM,KAAK,UAA0B,CAAA;AAC5C,eAAO,MAAM,IAAI,UAA0B,CAAA;AAY3C,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,YAEjE;AACD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAA;AAEhD,cAAM,KAAK;IACT,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,IAAI,MAAA;gBACC,KAAK,SAAI,EAAE,MAAM,SAAI;CAWlC;AAED,MAAM,MAAM,IAAI,GAAG,KAAK,CAAA;AACxB,wBAAgB,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED,qBAAa,KAAM,SAAQ,EAAE,CAAC,KAAK;IACzB,WAAW,EAAE,MAAM,IAAI,CAAA;CAChC;AAED,wBAAgB,UAAU,IAAI,IAAI,CAEjC"}
|