build: update to standard 14 (#24479)

This commit is contained in:
Samuel Attard 2020-07-09 10:18:49 -07:00 committed by GitHub
parent 9bd0fc5348
commit eb6616e4e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 495 additions and 665 deletions

View file

@ -990,6 +990,7 @@ if (!gotTheLock) {
// Create myWindow, load the rest of the app, etc... // Create myWindow, load the rest of the app, etc...
app.whenReady().then(() => { app.whenReady().then(() => {
myWindow = createWindow()
}) })
} }
``` ```
@ -1105,8 +1106,10 @@ For `infoType` equal to `complete`:
For `infoType` equal to `basic`: For `infoType` equal to `basic`:
Promise is fulfilled with `Object` containing fewer attributes than when requested with `complete`. Here's an example of basic response: Promise is fulfilled with `Object` containing fewer attributes than when requested with `complete`. Here's an example of basic response:
```js ```js
{ auxAttributes: {
{ amdSwitchable: true, auxAttributes:
{
amdSwitchable: true,
canSupportThreadedTextureMailbox: false, canSupportThreadedTextureMailbox: false,
directComposition: false, directComposition: false,
directRendering: true, directRendering: true,
@ -1119,12 +1122,14 @@ For `infoType` equal to `basic`:
sandboxed: false, sandboxed: false,
softwareRendering: false, softwareRendering: false,
supportsOverlays: false, supportsOverlays: false,
videoDecodeAcceleratorFlags: 0 }, videoDecodeAcceleratorFlags: 0
gpuDevice: },
[ { active: true, deviceId: 26657, vendorId: 4098 }, gpuDevice:
{ active: false, deviceId: 3366, vendorId: 32902 } ], [{ active: true, deviceId: 26657, vendorId: 4098 },
machineModelName: 'MacBookPro', { active: false, deviceId: 3366, vendorId: 32902 }],
machineModelVersion: '11.5' } machineModelName: 'MacBookPro',
machineModelVersion: '11.5'
}
``` ```
Using `basic` should be preferred if only basic information like `vendorId` or `driverId` is needed. Using `basic` should be preferred if only basic information like `vendorId` or `driverId` is needed.

View file

@ -38,7 +38,7 @@ the window after this event will have no visual flash:
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ show: false }) const win = new BrowserWindow({ show: false })
win.once('ready-to-show', () => { win.once('ready-to-show', () => {
win.show() win.show()
}) })
@ -60,7 +60,7 @@ immediately, and use a `backgroundColor` close to your app's background:
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ backgroundColor: '#2e2c29' }) const win = new BrowserWindow({ backgroundColor: '#2e2c29' })
win.loadURL('https://github.com') win.loadURL('https://github.com')
``` ```
@ -74,8 +74,8 @@ By using `parent` option, you can create child windows:
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let top = new BrowserWindow() const top = new BrowserWindow()
let child = new BrowserWindow({ parent: top }) const child = new BrowserWindow({ parent: top })
child.show() child.show()
top.show() top.show()
``` ```
@ -90,7 +90,7 @@ window, you have to set both `parent` and `modal` options:
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let child = new BrowserWindow({ parent: top, modal: true, show: false }) const child = new BrowserWindow({ parent: top, modal: true, show: false })
child.loadURL('https://github.com') child.loadURL('https://github.com')
child.once('ready-to-show', () => { child.once('ready-to-show', () => {
child.show() child.show()
@ -597,7 +597,7 @@ e.g. `APPCOMMAND_BROWSER_BACKWARD` is emitted as `browser-backward`.
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
win.on('app-command', (e, cmd) => { win.on('app-command', (e, cmd) => {
// Navigate the window back when the user hits their mouse back button // Navigate the window back when the user hits their mouse back button
if (cmd === 'browser-backward' && win.webContents.canGoBack()) { if (cmd === 'browser-backward' && win.webContents.canGoBack()) {
@ -772,7 +772,7 @@ To check if a DevTools extension is installed you can run the following:
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let installed = BrowserWindow.getDevToolsExtensions().hasOwnProperty('devtron') const installed = 'devtron' in BrowserWindow.getDevToolsExtensions()
console.log(installed) console.log(installed)
``` ```
@ -789,7 +789,7 @@ Objects created with `new BrowserWindow` have the following properties:
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
// In this example `win` is our instance // In this example `win` is our instance
let win = new BrowserWindow({ width: 800, height: 600 }) const win = new BrowserWindow({ width: 800, height: 600 })
win.loadURL('https://github.com') win.loadURL('https://github.com')
``` ```
@ -1314,9 +1314,9 @@ a HTML-rendered toolbar. For example:
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
let toolbarRect = document.getElementById('toolbar').getBoundingClientRect() const toolbarRect = document.getElementById('toolbar').getBoundingClientRect()
win.setSheetOffset(toolbarRect.height) win.setSheetOffset(toolbarRect.height)
``` ```
@ -1440,7 +1440,7 @@ Node's [`url.format`](https://nodejs.org/api/url.html#url_url_format_urlobject)
method: method:
```javascript ```javascript
let url = require('url').format({ const url = require('url').format({
protocol: 'file', protocol: 'file',
slashes: true, slashes: true,
pathname: require('path').join(__dirname, 'index.html') pathname: require('path').join(__dirname, 'index.html')

View file

@ -9,7 +9,7 @@ runtime that allows interacting with pages and instrumenting them.
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
try { try {
win.webContents.debugger.attach('1.1') win.webContents.debugger.attach('1.1')

View file

@ -11,7 +11,7 @@ control the download item.
```javascript ```javascript
// In the main process. // In the main process.
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
win.webContents.session.on('will-download', (event, item, webContents) => { win.webContents.session.on('will-download', (event, item, webContents) => {
// Set the save path, making Electron not to prompt a save dialog. // Set the save path, making Electron not to prompt a save dialog.
item.setSavePath('/tmp/save.pdf') item.setSavePath('/tmp/save.pdf')

View file

@ -15,7 +15,7 @@ To create a frameless window, you need to set `frame` to `false` in
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ width: 800, height: 600, frame: false }) const win = new BrowserWindow({ width: 800, height: 600, frame: false })
win.show() win.show()
``` ```
@ -33,7 +33,7 @@ Results in a hidden title bar and a full size content window, yet the title bar
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ titleBarStyle: 'hidden' }) const win = new BrowserWindow({ titleBarStyle: 'hidden' })
win.show() win.show()
``` ```
@ -43,7 +43,7 @@ Results in a hidden title bar with an alternative look where the traffic light b
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ titleBarStyle: 'hiddenInset' }) const win = new BrowserWindow({ titleBarStyle: 'hiddenInset' })
win.show() win.show()
``` ```
@ -58,7 +58,7 @@ This option is only applicable for frameless windows.
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ titleBarStyle: 'customButtonsOnHover', frame: false }) const win = new BrowserWindow({ titleBarStyle: 'customButtonsOnHover', frame: false })
win.show() win.show()
``` ```
@ -69,7 +69,7 @@ window transparent:
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ transparent: true, frame: false }) const win = new BrowserWindow({ transparent: true, frame: false })
win.show() win.show()
``` ```
@ -100,7 +100,7 @@ API:
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
win.setIgnoreMouseEvents(true) win.setIgnoreMouseEvents(true)
``` ```
@ -112,8 +112,8 @@ optional parameter can be used to forward mouse move messages to the web page,
allowing events such as `mouseleave` to be emitted: allowing events such as `mouseleave` to be emitted:
```javascript ```javascript
let win = require('electron').remote.getCurrentWindow() const win = require('electron').remote.getCurrentWindow()
let el = document.getElementById('clickThroughElement') const el = document.getElementById('clickThroughElement')
el.addEventListener('mouseenter', () => { el.addEventListener('mouseenter', () => {
win.setIgnoreMouseEvents(true, { forward: true }) win.setIgnoreMouseEvents(true, { forward: true })
}) })

View file

@ -17,7 +17,7 @@ renderer process:
```javascript ```javascript
const { BrowserWindow } = require('electron').remote const { BrowserWindow } = require('electron').remote
let win = new BrowserWindow({ width: 800, height: 600 }) const win = new BrowserWindow({ width: 800, height: 600 })
win.loadURL('https://github.com') win.loadURL('https://github.com')
``` ```

View file

@ -33,8 +33,8 @@ const { app, BrowserWindow, screen } = require('electron')
let win let win
app.whenReady().then(() => { app.whenReady().then(() => {
let displays = screen.getAllDisplays() const displays = screen.getAllDisplays()
let externalDisplay = displays.find((display) => { const externalDisplay = displays.find((display) => {
return display.bounds.x !== 0 || display.bounds.y !== 0 return display.bounds.x !== 0 || display.bounds.y !== 0
}) })

View file

@ -12,7 +12,7 @@ property of [`WebContents`](web-contents.md), or from the `session` module.
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ width: 800, height: 600 }) const win = new BrowserWindow({ width: 800, height: 600 })
win.loadURL('http://github.com') win.loadURL('http://github.com')
const ses = win.webContents.session const ses = win.webContents.session
@ -332,7 +332,7 @@ verify proc.
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
win.webContents.session.setCertificateVerifyProc((request, callback) => { win.webContents.session.setCertificateVerifyProc((request, callback) => {
const { hostname } = request const { hostname } = request
@ -655,7 +655,7 @@ const path = require('path')
app.whenReady().then(() => { app.whenReady().then(() => {
const protocol = session.fromPartition('some-partition').protocol const protocol = session.fromPartition('some-partition').protocol
protocol.registerFileProtocol('atom', (request, callback) => { protocol.registerFileProtocol('atom', (request, callback) => {
let url = request.url.substr(7) const url = request.url.substr(7)
callback({ path: path.normalize(`${__dirname}/${url}`) }) callback({ path: path.normalize(`${__dirname}/${url}`) })
}, (error) => { }, (error) => {
if (error) console.error('Failed to register protocol') if (error) console.error('Failed to register protocol')

View file

@ -41,7 +41,7 @@ An example TraceConfig that roughly matches what Chrome DevTools records:
'disabled-by-default-v8.cpu_profiler', 'disabled-by-default-v8.cpu_profiler',
'disabled-by-default-v8.cpu_profiler.hires' 'disabled-by-default-v8.cpu_profiler.hires'
], ],
excluded_categories: [ '*' ] excluded_categories: ['*']
} }
``` ```

View file

@ -209,7 +209,7 @@ not (transparent windows won't work correctly when DWM composition is disabled):
```javascript ```javascript
const { BrowserWindow, systemPreferences } = require('electron') const { BrowserWindow, systemPreferences } = require('electron')
let browserOptions = { width: 1000, height: 800 } const browserOptions = { width: 1000, height: 800 }
// Make the window transparent only if the platform supports it. // Make the window transparent only if the platform supports it.
if (process.platform !== 'win32' || systemPreferences.isAeroGlassEnabled()) { if (process.platform !== 'win32' || systemPreferences.isAeroGlassEnabled()) {
@ -218,7 +218,7 @@ if (process.platform !== 'win32' || systemPreferences.isAeroGlassEnabled()) {
} }
// Create the window. // Create the window.
let win = new BrowserWindow(browserOptions) const win = new BrowserWindow(browserOptions)
// Navigate. // Navigate.
if (browserOptions.transparent) { if (browserOptions.transparent) {

View file

@ -12,10 +12,10 @@ the [`BrowserWindow`](browser-window.md) object. An example of accessing the
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ width: 800, height: 1500 }) const win = new BrowserWindow({ width: 800, height: 1500 })
win.loadURL('http://github.com') win.loadURL('http://github.com')
let contents = win.webContents const contents = win.webContents
console.log(contents) console.log(contents)
``` ```
@ -418,7 +418,7 @@ To only prevent the menu shortcuts, use
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ width: 800, height: 600 }) const win = new BrowserWindow({ width: 800, height: 600 })
win.webContents.on('before-input-event', (event, input) => { win.webContents.on('before-input-event', (event, input) => {
// For example, only enable application menu keyboard shortcuts when // For example, only enable application menu keyboard shortcuts when
@ -665,7 +665,7 @@ app.whenReady().then(() => {
win = new BrowserWindow({ width: 800, height: 600 }) win = new BrowserWindow({ width: 800, height: 600 })
win.webContents.on('select-bluetooth-device', (event, deviceList, callback) => { win.webContents.on('select-bluetooth-device', (event, deviceList, callback) => {
event.preventDefault() event.preventDefault()
let result = deviceList.find((device) => { const result = deviceList.find((device) => {
return device.deviceName === 'test' return device.deviceName === 'test'
}) })
if (!result) { if (!result) {
@ -691,7 +691,7 @@ buffer.
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ webPreferences: { offscreen: true } }) const win = new BrowserWindow({ webPreferences: { offscreen: true } })
win.webContents.on('paint', (event, dirty, image) => { win.webContents.on('paint', (event, dirty, image) => {
// updateBitmap(dirty, image.getBitmap()) // updateBitmap(dirty, image.getBitmap())
}) })
@ -907,7 +907,7 @@ Returns `String` - The URL of the current web page.
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ width: 800, height: 600 }) const win = new BrowserWindow({ width: 800, height: 600 })
win.loadURL('http://github.com').then(() => { win.loadURL('http://github.com').then(() => {
const currentURL = win.webContents.getURL() const currentURL = win.webContents.getURL()
console.log(currentURL) console.log(currentURL)
@ -1372,7 +1372,7 @@ An example of `webContents.printToPDF`:
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
const fs = require('fs') const fs = require('fs')
let win = new BrowserWindow({ width: 800, height: 600 }) const win = new BrowserWindow({ width: 800, height: 600 })
win.loadURL('http://github.com') win.loadURL('http://github.com')
win.webContents.on('did-finish-load', () => { win.webContents.on('did-finish-load', () => {
@ -1397,7 +1397,7 @@ creation:
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
win.webContents.on('devtools-opened', () => { win.webContents.on('devtools-opened', () => {
win.webContents.addWorkSpace(__dirname) win.webContents.addWorkSpace(__dirname)
}) })
@ -1718,7 +1718,7 @@ Returns `Promise<void>` - resolves if the page is saved.
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
win.loadURL('https://github.com') win.loadURL('https://github.com')

View file

@ -816,7 +816,7 @@ const { shell } = require('electron')
const webview = document.querySelector('webview') const webview = document.querySelector('webview')
webview.addEventListener('new-window', async (e) => { webview.addEventListener('new-window', async (e) => {
const protocol = require('url').parse(e.url).protocol const protocol = (new URL(e.url)).protocol
if (protocol === 'http:' || protocol === 'https:') { if (protocol === 'http:' || protocol === 'https:') {
await shell.openExternal(e.url) await shell.openExternal(e.url)
} }

View file

@ -94,6 +94,6 @@ mainWindow.webContents.on('new-window', (event, url, frameName, disposition, opt
```javascript ```javascript
// renderer process (mainWindow) // renderer process (mainWindow)
let modal = window.open('', 'modal') const modal = window.open('', 'modal')
modal.document.write('<h1>Hello</h1>') modal.document.write('<h1>Hello</h1>')
``` ```

View file

@ -266,7 +266,7 @@ const getGuestForWebContents = (webContentsId, contents) => {
throw new Error(`Invalid webContentsId: ${webContentsId}`) throw new Error(`Invalid webContentsId: ${webContentsId}`)
} }
if (guest.hostWebContents !== contents) { if (guest.hostWebContents !== contents) {
throw new Error(`Access denied to webContents`) throw new Error('Access denied to webContents')
} }
return guest return guest
} }
@ -610,11 +610,11 @@ const { memory } = metrics[0] // Deprecated property
```js ```js
// Deprecated // Deprecated
let optionsA = { webPreferences: { blinkFeatures: '' } } const optionsA = { webPreferences: { blinkFeatures: '' } }
let windowA = new BrowserWindow(optionsA) const windowA = new BrowserWindow(optionsA)
// Replace with // Replace with
let optionsB = { webPreferences: { enableBlinkFeatures: '' } } const optionsB = { webPreferences: { enableBlinkFeatures: '' } }
let windowB = new BrowserWindow(optionsB) const windowB = new BrowserWindow(optionsB)
// Deprecated // Deprecated
window.on('app-command', (e, cmd) => { window.on('app-command', (e, cmd) => {
@ -785,11 +785,11 @@ The following list includes the breaking API changes made in Electron 2.0.
```js ```js
// Deprecated // Deprecated
let optionsA = { titleBarStyle: 'hidden-inset' } const optionsA = { titleBarStyle: 'hidden-inset' }
let windowA = new BrowserWindow(optionsA) const windowA = new BrowserWindow(optionsA)
// Replace with // Replace with
let optionsB = { titleBarStyle: 'hiddenInset' } const optionsB = { titleBarStyle: 'hiddenInset' }
let windowB = new BrowserWindow(optionsB) const windowB = new BrowserWindow(optionsB)
``` ```
### `menu` ### `menu`

View file

@ -107,7 +107,7 @@ To solve this, you can turn off node integration in Electron:
```javascript ```javascript
// In the main process. // In the main process.
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ const win = new BrowserWindow({
webPreferences: { webPreferences: {
nodeIntegration: false nodeIntegration: false
} }
@ -155,7 +155,7 @@ To achieve this goal, set the background in the constructor for [BrowserWindow][
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow({ const win = new BrowserWindow({
backgroundColor: '#fff' backgroundColor: '#fff'
}) })
``` ```

View file

@ -15,7 +15,7 @@ can open them programmatically by calling the `openDevTools()` API on the
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
win.webContents.openDevTools() win.webContents.openDevTools()
``` ```

View file

@ -70,7 +70,7 @@ fs.readdirSync('/path/to/example.asar')
Use a module from the archive: Use a module from the archive:
```javascript ```javascript
require('/path/to/example.asar/dir/module.js') require('./path/to/example.asar/dir/module.js')
``` ```
You can also display a web page in an `asar` archive with `BrowserWindow`: You can also display a web page in an `asar` archive with `BrowserWindow`:

View file

@ -9,9 +9,9 @@ const childProcess = require('child_process')
const electronPath = require('electron') const electronPath = require('electron')
// spawn the process // spawn the process
let env = { /* ... */ } const env = { /* ... */ }
let stdio = ['inherit', 'inherit', 'inherit', 'ipc'] const stdio = ['inherit', 'inherit', 'inherit', 'ipc']
let appProcess = childProcess.spawn(electronPath, ['./app'], { stdio, env }) const appProcess = childProcess.spawn(electronPath, ['./app'], { stdio, env })
// listen for IPC messages from the app // listen for IPC messages from the app
appProcess.on('message', (msg) => { appProcess.on('message', (msg) => {
@ -50,7 +50,7 @@ class TestDriver {
// handle rpc responses // handle rpc responses
this.process.on('message', (message) => { this.process.on('message', (message) => {
// pop the handler // pop the handler
let rpcCall = this.rpcCalls[message.msgId] const rpcCall = this.rpcCalls[message.msgId]
if (!rpcCall) return if (!rpcCall) return
this.rpcCalls[message.msgId] = null this.rpcCalls[message.msgId] = null
// reject/resolve // reject/resolve
@ -70,7 +70,7 @@ class TestDriver {
// to use: driver.rpc('method', 1, 2, 3).then(...) // to use: driver.rpc('method', 1, 2, 3).then(...)
async rpc (cmd, ...args) { async rpc (cmd, ...args) {
// send rpc request // send rpc request
let msgId = this.rpcCalls.length const msgId = this.rpcCalls.length
this.process.send({ msgId, cmd, args }) this.process.send({ msgId, cmd, args })
return new Promise((resolve, reject) => this.rpcCalls.push({ resolve, reject })) return new Promise((resolve, reject) => this.rpcCalls.push({ resolve, reject }))
} }
@ -92,10 +92,10 @@ async function onMessage ({ msgId, cmd, args }) {
let method = METHODS[cmd] let method = METHODS[cmd]
if (!method) method = () => new Error('Invalid method: ' + cmd) if (!method) method = () => new Error('Invalid method: ' + cmd)
try { try {
let resolve = await method(...args) const resolve = await method(...args)
process.send({ msgId, resolve }) process.send({ msgId, resolve })
} catch (err) { } catch (err) {
let reject = { const reject = {
message: err.message, message: err.message,
stack: err.stack, stack: err.stack,
name: err.name name: err.name
@ -119,7 +119,7 @@ Then, in your test suite, you can use your test-driver as follows:
const test = require('ava') const test = require('ava')
const electronPath = require('electron') const electronPath = require('electron')
let app = new TestDriver({ const app = new TestDriver({
path: electronPath, path: electronPath,
args: ['./app'], args: ['./app'],
env: { env: {

View file

@ -96,7 +96,7 @@ const { app, BrowserWindow } = require('electron')
function createWindow () { function createWindow () {
// Create the browser window. // Create the browser window.
let win = new BrowserWindow({ const win = new BrowserWindow({
width: 800, width: 800,
height: 600, height: 600,
webPreferences: { webPreferences: {

View file

@ -37,18 +37,18 @@ inAppPurchase.on('transactions-updated', (event, transactions) => {
// Check each transaction. // Check each transaction.
transactions.forEach(function (transaction) { transactions.forEach(function (transaction) {
let payment = transaction.payment const payment = transaction.payment
switch (transaction.transactionState) { switch (transaction.transactionState) {
case 'purchasing': case 'purchasing':
console.log(`Purchasing ${payment.productIdentifier}...`) console.log(`Purchasing ${payment.productIdentifier}...`)
break break
case 'purchased':
case 'purchased': {
console.log(`${payment.productIdentifier} purchased.`) console.log(`${payment.productIdentifier} purchased.`)
// Get the receipt url. // Get the receipt url.
let receiptURL = inAppPurchase.getReceiptURL() const receiptURL = inAppPurchase.getReceiptURL()
console.log(`Receipt URL: ${receiptURL}`) console.log(`Receipt URL: ${receiptURL}`)
@ -62,6 +62,8 @@ inAppPurchase.on('transactions-updated', (event, transactions) => {
inAppPurchase.finishTransactionByDate(transaction.transactionDate) inAppPurchase.finishTransactionByDate(transaction.transactionDate)
break break
}
case 'failed': case 'failed':
console.log(`Failed to purchase ${payment.productIdentifier}.`) console.log(`Failed to purchase ${payment.productIdentifier}.`)
@ -105,8 +107,8 @@ inAppPurchase.getProducts(PRODUCT_IDS).then(products => {
}) })
// Ask the user which product he/she wants to purchase. // Ask the user which product he/she wants to purchase.
let selectedProduct = products[0] const selectedProduct = products[0]
let selectedQuantity = 1 const selectedQuantity = 1
// Purchase the selected product. // Purchase the selected product.
inAppPurchase.purchaseProduct(selectedProduct.productIdentifier, selectedQuantity).then(isProductValid => { inAppPurchase.purchaseProduct(selectedProduct.productIdentifier, selectedQuantity).then(isProductValid => {

View file

@ -10,7 +10,7 @@ so the `nodeIntegrationInWorker` option should be set to `true` in
`webPreferences`. `webPreferences`.
```javascript ```javascript
let win = new BrowserWindow({ const win = new BrowserWindow({
webPreferences: { webPreferences: {
nodeIntegrationInWorker: true nodeIntegrationInWorker: true
} }
@ -44,7 +44,7 @@ loads no native modules after the Web Workers get started.
process.dlopen = () => { process.dlopen = () => {
throw new Error('Load native module is not safe') throw new Error('Load native module is not safe')
} }
let worker = new Worker('script.js') const worker = new Worker('script.js')
``` ```
[web-workers]: https://developer.mozilla.org/en/docs/Web/API/Web_Workers_API/Using_web_workers [web-workers]: https://developer.mozilla.org/en/docs/Web/API/Web_Workers_API/Using_web_workers

View file

@ -10,7 +10,7 @@ you want to show Notifications in the main process please check out the
[Notification](../api/notification.md) module. [Notification](../api/notification.md) module.
```javascript ```javascript
let myNotification = new Notification('Title', { const myNotification = new Notification('Title', {
body: 'Lorem Ipsum Dolor Sit Amet' body: 'Lorem Ipsum Dolor Sit Amet'
}) })

View file

@ -42,7 +42,7 @@ app.commandLine.appendSwitch('ppapi-flash-path', path.join(__dirname, pluginName
app.commandLine.appendSwitch('ppapi-flash-version', '17.0.0.169') app.commandLine.appendSwitch('ppapi-flash-version', '17.0.0.169')
app.whenReady().then(() => { app.whenReady().then(() => {
let win = new BrowserWindow({ const win = new BrowserWindow({
width: 800, width: 800,
height: 600, height: 600,
webPreferences: { webPreferences: {

View file

@ -146,7 +146,7 @@ const options = {
} }
} }
let client = webdriverio.remote(options) const client = webdriverio.remote(options)
client client
.init() .init()

View file

@ -149,7 +149,7 @@ To set the overlay icon for a window, you can use the
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
win.setOverlayIcon('path/to/overlay.png', 'Description for overlay') win.setOverlayIcon('path/to/overlay.png', 'Description for overlay')
``` ```
@ -168,7 +168,7 @@ To flash the BrowserWindow taskbar button, you can use the
```javascript ```javascript
const { BrowserWindow } = require('electron') const { BrowserWindow } = require('electron')
let win = new BrowserWindow() const win = new BrowserWindow()
win.once('focus', () => win.flashFrame(false)) win.once('focus', () => win.flashFrame(false))
win.flashFrame(true) win.flashFrame(true)
``` ```

View file

@ -134,6 +134,7 @@ class SlurpStream extends Writable {
this._data = Buffer.concat([this._data, chunk]); this._data = Buffer.concat([this._data, chunk]);
callback(); callback();
} }
data () { return this._data; } data () { return this._data; }
} }

View file

@ -31,7 +31,7 @@
"dotenv-safe": "^4.0.4", "dotenv-safe": "^4.0.4",
"dugite": "^1.45.0", "dugite": "^1.45.0",
"eslint": "^7.4.0", "eslint": "^7.4.0",
"eslint-config-standard": "^12.0.0", "eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.22.0", "eslint-plugin-import": "^2.22.0",
"eslint-plugin-mocha": "^7.0.1", "eslint-plugin-mocha": "^7.0.1",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
@ -53,7 +53,7 @@
"request": "^2.88.0", "request": "^2.88.0",
"semver": "^5.6.0", "semver": "^5.6.0",
"shx": "^0.3.2", "shx": "^0.3.2",
"standard-markdown": "^5.0.0", "standard-markdown": "^6.0.0",
"sumchecker": "^2.0.2", "sumchecker": "^2.0.2",
"tap-xunit": "^2.4.1", "tap-xunit": "^2.4.1",
"temp": "^0.8.3", "temp": "^0.8.3",

View file

@ -40,6 +40,7 @@ class GHKey {
this.repo = repo; this.repo = repo;
this.number = number; this.number = number;
} }
static NewFromPull (pull) { static NewFromPull (pull) {
const owner = pull.base.repo.owner.login; const owner = pull.base.repo.owner.login;
const repo = pull.base.repo.name; const repo = pull.base.repo.name;
@ -405,7 +406,7 @@ function getOldestMajorBranchOfPull (pull) {
} }
function getOldestMajorBranchOfCommit (commit, pool) { function getOldestMajorBranchOfCommit (commit, pool) {
return [ ...commit.prKeys.values() ] return [...commit.prKeys.values()]
.map(prKey => pool.pulls[prKey.number]) .map(prKey => pool.pulls[prKey.number])
.filter(pull => !!pull) .filter(pull => !!pull)
.map(pull => getOldestMajorBranchOfPull(pull)) .map(pull => getOldestMajorBranchOfPull(pull))
@ -531,13 +532,13 @@ const removeSupercededStackUpdates = (commits) => {
notupdates.push(commit); notupdates.push(commit);
continue; continue;
} }
const [ , dep, version ] = match; const [, dep, version] = match;
if (!newest[dep] || newest[dep].version < version) { if (!newest[dep] || newest[dep].version < version) {
newest[dep] = { commit, version }; newest[dep] = { commit, version };
} }
} }
return [ ...notupdates, ...Object.values(newest).map(o => o.commit) ]; return [...notupdates, ...Object.values(newest).map(o => o.commit)];
}; };
/*** /***

View file

@ -1007,7 +1007,7 @@ describe('BrowserWindow module', () => {
}); });
}); });
ifdescribe(process.platform === 'win32')(`Fullscreen state`, () => { ifdescribe(process.platform === 'win32')('Fullscreen state', () => {
it('with properties', () => { it('with properties', () => {
it('can be set with the fullscreen constructor option', () => { it('can be set with the fullscreen constructor option', () => {
w = new BrowserWindow({ fullscreen: true }); w = new BrowserWindow({ fullscreen: true });
@ -1021,7 +1021,7 @@ describe('BrowserWindow module', () => {
expect(w.fullScreen).to.be.true(); expect(w.fullScreen).to.be.true();
}); });
it(`checks normal bounds when fullscreen'ed`, async () => { it('checks normal bounds when fullscreen\'ed', async () => {
const bounds = w.getBounds(); const bounds = w.getBounds();
const enterFullScreen = emittedOnce(w, 'enter-full-screen'); const enterFullScreen = emittedOnce(w, 'enter-full-screen');
w.show(); w.show();
@ -1030,7 +1030,7 @@ describe('BrowserWindow module', () => {
expectBoundsEqual(w.getNormalBounds(), bounds); expectBoundsEqual(w.getNormalBounds(), bounds);
}); });
it(`checks normal bounds when unfullscreen'ed`, async () => { it('checks normal bounds when unfullscreen\'ed', async () => {
const bounds = w.getBounds(); const bounds = w.getBounds();
w.once('enter-full-screen', () => { w.once('enter-full-screen', () => {
w.fullScreen = false; w.fullScreen = false;
@ -1056,7 +1056,7 @@ describe('BrowserWindow module', () => {
expect(w.isFullScreen()).to.be.true(); expect(w.isFullScreen()).to.be.true();
}); });
it(`checks normal bounds when fullscreen'ed`, async () => { it('checks normal bounds when fullscreen\'ed', async () => {
const bounds = w.getBounds(); const bounds = w.getBounds();
w.show(); w.show();
@ -1067,7 +1067,7 @@ describe('BrowserWindow module', () => {
expectBoundsEqual(w.getNormalBounds(), bounds); expectBoundsEqual(w.getNormalBounds(), bounds);
}); });
it(`checks normal bounds when unfullscreen'ed`, async () => { it('checks normal bounds when unfullscreen\'ed', async () => {
const bounds = w.getBounds(); const bounds = w.getBounds();
w.show(); w.show();

View file

@ -203,7 +203,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
require('electron').crashReporter.start({ require('electron').crashReporter.start({
submitURL: `http://127.0.0.1:${port}`, submitURL: `http://127.0.0.1:${port}`,
ignoreSystemCrashHandler: true, ignoreSystemCrashHandler: true,
extra: { 'longParam': 'a'.repeat(130) } extra: { longParam: 'a'.repeat(130) }
}); });
setTimeout(() => process.crash()); setTimeout(() => process.crash());
}, port); }, port);
@ -381,7 +381,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
await remotely(() => { await remotely(() => {
require('electron').crashReporter.start({ require('electron').crashReporter.start({
submitURL: 'http://127.0.0.1', submitURL: 'http://127.0.0.1',
extra: { 'extra1': 'hi' } extra: { extra1: 'hi' }
}); });
}); });
const parameters = await remotely(() => require('electron').crashReporter.getParameters()); const parameters = await remotely(() => require('electron').crashReporter.getParameters());
@ -414,8 +414,8 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
crashReporter.start({ submitURL: 'http://' }); crashReporter.start({ submitURL: 'http://' });
const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } }); const bw = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
bw.loadURL('about:blank'); bw.loadURL('about:blank');
await bw.webContents.executeJavaScript(`require('electron').crashReporter.addExtraParameter('hello', 'world')`); await bw.webContents.executeJavaScript('require(\'electron\').crashReporter.addExtraParameter(\'hello\', \'world\')');
return bw.webContents.executeJavaScript(`require('electron').crashReporter.getParameters()`); return bw.webContents.executeJavaScript('require(\'electron\').crashReporter.getParameters()');
}); });
if (process.platform === 'linux') { if (process.platform === 'linux') {
// On Linux, 'getParameters' will also include the global parameters, // On Linux, 'getParameters' will also include the global parameters,

View file

@ -523,7 +523,7 @@ describe('net module', () => {
session: sess session: sess
}); });
const response = await getResponse(urlRequest); const response = await getResponse(urlRequest);
expect(response.headers['x-cookie']).to.equal(`undefined`); expect(response.headers['x-cookie']).to.equal('undefined');
}); });
it('should be able to use the sessions cookie store', async () => { it('should be able to use the sessions cookie store', async () => {

View file

@ -105,7 +105,7 @@ describe('session module', () => {
}); });
} }
it(`fails to set cookies with samesite=garbage`, async () => { it('fails to set cookies with samesite=garbage', async () => {
const { cookies } = session.defaultSession; const { cookies } = session.defaultSession;
const value = 'hithere'; const value = 'hithere';
await expect(cookies.set({ url, value, sameSite: 'garbage' as any })).to.eventually.be.rejectedWith('Failed to convert \'garbage\' to an appropriate cookie same site value'); await expect(cookies.set({ url, value, sameSite: 'garbage' as any })).to.eventually.be.rejectedWith('Failed to convert \'garbage\' to an appropriate cookie same site value');

View file

@ -1905,7 +1905,7 @@ describe('webContents module', () => {
wasCalled = true; wasCalled = true;
}); });
await w.loadURL('about:blank'); await w.loadURL('about:blank');
await w.webContents.executeJavaScript(`window.open('about:blank')`); await w.webContents.executeJavaScript('window.open(\'about:blank\')');
await new Promise((resolve) => { process.nextTick(resolve); }); await new Promise((resolve) => { process.nextTick(resolve); });
expect(wasCalled).to.equal(false); expect(wasCalled).to.equal(false);
await closeAllWindows(); await closeAllWindows();

View file

@ -274,7 +274,7 @@ describe('chrome extensions', () => {
await customSession.loadExtension(path.join(fixtures, 'extensions', 'persistent-background-page')); await customSession.loadExtension(path.join(fixtures, 'extensions', 'persistent-background-page'));
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession } }); const w = new BrowserWindow({ show: false, webPreferences: { session: customSession } });
const promise = emittedOnce(app, 'web-contents-created'); const promise = emittedOnce(app, 'web-contents-created');
await w.loadURL(`about:blank`); await w.loadURL('about:blank');
const [, bgPageContents] = await promise; const [, bgPageContents] = await promise;
expect(bgPageContents.session).to.not.equal(undefined); expect(bgPageContents.session).to.not.equal(undefined);
}); });

View file

@ -31,7 +31,7 @@ class GitFake {
// find the newest shared commit between branches a and b // find the newest shared commit between branches a and b
mergeBase (a: string, b:string): string { mergeBase (a: string, b:string): string {
for (const commit of [ ...this.branches[a].reverse() ]) { for (const commit of [...this.branches[a].reverse()]) {
if (this.branches[b].map((commit: Commit) => commit.sha1).includes(commit.sha1)) { if (this.branches[b].map((commit: Commit) => commit.sha1).includes(commit.sha1)) {
return commit.sha1; return commit.sha1;
} }
@ -57,7 +57,7 @@ class GitFake {
stdout = this.branches[branch].map((commit: Commit) => commit.sha1).join('\n'); stdout = this.branches[branch].map((commit: Commit) => commit.sha1).join('\n');
} else if (args.length > 1 && args[0] === 'log' && args.includes('--format=%H,%s')) { } else if (args.length > 1 && args[0] === 'log' && args.includes('--format=%H,%s')) {
// expected form: `git log --format=%H,%s sha1..branchName // expected form: `git log --format=%H,%s sha1..branchName
const [ start, branch ] = args[args.length - 1].split('..'); const [start, branch] = args[args.length - 1].split('..');
const lines : string[] = []; const lines : string[] = [];
let started = false; let started = false;
for (const commit of this.branches[branch]) { for (const commit of this.branches[branch]) {
@ -108,7 +108,7 @@ describe('release notes', () => {
const wrapper = (args: string[], path: string, options?: IGitExecutionOptions | undefined) => gitFake.exec(args, path, options); const wrapper = (args: string[], path: string, options?: IGitExecutionOptions | undefined) => gitFake.exec(args, path, options);
sandbox.replace(GitProcess, 'exec', wrapper); sandbox.replace(GitProcess, 'exec', wrapper);
gitFake.setBranch(oldBranch, [ ...sharedHistory, oldFix ]); gitFake.setBranch(oldBranch, [...sharedHistory, oldFix]);
}); });
afterEach(() => { afterEach(() => {
@ -120,8 +120,8 @@ describe('release notes', () => {
// while oldBranch was the latest stable release // while oldBranch was the latest stable release
it('are skipped if the target version is a new major line (x.0.0)', async function () { it('are skipped if the target version is a new major line (x.0.0)', async function () {
const version = 'v9.0.0'; const version = 'v9.0.0';
gitFake.setBranch(oldBranch, [ ...sharedHistory, oldTropFix ]); gitFake.setBranch(oldBranch, [...sharedHistory, oldTropFix]);
gitFake.setBranch(newBranch, [ ...sharedHistory, newTropFix ]); gitFake.setBranch(newBranch, [...sharedHistory, newTropFix]);
const results: any = await notes.get(oldBranch, newBranch, version); const results: any = await notes.get(oldBranch, newBranch, version);
expect(results.fix).to.have.lengthOf(0); expect(results.fix).to.have.lengthOf(0);
}); });
@ -130,8 +130,8 @@ describe('release notes', () => {
// multiple stable branches at once, including newBranch. // multiple stable branches at once, including newBranch.
it('are included if the target version is a minor or patch bump', async function () { it('are included if the target version is a minor or patch bump', async function () {
const version = 'v9.0.1'; const version = 'v9.0.1';
gitFake.setBranch(oldBranch, [ ...sharedHistory, oldTropFix ]); gitFake.setBranch(oldBranch, [...sharedHistory, oldTropFix]);
gitFake.setBranch(newBranch, [ ...sharedHistory, newTropFix ]); gitFake.setBranch(newBranch, [...sharedHistory, newTropFix]);
const results: any = await notes.get(oldBranch, newBranch, version); const results: any = await notes.get(oldBranch, newBranch, version);
expect(results.fix).to.have.lengthOf(1); expect(results.fix).to.have.lengthOf(1);
}); });
@ -146,7 +146,7 @@ describe('release notes', () => {
const testCommit = new Commit('89eb309d0b22bd4aec058ffaf983e81e56a5c378', 'feat: lole u got troled hard (#21891)'); const testCommit = new Commit('89eb309d0b22bd4aec058ffaf983e81e56a5c378', 'feat: lole u got troled hard (#21891)');
const version = 'v9.0.0'; const version = 'v9.0.0';
gitFake.setBranch(newBranch, [ ...sharedHistory, testCommit ]); gitFake.setBranch(newBranch, [...sharedHistory, testCommit]);
const results: any = await notes.get(oldBranch, newBranch, version); const results: any = await notes.get(oldBranch, newBranch, version);
expect(results.feat).to.have.lengthOf(1); expect(results.feat).to.have.lengthOf(1);
expect(results.feat[0].hash).to.equal(testCommit.sha1); expect(results.feat[0].hash).to.equal(testCommit.sha1);
@ -160,7 +160,7 @@ describe('release notes', () => {
it("honors 'feat' type", async function () { it("honors 'feat' type", async function () {
const testCommit = newFeat; const testCommit = newFeat;
gitFake.setBranch(newBranch, [ ...sharedHistory, testCommit ]); gitFake.setBranch(newBranch, [...sharedHistory, testCommit]);
const results: any = await notes.get(oldBranch, newBranch, version); const results: any = await notes.get(oldBranch, newBranch, version);
expect(results.feat).to.have.lengthOf(1); expect(results.feat).to.have.lengthOf(1);
expect(results.feat[0].hash).to.equal(testCommit.sha1); expect(results.feat[0].hash).to.equal(testCommit.sha1);
@ -168,7 +168,7 @@ describe('release notes', () => {
it("honors 'fix' type", async function () { it("honors 'fix' type", async function () {
const testCommit = newFix; const testCommit = newFix;
gitFake.setBranch(newBranch, [ ...sharedHistory, testCommit ]); gitFake.setBranch(newBranch, [...sharedHistory, testCommit]);
const results: any = await notes.get(oldBranch, newBranch, version); const results: any = await notes.get(oldBranch, newBranch, version);
expect(results.fix).to.have.lengthOf(1); expect(results.fix).to.have.lengthOf(1);
expect(results.fix[0].hash).to.equal(testCommit.sha1); expect(results.fix[0].hash).to.equal(testCommit.sha1);
@ -176,7 +176,7 @@ describe('release notes', () => {
it("honors 'BREAKING CHANGE' message", async function () { it("honors 'BREAKING CHANGE' message", async function () {
const testCommit = newBreaking; const testCommit = newBreaking;
gitFake.setBranch(newBranch, [ ...sharedHistory, testCommit ]); gitFake.setBranch(newBranch, [...sharedHistory, testCommit]);
const results: any = await notes.get(oldBranch, newBranch, version); const results: any = await notes.get(oldBranch, newBranch, version);
expect(results.breaking).to.have.lengthOf(1); expect(results.breaking).to.have.lengthOf(1);
expect(results.breaking[0].hash).to.equal(testCommit.sha1); expect(results.breaking[0].hash).to.equal(testCommit.sha1);

View file

@ -38,106 +38,106 @@ function ToWebM (frames, outputAsArray) {
const EBML = [ const EBML = [
{ {
'id': 0x1a45dfa3, // EBML id: 0x1a45dfa3, // EBML
'data': [ data: [
{ {
'data': 1, data: 1,
'id': 0x4286 // EBMLVersion id: 0x4286 // EBMLVersion
}, },
{ {
'data': 1, data: 1,
'id': 0x42f7 // EBMLReadVersion id: 0x42f7 // EBMLReadVersion
}, },
{ {
'data': 4, data: 4,
'id': 0x42f2 // EBMLMaxIDLength id: 0x42f2 // EBMLMaxIDLength
}, },
{ {
'data': 8, data: 8,
'id': 0x42f3 // EBMLMaxSizeLength id: 0x42f3 // EBMLMaxSizeLength
}, },
{ {
'data': 'webm', data: 'webm',
'id': 0x4282 // DocType id: 0x4282 // DocType
}, },
{ {
'data': 2, data: 2,
'id': 0x4287 // DocTypeVersion id: 0x4287 // DocTypeVersion
}, },
{ {
'data': 2, data: 2,
'id': 0x4285 // DocTypeReadVersion id: 0x4285 // DocTypeReadVersion
} }
] ]
}, },
{ {
'id': 0x18538067, // Segment id: 0x18538067, // Segment
'data': [ data: [
{ {
'id': 0x1549a966, // Info id: 0x1549a966, // Info
'data': [ data: [
{ {
'data': 1e6, // do things in millisecs (num of nanosecs for duration scale) data: 1e6, // do things in millisecs (num of nanosecs for duration scale)
'id': 0x2ad7b1 // TimecodeScale id: 0x2ad7b1 // TimecodeScale
}, },
{ {
'data': 'whammy', data: 'whammy',
'id': 0x4d80 // MuxingApp id: 0x4d80 // MuxingApp
}, },
{ {
'data': 'whammy', data: 'whammy',
'id': 0x5741 // WritingApp id: 0x5741 // WritingApp
}, },
{ {
'data': doubleToString(info.duration), data: doubleToString(info.duration),
'id': 0x4489 // Duration id: 0x4489 // Duration
} }
] ]
}, },
{ {
'id': 0x1654ae6b, // Tracks id: 0x1654ae6b, // Tracks
'data': [ data: [
{ {
'id': 0xae, // TrackEntry id: 0xae, // TrackEntry
'data': [ data: [
{ {
'data': 1, data: 1,
'id': 0xd7 // TrackNumber id: 0xd7 // TrackNumber
}, },
{ {
'data': 1, data: 1,
'id': 0x73c5 // TrackUID id: 0x73c5 // TrackUID
}, },
{ {
'data': 0, data: 0,
'id': 0x9c // FlagLacing id: 0x9c // FlagLacing
}, },
{ {
'data': 'und', data: 'und',
'id': 0x22b59c // Language id: 0x22b59c // Language
}, },
{ {
'data': 'V_VP8', data: 'V_VP8',
'id': 0x86 // CodecID id: 0x86 // CodecID
}, },
{ {
'data': 'VP8', data: 'VP8',
'id': 0x258688 // CodecName id: 0x258688 // CodecName
}, },
{ {
'data': 1, data: 1,
'id': 0x83 // TrackType id: 0x83 // TrackType
}, },
{ {
'id': 0xe0, // Video id: 0xe0, // Video
'data': [ data: [
{ {
'data': info.width, data: info.width,
'id': 0xb0 // PixelWidth id: 0xb0 // PixelWidth
}, },
{ {
'data': info.height, data: info.height,
'id': 0xba // PixelHeight id: 0xba // PixelHeight
} }
] ]
} }
@ -146,8 +146,8 @@ function ToWebM (frames, outputAsArray) {
] ]
}, },
{ {
'id': 0x1c53bb6b, // Cues id: 0x1c53bb6b, // Cues
'data': [ data: [
// cue insertion point // cue insertion point
] ]
} }
@ -165,23 +165,23 @@ function ToWebM (frames, outputAsArray) {
let clusterTimecode = 0; let clusterTimecode = 0;
while (frameNumber < frames.length) { while (frameNumber < frames.length) {
const cuePoint = { const cuePoint = {
'id': 0xbb, // CuePoint id: 0xbb, // CuePoint
'data': [ data: [
{ {
'data': Math.round(clusterTimecode), data: Math.round(clusterTimecode),
'id': 0xb3 // CueTime id: 0xb3 // CueTime
}, },
{ {
'id': 0xb7, // CueTrackPositions id: 0xb7, // CueTrackPositions
'data': [ data: [
{ {
'data': 1, data: 1,
'id': 0xf7 // CueTrack id: 0xf7 // CueTrack
}, },
{ {
'data': 0, // to be filled in when we know it data: 0, // to be filled in when we know it
'size': 8, size: 8,
'id': 0xf1 // CueClusterPosition id: 0xf1 // CueClusterPosition
} }
] ]
} }
@ -200,11 +200,11 @@ function ToWebM (frames, outputAsArray) {
let clusterCounter = 0; let clusterCounter = 0;
const cluster = { const cluster = {
'id': 0x1f43b675, // Cluster id: 0x1f43b675, // Cluster
'data': [ data: [
{ {
'data': Math.round(clusterTimecode), data: Math.round(clusterTimecode),
'id': 0xe7 // Timecode id: 0xe7 // Timecode
} }
].concat(clusterFrames.map(function (webp) { ].concat(clusterFrames.map(function (webp) {
const block = makeSimpleBlock({ const block = makeSimpleBlock({

789
yarn.lock

File diff suppressed because it is too large Load diff