@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make JX.Aphlict a real singleton with a more sensible initialization order

Summary:
Ref T5373. The control flow between `aphlict-listener` and `JX.Aphlict` is pretty weird right now, where the listener (which is the highest-level component) has intimate knowledge of how to put the SWF on the page.

Instead:

- Make `JX.Aphlict` a real singleton.
- Instantiate it sooner.
- Have it handle the flash setup handshake.

Test Plan: Loaded page in debug mode, saw normal flow take place.

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T5373

Differential Revision: https://secure.phabricator.com/D9699

+105 -84
+31 -30
resources/celerity/map.php
··· 8 8 'names' => 9 9 array( 10 10 'core.pkg.css' => '22e4fc33', 11 - 'core.pkg.js' => '941224f2', 11 + 'core.pkg.js' => 'f5ba2408', 12 12 'darkconsole.pkg.js' => 'df001cab', 13 13 'differential.pkg.css' => '4a93db37', 14 14 'differential.pkg.js' => 'd1443567', ··· 346 346 'rsrc/image/texture/table_header.png' => '5c433037', 347 347 'rsrc/image/texture/table_header_hover.png' => '038ec3b9', 348 348 'rsrc/image/texture/table_header_tall.png' => 'd56b434f', 349 - 'rsrc/js/application/aphlict/Aphlict.js' => '08be8878', 349 + 'rsrc/js/application/aphlict/Aphlict.js' => 'da12704d', 350 350 'rsrc/js/application/aphlict/behavior-aphlict-dropdown.js' => '862ea0fe', 351 - 'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => 'bdb2032d', 351 + 'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => 'a826c925', 352 352 'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18', 353 353 'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de', 354 354 'rsrc/js/application/conpherence/behavior-menu.js' => 'f0a41b9f', ··· 490 490 'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8', 491 491 'rsrc/js/phuix/PHUIXActionView.js' => '6e8cefa4', 492 492 'rsrc/js/phuix/PHUIXDropdownMenu.js' => 'bd4c8dca', 493 - 'rsrc/swf/aphlict.swf' => '14d5aa2e', 493 + 'rsrc/swf/aphlict.swf' => 'ef64606d', 494 494 ), 495 495 'symbols' => 496 496 array( ··· 539 539 'herald-rule-editor' => '6c9e6fb8', 540 540 'herald-test-css' => '778b008e', 541 541 'inline-comment-summary-css' => '8cfd34e8', 542 - 'javelin-aphlict' => '08be8878', 542 + 'javelin-aphlict' => 'da12704d', 543 543 'javelin-behavior' => '8a3ed18b', 544 544 'javelin-behavior-aphlict-dropdown' => '862ea0fe', 545 - 'javelin-behavior-aphlict-listen' => 'bdb2032d', 545 + 'javelin-behavior-aphlict-listen' => 'a826c925', 546 546 'javelin-behavior-aphront-basic-tokenizer' => 'b3a4b884', 547 547 'javelin-behavior-aphront-crop' => 'fa0f4fc2', 548 548 'javelin-behavior-aphront-drag-and-drop-textarea' => '92eb531d', ··· 878 878 3 => 'javelin-vector', 879 879 4 => 'javelin-stratcom', 880 880 ), 881 - '08be8878' => 882 - array( 883 - 0 => 'javelin-install', 884 - 1 => 'javelin-util', 885 - ), 886 881 '08e56a4e' => 887 882 array( 888 883 0 => 'javelin-install', ··· 1279 1274 1 => 'javelin-stratcom', 1280 1275 2 => 'javelin-dom', 1281 1276 ), 1277 + '62e18640' => 1278 + array( 1279 + 0 => 'javelin-install', 1280 + 1 => 'javelin-util', 1281 + 2 => 'javelin-dom', 1282 + 3 => 'javelin-typeahead-normalizer', 1283 + ), 1282 1284 '6453c869' => 1283 1285 array( 1284 1286 0 => 'javelin-install', ··· 1356 1358 array( 1357 1359 0 => 'javelin-behavior', 1358 1360 1 => 'javelin-dom', 1359 - ), 1360 - '62e18640' => 1361 - array( 1362 - 0 => 'javelin-install', 1363 - 1 => 'javelin-util', 1364 - 2 => 'javelin-dom', 1365 - 3 => 'javelin-typeahead-normalizer', 1366 1361 ), 1367 1362 '76b9fc3e' => 1368 1363 array( ··· 1642 1637 1 => 'javelin-stratcom', 1643 1638 2 => 'javelin-dom', 1644 1639 ), 1640 + 'a826c925' => 1641 + array( 1642 + 0 => 'javelin-behavior', 1643 + 1 => 'javelin-aphlict', 1644 + 2 => 'javelin-stratcom', 1645 + 3 => 'javelin-request', 1646 + 4 => 'javelin-uri', 1647 + 5 => 'javelin-dom', 1648 + 6 => 'javelin-json', 1649 + 7 => 'javelin-router', 1650 + 8 => 'javelin-util', 1651 + 9 => 'phabricator-notification', 1652 + ), 1645 1653 'a82a7769' => 1646 1654 array( 1647 1655 0 => 'javelin-behavior', ··· 1794 1802 2 => 'javelin-util', 1795 1803 3 => 'javelin-request', 1796 1804 ), 1797 - 'bdb2032d' => 1798 - array( 1799 - 0 => 'javelin-behavior', 1800 - 1 => 'javelin-aphlict', 1801 - 2 => 'javelin-stratcom', 1802 - 3 => 'javelin-request', 1803 - 4 => 'javelin-uri', 1804 - 5 => 'javelin-dom', 1805 - 6 => 'javelin-json', 1806 - 7 => 'javelin-router', 1807 - 8 => 'phabricator-notification', 1808 - ), 1809 1805 'bdb3e4d0' => 1810 1806 array( 1811 1807 0 => 'javelin-behavior', ··· 1924 1920 0 => 'javelin-install', 1925 1921 1 => 'javelin-util', 1926 1922 2 => 'javelin-stratcom', 1923 + ), 1924 + 'da12704d' => 1925 + array( 1926 + 0 => 'javelin-install', 1927 + 1 => 'javelin-util', 1927 1928 ), 1928 1929 'dd7e8ef5' => 1929 1930 array(
+4
support/aphlict/client/src/Aphlict.as
··· 42 42 this.externalInvoke('log', message); 43 43 } 44 44 45 + final protected function setStatus(status:String):void { 46 + this.externalInvoke('status', {type: status}); 47 + } 48 + 45 49 } 46 50 47 51 }
+2 -7
support/aphlict/client/src/AphlictClient.as
··· 42 42 this.uncaughtErrorHandler); 43 43 44 44 ExternalInterface.addCallback('connect', this.externalConnect); 45 - ExternalInterface.call( 46 - 'JX.Stratcom.invoke', 47 - 'aphlict-component-ready', 48 - null, 49 - {}); 45 + 46 + this.setStatus('ready'); 50 47 } 51 48 52 49 private function uncaughtErrorHandler(event:UncaughtErrorEvent):void { ··· 57 54 server:String, 58 55 port:Number, 59 56 subscriptions:Array):void { 60 - 61 - this.externalInvoke('connect'); 62 57 63 58 this.remoteServer = server; 64 59 this.remotePort = port;
+58 -22
webroot/rsrc/js/application/aphlict/Aphlict.js
··· 25 25 */ 26 26 JX.install('Aphlict', { 27 27 28 - construct : function(id, server, port, subscriptions) { 28 + construct: function(id, server, port, subscriptions) { 29 29 if (__DEV__) { 30 30 if (JX.Aphlict._instance) { 31 - JX.$E('Aphlict object is sort of a singleton..!'); 31 + JX.$E('Aphlict object is a singleton!'); 32 32 } 33 33 } 34 34 35 - JX.Aphlict._instance = this; 36 - 35 + this._id = id; 37 36 this._server = server; 38 37 this._port = port; 39 38 this._subscriptions = subscriptions; 40 39 41 - // Flash puts its "objects" into global scope in an inconsistent way, 42 - // because it was written in like 1816 when globals were awesome and IE4 43 - // didn't support other scopes since global scope is the best anyway. 44 - var container = document[id] || window[id]; 45 - 46 - this._flashContainer = container; 40 + JX.Aphlict._instance = this; 47 41 }, 48 42 49 - members : { 50 - _server : null, 51 - _port : null, 52 - _subscriptions : null, 53 - start : function() { 43 + members: { 44 + _id: null, 45 + _server: null, 46 + _port: null, 47 + _subscriptions: null, 48 + 49 + start: function(node, uri) { 50 + // NOTE: This is grotesque, but seems to work everywhere. 51 + node.innerHTML = 52 + '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">' + 53 + '<param name="movie" value="' + uri + '" />' + 54 + '<param name="allowScriptAccess" value="always" />' + 55 + '<param name="wmode" value="opaque" />' + 56 + '<embed src="' + uri + '" wmode="opaque"' + 57 + 'width="0" height="0" id="' + this._id + '">' + 58 + '</embed>' + 59 + '</object>'; 60 + }, 61 + 62 + _didStartFlash: function() { 63 + var id = this._id; 64 + 65 + // Flash puts its "objects" into global scope in an inconsistent way, 66 + // because it was written in like 1816 when globals were awesome and IE4 67 + // didn't support other scopes since global scope is the best anyway. 68 + var container = document[id] || window[id]; 69 + 70 + this._flashContainer = container; 54 71 this._flashContainer.connect( 55 72 this._server, 56 73 this._port, 57 74 this._subscriptions); 58 75 } 76 + 59 77 }, 60 78 61 - properties : { 62 - handler : null 79 + properties: { 80 + handler: null 63 81 }, 64 82 65 - statics : { 66 - _instance : null, 67 - didReceiveEvent : function(type, message) { 68 - if (!JX.Aphlict._instance) { 83 + statics: { 84 + _instance: null, 85 + 86 + getInstance: function() { 87 + var self = JX.Aphlict; 88 + if (!self._instance) { 89 + return null; 90 + } 91 + return self._instance; 92 + }, 93 + 94 + didReceiveEvent: function(type, message) { 95 + var client = JX.Aphlict.getInstance(); 96 + if (!client) { 69 97 return; 70 98 } 71 99 72 - var handler = JX.Aphlict._instance.getHandler(); 100 + if (type == 'status') { 101 + switch (message.type) { 102 + case 'ready': 103 + client._didStartFlash(); 104 + break; 105 + } 106 + } 107 + 108 + var handler = client.getHandler(); 73 109 if (handler) { 74 110 handler(type, message); 75 111 }
+10 -25
webroot/rsrc/js/application/aphlict/behavior-aphlict-listen.js
··· 16 16 17 17 var showing_reload = false; 18 18 19 - function onready() { 20 - var client = new JX.Aphlict( 21 - config.id, 22 - config.server, 23 - config.port, 24 - config.subscriptions); 25 - 26 - client 27 - .setHandler(onaphlictmessage) 28 - .start(); 29 - } 30 - 31 19 JX.Stratcom.listen('aphlict-receive-message', null, function(e) { 32 20 var message = e.getData(); 33 21 ··· 61 49 62 50 default: 63 51 case 'error': 52 + case 'log': 53 + case 'status': 64 54 if (config.debug) { 65 55 var details = message ? JX.JSON.stringify(message) : ''; 66 56 JX.log('(Aphlict) [' + type + '] ' + details); ··· 98 88 } 99 89 } 100 90 91 + var client = new JX.Aphlict( 92 + config.id, 93 + config.server, 94 + config.port, 95 + config.subscriptions); 101 96 102 - // Wait for the element to load, and don't do anything if it never loads. 103 - // If we just go crazy and start making calls to it before it loads, its 104 - // interfaces won't be registered yet. 105 - JX.Stratcom.listen('aphlict-component-ready', null, onready); 97 + client 98 + .setHandler(onaphlictmessage) 99 + .start(JX.$(config.containerID), config.swfURI); 106 100 107 - // Add Flash object to page 108 - JX.$(config.containerID).innerHTML = 109 - '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">' + 110 - '<param name="movie" value="' + config.swfURI + '" />' + 111 - '<param name="allowScriptAccess" value="always" />' + 112 - '<param name="wmode" value="opaque" />' + 113 - '<embed src="' + config.swfURI + '" wmode="opaque"' + 114 - 'width="0" height="0" id="' + config.id + '">' + 115 - '</embed></object>'; //Evan sanctioned 116 101 });
webroot/rsrc/swf/aphlict.swf

This is a binary file and will not be displayed.