Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PTY integration #756

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "submodules/v86"]
path = submodules/v86
url = [email protected]:copy/v86.git
[submodule "submodules/twisp"]
path = submodules/twisp
url = [email protected]:MercuryWorkshop/twisp.git
[submodule "submodules/epoxy-tls"]
path = submodules/epoxy-tls
url = [email protected]:MercuryWorkshop/epoxy-tls.git
3 changes: 3 additions & 0 deletions doc/devmeta/track-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ Comments beginning with `// track:`. See
It may be applicable to write an iterator in the
future, or something will come up that require
these to be handled with a modular approach instead.
- `track: checkpoint`
A location where some statement about the state of the
software must hold true.
8 changes: 8 additions & 0 deletions src/backend/src/modules/selfhosted/SelfHostedModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,18 @@ class SelfHostedModule extends AdvancedBase {
prefix: '/builtin/dev-center',
path: path_.resolve(__dirname, RELATIVE_PATH, 'src/dev-center'),
},
{
prefix: '/builtin/emulator/image',
path: path_.resolve(__dirname, RELATIVE_PATH, 'src/emulator/image'),
},
{
prefix: '/builtin/emulator',
path: path_.resolve(__dirname, RELATIVE_PATH, 'src/emulator/dist'),
},
{
prefix: '/vendor/v86/bios',
path: path_.resolve(__dirname, RELATIVE_PATH, 'submodules/v86/bios'),
},
{
prefix: '/vendor/v86',
path: path_.resolve(__dirname, RELATIVE_PATH, 'submodules/v86/build'),
Expand Down
4 changes: 3 additions & 1 deletion src/backend/src/om/entitystorage/SubdomainES.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class SubdomainES extends BaseES {
}
},
async upsert (entity, extra) {
await this._check_max_subdomains();
if ( ! extra.old_entity ) {
await this._check_max_subdomains();
}

return await this.upstream.upsert(entity, extra);
},
Expand Down
4 changes: 2 additions & 2 deletions src/backend/src/services/BaseService.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const { AdvancedBase } = require("../../../putility");
const { concepts } = require("@heyputer/putility");

const NOOP = async () => {};

class BaseService extends AdvancedBase {
class BaseService extends concepts.Service {
constructor (service_resources, ...a) {
const { services, config, my_config, name, args } = service_resources;
super(service_resources, ...a);
Expand Down
35 changes: 20 additions & 15 deletions src/backend/src/services/database/SqliteDatabaseAccessService.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,6 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {

this.db = new Database(this.config.path);

// Database upgrade logic
const HIGHEST_VERSION = 24;
const TARGET_VERSION = (() => {
const args = Context.get('args');
if ( args['database-target-version'] ) {
return parseInt(args['database-target-version']);
}
return HIGHEST_VERSION;
})();

const [{ user_version }] = do_setup
? [{ user_version: -1 }]
: await this._read('PRAGMA user_version');
this.log.info('database version: ' + user_version);

const upgrade_files = [];

const available_migrations = [
Expand Down Expand Up @@ -138,8 +123,28 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
[23, [
'0026_user-groups.dbmig.js',
]],
[24, [
'0027_emulator-app.dbmig.js',
]],
];

// Database upgrade logic
const HIGHEST_VERSION =
available_migrations[available_migrations.length - 1][0] + 1;
const TARGET_VERSION = (() => {
const args = Context.get('args');
if ( args['database-target-version'] ) {
return parseInt(args['database-target-version']);
}
return HIGHEST_VERSION;
})();

const [{ user_version }] = do_setup
? [{ user_version: -1 }]
: await this._read('PRAGMA user_version');
this.log.info('database version: ' + user_version);


for ( const [v_lt_or_eq, files] of available_migrations ) {
if ( v_lt_or_eq + 1 >= TARGET_VERSION && TARGET_VERSION !== HIGHEST_VERSION ) {
this.log.noticeme(`Early exit: target version set to ${TARGET_VERSION}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const insert = async (tbl, subject) => {
const keys = Object.keys(subject);

await write(
'INSERT INTO `'+ tbl +'` ' +
'(' + keys.map(key => key).join(', ') + ') ' +
'VALUES (' + keys.map(() => '?').join(', ') + ')',
keys.map(key => subject[key])
);
}

await insert('apps', {
uid: 'app-fbbdb72b-ad08-4cb4-86a1-de0f27cf2e1e',
owner_user_id: 1,
name: 'puter-linux',
index_url: 'https://builtins.namespaces.puter.com/emulator',
title: 'Puter Linux',
description: 'Linux emulator for Puter',
approved_for_listing: 1,
approved_for_opening_items: 1,
approved_for_incentive_program: 0,
timestamp: '2020-01-01 00:00:00',
});
29 changes: 29 additions & 0 deletions src/emulator/assets/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@

<script src="/puter.js/v2"></script>
<script src="/vendor/v86/libv86.js"></script>
<style>
div {
font-size: 12px;
line-height: 16px;
}
BODY {
padding: 0;
margin: 0;
background-color: #111;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
overflow: hidden;
background: linear-gradient(135deg, #232323 50%, transparent 50%) 0% 0% / 3em 3em #101010;
background-position: center center;
background-size: 5px 5px;
}
#screen_container {
padding: 5px;
background-color: #000;
box-shadow: 0 0 32px 0 rgba(0,0,0,0.7);
}
</style>
</head>
<body>

Expand All @@ -41,5 +65,10 @@
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
<% } %>

<div id="screen_container">
<div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
<canvas style="display: none"></canvas>
</div>

</body>
</html>
Loading