Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/terminal/bare-v8/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
getHeapSpaceStatistics: () => {
const err = new Error('Not implemented')
err.code = 'ERR_NOT_IMPLEMENTED'
throw err
}
}
5 changes: 5 additions & 0 deletions examples/terminal/bare-v8/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "bare-v8",
"version": "1.0.0",
"main": "index.js"
}
13 changes: 13 additions & 0 deletions examples/terminal/imports.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"crypto": "bare-crypto",
"events": "bare-events",
"fs": "bare-fs",
"http": "bare-http1",
"https": "bare-https",
"os": "bare-os",
"process": "bare-process",
"url": "bare-url",
"util": "bare-utils",
"v8": "bare-v8",
"zlib": "bare-zlib"
}
36 changes: 3 additions & 33 deletions examples/terminal/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
/** @typedef {import('pear-interface')} */ /* global Pear */
const { config, versions } = Pear
const [grn, rst, dim] = ['\x1b[32m', '\x1b[0m', '\x1b[2m']
const v = ({ key, length, fork }) => `v${fork}.${length}.${(key += '').length <= 12 ? key : key.slice(0, 12) + '…'}`
const { app, platform } = await versions()
const out = `${grn} ▅
▂▂▄▟▙▃
▄▄▄▄▆▆▆▆ ${config.name}
▄▄▄▄▄▆▆▆▆▆ ${dim}${v(app)}${rst}${grn}
▄▄▄▄▄▆▆▆▆▆
▄▄▄▄▄▄▆▆▆▆▆▆ ${rst}${grn}pear
▃▄▄▄▄▄▄▆▆▆▆▆▆▄ ${dim}${v(platform)}${rst}${grn}
▄▄▄▄▄▄▄▄▆▆▆▆▆▆▆▆
▄▄▄▄▄▄▄▄▆▆▆▆▆▆▆▆ ${rst}${grn}Welcome to the IoP
▄▄▄▄▄▄▆▆▆▆▆▆
▄▄▄▄▆▆▆▆
`
console.log('\n\x1b[s\x1b[J' + out)

const pipe = Pear.worker.pipe()
const isWorker = pipe !== null
if (isWorker) {
pipe.on('data', (data) => {
const str = data.toString()
console.log('parent:', str)
if (str === 'hello') console.log('world')
if (str === 'exit') {
console.log('exiting')
Pear.exit()
}
})
}
require('bare-process/global')
const out = require('prom-client', { with: { imports: './imports.json' } })
console.log('🚀 ~ out:', out)
16 changes: 15 additions & 1 deletion examples/terminal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"pear": {
"name": "termex",
"type": "terminal",
Expand All @@ -15,5 +14,20 @@
"devDependencies": {
"brittle": "^3.0.0",
"pear-interface": "^1.0.0"
},
"dependencies": {
"bare-crypto": "^1.11.2",
"bare-events": "^2.6.1",
"bare-fs": "^4.3.1",
"bare-http1": "^4.0.4",
"bare-https": "^2.0.0",
"bare-os": "^3.6.2",
"bare-path": "^3.0.0",
"bare-process": "^4.2.1",
"bare-url": "^2.2.2",
"bare-utils": "^1.5.1",
"bare-v8": "file://./bare-v8",
"bare-zlib": "^1.3.1",
"prom-client": "^15.1.3"
}
}
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"crc-universal": "^1.0.4",
"db-lock": "^1.2.0",
"debounceify": "^1.1.0",
"dependency-stream": "github:maidh91/dependency-stream#support-bare-module",
"drive-analyzer": "^1.1.1",
"drive-bundler": "^2.4.4",
"framed-stream": "^1.0.1",
Expand Down Expand Up @@ -120,6 +121,7 @@
"rocksdb-native": "^3.5.8",
"safety-catch": "^1.0.2",
"script-linker": "^2.5.4",
"sloppy-module-parser": "github:maidh91/sloppy-module-parser#support-bare-module",
"sodium-native": "^5.0.0",
"streamx": "^2.22.0",
"tiny-byte-size": "^1.1.0",
Expand Down
Loading