Skip to content

Commit d3485d7

Browse files
committed
Merge pull request #4 from firephp/integrate-firebug-sdk
Integrate firebug sdk
2 parents db42b63 + 18bdac3 commit d3485d7

4 files changed

Lines changed: 70 additions & 2 deletions

File tree

client/lib/main.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,35 @@ function main(options, callbacks) {
5656
// TODO: Get URI from mappings.
5757
uri = "http://localhost:8080/bundles/main.js";
5858
}
59-
SANDBOX(uri, function(sandbox) {
59+
SANDBOX(uri, {
60+
global: {
61+
// Not available in this context.
62+
Components: undefined
63+
},
64+
onInitModule: function(moduleInterface, moduleObj, pkg, sandbox, options) {
65+
var origRequire = moduleObj.require;
66+
moduleObj.require = function(identifier) {
67+
if (
68+
identifier === "chrome" ||
69+
/^sdk/.test(identifier)
70+
) {
71+
// Return SDK module that is not bundled.
72+
return require(identifier);
73+
}
74+
return origRequire(identifier);
75+
}
76+
for (var property in origRequire) {
77+
moduleObj.require[property] = origRequire[property];
78+
}
79+
// @see http://nodejs.org/docs/latest/api/globals.html
80+
moduleObj.require.resolve = function() {
81+
throw new Error("NYI");
82+
}
83+
moduleObj.require.async = function(id, successCallback, errorCallback) {
84+
throw new Error("NYI");
85+
}
86+
}
87+
}, function(sandbox) {
6088
sandbox.main(API);
6189
});
6290

components/adapters/firebug.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
const SYSTEM = require("firebug.sdk/lib/core/system").System;
3+
4+
5+
exports.for = function (API) {
6+
7+
API.console.log("isDeveloperBrowser: " + SYSTEM.isDeveloperBrowser());
8+
9+
return {};
10+
}
11+

components/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ exports.main = function (API) {
6363

6464

6565

66+
const FIREBUG_API = makeAPI(API, {
67+
name: "adapters/firebug"
68+
});
69+
const FIREBUG_EXPORTS = require("./adapters/firebug").for(FIREBUG_API);
70+
71+
6672

6773
} catch (err) {
6874
console.error(err.stack);

components/package.json

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,38 @@
66
"main.js": "./main.js"
77
}
88
},
9+
"imports": {
10+
"globals": {
11+
"Components": true
12+
}
13+
},
14+
"upstream": {
15+
"packages": {
16+
"top": [
17+
"../../../../_upstream/os-inception/*",
18+
"../../../lib/*",
19+
"/opt/services/*"
20+
]
21+
}
22+
},
23+
"mappings": {
24+
"firebug.sdk": "top/firebug.sdk"
25+
},
926
"dependencies": {
1027
"eventemitter2": "~0.4.14"
1128
},
1229
"directories": {
1330
"bundles": "../client/data/bundles/components"
1431
},
1532
"scripts": {
16-
"install": "../node_modules/.bin/smi install",
33+
"install": "../node_modules/.bin/smi install -vd",
1734
"bundle": "rm -Rf .rt ; ../node_modules/to.pinf.lib/bin/pinf-bundle ; ../node_modules/pinf-to-browser/bin/pinf-publish",
1835
"run": "../node_modules/pinf-to-browser/bin/pinf-run"
36+
},
37+
"config": {
38+
"smi.cli": {
39+
"packagesDirectory": "node_modules",
40+
"latestOnly": true
41+
}
1942
}
2043
}

0 commit comments

Comments
 (0)