From aebfb15aa24aeeac26513559a2836ea8d67fa7e5 Mon Sep 17 00:00:00 2001 From: Deathamns Date: Sun, 9 Nov 2014 17:50:58 +0100 Subject: [PATCH] Building extension files Adds possibility to build extension files (Chrome and Safari) from command line. To run from the project directory: python tools/build.py [meta] If the optional `meta` argument is set, then only the manifest and language files are uptated. Without that everything is being built (extension files too) into the `dist/build/version_number` folder. For Chrome there will be two files, a crx, and a .zip file which includes the key.pem private key (so this must not be shared, it's just a bit help for publishing it to the Chrome Web Store). Beside the extension files, update-files are generated too (for self hosting - Safari needs it). --- src/js/vapi-client.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/js/vapi-client.js b/src/js/vapi-client.js index e441292..26bc6d8 100644 --- a/src/js/vapi-client.js +++ b/src/js/vapi-client.js @@ -1,3 +1,4 @@ +// » header /* global addMessageListener, removeMessageListener, sendAsyncMessage */ // for non background pages @@ -51,8 +52,10 @@ var messagingConnector = function(response) { var uniqueId = function() { return parseInt(Math.random() * 1e10, 10).toString(36); }; +// « if (self.chrome) { + // » crx vAPI.chrome = true; vAPI.messaging = { port: null, @@ -60,15 +63,14 @@ if (self.chrome) { listeners: {}, requestId: 0, connectorId: uniqueId(), - connector: messagingConnector, setup: function() { this.port = chrome.runtime.connect({name: this.connectorId}); - this.port.onMessage.addListener(this.connector); + this.port.onMessage.addListener(messagingConnector); }, close: function() { if (this.port) { this.port.disconnect(); - this.port.onMessage.removeListener(this.connector); + this.port.onMessage.removeListener(messagingConnector); this.port = this.channels = this.listeners = this.connectorId = null; } }, @@ -105,7 +107,9 @@ if (self.chrome) { return this.channels[channelName]; } }; + // « } else if (self.safari) { + // » safariextz vAPI.safari = true; // relevant? @@ -115,7 +119,6 @@ if (self.chrome) { listeners: {}, requestId: 0, connectorId: uniqueId(), - connector: messagingConnector, setup: function() { this._connector = function(msg) { // messages from the background script are sent to every frame, @@ -123,7 +126,7 @@ if (self.chrome) { // what is meant for the current context if (msg.name === vAPI.messaging.connectorId || msg.name === 'broadcast') { - vAPI.messaging.connector(msg.message); + messagingConnector(msg.message); } }; safari.self.addEventListener('message', this._connector, false); @@ -174,7 +177,7 @@ if (self.chrome) { target: { page: { dispatchMessage: function(name, msg) { - vAPI.messaging.connector(msg); + messagingConnector(msg); } } } @@ -371,6 +374,8 @@ if (self.chrome) { url: window.location.href, type: 'main_frame' }); + // « } - +// » footer })(); +// « \ No newline at end of file