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