Skip to content

Commit 5a99a08

Browse files
committed
components
1 parent 3dfc236 commit 5a99a08

5 files changed

Lines changed: 114 additions & 2 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
exports.main = function (API) {
3+
4+
const OBSERVER_SERVICE = API.CC["@mozilla.org/observer-service;1"].getService(API.CI.nsIObserverService);
5+
6+
var requestIndex = 0;
7+
8+
const LISTENER = {
9+
observe: function(subject, topic, data) {
10+
if (topic == "http-on-examine-response") {
11+
12+
var httpChannel = subject.QueryInterface(API.CI.nsIHttpChannel);
13+
14+
try {
15+
var requestHeaders = [];
16+
var requestId;
17+
httpChannel.visitRequestHeaders({
18+
visitHeader: function(name, value) {
19+
requestHeaders.push({name: name, value: value});
20+
if(name.toLowerCase()=="x-request-id") {
21+
requestId = value;
22+
}
23+
}
24+
});
25+
var responseHeaders = [],
26+
contentType = false;
27+
httpChannel.visitResponseHeaders({
28+
visitHeader: function(name, value) {
29+
responseHeaders.push({name: name, value: value});
30+
if (name.toLowerCase() == "content-type")
31+
contentType = value;
32+
}
33+
});
34+
35+
requestIndex += 1;
36+
37+
API.emit("response", {
38+
"request": {
39+
"id": requestId || "id:" + httpChannel.URI.spec + ":" + requestIndex,
40+
"url": httpChannel.URI.spec,
41+
"hostname": httpChannel.URI.host,
42+
"port": httpChannel.URI.port,
43+
"method": httpChannel.requestMethod,
44+
"headers": requestHeaders
45+
}
46+
"status": httpChannel.responseStatus,
47+
"contentType": contentType,
48+
"headers": responseHeaders
49+
});
50+
51+
} catch (err) {
52+
API.console.error(err);
53+
}
54+
}
55+
}
56+
};
57+
58+
59+
OBSERVER_SERVICE.addObserver(LISTENER, "http-on-examine-response", false);
60+
61+
API.on("destroy", function () {
62+
OBSERVER_SERVICE.removeObserver(LISTENER, "http-on-examine-response");
63+
});
64+
}

components/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
exports.main = function () {
4+
5+
console.log("CALLED MAIN IN ADAPTER!")
6+
7+
}

components/package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "firephp-for-firebug.next-components",
3+
"main": "./main.js",
4+
"exports": {
5+
"bundles": {
6+
"main.js": "./main.js"
7+
}
8+
},
9+
"upstream": {
10+
"packages": {
11+
"top": [
12+
"../../../../_upstream/os-inception/*",
13+
"../../*",
14+
"../../../*",
15+
"../../../../../*"
16+
]
17+
}
18+
},
19+
"mappings": {
20+
"to.pinf.lib": "top/to.pinf.lib"
21+
},
22+
"scripts": {
23+
"install": "../node_modules/.bin/smi install",
24+
"build": "rm -Rf .rt ; ../node_modules/.bin/pinf-bundle"
25+
},
26+
"config": {
27+
"smi.cli": {
28+
"packagesDirectory": "node_modules"
29+
}
30+
}
31+
}

components/program.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"boot": {
3+
"package": "./package.json"
4+
},
5+
"config": {
6+
"github.com/pinf-it/pinf-it-bundler/0": {
7+
"target": "browser"
8+
}
9+
}
10+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"./client/node_modules/pinf-for-mozilla-addon-sdk": "top/pinf-for-mozilla-addon-sdk"
1616
},
1717
"scripts": {
18-
"install": "./node_modules/.bin/smi install ; cd ./server; npm install --unsafe-perm",
19-
"publish": "cd ./server; npm run-script publish",
18+
"install": "./node_modules/.bin/smi install ; cd components ; npm install --unsafe-perm ; cd .. ; cd ./server; npm install --unsafe-perm",
19+
"publish": "cd components ; npm run-script build ; cd .. ; cd ./server; npm run-script publish",
2020
"run": "cd ./server; npm run-script run",
2121
"start": "cd ./server; npm run-script start"
2222
},

0 commit comments

Comments
 (0)