kameleoon-react
Advanced tools
Comparing version 1.1.1 to 1.1.2
119
index.js
@@ -1,1 +0,118 @@ | ||
var React = require('react'); var backend = require("./lib/backend_patched.js"); var inject = require("./lib/inject_patched.js");var checkCapabilities = true; var postMessage = function(e) { if (e.type !== "many-events") { window.postMessage({ source: "react-devtools-content-script", payload: e.name == "profiler:update" ? { args: [null], id: e.callback, type: "callback" } : e }, "*") if (checkCapabilities && e.name == "profiler:update") { checkCapabilities = false; window.postMessage({ source: "react-devtools-content-script", payload: { events: [{ type: "event", evt: "requestCapabilities", cleaned: [] }], type: "many-events" } }); } } }window.addEventListener("message", function (e) { e.source === window && e.data && "react-devtools-bridge" === e.data.source && postMessage(e.data.payload) });window.postMessage({ source: "react-devtools-content-script", hello: !0 }, "*");window.KameleoonAPIReact = { runWhenComponentPresent: function(type, callback, filters, pollingInterval) { var Component = function(element, id) { this.id = id; this.state = element.state; this.props = element.props; this.fiber = element;this.setState = function(key, value) { this.fiber.updater.setInState([key], value); };this.setProps = function(key, value) { this.fiber.updater.setInProps([key], value); }; };var results = []; kameleoonReactHelpers.elementData.forEach(function(element, id){ if (element.type && element.type.name == type && element.updater && element.updater.setInState) { if (filters && Object.keys(filters).length > 0) { if (element.props) { var match = true; for (var key in filters) { var value = element.props[key]; if (!value || (typeof value == "string" ? value.indexOf(filters[key]) == -1 : value != filters[key])) { match = false; } } if (match) { results.push(new Component(element, id)); } } } else { results.push(new Component(element, id)); } } }); if (results.length > 0) { callback && callback(results); } else { Kameleoon.API.Utils.setTimeout(function () { KameleoonAPIReact.runWhenComponentPresent.apply(KameleoonAPIReact, [type, filters, callback]);}, pollingInterval ? pollingInterval : 200); } }, createReactElement: function(type, props, children) { return kameleoonReactHelpers.React.createElement(type, props, children); } };backend(React); inject();module.exports = {}; | ||
var React = require('react'); | ||
var backend = require("./lib/backend_patched.js"); | ||
var inject = require("./lib/inject_patched.js"); | ||
var checkCapabilities = true; | ||
var postMessage = function(e) | ||
{ | ||
if (e.type !== "many-events") | ||
{ | ||
window.postMessage({ | ||
source: "react-devtools-content-script", | ||
payload: e.name == "profiler:update" ? { | ||
args: [null], | ||
id: e.callback, | ||
type: "callback" | ||
} : e | ||
}, "*") | ||
if (checkCapabilities && e.name == "profiler:update") | ||
{ | ||
checkCapabilities = false; | ||
window.postMessage({ | ||
source: "react-devtools-content-script", | ||
payload: { | ||
events: [{ | ||
type: "event", | ||
evt: "requestCapabilities", | ||
cleaned: [] | ||
}], | ||
type: "many-events" | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
window.addEventListener("message", function (e) { | ||
e.source === window && e.data && "react-devtools-bridge" === e.data.source && postMessage(e.data.payload) | ||
}); | ||
window.postMessage({ | ||
source: "react-devtools-content-script", | ||
hello: !0 | ||
}, "*"); | ||
window.KameleoonAPIReact = { | ||
runWhenComponentPresent: function(type, callback, filters, pollingInterval) | ||
{ | ||
var Component = function(element, id) | ||
{ | ||
this.id = id; | ||
this.state = element.state; | ||
this.props = element.props; | ||
this.fiber = element; | ||
this.setState = function(key, value) | ||
{ | ||
this.fiber.updater.setInState([key], value); | ||
}; | ||
this.setProps = function(key, value) | ||
{ | ||
this.fiber.updater.setInProps([key], value); | ||
}; | ||
}; | ||
var results = []; | ||
kameleoonReactHelpers.elementData.forEach(function(element, id){ | ||
if (element.type && element.type.name == type && element.updater && element.updater.setInState) | ||
{ | ||
if (filters && Object.keys(filters).length > 0) | ||
{ | ||
if (element.props) | ||
{ | ||
var match = true; | ||
for (var key in filters) | ||
{ | ||
var value = element.props[key]; | ||
if (!value || (typeof value == "string" ? value.indexOf(filters[key]) == -1 : value != filters[key])) | ||
{ | ||
match = false; | ||
} | ||
} | ||
if (match) | ||
{ | ||
results.push(new Component(element, id)); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
results.push(new Component(element, id)); | ||
} | ||
} | ||
}); | ||
if (results.length > 0) | ||
{ | ||
callback && callback(results); | ||
} | ||
else | ||
{ | ||
Kameleoon.API.Utils.setTimeout(function () | ||
{ | ||
KameleoonAPIReact.runWhenComponentPresent.apply(KameleoonAPIReact, [type, filters, callback]); | ||
}, pollingInterval ? pollingInterval : 200); | ||
} | ||
}, | ||
createReactElement: function(type, props, children) | ||
{ | ||
return kameleoonReactHelpers.React.createElement(type, props, children); | ||
} | ||
}; | ||
backend(React); | ||
inject(); | ||
module.exports = {}; |
{ | ||
"name": "kameleoon-react", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
435079
9361