Permalink
Browse files

Got socket.io to not throw errors on jetpack startup, but not sure if…

… it works yet since there is still some wiring problems inside the deuxdrop UI code.
  • Loading branch information...
jrburke committed Jul 27, 2011
1 parent 21baf72 commit 83835e98c8e83e372d6481897f63d168eb01b10c
Showing with 35 additions and 11 deletions.
  1. +5 −0 .gitignore
  2. +24 −5 clients/addon/copyweb.sh
  3. +5 −5 clients/addon/lib/main.js
  4. +1 −1 clients/deps/modaTransport.js
View
@@ -1,2 +1,7 @@
clients/node_modules
clients/addon/data/web
+clients/addon/lib/env.js
+clients/addon/lib/modaTransport.js
+clients/addon/lib/q.js
+clients/addon/lib/socket.io.js
+clients/addon/lib/socket.io-client
View
@@ -2,21 +2,40 @@
# Copy over files needed on the addon side
-# First, fetch socket.io file from the fake server.
-wget http://127.0.0.1:8888/socket.io/socket.io.js
-mv socket.io.js lib/socket.io.js
+# First, create a socket.io file that works in Firefox.
+rm -rf lib/socket.io-client
+cp -r ../node_modules/socket.io/node_modules/socket.io-client lib/
# Copy over modaTransport and its dependencies to the addon side.
# NEEDS UPDATING if the modaTransport dependencies change.
cp ../deps/modaTransport.js lib/modaTransport.js
cp ../deps/q.js lib/q.js
cp ../deps/env.js lib/env.js
+# Update the modaTransport dependency to use the one in the copied
+# socket.io-client directory.
+sed -i '' 's:socket.io:socket.io-client/lib/io:' lib/modaTransport.js
+rm -rf lib/modaTransport.jsbak
+
+# Update any references to module.parent to be just require('io')
+find lib/socket.io-client/lib/*.js -exec sed -i '' 's:module.parent.exports:require(\"./io\"):' {} \;
+find lib/socket.io-client/lib/transports/*.js -exec sed -i '' 's:module.parent.exports:require(\"../io\"):' {} \;
+
+find lib/socket.io-client/lib/*.js -exec sed -i '' 's:process.EventEmitter:require(\"./events\"):' {} \;
+find lib/socket.io-client/lib/transports/*.js -exec sed -i '' 's:process.EventEmitter:require(\"../events\"):' {} \;
+
+find lib/socket.io-client/lib/*.js -exec sed -i '' 's:__dirname:\"\":' {} \;
+find lib/socket.io-client/lib/transports/*.js -exec sed -i '' 's:__dirname:\"\":' {} \;
+
+# Clear out builder, do not need it for this use, but needs to exist
+echo > lib/socket.io-client/bin/builder.js
+
+
# Copy over UI used by the content part of the addon.
rm -rf data/web
mkdir data/web
mkdir data/web/deps
mkdir data/web/firefox
-cp -r ../deps data/web/deps
-cp -r ../firefox data/web/firefox
+cp -r ../deps data/web
+cp -r ../firefox data/web
View
@@ -24,15 +24,15 @@
/*jslint indent: 2, strict: false */
/*global define: false */
-define([ 'exports', 'self', 'page-mod', 'Moda', 'chrome',
- 'modaTransport', './jetpack-protocol/index'],
-function (exports, self, pageMod, Moda, chrome,
- modaTransport, protocol) {
+define([ 'exports', 'self', 'page-mod', 'chrome', 'modaTransport',
+ './jetpack-protocol/index'],
+function (exports, self, pageMod, chrome, modaTransport,
+ protocol) {
var Cu = chrome.Cu,
jsm = {},
data = self.data,
- url = data.url('index.html'),
+ url = data.url('web/firefox/index.html'),
aboutUrl = data.url('content/about.html'),
redirectorUrl = data.url('content/redirector.js'),
modaContentUrl = data.url('content/modaContent.js'),
@@ -48,7 +48,7 @@ define(function (require, exports) {
localMeCheck = false,
deferIdCounter = 0,
waitingDeferreds = {},
- targetOrigin = window && window.location ? window.location.protocol +
+ targetOrigin = typeof window !== 'undefined' && window.location ? window.location.protocol +
'//' + window.location.host : '',
actions, socket, me, respond, addOnWorker;

0 comments on commit 83835e9

Please sign in to comment.