Fixes shell/fetch regression
This commit is contained in:
parent
7cd88eca14
commit
804c688a46
@ -1,16 +1,18 @@
|
||||
{
|
||||
"tasks": {
|
||||
"clean": "rm -rf dist dist_client_bundle dist_plug_bundle website_build",
|
||||
"deep-clean-mac": "rm -f deno.lock && rm -rf $HOME/Library/Caches/deno && deno task clean",
|
||||
"install": "deno install -f -A --importmap import_map.json silverbullet.ts",
|
||||
"check": "find . -name '*.ts*' | xargs deno check",
|
||||
"test": "deno test -A --unstable",
|
||||
"build": "deno run -A build_plugs.ts && deno run -A --unstable build_web.ts",
|
||||
"plugs": "deno run -A build_plugs.ts",
|
||||
"watch-web": "deno run -A --check build_web.ts --watch",
|
||||
"server": "deno run -A --check silverbullet.ts",
|
||||
|
||||
"watch-web": "deno run -A --check build_web.ts --watch",
|
||||
"watch-server": "deno run -A --check --watch silverbullet.ts",
|
||||
// The only reason to run a shell script is that deno task doesn't support globs yet (e.g. *.plug.yaml)
|
||||
"watch-plugs": "deno run -A --check build_plugs.ts -w",
|
||||
|
||||
"bundle": "deno run -A build_bundle.ts",
|
||||
// Regenerates some bundle files (checked into the repo)
|
||||
// Install lezer-generator with "npm install -g @lezer/generator"
|
||||
|
@ -562,6 +562,19 @@ export class Client {
|
||||
}
|
||||
|
||||
focus() {
|
||||
const viewState = this.ui.viewState;
|
||||
if (
|
||||
[
|
||||
viewState.showCommandPalette,
|
||||
viewState.showPageNavigator,
|
||||
viewState.showFilterBox,
|
||||
viewState.showConfirm,
|
||||
viewState.showPrompt,
|
||||
].some(Boolean)
|
||||
) {
|
||||
// Some other modal UI element is visible, don't focus editor now
|
||||
return;
|
||||
}
|
||||
this.editorView!.focus();
|
||||
}
|
||||
|
||||
|
@ -126,12 +126,12 @@ export class ClientSystem {
|
||||
// Syscalls that require some additional permissions
|
||||
this.system.registerSyscalls(
|
||||
["fetch"],
|
||||
sandboxFetchSyscalls(this.editor.remoteSpacePrimitives),
|
||||
sandboxFetchSyscalls(this.editor),
|
||||
);
|
||||
|
||||
this.system.registerSyscalls(
|
||||
["shell"],
|
||||
shellSyscalls(this.editor.remoteSpacePrimitives),
|
||||
shellSyscalls(this.editor),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
import type { SysCallMapping } from "../../plugos/system.ts";
|
||||
import type { HttpSpacePrimitives } from "../../common/spaces/http_space_primitives.ts";
|
||||
import {
|
||||
performLocalFetch,
|
||||
ProxyFetchRequest,
|
||||
ProxyFetchResponse,
|
||||
} from "../../common/proxy_fetch.ts";
|
||||
import type { Client } from "../client.ts";
|
||||
|
||||
export function sandboxFetchSyscalls(
|
||||
httpSpacePrimitives?: HttpSpacePrimitives,
|
||||
client: Client,
|
||||
): SysCallMapping {
|
||||
return {
|
||||
"sandboxFetch.fetch": async (
|
||||
@ -16,12 +16,12 @@ export function sandboxFetchSyscalls(
|
||||
options: ProxyFetchRequest,
|
||||
): Promise<ProxyFetchResponse> => {
|
||||
// console.log("Got sandbox fetch ", url);
|
||||
if (!httpSpacePrimitives) {
|
||||
if (!client.remoteSpacePrimitives) {
|
||||
// No SB server to proxy the fetch available so let's execute the request directly
|
||||
return performLocalFetch(url, options);
|
||||
}
|
||||
const resp = httpSpacePrimitives.authenticatedFetch(
|
||||
`${httpSpacePrimitives.url}/.rpc`,
|
||||
const resp = client.remoteSpacePrimitives.authenticatedFetch(
|
||||
`${client.remoteSpacePrimitives.url}/.rpc`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { HttpSpacePrimitives } from "../../common/spaces/http_space_primitives.ts";
|
||||
import { SysCallMapping } from "../../plugos/system.ts";
|
||||
import type { Client } from "../client.ts";
|
||||
|
||||
export function shellSyscalls(
|
||||
httpSpacePrimitives?: HttpSpacePrimitives,
|
||||
client: Client,
|
||||
): SysCallMapping {
|
||||
return {
|
||||
"shell.run": async (
|
||||
@ -10,11 +10,11 @@ export function shellSyscalls(
|
||||
cmd: string,
|
||||
args: string[],
|
||||
): Promise<{ stdout: string; stderr: string; code: number }> => {
|
||||
if (!httpSpacePrimitives) {
|
||||
if (!client.remoteSpacePrimitives) {
|
||||
throw new Error("Not supported in fully local mode");
|
||||
}
|
||||
const resp = httpSpacePrimitives.authenticatedFetch(
|
||||
`${httpSpacePrimitives.url}/.rpc`,
|
||||
const resp = client.remoteSpacePrimitives.authenticatedFetch(
|
||||
`${client.remoteSpacePrimitives.url}/.rpc`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
|
Loading…
Reference in New Issue
Block a user