@safe-engine/cocos 1.6.4 → 1.7.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.
Files changed (31) hide show
  1. package/dist/app.d.ts +2 -2
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/app.js +36 -26
  4. package/dist/box2d-wasm/PhysicsComponent.d.ts +2 -0
  5. package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
  6. package/dist/box2d-wasm/PhysicsComponent.js +16 -3
  7. package/dist/box2d-wasm/PhysicsSprite.d.ts +1 -0
  8. package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
  9. package/dist/box2d-wasm/PhysicsSprite.js +3 -4
  10. package/dist/box2d-wasm/PhysicsSystem.d.ts +1 -2
  11. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
  12. package/dist/box2d-wasm/PhysicsSystem.js +36 -31
  13. package/dist/gworld/components/AnimationComponent.d.ts +65 -0
  14. package/dist/gworld/components/AnimationComponent.d.ts.map +1 -0
  15. package/dist/gworld/components/AnimationComponent.js +141 -0
  16. package/dist/gworld/components/CollideComponent.d.ts +64 -0
  17. package/dist/gworld/components/CollideComponent.d.ts.map +1 -0
  18. package/dist/gworld/components/CollideComponent.js +265 -0
  19. package/dist/gworld/systems/AnimationSystem.d.ts +6 -0
  20. package/dist/gworld/systems/AnimationSystem.d.ts.map +1 -0
  21. package/dist/gworld/systems/AnimationSystem.js +30 -0
  22. package/dist/gworld/systems/CollideSystem.d.ts +20 -0
  23. package/dist/gworld/systems/CollideSystem.d.ts.map +1 -0
  24. package/dist/gworld/systems/CollideSystem.js +171 -0
  25. package/dist/helper/html-text-parser.d.ts +30 -0
  26. package/dist/helper/html-text-parser.d.ts.map +1 -0
  27. package/dist/helper/html-text-parser.js +354 -0
  28. package/dist/index.d.ts +0 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +0 -1
  31. package/package.json +1 -1
@@ -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([/&lt;/g, '<']);
42
+ this._specialSymbolArray.push([/&gt;/g, '>']);
43
+ this._specialSymbolArray.push([/&amp;/g, '&']);
44
+ this._specialSymbolArray.push([/&quot;/g, '"']);
45
+ this._specialSymbolArray.push([/&apos;/g, "'"]);
46
+ this._specialSymbolArray.push([/&nbsp;/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
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './app';
2
- export * from './box2d-wasm';
3
2
  export * from './collider';
4
3
  export * from './dragonbones';
5
4
  export * from './gworld';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,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,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,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,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './app';
2
- export * from './box2d-wasm';
3
2
  export * from './collider';
4
3
  export * from './dragonbones';
5
4
  export * from './gworld';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@safe-engine/cocos",
3
- "version": "1.6.4",
3
+ "version": "1.7.1",
4
4
  "description": "safe-engine with cocos renderer support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",