- From: Menard, Alexis <alexis.menard@intel.com>
- Date: Mon, 28 Nov 2016 22:53:47 +0000
- To: Felipe Nascimento de Moura <felipenmoura@gmail.com>
- CC: Marcos Caceres <marcos@marcosc.com>, "public-device-apis@w3.org" <public-device-apis@w3.org>
- Message-ID: <CDD9857A-0972-4297-B87B-4345EDE8F40A@intel.com>
On Nov 28, 2016, at 2:37 PM, Felipe Nascimento de Moura <felipenmoura@gmail.com<mailto:felipenmoura@gmail.com>> wrote: Hi. well, that's a good point, indeed! :) But window.addEventListener('deviceorientation', ... ) // depends on window. But using the Gyro and Accelerometer APIs proposed here (even Accelerometer only), you can achieve the same. Granted with a little bit more code. navigator.battery.level // depends on navigator Mozilla is not happy with is one. We may have a shot to improve things here. See https://www.fxsitecompat.com/en-CA/docs/2016/battery-status-api-has-been-removed/ window.addEventListener('deviceproximity', ... ) // depends on window We could work out that one in fact. Though I guess one can use the hardware ambient light sensor and btw deviceproximity a Mozilla only API. navigator.getUserMedia( ... ) // depends on navigator I don’t think this is a good candidate for Generic Sensor API subclasses. Not really comparable. window.addEventListener('devicelight', ... ) // depends on window Well we have this https://w3c.github.io/ambient-light/ (also implemented in Chrome behind a flag). Only ship on Mozilla, implemented on Chrome (but behind a flag), in Edge Preview. There is an opportunity to push the new one instead. navigator.geolocation.getCurrentPosition( ... ) // depends on navigator Right this one is old but again nothing prevents to provide a newer version based on the Generic Sensor API. We got the same problem. Maybe the global `Sensors` is indeed the best option. Maybe listing the sensors is a potential good use case however it triggers serious fingerprinting issues. The only way to prevent that would be to ask permissions to the users but who wants to answer 5+ prompts because a page is trying to figure out what kind of sensors you have. It’s better something targeted like “my app needs accelerometer -> ask the user”. There is a long discussion here about it : https://github.com/w3c/sensors/issues/145 On Mon, Nov 28, 2016 at 8:19 PM, Menard, Alexis <alexis.menard@intel.com<mailto:alexis.menard@intel.com>> wrote: Hi, The fact also that it doesn’t depends on navigator is I believe so that it can address JavaScript environments where navigator is not available, think of NodeJS in an IoT world. This is typically a place where your NodeJS app will query the sensors on the board and do something with it. Depending on the DOM is also not really an option. Thanks. On Nov 25, 2016, at 5:48 AM, Felipe Nascimento de Moura <felipenmoura@gmail.com<mailto:felipenmoura@gmail.com>> wrote: Hi. Reading this e-mail: http://lists.w3.org/Archives/Public/public-device-apis/2016Nov/0024.html I could add now, yet a new different pattern to the list I showed in the first e-mail: ``` let sensor = new Magnetometer(); // new instance of a global Constructor sensor.start(); sensor.onchange = function(event) { ... }; ``` I think this is the moment for us to think about a `core` for sensors, like `navigator.sensors....` :) On Thu, Nov 24, 2016 at 1:06 PM, Felipe Nascimento de Moura <felipenmoura@gmail.com<mailto:felipenmoura@gmail.com>> wrote: > https://github.com/w3c/sensors ... some are already supported in Chrome ;) nice, I have already done some tests with the currently supported ones, but even though, I think an aggregator for all the sensors is very important. Even for hacking and discoverability. navigator.sensors.tirePressure().then( ... ) Actually, navigator.sensors could even have a "getter" for any method that does not exist to return a rejected promise, instead of a "undefined is not a function" error. This way, calling `navigator.sensors.anInexistingSensor().then(...).catch(...)` would reject until the sensors was created or supported. Thinking it further, we could even have a `navigator.sensors.create` with a pattern for developers to create their own sensors based in other information...let's say: ``` navigator.sensors.create("darkRoom", function(mySensor){ Promise.all([ navigator.sensors.light(), navigator.sensors.proximity() ]).then(function([lightSensor, proximitySensor]){ // combine lightSensor and proximity to identify when the room is dark // and the device is not inside a pocket, for example // you can dispatch events here on mySensor }); }); // then, afterwards navigator.sensors.darkRoom().then(darkRoomSensor=>{ darkRoomSensor.addEventListener(...); }); ``` Did I go too far? :p On Thu, Nov 24, 2016 at 3:04 AM, Marcos Caceres <marcos@marcosc.com<mailto:marcos@marcosc.com>> wrote: On November 24, 2016 at 3:41:07 PM, Felipe Nascimento de Moura (felipenmoura@gmail.com<mailto:felipenmoura@gmail.com>) wrote: > I think I should be able to type "navigator.sensors" in my console and see > even an autocomplete with the possibilities. https://github.com/w3c/sensors ... some are already supported in Chrome ;) -- [ ]s -- Felipe N. Moura Web Developer, Google Developer Expert<https://developers.google.com/experts/people/felipe-moura>, Founder of BrazilJS<https://braziljs.org/> and Nasc<http://nasc.io/>. Website: http://felipenmoura.com<http://felipenmoura.com/> / http://nasc.io/ Twitter: @felipenmoura<http://twitter.com/felipenmoura> Facebook: http://fb.com/felipenmoura LinkedIn: http://goo.gl/qGmq --------------------------------- Changing the world is the least I expect from myself! -- [ ]s -- Felipe N. Moura Web Developer, Google Developer Expert<https://developers.google.com/experts/people/felipe-moura>, Founder of BrazilJS<https://braziljs.org/> and Nasc<http://nasc.io/>. Website: http://felipenmoura.com<http://felipenmoura.com/> / http://nasc.io/ Twitter: @felipenmoura<http://twitter.com/felipenmoura> Facebook: http://fb.com/felipenmoura LinkedIn: http://goo.gl/qGmq --------------------------------- Changing the world is the least I expect from myself! -- [ ]s -- Felipe N. Moura Web Developer, Google Developer Expert<https://developers.google.com/experts/people/felipe-moura>, Founder of BrazilJS<https://braziljs.org/> and Nasc<http://nasc.io/>. Website: http://felipenmoura.com<http://felipenmoura.com/> / http://nasc.io/ Twitter: @felipenmoura<http://twitter.com/felipenmoura> Facebook: http://fb.com/felipenmoura LinkedIn: http://goo.gl/qGmq --------------------------------- Changing the world is the least I expect from myself!
Received on Monday, 28 November 2016 22:54:25 UTC