1 of 40

Web APIs for 2018

Tim Roes

2 of 40

JavaScript Engineer @ Elastic

@tim_roes / tim.roes@elastic.co / www.timroes.de

Tim Roes

3 of 40

WebShare API

4 of 40

navigator.share({

title: 'e.g. page title',

text: 'Some text to share',

url: 'https://www.timroes.de'

})

.then(() => {

// User selected some share method

})

.catch(() => {

// User canceled the share menu

});

5 of 40

6 of 40

nothing

7 of 40

WebShare Target API

8 of 40

{

"name": "Twitter",

"short_name": "Twitter",

"icons": [...],

"share_target": {

"url_template": "share?title={title}&text={text}&url={url}"

}

}

9 of 40

nothing

nothing

nothing

10 of 40

Web Bluetooth

11 of 40

GATT

Service 'heart_beat'

0x000fff0-...-0123

Characteristic 'heart_rate_measurement'

Characteristic 'body_sensor_location'

Descriptor

Descriptor

Characteristic '0xfff00-...-1234'

Characteristic '0x12340-...-1231'

Descriptor

Descriptor

http://bit.ly/2lfpqwB

12 of 40

Demo

https://git.io/v9OvC

13 of 40

www.castillo.io/blog/muse-web-bluetooth

14 of 40

15 of 40

WebUSB API

16 of 40

USB Hardware

WebUSB Descriptor

Landing Page URL

Allowed Origins

Capabilities

Interface

Endpoint 1

Endpoint 2

17 of 40

Demo

https://git.io/v9Ovg

18 of 40

nothing

nothing

19 of 40

Payment Request

20 of 40

const methodData = [

{

supportedMethods: 'basic-card',

data: {

supportedNetworks: ['visa', 'mastercard'],

supportedTypes: ['debit', 'credit', 'prepaid']

}

}

];

21 of 40

const details = {

displayItems: [

{

label: 'Fabulous unicorn',

amount: { currency: 'EUR', value: '13.00' }

},

{

label: 'Replacement horn',

amount: { currency: 'EUR', value: '0.37' }

}

],

total: {

label: 'Total',

amount: { currency: 'EUR', value: '13.37' }

}

};

22 of 40

new PaymentRequest(methodData, details).show()

.then((response) => {

sendToBuyApi(repsonse.details).then((error) => {

if (error) {

response.complete('error');

} else {

response.complete('success');

}

});

});

23 of 40

Demo

https://git.io/v9Ova

More complete example:�https://emerald-eon.appspot.com/

24 of 40

25 of 40

WebNFC API

26 of 40

navigator.nfc.watch((message) => {

for (let record of message.records) {

console.log(`type: ${record.recordType}

mediaType: ${record.mediaType}

data: ${record.data}`);

}

});

27 of 40

navigator.nfc.push({

records: [

{ recordType: 'url', data: 'https://www.timroes.de' }

]

});

28 of 40

No Demo :'-(

29 of 40

public support (?)

nothing

30 of 40

Web VR

31 of 40

<a-scene>

<a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow></a-box>

<a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E" shadow></a-sphere>

<a-cylinder radius="0.5" height="1.5" color="#FFC65D" shadow></a-cylinder>

<a-plane position="0 0 -4" width="4" height="4" color="#7BC8A4" shadow></a-plane>

<a-sky color="#ECECEC"></a-sky>

</a-scene>

A-Frame (aframe.io)

32 of 40

33 of 40

39 (flagged)

More detailed: webvr.info

34 of 40

Resize Observer

35 of 40

const observer = new ResizeObserver(entries => {

for (let entry of entries) {

const { target, contentRect } = entry;

// ...

}

});

observer.observe(document.getElementById('watch-me'));

observer.observe(document.getElementById('another-watch'));

observer.unobserve(document.getElementById('watch-me'));

36 of 40

37 of 40

nothing

38 of 40

jpchase/OriginTrials

<meta http-equiv="origin-trial" content="Agefdr6eHq..."

data-feature="Web USB" data-expires="2017-07-25" >

39 of 40

Currently Available Origin Trials

Web VR (API changes) Chrome 62+ Until February 27, 2018

Generic Sensors Chrome 63+ Until February 27, 2018

Media Capabilities Chrome 64+ Until January 15, 2018

40 of 40

Web APIs for 2018

Tim Roes

@tim_roes / tim.roes@elastic.co

www.elastic.co / www.timroes.de

We are looking for people - everywhere! http://grnh.se/wa50mr1