Skip to content

Commit

Permalink
Merge branch 'main' into schema2
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiRegiani authored Nov 19, 2024
2 parents e192e1f + 9141cec commit e48c3fc
Show file tree
Hide file tree
Showing 84 changed files with 1,085 additions and 1,011 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ on:
- false
- true

run-name: Build ${{ inputs.channel }}

jobs:
build:
uses: holepunchto/actions/.github/workflows/keet-automation.yml@v1
Expand Down
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Pear Runtime Changelog

## v1.7.0

### Features

* CLI - `pear dump --dry-run` flag

### Fixes

Desktop - Fix Windows client restart
CLI - Fix broken stdin after Ctrl-C
Internal - Fix Pear-IPC unhandled error
Internal - Fix worker close on parent end

### Improvements

Internal - Removed `getMediaSourceId`
Internal - Removed terminal app reload and restart

## v1.6.0

### Features

* Internal - Added sidecar logs
* Performance - Added DHT persistent cache
* CLI - `pear dump --dry-run` flag

### Fixes

* Desktop - Forced teardown fix for Pear Desktop apps that take longer than 15 seconds to close
* Dependencies - udx-native updated to 1.13.3
* Internal - Block of spindown while platform is updating
* Desktop - Fix teardown of worker on app exit
* Desktop - Decal run from disk bug fix
* Desktop - Decal bar bug fix

### Improvements

* API - Removed deprecated preferences methods from Pear API
* Internal - Added RocksDB native support

## v1.5.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pear://pqbzjhqyonxprx8hghxexnmctw75mr91ewqw5dxe1zmntfyaddqy
### Stage Build

```
pear://fbdbkwt5yojdfidmqeh39tomepj348hn78xzwk181ecqr61jkzzo
pear://17g37zzfo3dnmchf57ixw93gpxcncjmfyzybf4tjo99xi55ewf7o
```

Note: Always use the production build unless you are sure of what you are doing. The stage build may introduce untested breaking changes that could affect other Pear apps.
Expand Down
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crasher('cli', SWAP)
cli()

async function cli () {
const ipc = new IPC({
const ipc = new IPC.Client({
lock: PLATFORM_LOCK,
socketPath: SOCKET_PATH,
connectTimeout: CONNECT_TIMEOUT,
Expand Down
6 changes: 3 additions & 3 deletions cmd/dump.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { outputter, permit, isTTY } = require('./iface')
const output = outputter('stage', {
dumping: ({ link, dir, list }) => list > -1 ? '' : `\n🍐 Dumping ${link} into ${dir}`,
file: ({ key, value }) => `${key}${value ? '\n' + value : ''}`,
complete: '\nDumping complete!\n',
complete: ({ dryRun }) => { return dryRun ? '\nDumping dry run complete!\n' : '\nDumping complete!\n' },
error: (err, info, ipc) => {
if (err.info && err.info.encrypted && info.ask && isTTY) {
return permit(ipc, err.info, 'dump')
Expand All @@ -19,11 +19,11 @@ const output = outputter('stage', {
})

module.exports = (ipc) => async function dump (cmd) {
const { checkout, json, encryptionKey, ask, force } = cmd.flags
const { dryRun, checkout, json, encryptionKey, ask, force } = cmd.flags
const { link } = cmd.args
let { dir } = cmd.args
if (!link) throw ERR_INVALID_INPUT('<link> must be specified.')
if (!dir) throw ERR_INVALID_INPUT('<dir> must be specified.')
dir = dir === '-' ? '-' : (isAbsolute(dir) ? dir : resolve('.', dir))
await output(json, ipc.dump({ id: Bare.pid, link, dir, checkout, encryptionKey, force }), { ask }, ipc)
await output(json, ipc.dump({ id: Bare.pid, link, dir, dryRun, checkout, encryptionKey, force }), { ask }, ipc)
}
2 changes: 1 addition & 1 deletion cmd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ module.exports = async (ipc, argv = Bare.argv.slice(1)) => {
arg('<channel|link>', 'Channel name or Pear link to stage'),
arg('[dir]', 'Project directory path (default: .)'),
flag('--dry-run|-d', 'Execute a stage without writing'),
flag('--bare|-b', 'File data only, no warmup optimization'),
flag('--ignore <list>', 'Comma separated file path ignore list'),
flag('--truncate <n>', 'Advanced. Truncate to version length n'),
flag('--name <name>', 'Advanced. Override app name'),
Expand Down Expand Up @@ -123,6 +122,7 @@ module.exports = async (ipc, argv = Bare.argv.slice(1)) => {
summary('Synchronize files from key to dir'),
arg('<link>', 'Pear link to dump from, supports pathname'),
arg('<dir>', 'Directory path to dump to, may be - for stdout'),
flag('--dry-run|-d', 'Execute a dump without writing'),
flag('--checkout <n>', 'Dump from specified checkout, n is version length'),
flag('--json', 'Newline delimited JSON output'),
flag('--force|-f', 'Force overwrite existing files'),
Expand Down
20 changes: 11 additions & 9 deletions decal.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
outline: none;
}
#bar {
background: #0D0F16;
background: #151517;
height: 50px;
padding-top: 12px;
padding-right: 8px;
Expand Down Expand Up @@ -492,12 +492,14 @@ <h1 id="header"></h1>
<script type="module">
import constants from './constants.js'
const hypercoreid = window[Symbol.for('hypercore-id-encoding')]
if (hypercoreid.normalize(Pear.config.key) !== hypercoreid.normalize(constants.ALIASES.keet)) {
if (Pear.config.options.platform?.__legacyTitlebar) {
document.getElementById('bar').style.display = 'block'
const winctrl = document.getElementById('window-controls')
const clone = winctrl.cloneNode()
global.winctrl = clone
if (Pear.config.key) {
if (hypercoreid.normalize(Pear.config.key) !== hypercoreid.normalize(constants.ALIASES.keet)) {
if (Pear.config.options.platform?.__legacyTitlebar) {
document.getElementById('bar').style.display = 'block'
const winctrl = document.getElementById('window-controls')
const clone = winctrl.cloneNode()
global.winctrl = clone
}
}
}
</script>
Expand Down Expand Up @@ -812,11 +814,11 @@ <h1 id="header"></h1>
}
show () {
this.shadowRoot.querySelector('#loader').style.display = 'block'
document.getElementById('bar').style.display = 'none'
document.getElementById('bar').style.display = 'block'
}
hide () {
this.shadowRoot.querySelector('#loader').style.display = 'none'
document.getElementById('bar').style.display = 'block'
document.getElementById('bar').style.display = 'none'
}
async restart () {
let countdown = 3000
Expand Down
1 change: 0 additions & 1 deletion def/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module.exports = [
flag('--encryption-key <name>', 'Application encryption key').hide(),
flag('--trusted').hide(),
flag('--detach').hide(),
flag('--trace <n>').hide(),
flag('--swap <path>').hide(),
flag('--start-id <id>').hide(),
flag('--sandbox').hide() // electron passthrough
Expand Down
5 changes: 0 additions & 5 deletions errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class PearError extends Error {
static ERR_UNSTAGED = ERR_UNSTAGED
static ERR_DIR_NONEMPTY = ERR_DIR_NONEMPTY
static ERR_OPERATION_FAILED = ERR_OPERATION_FAILED
static ERR_TRACER_FAILED = ERR_TRACER_FAILED
static ERR_HTTP_GONE = ERR_HTTP_GONE
static ERR_HTTP_BAD_REQUEST = ERR_HTTP_BAD_REQUEST
static ERR_HTTP_NOT_FOUND = ERR_HTTP_NOT_FOUND
Expand Down Expand Up @@ -127,10 +126,6 @@ function ERR_OPERATION_FAILED (msg) {
return new PearError(msg, 'ERR_OPERATION_FAILED', ERR_OPERATION_FAILED)
}

function ERR_TRACER_FAILED (msg) {
return new PearError(msg, 'ERR_TRACER_FAILED', ERR_TRACER_FAILED)
}

function ERR_ASSERTION (msg) {
return new PearError(msg, 'ERR_ASSERTION', ERR_ASSERTION)
}
Expand Down
3 changes: 3 additions & 0 deletions examples/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"height": 500,
"minWidth": 500,
"backgroundColor": "#1F2430"
},
"stage": {
"entrypoints": ["/app.js"]
}
},
"devDependencies": {
Expand Down
50 changes: 15 additions & 35 deletions gui/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const IPC = require('pear-ipc')
const ReadyResource = require('ready-resource')
const Worker = require('../lib/worker')
const constants = require('../constants')

const kMap = Symbol('pear.gui.map')
const kCtrl = Symbol('pear.gui.ctrl')

Expand Down Expand Up @@ -380,7 +379,9 @@ class App {
appReady = false
static root = unixPathResolve(resolve(__dirname, '..'))

constructor (state, ipc) {
constructor (gui) {
const { state, ipc } = gui
this.gui = gui
this.state = state
this.ipc = ipc
this.contextMenu = null
Expand Down Expand Up @@ -506,8 +507,8 @@ class App {
this.appReady = true
}

const { dev, devtools, trace, stage } = state
const show = (!trace && (dev || !stage))
const { dev, devtools, stage } = state
const show = (dev || !stage)
const unfilteredGuiOptions = state.options.gui || state.options

const guiOptions = {
Expand Down Expand Up @@ -583,17 +584,10 @@ class App {
},
afterNativeWindowClose: () => this.close(),
afterNativeViewCreated: devtools && ((app) => {
if (trace) return
app.view.webContents.openDevTools({ mode: 'detach' })
if (app.state.chromeWebrtcInternals) PearGUI.chrome('webrtc-internals')
}),
afterNativeViewLoaded: (trace
? async () => {
await new Promise((resolve) => setTimeout(resolve, 750)) // time for final blocks to be received
this.close()
this.quit()
}
: (isLinux ? (app) => linuxViewSize(app) : null)),
afterNativeViewLoaded: isLinux ? (app) => linuxViewSize(app) : null,
interload: async (app) => {
state.update({ top: app.win })
try {
Expand Down Expand Up @@ -647,16 +641,18 @@ class App {
resolve(false)
}
})

const unloaders = PearGUI.ctrls().map((ctrl) => {
const pipes = [...this.gui.pipes]
const closingPipes = pipes.map((pipe) => new Promise((resolve) => { pipe.once('close', resolve) }))
const unloaders = [closingPipes, ...PearGUI.ctrls().map((ctrl) => {
const closed = () => ctrl.closed
if (!ctrl.unload) {
if (ctrl.unloader) return ctrl.unloader.then(closed, closed)
return ctrl.close()
}
ctrl.unload({ type: 'close' })
return ctrl.unloader.then(closed, closed)
})
})]
for (const pipe of pipes) pipe.end()
const unloading = Promise.all(unloaders)
unloading.then(clear, clear)
const result = await Promise.race([timeout, unloading])
Expand Down Expand Up @@ -892,11 +888,6 @@ class GuiCtrl {
if (this.closed) return false
}

async getMediaSourceId () {
if (this.closed) throw Error(`Cannot get media source id if the ${this[kCtrl]} is closed`)
return (this.win && this.win.getMediaSourceId())
}

async dimensions (opts = null) {
if (this.closed) return null
const item = this[kCtrl] === 'view' ? this.view : this.win
Expand Down Expand Up @@ -1398,7 +1389,7 @@ class PearGUI extends ReadyResource {
constructor ({ socketPath, connectTimeout, tryboot, state }) {
super()
this.state = state
this.ipc = new IPC({
this.ipc = new IPC.Client({
lock: constants.PLATFORM_LOCK,
socketPath,
connectTimeout,
Expand Down Expand Up @@ -1474,7 +1465,6 @@ class PearGUI extends ReadyResource {
electron.ipcMain.handle('restore', (evt, ...args) => this.restore(...args))
electron.ipcMain.handle('focus', (evt, ...args) => this.focus(...args))
electron.ipcMain.handle('blur', (evt, ...args) => this.blur(...args))
electron.ipcMain.handle('getMediaSourceId', (evt, ...args) => this.getMediaSourceId(...args))
electron.ipcMain.handle('dimensions', (evt, ...args) => this.dimensions(...args))
electron.ipcMain.handle('isVisible', (evt, ...args) => this.isVisible(...args))
electron.ipcMain.handle('isClosed', (evt, ...args) => this.isClosed(...args))
Expand All @@ -1498,8 +1488,8 @@ class PearGUI extends ReadyResource {
electron.ipcMain.handle('versions', (evt, ...args) => this.versions(...args))
electron.ipcMain.handle('restart', (evt, ...args) => this.restart(...args))

electron.ipcMain.on('workerRun', (evt, link) => {
const pipe = this.worker.run(link)
electron.ipcMain.on('workerRun', (evt, link, args) => {
const pipe = this.worker.run(link, args)
const id = this.pipes.alloc(pipe)
pipe.on('close', () => {
this.pipes.free(id)
Expand Down Expand Up @@ -1529,16 +1519,10 @@ class PearGUI extends ReadyResource {
}
pipe.write(data)
})

electron.app.once('will-quit', () => {
for (const pipe of this.pipes) {
pipe.sp.kill('SIGTERM')
}
})
}

async app () {
const app = new App(this.state, this.ipc)
const app = new App(this)
this.once('close', async () => { app.quit() })
await app.start()
return app
Expand Down Expand Up @@ -1603,7 +1587,6 @@ class PearGUI extends ReadyResource {
hide () { return false },
focus () { return false },
blur () { return false },
getMediaSourceId () { return -1 },
dimensions () { return null },
maximize () { return false },
minimize () { return false },
Expand Down Expand Up @@ -1655,7 +1638,6 @@ class PearGUI extends ReadyResource {
if (act === 'show') return instance.show()
if (act === 'hide') return instance.hide()
if (act === 'dimensions') return instance.dimensions(...args)
if (act === 'getMediaSourceId') return instance.getMediaSourceId()
if (act === 'isClosed') return instance.isClosed()
if (act === 'isVisible') return instance.isVisible()
if (act === 'isMinimized') return instance.isMinimized()
Expand Down Expand Up @@ -1688,8 +1670,6 @@ class PearGUI extends ReadyResource {

blur ({ id }) { return this.get(id).blur() }

getMediaSourceId ({ id }) { return this.get(id).getMediaSourceId() }

dimensions ({ id, options }) { return this.get(id).dimensions(options) }

isVisible ({ id }) { return this.get(id).isVisible() }
Expand Down
4 changes: 0 additions & 4 deletions gui/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ module.exports = class PearGUI extends ReadyResource {
fullscreen () { return ipc.parent({ act: 'fullscreen', id: this.#id }) }
restore () { return ipc.parent({ act: 'restore', id: this.#id }) }
dimensions (options = null) { return ipc.parent({ act: 'dimensions', id: this.#id, options }) }
getMediaSourceId () { return ipc.parent({ act: 'getMediaSourceId', id: this.#id }) }
isVisible () { return ipc.parent({ act: 'isVisible', id: this.#id }) }
isMinimized () { return ipc.parent({ act: 'isMinimized', id: this.#id }) }
isMaximized () { return ipc.parent({ act: 'isMaximized', id: this.#id }) }
Expand All @@ -86,7 +85,6 @@ module.exports = class PearGUI extends ReadyResource {
fullscreen () { return ipc.fullscreen({ id: this.id }) }
restore () { return ipc.restore({ id: this.id }) }
close () { return ipc.close({ id: this.id }) }
getMediaSourceId () { return ipc.getMediaSourceId({ id: this.id }) }
dimensions (options = null) { return ipc.dimensions({ id: this.id, options }) }
isVisible () { return ipc.isVisible({ id: this.id }) }
isMinimized () { return ipc.isMinimized({ id: this.id }) }
Expand Down Expand Up @@ -162,7 +160,6 @@ module.exports = class PearGUI extends ReadyResource {
focus (options = null) { return ipc.focus({ id: this.id, options }) }
blur () { return ipc.blur({ id: this.id }) }

getMediaSourceId () { return ipc.getMediaSourceId({ id: this.id }) }
dimensions (options = null) { return ipc.dimensions({ id: this.id, options }) }
minimize () {
if (this.constructor[kGuiCtrl] === 'view') throw new Error('A View cannot be minimized')
Expand Down Expand Up @@ -241,7 +238,6 @@ class IPC {
restore (...args) { return electron.ipcRenderer.invoke('restore', ...args) }
focus (...args) { return electron.ipcRenderer.invoke('focus', ...args) }
blur (...args) { return electron.ipcRenderer.invoke('blur', ...args) }
getMediaSourceId (...args) { return electron.ipcRenderer.invoke('getMediaSourceId', ...args) }
dimensions (...args) { return electron.ipcRenderer.invoke('dimensions', ...args) }
isVisible (...args) { return electron.ipcRenderer.invoke('isVisible', ...args) }
isClosed (...args) { return electron.ipcRenderer.invoke('isClosed', ...args) }
Expand Down
Loading

0 comments on commit e48c3fc

Please sign in to comment.