@safe-engine/cocos 1.4.11 → 1.5.2
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 +0 -7
- package/dist/app.d.ts +13 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +6 -10
- package/dist/collider/CollideComponent.d.ts +64 -0
- package/dist/collider/CollideComponent.d.ts.map +1 -0
- package/dist/collider/CollideComponent.js +265 -0
- package/dist/collider/CollideSystem.d.ts +21 -0
- package/dist/collider/CollideSystem.d.ts.map +1 -0
- package/dist/collider/CollideSystem.js +181 -0
- package/dist/collider/index.d.ts +2 -0
- package/dist/collider/index.d.ts.map +1 -0
- package/dist/collider/index.js +10 -0
- package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +1 -1
- package/dist/dragonbones/PixiDragonBonesSprite.js +11 -11
- 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 +3 -2
- package/dist/dragonbones/index.d.ts.map +1 -1
- package/dist/dragonbones/index.js +9 -9
- package/dist/gworld/components/CollideComponent.d.ts +3 -3
- package/dist/gworld/components/GUIComponent.d.ts +0 -4
- package/dist/gworld/components/GUIComponent.d.ts.map +1 -1
- package/dist/gworld/components/GUIComponent.js +1 -39
- package/dist/gworld/components/NodeComp.d.ts +2 -2
- package/dist/gworld/components/NodeComp.d.ts.map +1 -1
- package/dist/gworld/components/RenderComponent.d.ts.map +1 -1
- package/dist/gworld/systems/CollideSystem.d.ts +2 -1
- package/dist/gworld/systems/CollideSystem.d.ts.map +1 -1
- package/dist/gworld/systems/CollideSystem.js +12 -2
- package/dist/gworld/systems/GUISystem.d.ts +0 -1
- package/dist/gworld/systems/GUISystem.d.ts.map +1 -1
- package/dist/gworld/systems/GUISystem.js +0 -11
- package/dist/gworld/systems/RenderSystem.d.ts.map +1 -1
- package/dist/gworld/systems/RenderSystem.js +0 -15
- 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 +1 -1
- package/dist/helper/utils.d.ts +1 -2
- package/dist/helper/utils.d.ts.map +1 -1
- package/dist/helper/utils.js +0 -10
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/richtext/RichTextComp.d.ts +13 -0
- package/dist/richtext/RichTextComp.d.ts.map +1 -0
- package/dist/richtext/RichTextComp.js +57 -0
- package/dist/richtext/RichTextSystem.d.ts +7 -0
- package/dist/richtext/RichTextSystem.d.ts.map +1 -0
- package/dist/richtext/RichTextSystem.js +28 -0
- package/dist/richtext/html-text-parser.d.ts +30 -0
- package/dist/richtext/html-text-parser.d.ts.map +1 -0
- package/dist/richtext/html-text-parser.js +354 -0
- package/dist/richtext/index.d.ts +2 -0
- package/dist/richtext/index.d.ts.map +1 -0
- package/dist/richtext/index.js +9 -0
- package/dist/spine/index.d.ts +31 -0
- package/dist/spine/index.d.ts.map +1 -0
- package/dist/spine/index.js +74 -0
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/****************************************************************************
|
|
2
|
+
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
3
|
+
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
4
|
+
|
|
5
|
+
https://www.cocos.com/
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated engine source code (the "Software"), a limited,
|
|
9
|
+
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
|
10
|
+
to use Cocos Creator solely to develop games on your target platforms. You shall
|
|
11
|
+
not use Cocos Creator software for developing other software or tools that's
|
|
12
|
+
used for developing games. You are not granted to publish, distribute,
|
|
13
|
+
sublicense, and/or sell copies of Cocos Creator.
|
|
14
|
+
|
|
15
|
+
The software or tools in this License Agreement are licensed, not sold.
|
|
16
|
+
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
****************************************************************************/
|
|
26
|
+
/**
|
|
27
|
+
* A utils class for parsing HTML texts. The parsed results will be an object array.
|
|
28
|
+
*/
|
|
29
|
+
export declare const HtmlTextParser: () => void;
|
|
30
|
+
//# sourceMappingURL=html-text-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-text-parser.d.ts","sourceRoot":"","sources":["../../src/richtext/html-text-parser.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;8EAwB8E;AAK9E;;GAEG;AACH,eAAO,MAAM,cAAc,YAS1B,CAAA"}
|
|
@@ -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":"index.d.ts","sourceRoot":"","sources":["../../src/richtext/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,SAG5B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupRichText = setupRichText;
|
|
4
|
+
var gworld_1 = require("../gworld");
|
|
5
|
+
var RichTextSystem_1 = require("./RichTextSystem");
|
|
6
|
+
function setupRichText() {
|
|
7
|
+
gworld_1.GameWorld.Instance.systems.add(RichTextSystem_1.RichTextSystem);
|
|
8
|
+
gworld_1.GameWorld.Instance.systems.configureOnce(RichTextSystem_1.RichTextSystem);
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { EntityManager, EventManager, System } from 'entityx-ts';
|
|
2
|
+
import { BaseComponentProps, ComponentX, GameWorld } from '..';
|
|
3
|
+
interface SpineData {
|
|
4
|
+
atlas: string;
|
|
5
|
+
skeleton: string;
|
|
6
|
+
texture?: string;
|
|
7
|
+
}
|
|
8
|
+
interface SpineSkeletonProps {
|
|
9
|
+
data: SpineData;
|
|
10
|
+
skin?: string;
|
|
11
|
+
animation?: string;
|
|
12
|
+
timeScale?: number;
|
|
13
|
+
loop?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class SpineSkeleton extends ComponentX<SpineSkeletonProps & BaseComponentProps<SpineSkeleton>> {
|
|
16
|
+
data: SpineData;
|
|
17
|
+
skin: string;
|
|
18
|
+
animation: string;
|
|
19
|
+
loop: boolean;
|
|
20
|
+
timeScale: number;
|
|
21
|
+
setAnimation(name: string, loop?: boolean): void;
|
|
22
|
+
setSkeletonData(data: string): void;
|
|
23
|
+
}
|
|
24
|
+
export declare class SpineSystem implements System {
|
|
25
|
+
configure(event_manager: EventManager): void;
|
|
26
|
+
private onAddSpineSkeleton;
|
|
27
|
+
update(entities: EntityManager, events: EventManager, dt: number): any;
|
|
28
|
+
}
|
|
29
|
+
export declare function setupSpine(world: GameWorld): void;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAA;AAE5E,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS,EAAY,MAAM,IAAI,CAAA;AAGxE,UAAU,SAAS;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AACD,qBAAa,aAAc,SAAQ,UAAU,CAAC,kBAAkB,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;IACnG,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,OAAO,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IAEjB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,UAAQ;IAOvC,eAAe,CAAC,IAAI,EAAE,MAAM;CAK7B;AAED,qBAAa,WAAY,YAAW,MAAM;IACxC,SAAS,CAAC,aAAa,EAAE,YAAY;IAGrC,OAAO,CAAC,kBAAkB,CAazB;IACD,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;CAIjE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,QAI1C"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.SpineSystem = exports.SpineSkeleton = void 0;
|
|
19
|
+
exports.setupSpine = setupSpine;
|
|
20
|
+
var entityx_ts_1 = require("entityx-ts");
|
|
21
|
+
var __1 = require("..");
|
|
22
|
+
var CCSkeletonAnimation_1 = require("./CCSkeletonAnimation");
|
|
23
|
+
var SpineSkeleton = /** @class */ (function (_super) {
|
|
24
|
+
__extends(SpineSkeleton, _super);
|
|
25
|
+
function SpineSkeleton() {
|
|
26
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
+
}
|
|
28
|
+
SpineSkeleton.prototype.setAnimation = function (name, loop) {
|
|
29
|
+
if (loop === void 0) { loop = false; }
|
|
30
|
+
var skel = this.node.instance;
|
|
31
|
+
if (skel.setAnimation) {
|
|
32
|
+
skel.setAnimation(0, name, loop);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
SpineSkeleton.prototype.setSkeletonData = function (data) {
|
|
36
|
+
var skel = this.node.instance;
|
|
37
|
+
var atlas = data.replace('.json', '.atlas');
|
|
38
|
+
skel.initWithArgs(data, atlas, this.node.scale);
|
|
39
|
+
};
|
|
40
|
+
return SpineSkeleton;
|
|
41
|
+
}(__1.ComponentX));
|
|
42
|
+
exports.SpineSkeleton = SpineSkeleton;
|
|
43
|
+
var SpineSystem = /** @class */ (function () {
|
|
44
|
+
function SpineSystem() {
|
|
45
|
+
this.onAddSpineSkeleton = function (_a) {
|
|
46
|
+
var entity = _a.entity;
|
|
47
|
+
var spineComp = entity.getComponent(SpineSkeleton);
|
|
48
|
+
var _b = spineComp.props, data = _b.data, skin = _b.skin, animation = _b.animation, loop = _b.loop, _c = _b.timeScale, timeScale = _c === void 0 ? 1 : _c;
|
|
49
|
+
var atlas = data.atlas, skeleton = data.skeleton;
|
|
50
|
+
// cc.log(skel, atlas);
|
|
51
|
+
var node = CCSkeletonAnimation_1.SkeletonAnimation.createWithJsonFile(skeleton, atlas, timeScale);
|
|
52
|
+
if (skin) {
|
|
53
|
+
node.setSkin(skin);
|
|
54
|
+
}
|
|
55
|
+
if (animation) {
|
|
56
|
+
node.setAnimation(0, animation, loop);
|
|
57
|
+
}
|
|
58
|
+
spineComp.node = entity.assign(new __1.NodeComp(node, entity));
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
SpineSystem.prototype.configure = function (event_manager) {
|
|
62
|
+
event_manager.subscribe(entityx_ts_1.EventTypes.ComponentAdded, SpineSkeleton, this.onAddSpineSkeleton);
|
|
63
|
+
};
|
|
64
|
+
SpineSystem.prototype.update = function () {
|
|
65
|
+
// throw new Error('Method not implemented.');
|
|
66
|
+
};
|
|
67
|
+
return SpineSystem;
|
|
68
|
+
}());
|
|
69
|
+
exports.SpineSystem = SpineSystem;
|
|
70
|
+
function setupSpine(world) {
|
|
71
|
+
world.systems.add(SpineSystem);
|
|
72
|
+
// world.listUpdate.push(SpineSystem)
|
|
73
|
+
world.systems.configureOnce(SpineSystem);
|
|
74
|
+
}
|