pear-electron 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +808 -0
- package/bin.js +36 -0
- package/boot.js +31 -0
- package/decal.html +733 -0
- package/electron-main.js +112 -0
- package/fonts.css +82 -0
- package/gui/decal.js +2 -0
- package/gui/gui.js +1814 -0
- package/gui/index.js +2 -0
- package/gui/preload.js +366 -0
- package/index.js +3 -0
- package/lib/bootstrap.js +155 -0
- package/lib/bundle.js +33 -0
- package/package.json +101 -0
- package/preload.js +348 -0
- package/runtime.js +123 -0
- package/scripts/bootstrap.js +20 -0
- package/scripts/bundle.js +3 -0
- package/scripts/decal.js +28 -0
package/bin.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env pear run -f
|
|
2
|
+
/* global Pear, Bare */
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const { runtimes } = Pear.config.entrypoint.startsWith('/node_modules/.bin')
|
|
5
|
+
? require('../pear-electron/package.json').pear
|
|
6
|
+
: require('./package.json').pear
|
|
7
|
+
const IPC = require('pear-ipc')
|
|
8
|
+
const { encode } = require('hypercore-id-encoding')
|
|
9
|
+
const { PLATFORM_LOCK, SOCKET_PATH, CONNECT_TIMEOUT } = require('pear-api/constants')
|
|
10
|
+
const tryboot = require('pear-api/tryboot')
|
|
11
|
+
const link = require('pear-link')()
|
|
12
|
+
|
|
13
|
+
async function pearElectron () {
|
|
14
|
+
const { protocol, drive } = link(runtimes)
|
|
15
|
+
|
|
16
|
+
const opts = {
|
|
17
|
+
id: Bare.pid,
|
|
18
|
+
link: protocol + '//' + encode(drive.key) + '/by-arch/',
|
|
19
|
+
dir: path.join(new URL(Pear.config.applink).pathname, 'node_modules', 'pear-electron'),
|
|
20
|
+
// checkout: drive.length,
|
|
21
|
+
force: true
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
const ipc = new IPC.Client({
|
|
25
|
+
lock: PLATFORM_LOCK,
|
|
26
|
+
socketPath: SOCKET_PATH,
|
|
27
|
+
connectTimeout: CONNECT_TIMEOUT,
|
|
28
|
+
connect: tryboot
|
|
29
|
+
})
|
|
30
|
+
await ipc.ready()
|
|
31
|
+
const stream = ipc.dump(opts)
|
|
32
|
+
for await (const output of stream) console.log(output)
|
|
33
|
+
await ipc.close()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
pearElectron().catch(console.error)
|
package/boot.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @typedef {import('pear-interface')} */
|
|
2
|
+
'use strict'
|
|
3
|
+
const RUNTIME_INFO = JSON.parse(process.argv[process.argv.indexOf('--runtime-info') + 1])
|
|
4
|
+
class API {
|
|
5
|
+
static CHECKOUT = RUNTIME_INFO.checkout
|
|
6
|
+
static MOUNT = RUNTIME_INFO.mount
|
|
7
|
+
static get CONSTANTS () { return require('pear-api/constants') }
|
|
8
|
+
config = {}
|
|
9
|
+
}
|
|
10
|
+
global.Pear = new API()
|
|
11
|
+
const { isElectron, isElectronRenderer, isElectronWorker } = require('which-runtime')
|
|
12
|
+
const BOOT_ELECTRON_MAIN = 1
|
|
13
|
+
const BOOT_ELECTRON_PRELOAD = 2
|
|
14
|
+
switch (getBootType()) {
|
|
15
|
+
case BOOT_ELECTRON_MAIN: {
|
|
16
|
+
require('./electron-main.js')
|
|
17
|
+
break
|
|
18
|
+
}
|
|
19
|
+
case BOOT_ELECTRON_PRELOAD: {
|
|
20
|
+
require('./preload.js')
|
|
21
|
+
break
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getBootType () {
|
|
26
|
+
if (isElectron) {
|
|
27
|
+
return (isElectronRenderer || isElectronWorker)
|
|
28
|
+
? BOOT_ELECTRON_PRELOAD
|
|
29
|
+
: BOOT_ELECTRON_MAIN
|
|
30
|
+
}
|
|
31
|
+
}
|