Skip to content

Commit

Permalink
more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
crcn committed Sep 26, 2022
1 parent b06d04a commit 5191c19
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
14 changes: 7 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
"name": "Paperclip",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}/libs/vscode-extension",
"runtimeExecutable": "${execPath}/integrations/vscode",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/libs/vscode-extension"
"--extensionDevelopmentPath=${workspaceFolder}/integrations/vscode"
]
},
{
"name": "Paperclip Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}/libs/vscode-extension",
"runtimeExecutable": "${execPath}/integrations/vscode",

"args": [
"${workspaceFolder}/libs/vscode-extension/src/test/all/fixtures",
"--extensionDevelopmentPath=${workspaceFolder}/packages/vscode-extension",
"--extensionTestsPath=${workspaceFolder}/packages/vscode-extension/lib/test"
"${workspaceFolder}/integrations/vscode/src/test/all/fixtures",
"--extensionDevelopmentPath=${workspaceFolder}/integrations/vscode",
"--extensionTestsPath=${workspaceFolder}/integrations/vscode/lib/test"
],
"outFiles": [
"${workspaceFolder}/packages/vscode-extension/lib/test/**/*-test.js"
"${workspaceFolder}/integrations/vscode/lib/test/**/*-test.js"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions integrations/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"lint": "eslint src",
"build:watch": "concurrently \"tsc --watch --preserveWatchOutput\" \"npm run build:syntaxes:watch\"",
"prepublishOnly": "npm run build",
"publish:local": "rm -rf node_modules && npm install && vsce package && vsce publish",
"publish:marketplace": "rm -rf node_modules && npm install && vsce package && vsce publish -p $VSCE_TOKEN"
"publish:local": "rm -rf node_modules && npm install && vsce package --no-yarn && vsce publish",
"publish:marketplace": "rm -rf node_modules && npm install && vsce package --no-yarn && vsce publish -p $VSCE_TOKEN"
},
"author": "",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const startDesignServer = async () => {
const binPath = await loadCLIBinPath("/tmp/paperclip");
console.log(binPath);

execa(binPath, [`designer`, `--port`, port], {
execa(binPath, [`designer`, `--port`, String(port)], {
stdio: "inherit",
});

Expand Down
23 changes: 12 additions & 11 deletions integrations/vscode/src/extension/preview/live-window.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { window, WebviewPanel, ViewColumn } from "vscode";
import { window, WebviewPanel, ViewColumn, env, Uri } from "vscode";
import * as path from "path";
import { ObservableMap, Store } from "@paperclip-ui/common";
import { EventEmitter } from "events";
Expand Down Expand Up @@ -95,7 +95,7 @@ export class LiveWindow {
}
};

private _render() {
private async _render() {
const state = this.getState();

this._panel.title = `⚡️ ${
Expand All @@ -105,12 +105,19 @@ export class LiveWindow {
}`;

this._panel.webview.html = "";
this._panel.webview.html = this._getHTML();
this._panel.webview.html = await this._getHTML();
}

private _getHTML() {
private async _getHTML() {
const state = this.getState();

// For Codespace
const designerHost = await env.asExternalUri(
Uri.parse(`http://localhost:${this._devServerPort}`)
);

console.log(`Opening preview: ${designerHost}`);

return `<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -167,12 +174,6 @@ export class LiveWindow {
const vscode = acquireVsCodeApi();
const initialState = ${JSON.stringify(state)};
vscode.setState(initialState);
const designServerHost = "localhost:${this._devServerPort}";
const protocol = "http:";
const designServerUrl = protocol + "//" + designServerHost;
</script>
</head>
Expand All @@ -181,7 +182,7 @@ export class LiveWindow {
</body>
<script>
const iframe = document.createElement("iframe");
iframe.src = designServerUrl + "?${qs.stringify(state.location.query)}";
iframe.src = "${designerHost}?${qs.stringify(state.location.query)}";
Object.assign(iframe.style, {
width: "100vw",
height: "100wh",
Expand Down
2 changes: 2 additions & 0 deletions libs/designer/src/server/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub fn routes() -> impl Filter<Extract = (StaticFile,), Error = Rejection> + Clo

fn path_from_tail() -> impl Filter<Extract = (String,), Error = Rejection> + Clone {
tail().and_then(move |tail: Tail| {
println!("tailing from file");
future::ready::<Result<String, Rejection>>(Ok(tail.as_str().to_string()))
})
}
Expand All @@ -51,6 +52,7 @@ pub async fn static_file_reply(
if let Some(file) = file {
return Ok(StaticFile(&file));
} else {
println!("File {} not found", path);
}
Err(warp::reject::not_found())
}
4 changes: 2 additions & 2 deletions libs/designer/src/server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ pub async fn start<IO: ProjectIO + 'static>(

let server = Server::bind(&addr).serve(make_service_fn(move |_| {

let cors = warp::cors().allow_any_origin();
println!("request made");

// let route = warp::fs::dir(get_designer_path()).with(cors);
let cors = warp::cors().allow_any_origin();
let route = routes().with(cors);

let mut warp = warp::service(route);
Expand Down

0 comments on commit 5191c19

Please sign in to comment.