Skip to content

Commit 81b69d6

Browse files
authored
Merge branch 'main' into remove-ResolvedFreshConfig
2 parents 377ebd1 + cea7a2a commit 81b69d6

5 files changed

Lines changed: 13 additions & 143 deletions

File tree

src/config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as path from "@std/path";
2-
import type { Mode } from "./runtime/server/mod.ts";
32

43
export interface FreshConfig {
54
root: string;
@@ -16,9 +15,9 @@ export interface FreshConfig {
1615
basePath: string;
1716
staticDir: string;
1817
/**
19-
* Tells you in which mode Fresh is currently running in.
18+
* The mode Fresh can run in.
2019
*/
21-
mode: Mode;
20+
mode: "development" | "production";
2221
}
2322

2423
export function parseRootPath(root: string, cwd: string): string {

src/mod.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export {
1212
export type { RouteConfig } from "./types.ts";
1313
export type { Middleware, MiddlewareFn } from "./middlewares/mod.ts";
1414
export { staticFiles } from "./middlewares/static_files.ts";
15-
export type { Mode } from "./runtime/server/mod.ts";
1615
export type { FreshConfig } from "./config.ts";
1716
export type { FreshContext, Island, PageProps } from "./context.ts";
1817
export { createDefine, type Define } from "./define.ts";

src/runtime/server/mod.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

update/src/maybePrependReqVar.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

www/utils/screenshot.ts

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,30 @@
1-
import puppeteer from "npm:puppeteer@22.4.1";
2-
import { Image } from "https://deno.land/x/imagescript@1.2.17/mod.ts";
3-
import { join } from "@std/path";
1+
import puppeteer from "npm:puppeteer@24.7.2";
2+
import { Image } from "https://deno.land/x/imagescript@1.3.0/mod.ts";
43

5-
const url = Deno.args[0];
6-
const id = Deno.args[1];
7-
8-
if (Deno.args.length == 0) {
9-
// deno-lint-ignore no-console
10-
console.log("Usage: screenshot <url> <id>");
11-
Deno.exit(0);
12-
}
13-
14-
if (!(url.match(/^http[s]?:\/\//)) || !url) {
15-
// deno-lint-ignore no-console
16-
console.log("Provided URL is Broken or Wrong");
17-
Deno.exit(0);
4+
if (Deno.args.length !== 2) {
5+
throw new Error("Usage: screenshot <url> <id>");
186
}
197

20-
if (!id) {
21-
// deno-lint-ignore no-console
22-
console.log("Provide id to Process");
23-
Deno.exit(0);
8+
const [url, id] = Deno.args;
9+
const parsedUrl = new URL(url);
10+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
11+
throw new Error("Invalid URL");
2412
}
2513

26-
const outDir = "./www/static/showcase";
2714
const browser = await puppeteer.launch({
2815
defaultViewport: { width: 1200, height: 675 },
29-
headless: "new",
16+
headless: true,
3017
});
3118
const page = await browser.newPage();
3219
await page.goto(url, { waitUntil: "networkidle2" });
3320
const raw = await page.screenshot();
34-
3521
await browser.close();
3622

37-
if (!(raw instanceof Uint8Array)) {
38-
// deno-lint-ignore no-console
39-
console.log("Invalid Image");
40-
Deno.exit(0);
41-
}
4223
// convert to jpeg
4324
const image2x = await Image.decode(raw);
44-
const jpeg2x = join(outDir, `${id}2x.jpg`);
25+
const jpeg2x = import.meta.resolve(`../static/showcase/${id}2x.jpg`);
4526
await Deno.writeFile(jpeg2x, await image2x.encodeJPEG(80));
4627

47-
const jpeg1x = join(outDir, `${id}1x.jpg`);
28+
const jpeg1x = import.meta.resolve(`../static/showcase/${id}1x.jpg`);
4829
const image1x = image2x.resize(image2x.width / 2, Image.RESIZE_AUTO);
4930
await Deno.writeFile(jpeg1x, await image1x.encodeJPEG(80));

0 commit comments

Comments
 (0)