mirror of
https://github.com/MercuryWorkshop/anuraOS.git
synced 2025-09-04 17:19:24 +00:00
regedit nested key fix and logger streams
This commit is contained in:
@@ -314,6 +314,39 @@ let win = anura.wm.createGeneric("Example Window");
|
||||
// do stuff with the window that gets returned
|
||||
```
|
||||
|
||||
## anura.logger
|
||||
|
||||
This API provides a logger for Anura, which just wraps the console object.
|
||||
|
||||
### Functions
|
||||
|
||||
#### Wrapper Functions
|
||||
|
||||
| Function | Description |
|
||||
| -------------------- | --------------------- |
|
||||
| `anura.logger.log` | Wraps `console.log` |
|
||||
| `anura.logger.debug` | Wraps `console.debug` |
|
||||
| `anura.logger.info` | Wraps `console.info` |
|
||||
| `anura.logger.warn` | Wraps `console.warn` |
|
||||
| `anura.logger.error` | Wraps `console.error` |
|
||||
|
||||
#### anura.logger.createStreams(prefix?: string): `{stdout: WritableStream, stderr: WritableStream}`
|
||||
|
||||
This function creates a pair of writable streams that processes can be piped to
|
||||
for console output. The prefix argument is optional and will be prepended to all
|
||||
log messages.
|
||||
|
||||
**Usage:**
|
||||
|
||||
```js
|
||||
const { stdout, stderr } = anura.logger.createStreams("my-process: ");
|
||||
|
||||
const proc = await anura.processes.execute("/path/to/script.ajs");
|
||||
|
||||
proc.stdout.pipeTo(stdout);
|
||||
proc.stderr.pipeTo(stderr);
|
||||
```
|
||||
|
||||
## anura.net
|
||||
|
||||
This API provides access to Anura's networking backend, for routing your requests through a [Wisp](https://github.com/MercuryWorkshop/wisp-protocol) compatible backend using [libcurl.js](https://github.com/ading2210/libcurl.js).\
|
||||
|
26
src/Anura.ts
26
src/Anura.ts
@@ -81,8 +81,34 @@ class Anura {
|
||||
logger = {
|
||||
log: console.log.bind(console, "anuraOS:"),
|
||||
debug: console.debug.bind(console, "anuraOS:"),
|
||||
info: console.info.bind(console, "anuraOS:"),
|
||||
warn: console.warn.bind(console, "anuraOS:"),
|
||||
error: console.error.bind(console, "anuraOS:"),
|
||||
|
||||
// Create a set of streams for stdio to pipe to, useful for debugging
|
||||
createStreams: (prefix?: string) => {
|
||||
const de = new TextEncoder();
|
||||
|
||||
return {
|
||||
stdout: new WritableStream({
|
||||
write: (message) => {
|
||||
if (typeof message !== "string") {
|
||||
message = new TextDecoder().decode(message);
|
||||
}
|
||||
console.log(`anuraOS: ${prefix ? `[${prefix}] ` : ""}${message}`);
|
||||
},
|
||||
}),
|
||||
|
||||
stderr: new WritableStream({
|
||||
write: (message) => {
|
||||
if (typeof message !== "string") {
|
||||
message = new TextDecoder().decode(message);
|
||||
}
|
||||
console.error(`anuraOS: ${prefix ? `[${prefix}] ` : ""}${message}`);
|
||||
},
|
||||
}),
|
||||
};
|
||||
},
|
||||
};
|
||||
async registerApp(app: App) {
|
||||
if (app.package in this.apps) {
|
||||
|
@@ -234,7 +234,9 @@ class RegEdit extends App {
|
||||
})
|
||||
.map((item: any) => (
|
||||
<tr>
|
||||
<td class="name">{item[0]}</td>
|
||||
<td class="name" title={item[0]}>
|
||||
{item[0]}
|
||||
</td>
|
||||
<td class="type">{typeof item[1]}</td>
|
||||
<td class="value">
|
||||
{typeof item[1] === "boolean" ? (
|
||||
@@ -243,10 +245,9 @@ class RegEdit extends App {
|
||||
type="checkbox"
|
||||
checked={item[1]}
|
||||
on:change={function (e: any) {
|
||||
const elements =
|
||||
e.srcElement.parentElement.children;
|
||||
console.log(item[0], e.srcElement.srcchecked);
|
||||
anura.settings.set(item[0], e.srcElement.checked);
|
||||
sel[item[0]] = e.srcElement.checked;
|
||||
anura.settings.save();
|
||||
}}
|
||||
/>
|
||||
<span></span>
|
||||
@@ -262,14 +263,8 @@ class RegEdit extends App {
|
||||
try {
|
||||
const parsed = JSON.parse(event.srcElement.value);
|
||||
|
||||
anura.settings.set(elements[0].innerText, parsed);
|
||||
|
||||
// anura.settings.cache[
|
||||
// elements[0].innerText
|
||||
// ] = JSON.parse(
|
||||
// elements[2].value,
|
||||
// );
|
||||
// anura.settings.save();
|
||||
sel[item[0]] = parsed;
|
||||
anura.settings.save();
|
||||
} catch (e) {
|
||||
elements[2].value = anura.settings.get(item[0]);
|
||||
anura.notifications.add({
|
||||
@@ -297,36 +292,27 @@ class RegEdit extends App {
|
||||
);
|
||||
|
||||
async open(): Promise<WMWindow | undefined> {
|
||||
let win: WMWindow | undefined;
|
||||
if (!anura.settings.get("disable-regedit-warning")) {
|
||||
anura.dialog
|
||||
.confirm(
|
||||
"Are you sure you want to continue?",
|
||||
"Editing the registry can cause irreparable damage to your system!",
|
||||
)
|
||||
.then(async (value) => {
|
||||
if (value === true) {
|
||||
win = anura.wm.create(this, {
|
||||
title: "Registry Editor",
|
||||
width: "910px",
|
||||
height: `${(720 * window.innerHeight) / 1080}px`,
|
||||
resizable: true,
|
||||
});
|
||||
|
||||
win.content.appendChild(await this.page());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
win = anura.wm.create(this, {
|
||||
title: "Registry Editor",
|
||||
width: "910px",
|
||||
height: `${(720 * window.innerHeight) / 1080}px`,
|
||||
resizable: true,
|
||||
});
|
||||
|
||||
win.content.appendChild(await this.page());
|
||||
if (
|
||||
!anura.settings.get("disable-regedit-warning") &&
|
||||
!(await anura.dialog.confirm(
|
||||
"Are you sure you want to continue?",
|
||||
"Editing the registry can cause irreparable damage to your system!",
|
||||
))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
anura.settings.set("disable-regedit-warning", true);
|
||||
|
||||
const win = anura.wm.create(this, {
|
||||
title: "Registry Editor",
|
||||
width: "910px",
|
||||
height: `${(720 * window.innerHeight) / 1080}px`,
|
||||
resizable: true,
|
||||
});
|
||||
|
||||
win.content.appendChild(await this.page());
|
||||
|
||||
return win;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user