swf2js 0.1.1 → 0.1.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.
Files changed (50) hide show
  1. package/README.md +9 -9
  2. package/package.json +2 -1
  3. package/src/cli.js +15 -6
  4. package/src/emitter/bundle-emitter.js +56 -16
  5. package/src/runtime/avm1-runtime.js +329 -84
  6. package/src/runtime/avm2-runtime.js +56 -6
  7. package/src/runtime/embedded-movie-runtime.js +6 -1
  8. package/src/runtime/index.js +2 -6
  9. package/src/runtime/movie-runtime.js +2 -1
  10. package/src/runtime/swflib/assemble.js +34 -0
  11. package/src/runtime/swflib/bitmap-image.js +4 -0
  12. package/src/runtime/swflib/bitmap.js +1004 -0
  13. package/src/runtime/swflib/builtins.js +156 -0
  14. package/src/runtime/swflib/bytearray.js +949 -0
  15. package/src/runtime/swflib/compiled-swf.js +3 -0
  16. package/src/runtime/swflib/context-menu.js +245 -0
  17. package/src/runtime/swflib/cursor-flag.js +12 -0
  18. package/src/runtime/swflib/dictionary.js +121 -0
  19. package/src/runtime/swflib/display.js +823 -0
  20. package/src/runtime/swflib/events.js +754 -0
  21. package/src/runtime/swflib/filters.js +298 -0
  22. package/src/runtime/swflib/flash.js +130 -0
  23. package/src/runtime/swflib/geom.js +759 -0
  24. package/src/runtime/swflib/glyph-metrics.js +14 -0
  25. package/src/runtime/swflib/graphics.js +735 -0
  26. package/src/runtime/swflib/host.js +2 -0
  27. package/src/runtime/swflib/inherit.js +22 -0
  28. package/src/runtime/swflib/input.js +1085 -0
  29. package/src/runtime/swflib/loader.js +687 -0
  30. package/src/runtime/swflib/marks.js +16 -0
  31. package/src/runtime/swflib/matrix3d.js +144 -0
  32. package/src/runtime/swflib/pointer-bridge.js +8 -0
  33. package/src/runtime/swflib/projection.js +158 -0
  34. package/src/runtime/swflib/render.js +1240 -0
  35. package/src/runtime/swflib/sound.js +1166 -0
  36. package/src/runtime/swflib/sprite-drag.js +116 -0
  37. package/src/runtime/swflib/stage-ref.js +9 -0
  38. package/src/runtime/swflib/stage.js +484 -0
  39. package/src/runtime/swflib/system.js +987 -0
  40. package/src/runtime/swflib/text-field.js +519 -0
  41. package/src/runtime/swflib/text-paint.js +797 -0
  42. package/src/runtime/swflib/text.js +1387 -0
  43. package/src/runtime/swflib/transform.js +133 -0
  44. package/src/runtime/swflib/xml.js +268 -0
  45. package/src/transpiler/avm1/avm1-ir.js +2 -1
  46. package/src/transpiler/avm1/avm1-rewrite.js +23 -2
  47. package/src/transpiler/avm1/avm1-transpiler.js +4 -1
  48. package/src/transpiler/avm2/avm2-transpiler.js +38 -7
  49. package/src/transpiler/timeline/timeline-codegen.js +366 -123
  50. package/src/runtime/swflib.js +0 -14050
@@ -0,0 +1,987 @@
1
+ import { asPackages, builtins } from './flash.js';
2
+ import { ByteArray, Endian } from './bytearray.js';
3
+ import { AsyncErrorEvent, Event, EventDispatcher, HTTPStatusEvent, IOErrorEvent, ProgressEvent, StatusEvent } from './events.js';
4
+ import { global } from './host.js';
5
+ import { XML } from './xml.js';
6
+
7
+ export class SharedObject extends EventDispatcher {
8
+ constructor() { super(); }
9
+ }
10
+ Object.assign(SharedObject, {
11
+ getLocal: function (name, localPath, secure) {
12
+ var key = 'swoof.so.' + String(name || 'default') + (localPath ? '.' + localPath : '');
13
+ var data = {};
14
+ try {
15
+ if (typeof localStorage !== 'undefined') {
16
+ var raw = localStorage.getItem(key);
17
+ if (raw) data = JSON.parse(raw) || {};
18
+ }
19
+ } catch (_) { data = {}; }
20
+ return Object.assign(new SharedObject(), {
21
+ data: data,
22
+ size: 0,
23
+ fps: 0,
24
+ objectEncoding: 3,
25
+ client: null,
26
+ flush: function () {
27
+ try {
28
+ if (typeof localStorage !== 'undefined') {
29
+ localStorage.setItem(key, JSON.stringify(this.data || {}));
30
+ }
31
+ return 'flushed';
32
+ } catch (_) {
33
+ return 'pending';
34
+ }
35
+ },
36
+ clear: function () {
37
+ this.data = {};
38
+ try {
39
+ if (typeof localStorage !== 'undefined') localStorage.removeItem(key);
40
+ } catch (_) {}
41
+ },
42
+ close: function () {},
43
+ setProperty: function (prop, value) {
44
+ this.data[prop] = value;
45
+ },
46
+ });
47
+ },
48
+ getRemote: function () { return SharedObject.getLocal.apply(SharedObject, arguments); },
49
+ deleteAll: function (url) {
50
+ if (typeof localStorage === 'undefined') return 0;
51
+ var removed = 0, prefix = 'swoof.so.';
52
+ try {
53
+ var keys = [];
54
+ for (var i = 0; i < localStorage.length; i++) {
55
+ var key = localStorage.key(i);
56
+ if (key && key.indexOf(prefix) === 0 && (!url || key.indexOf(String(url)) >= 0)) keys.push(key);
57
+ }
58
+ for (var j = 0; j < keys.length; j++) { localStorage.removeItem(keys[j]); removed++; }
59
+ } catch (_) {}
60
+ return removed;
61
+ },
62
+ getDiskUsage: function (url) {
63
+ if (typeof localStorage === 'undefined') return 0;
64
+ var bytes = 0;
65
+ try {
66
+ for (var i = 0; i < localStorage.length; i++) {
67
+ var key = localStorage.key(i);
68
+ if (key && key.indexOf('swoof.so.') === 0 && (!url || key.indexOf(String(url)) >= 0)) {
69
+ bytes += (key.length + String(localStorage.getItem(key) || '').length) * 2;
70
+ }
71
+ }
72
+ } catch (_) {}
73
+ return bytes;
74
+ },
75
+ });
76
+
77
+ export var nav = typeof navigator !== 'undefined' ? navigator : {};
78
+ export var screenInfo = typeof screen !== 'undefined' ? screen : {};
79
+ export var platformInfo = ((nav.userAgentData && nav.userAgentData.platform) || nav.platform || '') +
80
+ ' ' + (nav.userAgent || '');
81
+ export var playerPlatform = 'LNX';
82
+ if (/Android/i.test(platformInfo)) playerPlatform = 'AND';
83
+ else if (/\bWin/i.test(platformInfo)) playerPlatform = 'WIN';
84
+ else if (/Mac|iPhone|iPad|iPod/i.test(platformInfo)) playerPlatform = 'MAC';
85
+ export var manufacturerOS = { AND: 'Android', WIN: 'Windows', MAC: 'Macintosh', LNX: 'Linux' }[playerPlatform];
86
+ export var Capabilities = {
87
+ // Final public Adobe Flash Player release, independent of LoaderInfo.swfVersion.
88
+ get version() { return playerPlatform + ' 32,0,0,465'; },
89
+ get manufacturer() { return 'Adobe ' + manufacturerOS; },
90
+ os: nav.platform || nav.userAgent || 'Unknown',
91
+ playerType: 'StandAlone',
92
+ language: nav.language || 'en',
93
+ isDebugger: false,
94
+ screenResolutionX: screenInfo.width || 0,
95
+ screenResolutionY: screenInfo.height || 0,
96
+ };
97
+
98
+ export function securityHost(value) {
99
+ var raw = String(value == null ? '' : value).trim().toLowerCase();
100
+ if (!raw) return '';
101
+ raw = raw.replace(/^(?:\*\.|\.)/, '');
102
+ try { return new URL(raw.indexOf('://') >= 0 ? raw : 'http://' + raw).hostname.toLowerCase(); }
103
+ catch (_) { return raw.split('/')[0].split(':')[0]; }
104
+ }
105
+
106
+ export function domainMatches(rule, host) {
107
+ rule = String(rule || '').toLowerCase();
108
+ if (rule === '*') return true;
109
+ var wildcard = rule.indexOf('*.') === 0 || rule.indexOf('.') === 0;
110
+ var wanted = securityHost(rule);
111
+ if (!wanted || !host) return false;
112
+ return host === wanted || (wildcard && host.slice(-(wanted.length + 1)) === '.' + wanted);
113
+ }
114
+
115
+ export var currentHost = typeof location !== 'undefined' ? securityHost(location.hostname || location.host) : '';
116
+ export var allowedDomains = [];
117
+ export var insecureDomains = [];
118
+ export var policyFiles = Object.create(null);
119
+ export var policyRequests = new Map();
120
+ export function resolvePolicyURL(value) {
121
+ try {
122
+ var url = new URL(String(value || '').trim(), global.location?.href);
123
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') return null;
124
+ url.hash = '';
125
+ return url;
126
+ } catch (_) { return null; }
127
+ }
128
+
129
+ export function fetchPolicyFile(policy) {
130
+ if (policy.result) return policy.result;
131
+ var url = policy.url.href;
132
+ policy.result = Promise.resolve().then(function () { return fetch(url); }).then(function (response) {
133
+ if (!response.ok) return false;
134
+ return response.text();
135
+ }).then(function (xml) {
136
+ var domains = [];
137
+ if (xml !== false) {
138
+ var re = /<allow-access-from\b[^>]*\bdomain\s*=\s*["']([^"']+)["'][^>]*>/gi;
139
+ var match;
140
+ while ((match = re.exec(xml))) domains.push(match[1].trim().toLowerCase());
141
+ }
142
+ policyFiles[url] = domains;
143
+ return xml !== false;
144
+ }).catch(function () { policyFiles[url] = []; return false; });
145
+ return policy.result;
146
+ }
147
+ export var Security = {
148
+ domain: currentHost,
149
+ exactSettings: false,
150
+ sandboxType: 'remote',
151
+ _allowedDomains: allowedDomains,
152
+ _insecureDomains: insecureDomains,
153
+ _policyFiles: policyFiles,
154
+ allowDomain: function () {
155
+ for (var i = 0; i < arguments.length; i++) {
156
+ var args = Array.isArray(arguments[i]) ? arguments[i] : [arguments[i]];
157
+ for (var j = 0; j < args.length; j++) {
158
+ var domain = String(args[j] == null ? '' : args[j]).trim().toLowerCase();
159
+ if (domain && allowedDomains.indexOf(domain) < 0) allowedDomains.push(domain);
160
+ }
161
+ }
162
+ },
163
+ allowInsecureDomain: function () {
164
+ for (var i = 0; i < arguments.length; i++) {
165
+ var args = Array.isArray(arguments[i]) ? arguments[i] : [arguments[i]];
166
+ for (var j = 0; j < args.length; j++) {
167
+ var domain = String(args[j] == null ? '' : args[j]).trim().toLowerCase();
168
+ if (domain && insecureDomains.indexOf(domain) < 0) insecureDomains.push(domain);
169
+ }
170
+ }
171
+ },
172
+ isDomainAllowed: function (value, insecure) {
173
+ var host = securityHost(value);
174
+ if (currentHost && host === currentHost) return true;
175
+ var rules = insecure ? insecureDomains.concat(allowedDomains) : allowedDomains;
176
+ for (var i = 0; i < rules.length; i++) if (domainMatches(rules[i], host)) return true;
177
+ return false;
178
+ },
179
+ loadPolicyFile: function (url) {
180
+ if (!String(url || '').trim()) return;
181
+ var target = resolvePolicyURL(url);
182
+ if (target && !policyRequests.has(target.href)) {
183
+ policyRequests.set(target.href, { url: target, scope: target.pathname.slice(0, target.pathname.lastIndexOf('/') + 1) });
184
+ }
185
+ },
186
+ _checkPolicyFiles: function (url) {
187
+ var resource = resolvePolicyURL(url);
188
+ if (!resource || typeof fetch !== 'function' || resource.origin === global.location?.origin) return;
189
+ var pending = [];
190
+ for (var policy of policyRequests.values()) {
191
+ if (resource.origin === policy.url.origin && resource.pathname.startsWith(policy.scope)) {
192
+ pending.push(fetchPolicyFile(policy));
193
+ }
194
+ }
195
+ if (pending.length) return Promise.all(pending);
196
+ },
197
+ };
198
+ export var System = {
199
+ security: Security,
200
+ capabilities: Capabilities,
201
+ setClipboard: function (text) {
202
+ try {
203
+ if (typeof navigator !== 'undefined' && navigator.clipboard && navigator.clipboard.writeText) {
204
+ return navigator.clipboard.writeText(String(text == null ? '' : text)).catch(function () {});
205
+ }
206
+ } catch (_) {}
207
+ return Promise.resolve(false);
208
+ },
209
+ totalMemory: 0,
210
+ };
211
+
212
+ // ApplicationDomain keeps loaded definitions local while resolving parent
213
+ // definitions on demand. The main domain also sees its runtime's packages
214
+ // and the AVM2 registry installed by the bundle.
215
+ export var avm2DefinitionLookup;
216
+ export function assignAvm2DefinitionLookup(lookup) { avm2DefinitionLookup = lookup; }
217
+ export function lookupDefinitionPath(root, parts) {
218
+ var value = root;
219
+ for (var i = 0; i < parts.length; i++) {
220
+ if (!parts[i] || value == null || !Object.prototype.hasOwnProperty.call(value, parts[i])) return undefined;
221
+ value = value[parts[i]];
222
+ }
223
+ return value;
224
+ }
225
+ export var MIN_DOMAIN_MEMORY_LENGTH = 1024;
226
+ export var domainMemoryUsers = new WeakMap();
227
+
228
+ export function changeDomainMemoryUsers(bytes, delta) {
229
+ if (!bytes) return;
230
+ var users = (domainMemoryUsers.get(bytes) || 0) + delta;
231
+ if (users) domainMemoryUsers.set(bytes, users);
232
+ else domainMemoryUsers.delete(bytes);
233
+ }
234
+
235
+ export function checkDomainMemoryLength(bytes, length) {
236
+ if (length < MIN_DOMAIN_MEMORY_LENGTH && domainMemoryUsers.has(bytes)) {
237
+ throw new RangeError('Cannot shrink installed domain memory below ' + MIN_DOMAIN_MEMORY_LENGTH + ' bytes');
238
+ }
239
+ }
240
+
241
+ export class ApplicationDomain {
242
+ constructor(parentDomain) {
243
+ this.parentDomain = parentDomain == null
244
+ ? (ApplicationDomain.currentDomain || null)
245
+ : parentDomain;
246
+ this._domainMemory = null;
247
+ this._domainMemoryScratch = null;
248
+ this._definitions = Object.create(null);
249
+ }
250
+
251
+ hasDefinition(name) {
252
+ try { this.getDefinition(name); return true; } catch (_) { return false; }
253
+ }
254
+
255
+ getDefinition(name) {
256
+ var qualified = String(name == null ? '' : name).replace(/::/g, '.').replace(/:/g, '.');
257
+ if (Object.prototype.hasOwnProperty.call(this._definitions, qualified)) return this._definitions[qualified];
258
+ if (this.parentDomain && this.parentDomain !== this && this.parentDomain.hasDefinition(qualified)) {
259
+ return this.parentDomain.getDefinition(qualified);
260
+ }
261
+ // Child domains inherit the main domain's runtime and bundle definitions.
262
+ if (this === ApplicationDomain.currentDomain) {
263
+ var parts = qualified.split('.');
264
+ if (parts[0] === 'flash' && parts.length > 1) {
265
+ var packaged = lookupDefinitionPath(asPackages, parts.slice(1));
266
+ if (packaged !== undefined) return packaged;
267
+ }
268
+ if (avm2DefinitionLookup) {
269
+ var registered = avm2DefinitionLookup(qualified);
270
+ if (registered !== undefined) return registered;
271
+ }
272
+ if (Object.prototype.hasOwnProperty.call(builtins, qualified)) return builtins[qualified];
273
+ var value = lookupDefinitionPath(global, parts);
274
+ if (value !== undefined) return value;
275
+ }
276
+ throw new ReferenceError('Definition not found: ' + qualified);
277
+ }
278
+
279
+ _registerDefinition(name, definition) {
280
+ var qualified = String(name == null ? '' : name).replace(/::/g, '.').replace(/:/g, '.');
281
+ if (!qualified) throw new TypeError('Definition name must not be empty.');
282
+ // Flash domains do not replace definitions already visible in an ancestor.
283
+ if (this.parentDomain && this.parentDomain !== this && this.parentDomain.hasDefinition(qualified)) {
284
+ return this.parentDomain.getDefinition(qualified);
285
+ }
286
+ if (!Object.prototype.hasOwnProperty.call(this._definitions, qualified)) {
287
+ this._definitions[qualified] = definition;
288
+ }
289
+ return this._definitions[qualified];
290
+ }
291
+
292
+ _getDomainMemoryView() {
293
+ if (this._domainMemory) return this._domainMemory._getDomainMemoryView();
294
+ if (!this._domainMemoryScratch) this._domainMemoryScratch = new DataView(new ArrayBuffer(MIN_DOMAIN_MEMORY_LENGTH));
295
+ return this._domainMemoryScratch;
296
+ }
297
+ }
298
+ Object.defineProperty(ApplicationDomain.prototype, 'domainMemory', {
299
+ enumerable: true,
300
+ get: function () { return this._domainMemory; },
301
+ set: function (memory) {
302
+ if (memory == null) memory = null;
303
+ else {
304
+ if (!(memory instanceof ByteArray)) throw new TypeError('ApplicationDomain.domainMemory must be a ByteArray');
305
+ if (memory.length < MIN_DOMAIN_MEMORY_LENGTH) throw new RangeError('Domain memory requires at least ' + MIN_DOMAIN_MEMORY_LENGTH + ' bytes');
306
+ }
307
+ if (memory === this._domainMemory) return;
308
+ changeDomainMemoryUsers(this._domainMemory, -1);
309
+ this._domainMemory = memory;
310
+ changeDomainMemoryUsers(memory, 1);
311
+ },
312
+ });
313
+ ApplicationDomain.currentDomain = new ApplicationDomain(null);
314
+ Object.defineProperty(ApplicationDomain, 'MIN_DOMAIN_MEMORY_LENGTH', { value: MIN_DOMAIN_MEMORY_LENGTH });
315
+
316
+ export class LoaderContext {
317
+ constructor(checkPolicyFile, applicationDomain, securityDomain) {
318
+ this.checkPolicyFile = Boolean(checkPolicyFile);
319
+ this.applicationDomain = applicationDomain == null ? null : applicationDomain;
320
+ this.securityDomain = securityDomain == null ? null : securityDomain;
321
+ this._allowCodeImport = true;
322
+ this.parameters = null;
323
+ }
324
+
325
+ get allowCodeImport() { return this._allowCodeImport; }
326
+ set allowCodeImport(value) { this._allowCodeImport = Boolean(value); }
327
+ get allowLoadBytesCodeExecution() { return this.allowCodeImport; }
328
+ set allowLoadBytesCodeExecution(value) { this.allowCodeImport = value; }
329
+ }
330
+
331
+ export class URLRequest {
332
+ constructor(url) {
333
+ this.url = url || '';
334
+ this.method = 'GET';
335
+ this.data = null;
336
+ this.contentType = null;
337
+ this.requestHeaders = [];
338
+ this.digest = null;
339
+ }
340
+ }
341
+
342
+ export class URLRequestHeader {
343
+ constructor(name, value) {
344
+ this.name = name == null ? '' : String(name);
345
+ this.value = value == null ? '' : String(value);
346
+ }
347
+ }
348
+ export class URLVariables {
349
+ constructor(source) {
350
+ if (source != null && String(source) !== '') this.decode(source);
351
+ }
352
+
353
+ decode(source) {
354
+ for (var part of String(source).split('&')) {
355
+ var equals = part.indexOf('=');
356
+ if (equals < 0) {
357
+ var error = new Error('Error #2101: URLVariables requires a URL-encoded name/value pair.');
358
+ error.errorID = 2101;
359
+ throw error;
360
+ }
361
+ var name = decodeURIComponent(part.slice(0, equals).replace(/\+/g, ' '));
362
+ var value = decodeURIComponent(part.slice(equals + 1).replace(/\+/g, ' '));
363
+ var current = Object.prototype.hasOwnProperty.call(this, name) ? this[name] : undefined;
364
+ if (Array.isArray(current)) current.push(value);
365
+ else Object.defineProperty(this, name, { configurable: true, enumerable: true, writable: true,
366
+ value: current == null ? value : [current, value] });
367
+ }
368
+ }
369
+
370
+ toString() {
371
+ var out = [];
372
+ for (var name of Object.keys(this)) {
373
+ var value = this[name];
374
+ if (typeof value === 'function') continue;
375
+ var key = encodeURIComponent(name) + '=';
376
+ for (var item of Array.isArray(value) ? value : [value]) out.push(key + encodeURIComponent(String(item)));
377
+ }
378
+ return out.join('&');
379
+ }
380
+ }
381
+ export var localConnectionReceivers = new Map();
382
+ export var localConnectionStates = new WeakMap();
383
+ export var localConnectionRestricted = new Set(['send', 'connect', 'close', 'allowDomain', 'allowInsecureDomain',
384
+ 'client', 'domain', 'onStatus', 'prototype', 'addEventListener', 'removeEventListener', 'dispatchEvent',
385
+ 'hasEventListener', 'willTrigger']);
386
+
387
+ export class LocalConnection extends EventDispatcher {
388
+ constructor() {
389
+ super();
390
+ this.client = this;
391
+ localConnectionStates.set(this, {
392
+ domain: securityHost(global.location && (global.location.hostname || global.location.host)) || 'localhost',
393
+ secure: !!global.location && global.location.protocol === 'https:',
394
+ allowed: [], insecure: [], registration: null, legacy: false,
395
+ });
396
+ }
397
+
398
+ connect(value) {
399
+ var name = localConnectionName(value);
400
+ var state = localConnectionStates.get(this);
401
+ if (name.includes(':')) throw localConnectionArgument('A receiving LocalConnection name cannot contain a colon');
402
+ var key = name.startsWith('_') ? name : state.domain + ':' + name;
403
+ if (state.registration || localConnectionReceivers.has(key)) throw localConnectionArgument('LocalConnection name is already in use');
404
+ state.registration = { receiver: this, key: key };
405
+ localConnectionReceivers.set(key, state.registration);
406
+ }
407
+
408
+ close() {
409
+ var state = localConnectionStates.get(this);
410
+ if (!state.registration) throw localConnectionArgument('LocalConnection is not connected');
411
+ localConnectionReceivers.delete(state.registration.key);
412
+ state.registration = null;
413
+ }
414
+
415
+ allowDomain(...domains) {
416
+ localConnectionStates.get(this).allowed.push(...domains.map(String));
417
+ }
418
+
419
+ allowInsecureDomain(...domains) {
420
+ localConnectionStates.get(this).insecure.push(...domains.map(String));
421
+ }
422
+
423
+ send(connectionName, methodName, ...args) {
424
+ var name = localConnectionName(connectionName);
425
+ var method = localConnectionName(methodName);
426
+ if (localConnectionRestricted.has(method) || Object.prototype.hasOwnProperty.call(Object.prototype, method)) {
427
+ throw localConnectionArgument('Restricted LocalConnection method ' + method);
428
+ }
429
+ var sender = this;
430
+ var state = localConnectionStates.get(sender);
431
+ var separator = name.indexOf(':');
432
+ var key;
433
+ if (separator >= 0) {
434
+ var host = name.slice(0, separator).toLowerCase();
435
+ var connection = name.slice(separator + 1);
436
+ if (!host || !connection || connection.includes(':')) throw localConnectionArgument('Invalid qualified LocalConnection name');
437
+ key = host + ':' + connection;
438
+ } else key = name.startsWith('_') ? name : state.domain + ':' + name;
439
+ var payload = new ByteArray();
440
+ payload.writeObject(args);
441
+ if (payload.length > 40 * 1024) throw localConnectionArgument('LocalConnection message exceeds 40 KiB');
442
+ payload.position = 0;
443
+ var registration = localConnectionReceivers.get(key);
444
+ setTimeout(function () {
445
+ var level = 'error';
446
+ if (registration && localConnectionReceivers.get(key) === registration) {
447
+ var receiver = registration.receiver;
448
+ var receiverState = localConnectionStates.get(receiver);
449
+ if (state.legacy) level = 'status';
450
+ try {
451
+ if (localConnectionAllows(receiver, state) && localConnectionReceivers.get(key) === registration) {
452
+ var client = receiverState.legacy ? receiver : receiver.client;
453
+ var callback = localConnectionCallback(client, method);
454
+ if (callback) {
455
+ var decoded = payload.readObject();
456
+ level = 'status';
457
+ callback.apply(client, decoded);
458
+ }
459
+ }
460
+ } catch (error) {
461
+ if (!receiverState.legacy) EventDispatcher.prototype.dispatchEvent.call(receiver,
462
+ new AsyncErrorEvent(AsyncErrorEvent.ASYNC_ERROR, false, false, error && error.message, error));
463
+ }
464
+ }
465
+ if (state.legacy) {
466
+ var onStatus = localConnectionCallback(sender, 'onStatus');
467
+ if (onStatus) onStatus.call(sender, { level: level, code: '' });
468
+ else if (typeof System.onStatus === 'function') System.onStatus({ level: level, code: '' });
469
+ } else EventDispatcher.prototype.dispatchEvent.call(sender, new StatusEvent(StatusEvent.STATUS, false, false, '', level));
470
+ }, 0);
471
+ }
472
+ }
473
+ Object.defineProperty(LocalConnection.prototype, 'domain', { get: function () { return localConnectionStates.get(this).domain; } });
474
+
475
+ export function localConnectionArgument(message) {
476
+ var error = new Error(message);
477
+ error.name = 'ArgumentError';
478
+ return error;
479
+ }
480
+
481
+ export function localConnectionName(value) {
482
+ if (value == null) throw new TypeError('A LocalConnection name must be non-null');
483
+ var name = String(value);
484
+ if (!name || /[\x00-\x1f\x7f]/.test(name)) throw localConnectionArgument('Invalid LocalConnection name');
485
+ return name;
486
+ }
487
+
488
+ export function localConnectionCallback(client, name) {
489
+ if (client == null || typeof client !== 'object') return null;
490
+ for (var target = client; target && target !== Object.prototype && target !== EventDispatcher.prototype &&
491
+ target !== LocalConnection.prototype && target !== Avm1LocalConnection.prototype; target = Object.getPrototypeOf(target)) {
492
+ var property = Object.getOwnPropertyDescriptor(target, name);
493
+ if (property) return typeof property.value === 'function' ? property.value : null;
494
+ }
495
+ return null;
496
+ }
497
+
498
+ export function localConnectionAllows(receiver, sender) {
499
+ var state = localConnectionStates.get(receiver);
500
+ var insecure = state.secure && !sender.secure;
501
+ if (state.legacy) {
502
+ var policy = localConnectionCallback(receiver, insecure ? 'allowInsecureDomain' : 'allowDomain');
503
+ if (policy) return policy.call(receiver, sender.domain) === true;
504
+ }
505
+ return (!insecure && state.domain === sender.domain) || (insecure ? state.insecure : state.allowed)
506
+ .some(function (rule) { return domainMatches(rule, sender.domain); });
507
+ }
508
+
509
+ export class Avm1LocalConnection extends LocalConnection {
510
+ constructor() {
511
+ super();
512
+ localConnectionStates.get(this).legacy = true;
513
+ }
514
+
515
+ connect(name) {
516
+ try { super.connect(name); return true; } catch (_) { return false; }
517
+ }
518
+
519
+ send(...args) {
520
+ try { super.send(...args); return true; } catch (_) { return false; }
521
+ }
522
+
523
+ close() {
524
+ if (localConnectionStates.get(this).registration) super.close();
525
+ }
526
+ }
527
+ Object.defineProperty(Avm1LocalConnection.prototype, 'domain', { value: function () { return localConnectionStates.get(this).domain; } });
528
+ Avm1LocalConnection.prototype.allowDomain = Avm1LocalConnection.prototype.allowInsecureDomain = undefined;
529
+
530
+ export var pendingSocketFailures = new WeakMap();
531
+ export class Socket extends EventDispatcher {
532
+ constructor(host, port) {
533
+ super();
534
+ this.endian = Endian.BIG_ENDIAN;
535
+ this.objectEncoding = ByteArray.defaultObjectEncoding;
536
+ this.timeout = 20000;
537
+ if (host != null || (port | 0) !== 0) this.connect(host, port);
538
+ }
539
+
540
+ connect(host, port) {
541
+ port |= 0;
542
+ if (port < 0 || port > 65535) {
543
+ var error = new Error('Socket port is outside the TCP range');
544
+ error.name = 'SecurityError';
545
+ throw error;
546
+ }
547
+ var previous = pendingSocketFailures.get(this);
548
+ if (previous != null) clearTimeout(previous);
549
+ // The browser host has no raw TCP transport. Deliver the ordinary
550
+ // failure event so ActionScript can continue through its offline path.
551
+ var socket = this;
552
+ var failure = setTimeout(function () {
553
+ if (pendingSocketFailures.get(socket) !== failure) return;
554
+ pendingSocketFailures.delete(socket);
555
+ socket.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false,
556
+ 'Raw TCP sockets are unavailable in this browser.'));
557
+ }, 0);
558
+ pendingSocketFailures.set(socket, failure);
559
+ }
560
+
561
+ close() {
562
+ var failure = pendingSocketFailures.get(this);
563
+ if (failure == null) socketNotOpen();
564
+ pendingSocketFailures.delete(this);
565
+ clearTimeout(failure);
566
+ }
567
+ }
568
+ Object.defineProperties(Socket.prototype, {
569
+ connected: { get: function () { return false; } },
570
+ bytesAvailable: { get: function () { return 0; } },
571
+ bytesPending: { get: function () { return 0; } },
572
+ });
573
+ export function socketNotOpen() { throw new Error('Socket is not open'); }
574
+ for (var socketOperation of [
575
+ 'flush', 'readBoolean', 'readByte', 'readBytes', 'readDouble', 'readFloat', 'readInt', 'readMultiByte',
576
+ 'readObject', 'readShort', 'readUnsignedByte', 'readUnsignedInt', 'readUnsignedShort', 'readUTF', 'readUTFBytes',
577
+ 'writeBoolean', 'writeByte', 'writeBytes', 'writeDouble', 'writeFloat', 'writeInt', 'writeMultiByte',
578
+ 'writeObject', 'writeShort', 'writeUnsignedInt', 'writeUTF', 'writeUTFBytes',
579
+ ]) Socket.prototype[socketOperation] = socketNotOpen;
580
+
581
+ export class URLLoaderDataFormat {
582
+ static TEXT = 'text';
583
+ static BINARY = 'binary';
584
+ static VARIABLES = 'variables';
585
+ }
586
+
587
+ export class URLLoader extends EventDispatcher {
588
+ constructor(request) {
589
+ super();
590
+ this.data = null;
591
+ this.dataFormat = URLLoaderDataFormat.TEXT;
592
+ this.bytesLoaded = 0;
593
+ this.bytesTotal = 0;
594
+ this.status = 0;
595
+ this._xhr = null;
596
+ this._loadGeneration = 0;
597
+ if (request != null) this.load(request);
598
+ }
599
+ load(request) {
600
+ this.close();
601
+ var generation = this._loadGeneration;
602
+ this.status = 0;
603
+ this.bytesLoaded = 0;
604
+ this.bytesTotal = 0;
605
+ this.data = null;
606
+ var url = request && request.url;
607
+ var method = String(request?.method || 'GET').toUpperCase();
608
+ var body = null;
609
+ var form = request?.data instanceof URLVariables ||
610
+ (request?.data != null && Object.getPrototypeOf(request.data) === Object.prototype);
611
+ try {
612
+ if (!url) throw new Error('No URL');
613
+ url = String(url);
614
+ body = requestBody(request.data);
615
+ if (method === 'GET' || method === 'HEAD') {
616
+ if (body != null && typeof body !== 'string') throw new Error('Binary data requires a request body');
617
+ url = requestQueryURL(url, body);
618
+ body = null;
619
+ }
620
+ } catch (error) {
621
+ this._deferError(generation, error.message);
622
+ return;
623
+ }
624
+ var self = this;
625
+ var policy = Security._checkPolicyFiles(url);
626
+ if (policy) {
627
+ policy.then(function () {
628
+ if (self._loadGeneration === generation) self._loadRequest(request, url, method, body, form, generation);
629
+ });
630
+ } else this._loadRequest(request, url, method, body, form, generation);
631
+ }
632
+ _deferError(generation, message) {
633
+ var self = this;
634
+ setTimeout(function () {
635
+ if (self._loadGeneration !== generation) return;
636
+ notifyURLLoader(self, new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, message, 2032));
637
+ }, 0);
638
+ }
639
+ _loadRequest(request, url, method, body, form, generation) {
640
+ var self = this;
641
+ var xhr, opened = false, responseStatus = null, lastProgress = null;
642
+ var address = responseAddress(url);
643
+ var http = /^https?:/i.test(address);
644
+ function current() { return self._loadGeneration === generation && self._xhr === xhr; }
645
+ function dispatch(event) { notifyURLLoader(self, event); }
646
+ function checkResponse(success) {
647
+ if (!current()) return false;
648
+ var status = xhr.status | 0;
649
+ if (!opened && (success || status >= 200 && status < 300)) {
650
+ opened = true;
651
+ dispatch(new Event(Event.OPEN));
652
+ if (!current()) return false;
653
+ }
654
+ if (status && !responseStatus) {
655
+ self.status = status;
656
+ var headers = String(xhr.getAllResponseHeaders?.() || '').split(/\r?\n/).flatMap(function (line) {
657
+ var colon = line.indexOf(':');
658
+ return colon > 0 ? [new URLRequestHeader(line.slice(0, colon).trim(), line.slice(colon + 1).trim())] : [];
659
+ });
660
+ var responseURL = xhr.responseURL || address;
661
+ responseStatus = { status: status, url: responseURL, headers: headers,
662
+ redirected: responseAddress(responseURL) !== address };
663
+ dispatch(new HTTPStatusEvent(HTTPStatusEvent.HTTP_RESPONSE_STATUS, false, false,
664
+ status, responseURL, headers, responseStatus.redirected));
665
+ }
666
+ return current();
667
+ }
668
+ function progress(loaded, total) {
669
+ self.bytesLoaded = Math.max(lastProgress?.loaded || 0, loaded);
670
+ self.bytesTotal = total;
671
+ if (lastProgress?.loaded === self.bytesLoaded && lastProgress.total === total) return;
672
+ lastProgress = { loaded: self.bytesLoaded, total: total };
673
+ dispatch(new ProgressEvent(ProgressEvent.PROGRESS, false, false, self.bytesLoaded, total));
674
+ }
675
+ function statusEvent() {
676
+ if (!responseStatus && !http) return;
677
+ var details = responseStatus || { status: 0, url: address, headers: [], redirected: false };
678
+ dispatch(new HTTPStatusEvent(HTTPStatusEvent.HTTP_STATUS, false, false,
679
+ details.status, details.url, details.headers, details.redirected));
680
+ }
681
+ function fail(message) {
682
+ if (!current()) return;
683
+ statusEvent();
684
+ if (!current()) return;
685
+ self._xhr = null;
686
+ notifyURLLoader(self, new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, message, 2032));
687
+ }
688
+
689
+ try {
690
+ xhr = new XMLHttpRequest();
691
+ this._xhr = xhr;
692
+ xhr.open(method, url, true);
693
+ xhr.responseType = 'arraybuffer';
694
+ var hasContentType = false;
695
+ for (var header of request.requestHeaders || []) {
696
+ if (header?.name == null || typeof xhr.setRequestHeader !== 'function') continue;
697
+ var name = String(header.name);
698
+ if (name.toLowerCase() === 'content-type') hasContentType = true;
699
+ xhr.setRequestHeader(name, String(header.value ?? ''));
700
+ }
701
+ if (body != null && !hasContentType && (request.contentType || form)) {
702
+ xhr.setRequestHeader('Content-Type', request.contentType || 'application/x-www-form-urlencoded; charset=UTF-8');
703
+ }
704
+
705
+ xhr.onreadystatechange = function () {
706
+ if (xhr.readyState === 2) checkResponse(false);
707
+ };
708
+ xhr.onprogress = function (event) {
709
+ if (!checkResponse(xhr.status === 0 && !http) || xhr.status >= 400) return;
710
+ progress(Math.max(0, Number(event.loaded) || 0), event.lengthComputable === false ? 0 : Number(event.total) || 0);
711
+ };
712
+ xhr.onload = function (event) {
713
+ var status = xhr.status | 0;
714
+ var success = status >= 200 && status < 300 || status === 0 && !http;
715
+ if (!checkResponse(success)) return;
716
+ if (!success) { fail('HTTP ' + status); return; }
717
+
718
+ var bytes = xhrResponseBytes(xhr);
719
+ var loaded = event?.loaded ?? Math.max(lastProgress?.loaded || 0, bytes.length);
720
+ var total = (event?.lengthComputable && event.total) || lastProgress?.total || loaded;
721
+ progress(loaded, total);
722
+ if (!current()) return;
723
+
724
+ var data;
725
+ try {
726
+ if (self.dataFormat === URLLoaderDataFormat.BINARY) {
727
+ data = new ByteArray();
728
+ data.length = bytes.length;
729
+ data._getU8().set(bytes);
730
+ } else {
731
+ var text = urlLoaderText(bytes);
732
+ data = self.dataFormat === URLLoaderDataFormat.VARIABLES ? new URLVariables(text) : text;
733
+ }
734
+ } catch (error) { fail(error.message); return; }
735
+
736
+ statusEvent();
737
+ if (!current()) return;
738
+ self._xhr = null;
739
+ self.data = data;
740
+ dispatch(new Event(Event.COMPLETE));
741
+ };
742
+ xhr.onerror = function () { fail('Error #2032: Stream Error'); };
743
+ xhr.ontimeout = function () { fail('Error #2032: Request timed out'); };
744
+ xhr.onabort = function () { fail('Error #2032: Request aborted'); };
745
+ xhr.send(body);
746
+ } catch (error) {
747
+ if (this._loadGeneration !== generation) return;
748
+ this._xhr = null;
749
+ this._deferError(generation, error.message);
750
+ }
751
+ }
752
+ close() {
753
+ this._loadGeneration++;
754
+ var xhr = this._xhr;
755
+ this._xhr = null;
756
+ if (xhr) {
757
+ try { xhr.abort(); } catch (_) {}
758
+ }
759
+ }
760
+ }
761
+
762
+ export function notifyURLLoader(loader, event) {
763
+ try { loader.dispatchEvent(event); } catch (_) {}
764
+ }
765
+
766
+ export function requestBody(data) {
767
+ if (data == null) return null;
768
+ if (data instanceof URLVariables || Object.getPrototypeOf(data) === Object.prototype) {
769
+ return URLVariables.prototype.toString.call(data);
770
+ }
771
+ if (data instanceof ByteArray) return data._getU8().slice();
772
+ if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) return data;
773
+ return String(data);
774
+ }
775
+
776
+ export function requestQueryURL(url, query) {
777
+ if (!query) return url;
778
+ var start = url.indexOf('#');
779
+ var fragment = start < 0 ? '' : url.slice(start);
780
+ var base = start < 0 ? url : url.slice(0, start);
781
+ var separator = !base.includes('?') ? '?' : /[?&]$/.test(base) ? '' : '&';
782
+ return base + separator + query + fragment;
783
+ }
784
+
785
+ export function responseAddress(url) {
786
+ try {
787
+ var absolute = new URL(url, global.location?.href);
788
+ absolute.hash = '';
789
+ return absolute.href;
790
+ } catch (_) { return url.split('#')[0]; }
791
+ }
792
+
793
+ export function xhrResponseBytes(xhr) {
794
+ if (xhr.response instanceof ArrayBuffer) return new Uint8Array(xhr.response);
795
+ if (ArrayBuffer.isView(xhr.response)) return new Uint8Array(xhr.response.buffer, xhr.response.byteOffset, xhr.response.byteLength);
796
+ var text = xhr.response || '';
797
+ try { text = xhr.responseText ?? text; } catch (_) {}
798
+ return new TextEncoder().encode(String(text));
799
+ }
800
+
801
+ export function urlLoaderText(bytes) {
802
+ var encoding = bytes[0] === 0xff && bytes[1] === 0xfe ? 'utf-16le' :
803
+ bytes[0] === 0xfe && bytes[1] === 0xff ? 'utf-16be' : 'utf-8';
804
+ return new TextDecoder(encoding).decode(bytes);
805
+ }
806
+
807
+
808
+
809
+
810
+
811
+ export class URLRequestMethod {
812
+ static GET = 'GET';
813
+ static POST = 'POST';
814
+ static PUT = 'PUT';
815
+ static DELETE = 'DELETE';
816
+ }
817
+
818
+ export function navigateToURL(request, windowName) {
819
+ var url = request && (request.url || request);
820
+ if (!url || typeof window === 'undefined') return;
821
+ try {
822
+ window.open(String(url), windowName || '_blank');
823
+ } catch (_) {
824
+ try { window.location.href = String(url); } catch (_) {}
825
+ }
826
+ }
827
+
828
+ export var ExternalInterface = {
829
+ available: typeof window !== 'undefined',
830
+ active: false,
831
+ objectID: null,
832
+ addCallback: function (name, fn) {
833
+ if (typeof window === 'undefined' || !name) return;
834
+ window[name] = fn;
835
+ this.active = true;
836
+ },
837
+ call: function (name) {
838
+ if (typeof window === 'undefined' || !name) return null;
839
+ var fn = window[name];
840
+ if (typeof fn !== 'function') return null;
841
+ var args = Array.prototype.slice.call(arguments, 1);
842
+ try { return fn.apply(window, args); } catch (_) { return null; }
843
+ },
844
+ };
845
+
846
+ export function asInt(v) { return v | 0; }
847
+ export function asUint(v) { return v >>> 0; }
848
+
849
+ export function getDefinitionByName(name) {
850
+ return ApplicationDomain.currentDomain.getDefinition(name);
851
+ }
852
+
853
+ export var qualifiedBuiltinNames = new WeakMap();
854
+ export function getQualifiedClassName(value) {
855
+ if (value === null) return 'null';
856
+ if (value === undefined) return 'void';
857
+ if (typeof value === 'number') {
858
+ if (!Number.isInteger(value)) return 'Number';
859
+ if (value >= -2147483648 && value <= 2147483647) return 'int';
860
+ return value > 2147483647 && value <= 4294967295 ? 'uint' : 'Number';
861
+ }
862
+ if (typeof value === 'string') return 'String';
863
+ if (typeof value === 'boolean') return 'Boolean';
864
+ if (value === asInt) return 'int';
865
+ if (value === asUint) return 'uint';
866
+ var ctor = typeof value === 'function' ? value : Object.getPrototypeOf(value)?.constructor;
867
+ if (ctor && Object.prototype.hasOwnProperty.call(ctor, '__swoofQualifiedName')) {
868
+ var name = ctor.__swoofQualifiedName;
869
+ var split = name.lastIndexOf('.');
870
+ return split < 0 ? name : name.slice(0, split) + '::' + name.slice(split + 1);
871
+ }
872
+ if (qualifiedBuiltinNames.has(ctor)) return qualifiedBuiltinNames.get(ctor);
873
+ if (typeof value === 'function') {
874
+ if (value === Object || value === Array || value === String || value === Date ||
875
+ value === Number || value === Boolean || value === RegExp || value === Error) return value.name;
876
+ return 'Function';
877
+ }
878
+ return ctor && ctor.name || 'Object';
879
+ }
880
+
881
+ export function describeType(value) {
882
+ var isClass = typeof value === 'function' && (qualifiedBuiltinNames.has(value) ||
883
+ Object.hasOwn(value, '__swoofQualifiedName') || value === Object || value === Array ||
884
+ value === Number || value === Boolean || value === String || value === Function ||
885
+ value === Date || value === RegExp || value === Error || value === asInt || value === asUint);
886
+ var type = isClass ? value : value == null ? null : Object.getPrototypeOf(value)?.constructor;
887
+ var name = getQualifiedClassName(value);
888
+ function escape(value) {
889
+ return String(value).replace(/[&<"\r\n\t]/g, function (char) {
890
+ return { '&': '&amp;', '<': '&lt;', '"': '&quot;', '\r': '&#xD;', '\n': '&#xA;', '\t': '&#x9;' }[char];
891
+ });
892
+ }
893
+ function tag(name, attrs, content) {
894
+ var attributes = Object.keys(attrs).map(function (key) { return ' ' + key + '="' + escape(attrs[key]) + '"'; }).join('');
895
+ return content ? '<' + name + attributes + '>' + content + '</' + name + '>' : '<' + name + attributes + '/>';
896
+ }
897
+ function reflection(ctor) {
898
+ return ctor && Object.hasOwn(ctor, '__avm2Reflection') ? ctor.__avm2Reflection : null;
899
+ }
900
+ function metadata(annotations) {
901
+ return (annotations || []).map(function (annotation) {
902
+ return tag('metadata', { name: annotation[0] }, annotation[1].map(function (entry) {
903
+ return tag('arg', { key: entry[0], value: entry[1] });
904
+ }).join(''));
905
+ }).join('');
906
+ }
907
+ function parameters(args) {
908
+ return args.map(function (arg, index) {
909
+ return tag('parameter', { index: index + 1, type: arg[0], optional: arg[1] });
910
+ }).join('');
911
+ }
912
+ function members(types, column) {
913
+ var seen = new Map();
914
+ for (var owner of types) {
915
+ for (var [kind, member, memberType, annotations, args] of reflection(owner)?.[column] || []) {
916
+ var existing = seen.get(member);
917
+ if (existing && existing.tag === 'accessor' && (kind === 2 || kind === 3)) {
918
+ if (existing.kind !== kind && existing.attrs.access !== 'readwrite') {
919
+ existing.attrs.access = 'readwrite';
920
+ existing.content += metadata(annotations);
921
+ }
922
+ continue;
923
+ }
924
+ if (existing) continue;
925
+ var attrs = { name: member };
926
+ var content = metadata(annotations);
927
+ var element = kind === 0 ? 'variable' : kind === 6 ? 'constant' : kind === 1 ? 'method' : 'accessor';
928
+ if (kind === 1) {
929
+ attrs.returnType = memberType;
930
+ attrs.declaredBy = getQualifiedClassName(owner);
931
+ content = parameters(args) + content;
932
+ } else {
933
+ attrs.type = memberType;
934
+ if (element === 'accessor') {
935
+ attrs.access = kind === 2 ? 'readonly' : 'writeonly';
936
+ attrs.declaredBy = getQualifiedClassName(owner);
937
+ }
938
+ }
939
+ seen.set(member, { kind: kind, tag: element, attrs: attrs, content: content });
940
+ }
941
+ }
942
+ return Array.from(seen.values(), function (entry) { return tag(entry.tag, entry.attrs, entry.content); }).join('');
943
+ }
944
+ var lineage = [];
945
+ if (type) {
946
+ for (var proto = type.prototype; proto; proto = Object.getPrototypeOf(proto)) {
947
+ if (typeof proto.constructor === 'function') lineage.push(proto.constructor);
948
+ }
949
+ }
950
+ if (type && !lineage.length) lineage.push(type);
951
+ if (type && Object.hasOwn(type, '__avm2InterfaceTraits')) lineage.length = 1;
952
+ var interfaces = new Set();
953
+ function addInterfaces(ctor) {
954
+ if (!Object.hasOwn(ctor, '__avm2Interfaces')) return;
955
+ for (var iface of ctor.__avm2Interfaces) {
956
+ if (interfaces.has(iface)) continue;
957
+ interfaces.add(iface);
958
+ addInterfaces(iface);
959
+ }
960
+ }
961
+ for (var ancestor of lineage) addInterfaces(ancestor);
962
+ var definition = reflection(type);
963
+ var instance = lineage.slice(1).map(function (ancestor) {
964
+ return tag('extendsClass', { type: getQualifiedClassName(ancestor) });
965
+ }).join('');
966
+ instance += Array.from(interfaces, function (iface) {
967
+ return tag('implementsInterface', { type: getQualifiedClassName(iface) });
968
+ }).join('');
969
+ if (isClass && definition?.[1].length) instance += tag('constructor', {}, parameters(definition[1]));
970
+ instance += members(lineage, 2) + metadata(definition?.[4]);
971
+ var attributes = { name: name };
972
+ if (isClass) attributes.base = 'Class';
973
+ else if (lineage[1]) attributes.base = getQualifiedClassName(lineage[1]);
974
+ attributes.isDynamic = isClass || Boolean(type) && (definition ? !(definition[0] & 1) : type === Object || type === Array || type === Function);
975
+ attributes.isFinal = isClass || Boolean(definition?.[0] & 2);
976
+ attributes.isStatic = isClass;
977
+ var classDescription = isClass
978
+ ? tag('extendsClass', { type: 'Class' }) + tag('extendsClass', { type: 'Object' }) +
979
+ members([type], 3) + tag('factory', { type: name }, instance)
980
+ : instance;
981
+ return new XML(tag('type', attributes, classDescription));
982
+ }
983
+
984
+ export function getTimer() {
985
+ return Date.now() & 0x7fffffff;
986
+ }
987
+