diff --git a/common/spaces/http_space_primitives.ts b/common/spaces/http_space_primitives.ts index 732f1e98..ad68fa9d 100644 --- a/common/spaces/http_space_primitives.ts +++ b/common/spaces/http_space_primitives.ts @@ -15,7 +15,7 @@ export class HttpSpacePrimitives implements SpacePrimitives { private async authenticatedFetch( url: string, - options: any + options: any, ): Promise { if (this.token) { options.headers = options.headers || {}; @@ -40,7 +40,7 @@ export class HttpSpacePrimitives implements SpacePrimitives { async readFile( name: string, - encoding: FileEncoding + encoding: FileEncoding, ): Promise<{ data: FileData; meta: FileMeta }> { let res = await this.authenticatedFetch(`${this.fsUrl}/${name}`, { method: "GET", @@ -76,7 +76,7 @@ export class HttpSpacePrimitives implements SpacePrimitives { name: string, encoding: FileEncoding, data: FileData, - selfUpdate?: boolean + selfUpdate?: boolean, ): Promise { let body: any = null; @@ -122,9 +122,9 @@ export class HttpSpacePrimitives implements SpacePrimitives { private responseToMeta(name: string, res: Response): FileMeta { return { name, - size: +res.headers.get("Content-length")!, + size: +res.headers.get("X-Content-Length")!, contentType: res.headers.get("Content-type")!, - lastModified: +(res.headers.get("Last-Modified") || "0"), + lastModified: +(res.headers.get("X-Last-Modified") || "0"), perm: (res.headers.get("X-Permission") as "rw" | "ro") || "rw", }; } @@ -140,7 +140,7 @@ export class HttpSpacePrimitives implements SpacePrimitives { "Content-type": "application/json", }, body: JSON.stringify(args), - } + }, ); if (req.status !== 200) { let error = await req.text(); @@ -156,7 +156,7 @@ export class HttpSpacePrimitives implements SpacePrimitives { plug: Plug, env: string, name: string, - args: any[] + args: any[], ): Promise { // Invoke locally if (!env || env === "client") { @@ -171,7 +171,7 @@ export class HttpSpacePrimitives implements SpacePrimitives { "Content-type": "application/json", }, body: JSON.stringify(args), - } + }, ); if (req.status !== 200) { let error = await req.text(); diff --git a/server/http_server.ts b/server/http_server.ts index 1905eb42..79130bd9 100644 --- a/server/http_server.ts +++ b/server/http_server.ts @@ -39,6 +39,7 @@ import spaceSyscalls from "./syscalls/space.ts"; import { systemSyscalls } from "./syscalls/system.ts"; import { AssetBundlePlugSpacePrimitives } from "../common/spaces/asset_bundle_space_primitives.ts"; import assetSyscalls from "../plugos/syscalls/asset.ts"; +import { FlashServer } from "https://deno.land/x/oak@v11.1.0/mod.ts"; export type ServerOptions = { port: number; @@ -65,7 +66,7 @@ export class HttpServer { constructor(options: ServerOptions) { this.port = options.port; - this.app = new Application(); + this.app = new Application(); //{ serverConstructor: FlashServer }); this.assetBundle = options.assetBundle; this.password = options.password; @@ -247,11 +248,11 @@ export class HttpServer { // Simple password authentication if (this.password) { - this.app.use(({ request, response }, next) => { + this.app.use(async ({ request, response }, next) => { if ( request.headers.get("Authorization") === `Bearer ${this.password}` ) { - return next(); + await next(); } else { response.status = 401; response.body = "Unauthorized"; @@ -407,7 +408,7 @@ function buildFsRouter(spacePrimitives: SpacePrimitives): Router { ); response.status = 200; response.headers.set( - "Last-Modified", + "X-Last-Modified", "" + attachmentData.meta.lastModified, ); response.headers.set("X-Permission", attachmentData.meta.perm); @@ -431,9 +432,9 @@ function buildFsRouter(spacePrimitives: SpacePrimitives): Router { false, ); response.status = 200; - response.headers.set("Last-Modified", "" + meta.lastModified); response.headers.set("Content-Type", meta.contentType); - response.headers.set("Content-Length", "" + meta.size); + response.headers.set("X-Last-Modified", "" + meta.lastModified); + response.headers.set("X-Content-Length", "" + meta.size); response.headers.set("X-Permission", meta.perm); response.body = "OK"; } catch (err) { @@ -441,18 +442,21 @@ function buildFsRouter(spacePrimitives: SpacePrimitives): Router { response.body = "Write failed"; console.error("Pipeline failed", err); } + console.log("Done with put", name); }) - .options("\/(.+)", async ({ response, params }, next) => { + .options("\/(.+)", async ({ response, params }) => { const name = params[0]; try { const meta = await spacePrimitives.getFileMeta(name); response.status = 200; - response.headers.set("Last-Modified", "" + meta.lastModified); response.headers.set("Content-Type", meta.contentType); - response.headers.set("Content-Length", "" + meta.size); + response.headers.set("X-Last-Modified", "" + meta.lastModified); + response.headers.set("X-Content-Length", "" + meta.size); response.headers.set("X-Permission", meta.perm); - } catch { - next(); + } catch (err) { + response.status = 500; + response.body = "Options failed"; + console.error("Options failed", err); } }) .delete("\/(.+)", async ({ response, params }) => { diff --git a/server/server.ts b/server/server.ts index db30c4f1..31172395 100755 --- a/server/server.ts +++ b/server/server.ts @@ -23,7 +23,7 @@ const port = +args.port; import assetBundle from "../dist/asset_bundle.json" assert { type: "json" }; import { AssetBundle } from "../plugos/asset_bundle_reader.ts"; -console.log("Pages dir", pagesPath); +console.log("Pages folder:", pagesPath); const httpServer = new HttpServer({ port: port, diff --git a/web/editor.tsx b/web/editor.tsx index c570f502..5a6b0211 100644 --- a/web/editor.tsx +++ b/web/editor.tsx @@ -272,9 +272,6 @@ export class Editor { save(immediate = false): Promise { return new Promise((resolve, reject) => { - if (!this.viewState.unsavedChanges) { - return resolve(); - } if (this.saveTimeout) { clearTimeout(this.saveTimeout); } diff --git a/website/CHANGELOG.md b/website/CHANGELOG.md index 3d5e941a..c4460aac 100644 --- a/website/CHANGELOG.md +++ b/website/CHANGELOG.md @@ -1,5 +1,25 @@ An attempt at documenting of the changes/new features introduced in each release. +--- +## Deno release +* The entire repo has been migrated to [Deno](https://deno.land) +* This may temporarily break some things. +* If somehow you’re experiencing trouble, try the following: + * Delete all files under `_plug` in your pages folder, e.g. with `rm -rf pages/_plug`. + * Delete your `data.db` +* Changes: + * `PLUGS` is now longer required + * `PLUGS` no longer supports `builtin:` plug URLs, all builtins are automatically loaded and no longer should be listed. +* Plugs no longer should be built with node and npm, PRs will be issued to all existing plugs later to help with this transition. +* Know breakages: + * Full text search is not yet implemented (the SQLite used does not support it right now) + * Github auth has not been ported (yet) +* Technical changes: + * Server runs on Deno (and Oak instead of Express) + * Client is now built with ESBuild + * React has been replaced with Preact + * Package management in Deno works based on http imports, so npm is no longer used. + --- ## 0.0.35 @@ -66,4 +86,4 @@ An attempt at documenting of the changes/new features introduced in each release 4. The currently open page (at the bottom) * Filter boxes (used for the page switching and command palette among other things) now also support PgUp, PgDown, Home and End and have some visual glitches fixed as well. * Reverted exposing an empty `window` object to sandboxes running in workers and node.js (introduced in 0.0.28) -* Renamed Markdown-preview related commands to something more consistent \ No newline at end of file +* Renamed Markdown-preview related commands to something more consistentnt \ No newline at end of file diff --git a/website/_headers b/website/_headers index c596b537..d1d18510 100644 --- a/website/_headers +++ b/website/_headers @@ -1,8 +1,8 @@ /fs/_plug/* Content-Type: application/json - Last-Modified: 0 + X-Last-Modified: 0 X-Permission: ro /fs/* Content-Type: text/markdown - Last-Modified: 0 + X-Last-Modified: 0 X-Permission: rw