@awayfl/awayfl-player 0.2.37 → 0.2.38
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/LICENSE +201 -201
- package/README.md +36 -36
- package/awayfl.config.js +85 -85
- package/builtins/playerglobal.json +2752 -2752
- package/builtins/playerglobal_new.json +4169 -4169
- package/bundle/awayfl-player.umd.js +14 -131
- package/bundle/awayfl-player.umd.js.gz +0 -0
- package/bundle/awayfl-player.umd.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +9 -9
- package/dist/lib/AVM1Player.d.ts +4 -4
- package/dist/lib/AVM1Player.js +13 -13
- package/dist/lib/AVM2Player.d.ts +4 -4
- package/dist/lib/AVM2Player.js +14 -14
- package/dist/lib/AVMDebugInterface.d.ts +21 -21
- package/dist/lib/AVMDebugInterface.js +279 -279
- package/dist/lib/AVMPlayer.d.ts +6 -6
- package/dist/lib/AVMPlayer.js +27 -27
- package/dist/src/Main.d.ts +1 -1
- package/dist/src/Main.js +19 -19
- package/index.ts +9 -9
- package/lib/AVM1Player.ts +9 -9
- package/lib/AVM2Player.ts +12 -12
- package/lib/AVMDebugInterface.ts +345 -345
- package/lib/AVMPlayer.ts +29 -29
- package/package.json +97 -97
- package/rollup.config.js +30 -30
- package/scripts/copyVersionToIndex.js +33 -33
- package/scripts/initAwayDev_mac.sh +177 -177
- package/scripts/initAwayDev_mac_pnpm.sh +177 -177
- package/scripts/initAwayDev_win.bat +198 -198
- package/scripts/unlinkAwayDev_mac.sh +140 -140
- package/scripts/unlinkAwayDev_mac_pnpm.sh +140 -140
- package/scripts/unlinkAwayDev_win.bat +140 -140
- package/scripts/updateAwayDev_mac.sh +86 -90
- package/scripts/updateAwayDev_win.bat +69 -69
- package/scripts/updateAway_any.bat +73 -73
- package/tsconfig.json +12 -12
- package/webpack.config.js +496 -496
|
@@ -1,279 +1,279 @@
|
|
|
1
|
-
import { AVMStage, registerDebugMethod } from "@awayfl/swf-loader";
|
|
2
|
-
import { PickGroup } from "@awayjs/view";
|
|
3
|
-
import { SharedObjectDebug as SOavm2 } from "@awayfl/playerglobal";
|
|
4
|
-
import { SharedObjectDebug as SOavm1 } from "@awayfl/avm1";
|
|
5
|
-
function fullSerializer(obj) {
|
|
6
|
-
var clone = Object.assign({}, obj);
|
|
7
|
-
Object.keys(clone).forEach(function (key) {
|
|
8
|
-
if (typeof clone[key] === 'object') {
|
|
9
|
-
clone[key] = fullSerializer(clone[key]);
|
|
10
|
-
}
|
|
11
|
-
else if (typeof clone[key] === 'function') {
|
|
12
|
-
// replace func with it string representation
|
|
13
|
-
clone[key] = clone[key].toString();
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
return clone;
|
|
17
|
-
}
|
|
18
|
-
var OBJECT_FIELDS = ['id', 'visible', 'index', 'assetType:type', 'name'];
|
|
19
|
-
var AVMDebug = /** @class */ (function () {
|
|
20
|
-
function AVMDebug(player) {
|
|
21
|
-
this.player = player;
|
|
22
|
-
this._rafState = 'play';
|
|
23
|
-
this._defaultRaf = self.requestAnimationFrame;
|
|
24
|
-
this._requestedCallbacks = [];
|
|
25
|
-
registerDebugMethod(this._dirObjectByIds.bind(this), {
|
|
26
|
-
name: "dirObjectByIds",
|
|
27
|
-
description: "Export selected object to console",
|
|
28
|
-
declaration: [{ name: 'ids', type: "object" }]
|
|
29
|
-
});
|
|
30
|
-
registerDebugMethod(this._applyPropsByIds.bind(this), {
|
|
31
|
-
name: "applyPropsByIds",
|
|
32
|
-
description: "Apply propertyes by node ids",
|
|
33
|
-
declaration: [{ name: 'ids', type: "object" }, { name: 'object', type: 'object' }]
|
|
34
|
-
});
|
|
35
|
-
registerDebugMethod(this._removeObjectByIds.bind(this), {
|
|
36
|
-
name: "removeObjectByIds",
|
|
37
|
-
description: "Remove object from sceen tree",
|
|
38
|
-
declaration: [{ name: 'ids', type: "object" }]
|
|
39
|
-
});
|
|
40
|
-
registerDebugMethod(this._getInfo.bind(this), {
|
|
41
|
-
name: "getInfo",
|
|
42
|
-
description: "Get file info for app",
|
|
43
|
-
declaration: [{ name: "return", type: "object" }]
|
|
44
|
-
});
|
|
45
|
-
registerDebugMethod(this._getSceneTree.bind(this), {
|
|
46
|
-
name: "getNodeTree",
|
|
47
|
-
description: "Get sceen tree of app",
|
|
48
|
-
declaration: [
|
|
49
|
-
{ name: "return", type: "object" },
|
|
50
|
-
{ name: "flat", type: "boolean" },
|
|
51
|
-
{ name: "from", type: "number" },
|
|
52
|
-
{ name: "rect", type: "object" }
|
|
53
|
-
]
|
|
54
|
-
});
|
|
55
|
-
registerDebugMethod(this._getStageCanvas.bind(this), {
|
|
56
|
-
name: "getStageCanvas",
|
|
57
|
-
description: "Get canvas attahed to stage",
|
|
58
|
-
declaration: []
|
|
59
|
-
});
|
|
60
|
-
registerDebugMethod(this._setRAFState.bind(this), {
|
|
61
|
-
name: "setRAFState",
|
|
62
|
-
description: "Changed RAF state",
|
|
63
|
-
declaration: [
|
|
64
|
-
{ name: 'return', type: 'string' },
|
|
65
|
-
{ name: 'state', type: 'string' }
|
|
66
|
-
]
|
|
67
|
-
});
|
|
68
|
-
registerDebugMethod(this._getRAFState.bind(this), {
|
|
69
|
-
name: "getRAFState",
|
|
70
|
-
description: "Changed RAF state",
|
|
71
|
-
declaration: [
|
|
72
|
-
{ name: 'return', type: 'string' },
|
|
73
|
-
{ name: 'state', type: 'string' }
|
|
74
|
-
]
|
|
75
|
-
});
|
|
76
|
-
this._mokedRaf = this._mokedRaf.bind(this);
|
|
77
|
-
//@ts-ignore
|
|
78
|
-
window._AWAY_DEBUG_PLAYER_ = this;
|
|
79
|
-
}
|
|
80
|
-
AVMDebug.prototype.onAvmInit = function (version) {
|
|
81
|
-
//@ts-ignore
|
|
82
|
-
window._AWAY_DEBUG_STORAGE = version === 1 ? SOavm1 : SOavm2;
|
|
83
|
-
};
|
|
84
|
-
AVMDebug.prototype._mokedRaf = function (callback) {
|
|
85
|
-
if (this._requestedCallbacks.indexOf(callback) !== -1)
|
|
86
|
-
return;
|
|
87
|
-
this._requestedCallbacks.push(callback);
|
|
88
|
-
return 0;
|
|
89
|
-
};
|
|
90
|
-
AVMDebug.prototype._setRAFState = function (state) {
|
|
91
|
-
if (!state)
|
|
92
|
-
return this._rafState;
|
|
93
|
-
if (state === this._rafState)
|
|
94
|
-
return;
|
|
95
|
-
if (state === 'next' && this._rafState === 'stop') {
|
|
96
|
-
var time_1 = performance.now();
|
|
97
|
-
var callbacks = this._requestedCallbacks.slice();
|
|
98
|
-
this._rafState = 'next';
|
|
99
|
-
this._requestedCallbacks.length = 0;
|
|
100
|
-
callbacks.forEach(function (e) { return e && e(time_1); });
|
|
101
|
-
return this._rafState = 'stop';
|
|
102
|
-
}
|
|
103
|
-
if (state === 'stop') {
|
|
104
|
-
this._requestedCallbacks.length = 0;
|
|
105
|
-
self.requestAnimationFrame = this._mokedRaf;
|
|
106
|
-
return this._rafState = 'stop';
|
|
107
|
-
}
|
|
108
|
-
if (state === 'play') {
|
|
109
|
-
var time_2 = performance.now();
|
|
110
|
-
var callbacks = this._requestedCallbacks.slice();
|
|
111
|
-
this._rafState = 'play';
|
|
112
|
-
this._requestedCallbacks.length = 0;
|
|
113
|
-
self.requestAnimationFrame = this._defaultRaf;
|
|
114
|
-
callbacks.forEach(function (e) { return e && e(time_2); });
|
|
115
|
-
}
|
|
116
|
-
return this._rafState;
|
|
117
|
-
};
|
|
118
|
-
AVMDebug.prototype._getRAFState = function () {
|
|
119
|
-
return this._rafState;
|
|
120
|
-
};
|
|
121
|
-
AVMDebug.prototype._selectNode = function (ids) {
|
|
122
|
-
var node = this.player.root;
|
|
123
|
-
var _loop_1 = function (i) {
|
|
124
|
-
node = node._children.find(function (e) { return e.id === i; });
|
|
125
|
-
if (!node) {
|
|
126
|
-
return "break";
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
|
|
130
|
-
var i = ids_1[_i];
|
|
131
|
-
var state_1 = _loop_1(i);
|
|
132
|
-
if (state_1 === "break")
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
if (!node) {
|
|
136
|
-
throw new Error("Node not found");
|
|
137
|
-
}
|
|
138
|
-
return node;
|
|
139
|
-
};
|
|
140
|
-
AVMDebug.prototype._getStageCanvas = function () {
|
|
141
|
-
return this.player.view.stage.container;
|
|
142
|
-
};
|
|
143
|
-
AVMDebug.prototype._dirObjectByIds = function (ids) {
|
|
144
|
-
var node = this._selectNode(ids);
|
|
145
|
-
//@ts-ignore
|
|
146
|
-
var exposeID = window._lastTempNode = window._lastTempNode || 1;
|
|
147
|
-
//@ts-ignore
|
|
148
|
-
window._lastTempNode++;
|
|
149
|
-
window['tempNode' + exposeID] = node;
|
|
150
|
-
console.log('tempNode' + exposeID, '=');
|
|
151
|
-
console.dir(node);
|
|
152
|
-
};
|
|
153
|
-
AVMDebug.prototype._getNodeBounds = function (node) {
|
|
154
|
-
var view = this.player.view;
|
|
155
|
-
var box;
|
|
156
|
-
var pool = AVMStage.instance && AVMStage.instance().pool;
|
|
157
|
-
if (pool) {
|
|
158
|
-
//@ts-ignore
|
|
159
|
-
var partition = pool.getNode(node).partition;
|
|
160
|
-
var picker = PickGroup.getInstance().getBoundsPicker(partition);
|
|
161
|
-
//@ts-ignore
|
|
162
|
-
box = picker.getBoxBounds(pool.getNode(this.player.root), true, true);
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
//@ts-ignore
|
|
166
|
-
box = PickGroup.getInstance().getBoundsPicker(node.partition).getBoxBounds(this.player.root);
|
|
167
|
-
}
|
|
168
|
-
if (!box)
|
|
169
|
-
return null;
|
|
170
|
-
var sx = view.width / this.player.stageWidth;
|
|
171
|
-
var sy = view.height / this.player.stageHeight;
|
|
172
|
-
//console.log("DisplayObject:getRect not yet implemented");FromBounds
|
|
173
|
-
return {
|
|
174
|
-
x: box.x * sx,
|
|
175
|
-
y: box.y * sy,
|
|
176
|
-
width: box.width * sx,
|
|
177
|
-
height: box.height * sy
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
AVMDebug.prototype._traverse = function (node, req, rect, visibleOnly) {
|
|
181
|
-
if (req === void 0) { req = false; }
|
|
182
|
-
if (rect === void 0) { rect = false; }
|
|
183
|
-
if (visibleOnly === void 0) { visibleOnly = false; }
|
|
184
|
-
var ret = {
|
|
185
|
-
parentId: node.parent ? node.parent.id : -1,
|
|
186
|
-
children: null,
|
|
187
|
-
rect: null,
|
|
188
|
-
};
|
|
189
|
-
for (var _i = 0, OBJECT_FIELDS_1 = OBJECT_FIELDS; _i < OBJECT_FIELDS_1.length; _i++) {
|
|
190
|
-
var name_1 = OBJECT_FIELDS_1[_i];
|
|
191
|
-
var sub = name_1.split(":");
|
|
192
|
-
if (sub.length > 1) {
|
|
193
|
-
ret[sub[1]] = node[sub[0]];
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
ret[name_1] = node[name_1];
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
ret["globalVisible"] =
|
|
200
|
-
node.parent ? (node.parent.visible && node.visible) : node.visible;
|
|
201
|
-
if (rect) {
|
|
202
|
-
ret.rect = this._getNodeBounds(node);
|
|
203
|
-
}
|
|
204
|
-
if (req) {
|
|
205
|
-
ret.children = [];
|
|
206
|
-
for (var _a = 0, _b = node._children; _a < _b.length; _a++) {
|
|
207
|
-
var c = _b[_a];
|
|
208
|
-
if (visibleOnly && c.visible || !visibleOnly) {
|
|
209
|
-
ret.children.push(this._traverse(c, req, rect, visibleOnly));
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return ret;
|
|
214
|
-
};
|
|
215
|
-
AVMDebug.prototype._removeObjectByIds = function (ids) {
|
|
216
|
-
var node = this._selectNode(ids);
|
|
217
|
-
node.parent.removeChild(node);
|
|
218
|
-
};
|
|
219
|
-
AVMDebug.prototype._applyPropsByIds = function (ids, object) {
|
|
220
|
-
var node = this._selectNode(ids);
|
|
221
|
-
Object.assign(node, object);
|
|
222
|
-
};
|
|
223
|
-
AVMDebug.prototype._getSceneTree = function (params, fromArg, rectArg) {
|
|
224
|
-
if (typeof params !== 'object') {
|
|
225
|
-
params = {
|
|
226
|
-
flat: params || false,
|
|
227
|
-
from: fromArg || 0,
|
|
228
|
-
rect: rectArg || false,
|
|
229
|
-
visibleOnly: false
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
var _a = params.flat, flat = _a === void 0 ? false : _a, _b = params.from, from = _b === void 0 ? 0 : _b, _c = params.rect, rect = _c === void 0 ? false : _c, _d = params.visibleOnly, visibleOnly = _d === void 0 ? false : _d;
|
|
233
|
-
var tree = [];
|
|
234
|
-
//@ts-ignore
|
|
235
|
-
var q = this.player.root._children.slice();
|
|
236
|
-
while (true) {
|
|
237
|
-
var node = q.pop();
|
|
238
|
-
if (!node) {
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
tree.push(this._traverse(node, !flat, rect, visibleOnly));
|
|
242
|
-
if (flat) {
|
|
243
|
-
q.push.apply(q, node._children.reverse().filter(function (e) { return (e.visible && visibleOnly || !visibleOnly); }));
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return tree;
|
|
247
|
-
};
|
|
248
|
-
AVMDebug.prototype._getInfo = function () {
|
|
249
|
-
var _a;
|
|
250
|
-
var player = this.player;
|
|
251
|
-
var avm = player._avmHandler.avmVersion;
|
|
252
|
-
var _b = player._swfFile, swfVersion = _b.swfVersion, fpVersion = _b.fpVersion, frameCount = _b.frameCount, frameRate = _b.frameRate, compression = _b.compression, bytesTotal = _b.bytesTotal;
|
|
253
|
-
var path = (_a = player._gameConfig.binary.filter(function (_a) {
|
|
254
|
-
var resourceType = _a.resourceType;
|
|
255
|
-
return resourceType === 'GAME';
|
|
256
|
-
})[0]) === null || _a === void 0 ? void 0 : _a.path;
|
|
257
|
-
if (path && path.indexOf('?') > -1) {
|
|
258
|
-
path = path.substring(0, path.indexOf('?'));
|
|
259
|
-
}
|
|
260
|
-
return {
|
|
261
|
-
file: {
|
|
262
|
-
name: player._gameConfig.title,
|
|
263
|
-
path: path,
|
|
264
|
-
size: bytesTotal
|
|
265
|
-
},
|
|
266
|
-
runtime: {
|
|
267
|
-
swfVersion: swfVersion,
|
|
268
|
-
fpVersion: fpVersion,
|
|
269
|
-
frameCount: frameCount,
|
|
270
|
-
frameRate: frameRate,
|
|
271
|
-
compression: compression,
|
|
272
|
-
avm: avm
|
|
273
|
-
},
|
|
274
|
-
config: fullSerializer(player._gameConfig)
|
|
275
|
-
};
|
|
276
|
-
};
|
|
277
|
-
return AVMDebug;
|
|
278
|
-
}());
|
|
279
|
-
export { AVMDebug };
|
|
1
|
+
import { AVMStage, registerDebugMethod } from "@awayfl/swf-loader";
|
|
2
|
+
import { PickGroup } from "@awayjs/view";
|
|
3
|
+
import { SharedObjectDebug as SOavm2 } from "@awayfl/playerglobal";
|
|
4
|
+
import { SharedObjectDebug as SOavm1 } from "@awayfl/avm1";
|
|
5
|
+
function fullSerializer(obj) {
|
|
6
|
+
var clone = Object.assign({}, obj);
|
|
7
|
+
Object.keys(clone).forEach(function (key) {
|
|
8
|
+
if (typeof clone[key] === 'object') {
|
|
9
|
+
clone[key] = fullSerializer(clone[key]);
|
|
10
|
+
}
|
|
11
|
+
else if (typeof clone[key] === 'function') {
|
|
12
|
+
// replace func with it string representation
|
|
13
|
+
clone[key] = clone[key].toString();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return clone;
|
|
17
|
+
}
|
|
18
|
+
var OBJECT_FIELDS = ['id', 'visible', 'index', 'assetType:type', 'name'];
|
|
19
|
+
var AVMDebug = /** @class */ (function () {
|
|
20
|
+
function AVMDebug(player) {
|
|
21
|
+
this.player = player;
|
|
22
|
+
this._rafState = 'play';
|
|
23
|
+
this._defaultRaf = self.requestAnimationFrame;
|
|
24
|
+
this._requestedCallbacks = [];
|
|
25
|
+
registerDebugMethod(this._dirObjectByIds.bind(this), {
|
|
26
|
+
name: "dirObjectByIds",
|
|
27
|
+
description: "Export selected object to console",
|
|
28
|
+
declaration: [{ name: 'ids', type: "object" }]
|
|
29
|
+
});
|
|
30
|
+
registerDebugMethod(this._applyPropsByIds.bind(this), {
|
|
31
|
+
name: "applyPropsByIds",
|
|
32
|
+
description: "Apply propertyes by node ids",
|
|
33
|
+
declaration: [{ name: 'ids', type: "object" }, { name: 'object', type: 'object' }]
|
|
34
|
+
});
|
|
35
|
+
registerDebugMethod(this._removeObjectByIds.bind(this), {
|
|
36
|
+
name: "removeObjectByIds",
|
|
37
|
+
description: "Remove object from sceen tree",
|
|
38
|
+
declaration: [{ name: 'ids', type: "object" }]
|
|
39
|
+
});
|
|
40
|
+
registerDebugMethod(this._getInfo.bind(this), {
|
|
41
|
+
name: "getInfo",
|
|
42
|
+
description: "Get file info for app",
|
|
43
|
+
declaration: [{ name: "return", type: "object" }]
|
|
44
|
+
});
|
|
45
|
+
registerDebugMethod(this._getSceneTree.bind(this), {
|
|
46
|
+
name: "getNodeTree",
|
|
47
|
+
description: "Get sceen tree of app",
|
|
48
|
+
declaration: [
|
|
49
|
+
{ name: "return", type: "object" },
|
|
50
|
+
{ name: "flat", type: "boolean" },
|
|
51
|
+
{ name: "from", type: "number" },
|
|
52
|
+
{ name: "rect", type: "object" }
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
registerDebugMethod(this._getStageCanvas.bind(this), {
|
|
56
|
+
name: "getStageCanvas",
|
|
57
|
+
description: "Get canvas attahed to stage",
|
|
58
|
+
declaration: []
|
|
59
|
+
});
|
|
60
|
+
registerDebugMethod(this._setRAFState.bind(this), {
|
|
61
|
+
name: "setRAFState",
|
|
62
|
+
description: "Changed RAF state",
|
|
63
|
+
declaration: [
|
|
64
|
+
{ name: 'return', type: 'string' },
|
|
65
|
+
{ name: 'state', type: 'string' }
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
registerDebugMethod(this._getRAFState.bind(this), {
|
|
69
|
+
name: "getRAFState",
|
|
70
|
+
description: "Changed RAF state",
|
|
71
|
+
declaration: [
|
|
72
|
+
{ name: 'return', type: 'string' },
|
|
73
|
+
{ name: 'state', type: 'string' }
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
this._mokedRaf = this._mokedRaf.bind(this);
|
|
77
|
+
//@ts-ignore
|
|
78
|
+
window._AWAY_DEBUG_PLAYER_ = this;
|
|
79
|
+
}
|
|
80
|
+
AVMDebug.prototype.onAvmInit = function (version) {
|
|
81
|
+
//@ts-ignore
|
|
82
|
+
window._AWAY_DEBUG_STORAGE = version === 1 ? SOavm1 : SOavm2;
|
|
83
|
+
};
|
|
84
|
+
AVMDebug.prototype._mokedRaf = function (callback) {
|
|
85
|
+
if (this._requestedCallbacks.indexOf(callback) !== -1)
|
|
86
|
+
return;
|
|
87
|
+
this._requestedCallbacks.push(callback);
|
|
88
|
+
return 0;
|
|
89
|
+
};
|
|
90
|
+
AVMDebug.prototype._setRAFState = function (state) {
|
|
91
|
+
if (!state)
|
|
92
|
+
return this._rafState;
|
|
93
|
+
if (state === this._rafState)
|
|
94
|
+
return;
|
|
95
|
+
if (state === 'next' && this._rafState === 'stop') {
|
|
96
|
+
var time_1 = performance.now();
|
|
97
|
+
var callbacks = this._requestedCallbacks.slice();
|
|
98
|
+
this._rafState = 'next';
|
|
99
|
+
this._requestedCallbacks.length = 0;
|
|
100
|
+
callbacks.forEach(function (e) { return e && e(time_1); });
|
|
101
|
+
return this._rafState = 'stop';
|
|
102
|
+
}
|
|
103
|
+
if (state === 'stop') {
|
|
104
|
+
this._requestedCallbacks.length = 0;
|
|
105
|
+
self.requestAnimationFrame = this._mokedRaf;
|
|
106
|
+
return this._rafState = 'stop';
|
|
107
|
+
}
|
|
108
|
+
if (state === 'play') {
|
|
109
|
+
var time_2 = performance.now();
|
|
110
|
+
var callbacks = this._requestedCallbacks.slice();
|
|
111
|
+
this._rafState = 'play';
|
|
112
|
+
this._requestedCallbacks.length = 0;
|
|
113
|
+
self.requestAnimationFrame = this._defaultRaf;
|
|
114
|
+
callbacks.forEach(function (e) { return e && e(time_2); });
|
|
115
|
+
}
|
|
116
|
+
return this._rafState;
|
|
117
|
+
};
|
|
118
|
+
AVMDebug.prototype._getRAFState = function () {
|
|
119
|
+
return this._rafState;
|
|
120
|
+
};
|
|
121
|
+
AVMDebug.prototype._selectNode = function (ids) {
|
|
122
|
+
var node = this.player.root;
|
|
123
|
+
var _loop_1 = function (i) {
|
|
124
|
+
node = node._children.find(function (e) { return e.id === i; });
|
|
125
|
+
if (!node) {
|
|
126
|
+
return "break";
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
|
|
130
|
+
var i = ids_1[_i];
|
|
131
|
+
var state_1 = _loop_1(i);
|
|
132
|
+
if (state_1 === "break")
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
if (!node) {
|
|
136
|
+
throw new Error("Node not found");
|
|
137
|
+
}
|
|
138
|
+
return node;
|
|
139
|
+
};
|
|
140
|
+
AVMDebug.prototype._getStageCanvas = function () {
|
|
141
|
+
return this.player.view.stage.container;
|
|
142
|
+
};
|
|
143
|
+
AVMDebug.prototype._dirObjectByIds = function (ids) {
|
|
144
|
+
var node = this._selectNode(ids);
|
|
145
|
+
//@ts-ignore
|
|
146
|
+
var exposeID = window._lastTempNode = window._lastTempNode || 1;
|
|
147
|
+
//@ts-ignore
|
|
148
|
+
window._lastTempNode++;
|
|
149
|
+
window['tempNode' + exposeID] = node;
|
|
150
|
+
console.log('tempNode' + exposeID, '=');
|
|
151
|
+
console.dir(node);
|
|
152
|
+
};
|
|
153
|
+
AVMDebug.prototype._getNodeBounds = function (node) {
|
|
154
|
+
var view = this.player.view;
|
|
155
|
+
var box;
|
|
156
|
+
var pool = AVMStage.instance && AVMStage.instance().pool;
|
|
157
|
+
if (pool) {
|
|
158
|
+
//@ts-ignore
|
|
159
|
+
var partition = pool.getNode(node).partition;
|
|
160
|
+
var picker = PickGroup.getInstance().getBoundsPicker(partition);
|
|
161
|
+
//@ts-ignore
|
|
162
|
+
box = picker.getBoxBounds(pool.getNode(this.player.root), true, true);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
//@ts-ignore
|
|
166
|
+
box = PickGroup.getInstance().getBoundsPicker(node.partition).getBoxBounds(this.player.root);
|
|
167
|
+
}
|
|
168
|
+
if (!box)
|
|
169
|
+
return null;
|
|
170
|
+
var sx = view.width / this.player.stageWidth;
|
|
171
|
+
var sy = view.height / this.player.stageHeight;
|
|
172
|
+
//console.log("DisplayObject:getRect not yet implemented");FromBounds
|
|
173
|
+
return {
|
|
174
|
+
x: box.x * sx,
|
|
175
|
+
y: box.y * sy,
|
|
176
|
+
width: box.width * sx,
|
|
177
|
+
height: box.height * sy
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
AVMDebug.prototype._traverse = function (node, req, rect, visibleOnly) {
|
|
181
|
+
if (req === void 0) { req = false; }
|
|
182
|
+
if (rect === void 0) { rect = false; }
|
|
183
|
+
if (visibleOnly === void 0) { visibleOnly = false; }
|
|
184
|
+
var ret = {
|
|
185
|
+
parentId: node.parent ? node.parent.id : -1,
|
|
186
|
+
children: null,
|
|
187
|
+
rect: null,
|
|
188
|
+
};
|
|
189
|
+
for (var _i = 0, OBJECT_FIELDS_1 = OBJECT_FIELDS; _i < OBJECT_FIELDS_1.length; _i++) {
|
|
190
|
+
var name_1 = OBJECT_FIELDS_1[_i];
|
|
191
|
+
var sub = name_1.split(":");
|
|
192
|
+
if (sub.length > 1) {
|
|
193
|
+
ret[sub[1]] = node[sub[0]];
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
ret[name_1] = node[name_1];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
ret["globalVisible"] =
|
|
200
|
+
node.parent ? (node.parent.visible && node.visible) : node.visible;
|
|
201
|
+
if (rect) {
|
|
202
|
+
ret.rect = this._getNodeBounds(node);
|
|
203
|
+
}
|
|
204
|
+
if (req) {
|
|
205
|
+
ret.children = [];
|
|
206
|
+
for (var _a = 0, _b = node._children; _a < _b.length; _a++) {
|
|
207
|
+
var c = _b[_a];
|
|
208
|
+
if (visibleOnly && c.visible || !visibleOnly) {
|
|
209
|
+
ret.children.push(this._traverse(c, req, rect, visibleOnly));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return ret;
|
|
214
|
+
};
|
|
215
|
+
AVMDebug.prototype._removeObjectByIds = function (ids) {
|
|
216
|
+
var node = this._selectNode(ids);
|
|
217
|
+
node.parent.removeChild(node);
|
|
218
|
+
};
|
|
219
|
+
AVMDebug.prototype._applyPropsByIds = function (ids, object) {
|
|
220
|
+
var node = this._selectNode(ids);
|
|
221
|
+
Object.assign(node, object);
|
|
222
|
+
};
|
|
223
|
+
AVMDebug.prototype._getSceneTree = function (params, fromArg, rectArg) {
|
|
224
|
+
if (typeof params !== 'object') {
|
|
225
|
+
params = {
|
|
226
|
+
flat: params || false,
|
|
227
|
+
from: fromArg || 0,
|
|
228
|
+
rect: rectArg || false,
|
|
229
|
+
visibleOnly: false
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
var _a = params.flat, flat = _a === void 0 ? false : _a, _b = params.from, from = _b === void 0 ? 0 : _b, _c = params.rect, rect = _c === void 0 ? false : _c, _d = params.visibleOnly, visibleOnly = _d === void 0 ? false : _d;
|
|
233
|
+
var tree = [];
|
|
234
|
+
//@ts-ignore
|
|
235
|
+
var q = this.player.root._children.slice();
|
|
236
|
+
while (true) {
|
|
237
|
+
var node = q.pop();
|
|
238
|
+
if (!node) {
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
tree.push(this._traverse(node, !flat, rect, visibleOnly));
|
|
242
|
+
if (flat) {
|
|
243
|
+
q.push.apply(q, node._children.reverse().filter(function (e) { return (e.visible && visibleOnly || !visibleOnly); }));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return tree;
|
|
247
|
+
};
|
|
248
|
+
AVMDebug.prototype._getInfo = function () {
|
|
249
|
+
var _a;
|
|
250
|
+
var player = this.player;
|
|
251
|
+
var avm = player._avmHandler.avmVersion;
|
|
252
|
+
var _b = player._swfFile, swfVersion = _b.swfVersion, fpVersion = _b.fpVersion, frameCount = _b.frameCount, frameRate = _b.frameRate, compression = _b.compression, bytesTotal = _b.bytesTotal;
|
|
253
|
+
var path = (_a = player._gameConfig.binary.filter(function (_a) {
|
|
254
|
+
var resourceType = _a.resourceType;
|
|
255
|
+
return resourceType === 'GAME';
|
|
256
|
+
})[0]) === null || _a === void 0 ? void 0 : _a.path;
|
|
257
|
+
if (path && path.indexOf('?') > -1) {
|
|
258
|
+
path = path.substring(0, path.indexOf('?'));
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
file: {
|
|
262
|
+
name: player._gameConfig.title,
|
|
263
|
+
path: path,
|
|
264
|
+
size: bytesTotal
|
|
265
|
+
},
|
|
266
|
+
runtime: {
|
|
267
|
+
swfVersion: swfVersion,
|
|
268
|
+
fpVersion: fpVersion,
|
|
269
|
+
frameCount: frameCount,
|
|
270
|
+
frameRate: frameRate,
|
|
271
|
+
compression: compression,
|
|
272
|
+
avm: avm
|
|
273
|
+
},
|
|
274
|
+
config: fullSerializer(player._gameConfig)
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
return AVMDebug;
|
|
278
|
+
}());
|
|
279
|
+
export { AVMDebug };
|
package/dist/lib/AVMPlayer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AVMStage, AVMEvent } from "@awayfl/swf-loader";
|
|
2
|
-
export declare class AVMPlayer extends AVMStage {
|
|
3
|
-
private _debug;
|
|
4
|
-
constructor(gameConfig: any);
|
|
5
|
-
protected onAVMAvailable(event: AVMEvent): void;
|
|
6
|
-
}
|
|
1
|
+
import { AVMStage, AVMEvent } from "@awayfl/swf-loader";
|
|
2
|
+
export declare class AVMPlayer extends AVMStage {
|
|
3
|
+
private _debug;
|
|
4
|
+
constructor(gameConfig: any);
|
|
5
|
+
protected onAVMAvailable(event: AVMEvent): void;
|
|
6
|
+
}
|
|
7
7
|
//# sourceMappingURL=AVMPlayer.d.ts.map
|
package/dist/lib/AVMPlayer.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
2
|
-
import { AVMStage, AVMEvent, AVMVERSION } from "@awayfl/swf-loader";
|
|
3
|
-
import { AVMDebug } from "./AVMDebugInterface";
|
|
4
|
-
import { AVM1Handler } from '@awayfl/avm1';
|
|
5
|
-
import { AVM2Handler } from '@awayfl/avm2';
|
|
6
|
-
import { PlayerGlobal } from "@awayfl/playerglobal";
|
|
7
|
-
var AVMPlayer = /** @class */ (function (_super) {
|
|
8
|
-
__extends(AVMPlayer, _super);
|
|
9
|
-
function AVMPlayer(gameConfig) {
|
|
10
|
-
var _this = _super.call(this, gameConfig) || this;
|
|
11
|
-
_this.registerAVMStageHandler(new AVM1Handler());
|
|
12
|
-
_this.registerAVMStageHandler(new AVM2Handler(new PlayerGlobal()));
|
|
13
|
-
_this.addEventListener(AVMEvent.AVM_COMPLETE, function (event) { return _this.onAVMAvailable(event); });
|
|
14
|
-
// export player api
|
|
15
|
-
//if(!release) {
|
|
16
|
-
_this._debug = new AVMDebug(_this);
|
|
17
|
-
return _this;
|
|
18
|
-
//}
|
|
19
|
-
}
|
|
20
|
-
AVMPlayer.prototype.onAVMAvailable = function (event) {
|
|
21
|
-
if (this._debug) {
|
|
22
|
-
this._debug.onAvmInit(event.avmVersion === AVMVERSION.AVM1 ? 1 : 2);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
return AVMPlayer;
|
|
26
|
-
}(AVMStage));
|
|
27
|
-
export { AVMPlayer };
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import { AVMStage, AVMEvent, AVMVERSION } from "@awayfl/swf-loader";
|
|
3
|
+
import { AVMDebug } from "./AVMDebugInterface";
|
|
4
|
+
import { AVM1Handler } from '@awayfl/avm1';
|
|
5
|
+
import { AVM2Handler } from '@awayfl/avm2';
|
|
6
|
+
import { PlayerGlobal } from "@awayfl/playerglobal";
|
|
7
|
+
var AVMPlayer = /** @class */ (function (_super) {
|
|
8
|
+
__extends(AVMPlayer, _super);
|
|
9
|
+
function AVMPlayer(gameConfig) {
|
|
10
|
+
var _this = _super.call(this, gameConfig) || this;
|
|
11
|
+
_this.registerAVMStageHandler(new AVM1Handler());
|
|
12
|
+
_this.registerAVMStageHandler(new AVM2Handler(new PlayerGlobal()));
|
|
13
|
+
_this.addEventListener(AVMEvent.AVM_COMPLETE, function (event) { return _this.onAVMAvailable(event); });
|
|
14
|
+
// export player api
|
|
15
|
+
//if(!release) {
|
|
16
|
+
_this._debug = new AVMDebug(_this);
|
|
17
|
+
return _this;
|
|
18
|
+
//}
|
|
19
|
+
}
|
|
20
|
+
AVMPlayer.prototype.onAVMAvailable = function (event) {
|
|
21
|
+
if (this._debug) {
|
|
22
|
+
this._debug.onAvmInit(event.avmVersion === AVMVERSION.AVM1 ? 1 : 2);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return AVMPlayer;
|
|
26
|
+
}(AVMStage));
|
|
27
|
+
export { AVMPlayer };
|
package/dist/src/Main.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=Main.d.ts.map
|