Commit Graph
1260 Commits
Author SHA1 Message Date
Marvin Hagemeister 4fc1a2b92e fix(init): include favicon.ico in init package (#2943)
Fixes a regression introduced by
https://github.com/denoland/fresh/pull/2867

Fixes https://github.com/denoland/fresh/issues/2941
2025-05-14 22:38:10 +02:00
Asher Gomez 7728e1cb52 chore(core): simplify tasks (#2892) 2025-05-14 13:27:13 +02:00
Marvin Hagemeister c3095f38c4 chore: release 2.0.0-alpha.30 (#2939) 2025-05-14 10:55:47 +02:00
Christian Svensson e2d0624512 fix: do not skip app-wrapper for sibling routes (#2911)
This PR adds a unit test for the issue in #2910. I have not found a
solution yet, since I'm not very familiar with the `fsRoutes` code, and
what it is doing. But a thought a unit test with the failing code could
help to find a bug fix.

**Edit:** I managed to fix the failing test by removing a couple of
lines, but I'm not too familiar with the code so I'm not sure if it's
correct. It seems to pass all the tests still...

Closes #2910
2025-05-13 18:03:13 +02:00
Christian Svensson f15f225576 fix: make static folders with dot such as .well-known allowed (#2929)
This PR intends to address an error logged when opening a DevTools in a
Chromium based browser while using Fresh in dev mode.

<details>

<summary><strong>See error</strong></summary>

```
Error: Processed file resolved outside of static dir C:\Users\<name>\fresh-site\src\static\.well-known\appspecific\com.chrome.devtools.json
    at MemoryBuildCache.readFile (https://jsr.io/@fresh/core/2.0.0-alpha.29/src/dev/dev_build_cache.ts:81:13)
    at eventLoopTick (ext:core/01_core.js:178:7)
    at async freshStaticFiles (https://jsr.io/@fresh/core/2.0.0-alpha.29/src/middlewares/static_files.ts:30:18)
    at async FreshReqContext.fn (https://jsr.io/@fresh/core/2.0.0-alpha.29/src/middlewares/mod.ts:99:18)
    at async https://jsr.io/@fresh/core/2.0.0-alpha.29/src/dev/middlewares/error_overlay/middleware.tsx:15:14
    at async FreshReqContext.fn (https://jsr.io/@fresh/core/2.0.0-alpha.29/src/middlewares/mod.ts:99:18)
    at async fn (https://jsr.io/@fresh/core/2.0.0-alpha.29/src/middlewares/mod.ts:99:18)
    at async https://jsr.io/@fresh/core/2.0.0-alpha.29/src/app.ts:232:16
    at async mapped (ext:deno_http/00_serve.ts:407:18)
```

</details>

DevTools tries to load a
`<root>/static/.well-known/appspecific/com.chrome.devtools.json` file,
which incorrectly is flagged as "outside" the static directory, and thus
generates errors instead of 404.

Maybe hidden folders (starting with `.`) in `/static` should be opt-in
though? I'm not sure if anyone puts folders with `.` prefix inside
`static/` without intending them to be accessible?

- `..` throws errors (outside staticDir)
- `.` returns "missing file" (unless `config.allowHiddenFolders` is
true)

## Automatic workspace folders

I think a follow-up PR could be for the Dev `Builder` to also implement
support for [Automatic workspace
folders](https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md),
by returning JSON content automatically at
`.well-known/appspecific/com.chrome.devtools.json`.

I think a good first step is to allow `.<folder-name>`, especially since
`.well-known/` has [many valid
use-cases](https://en.wikipedia.org/wiki/Well-known_URI), and as such is
not unreasonable to want to add static files in.
2025-05-13 10:03:05 +02:00
TylerandTyler 50e5bc7ae4 docs: fix readme url for deployment (#2930)
fixes #2695

this is my best guess to what the url is meant to link to now

Co-authored-by: Tyler <26290074+thegitduck@users.noreply.github.com>
2025-05-13 09:31:11 +02:00
Marvin Hagemeister fcd94809c8 fix(esbuild): disable spammy warning for monaco editor (#2928)
It's a super spammy warning message when you're using the monaco editor.
They have code like that as the result of minifcation.

Fixes https://github.com/denoland/fresh/issues/2775
2025-05-13 00:13:21 +02:00
Asher Gomez 84a03ee66c chore(init): cleanup twind options (#2868)
These values are no longer used.
2025-05-12 23:29:17 +02:00
Asher Gomez 8ea3dbeac5 refactor(www): use useSignal() instead of useState() (#2894) 2025-05-12 23:28:46 +02:00
Marvin Hagemeister d2da471d67 fix(partial): form dialog method not supported (#2927)
The `<form>` method value `dialog` does no network request, so we should
ignore it for partials.

Fixes https://github.com/denoland/fresh/issues/2885
2025-05-12 21:19:19 +02:00
Marvin Hagemeister 95b82f5281 chore: don't spam test output with "Listening on..." (#2926)
Follow up to https://github.com/denoland/fresh/pull/2897
2025-05-12 20:34:14 +02:00
Marvin Hagemeister 24ad244a79 fix: error when no Response instance is returned (#2924)
Fixes https://github.com/denoland/fresh/issues/1494
2025-05-12 20:30:45 +02:00
Marvin Hagemeister a49fc3796f chore: ignore check fmt on canary (#2925)
Ignore checking formatting on canary as the formatting might be
different from stable releases of Deno.
2025-05-12 20:30:17 +02:00
d68b5ecd5b refactor: replace puppeteer with astral for screenshot and close #2919 (#2920)
due to resolves the `NotFound: No such file or directory` error in the
`www/utils/screenshot.ts` script, which was caused by improper file path
construction. This error prevented screenshots from being saved
correctly. close #2919

-- update --patch1
## Current Status
- Using npm:puppeteer for webpage screenshots
- npm lifecycle script warnings present
- deno-puppeteer is no longer maintained
- npm:puppeteer still has compatibility issues

## References
- [astral](https://github.com/lino-levan/astral): Browser automation
library designed for Deno
-
[deno-puppeteer#92](https://github.com/lucacasonato/deno-puppeteer/issues/92):
Recent discussion about deno-puppeteer

## Changes Made
1. Dependency Replacement
   - Replaced npm:puppeteer with jsr:@astral/astral
   - Removed npm lifecycle script warnings

2. Dependency Management Optimization
   - Centralized all imports in deno.json
   - Using jsr: and URL imports

## Testing Steps
1. Run screenshot command:
```bash
deno task screenshot https://google.com google
```

2. Check output:
   - Verify no npm warnings
   - Validate generated image files:
     - ./www/static/showcase/google2x.jpg
     - ./www/static/showcase/google1x.jpg
   - Confirm image quality

3. Run complete test suite:
```bash
deno task ok
```
- Ensure all tests pass

4. Verify functionality:
   - Screenshot feature works correctly
   - Image processing (2x/1x) functions properly

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2025-05-12 20:02:15 +02:00
Marvin Hagemeister 09705b9b7f fix: bigint key values erroring (#2923)
Fixes https://github.com/denoland/fresh/issues/2802
2025-05-12 19:49:13 +02:00
Tim Reichen 1cfb4bc876 refactor: make App.prototype.handler() sync (#2906) 2025-05-12 10:12:50 +02:00
Tim Reichen 9605cd81b5 refactor: move mergePaths() to utils.ts (#2905) 2025-05-12 09:59:37 +02:00
Tim Reichen c6d4c47e00 refactor: App.prototype.listen() (#2907) 2025-05-12 09:58:37 +02:00
Christian Svensson c0e2b80690 fix: allow relative paths for outDir and staticDir (#2914)
This PR consists of several commits, where the goal is to re-enable the
test (fix for Windows), as well as allow relative paths for config
options to address #2913.

1. Re-enables test and normalizes paths for Windows
2. Add unit test for `normalizeConfig` and the `root` option
3. Add unit test for `normalizeConfig` for `build.outDir` and
`staticDir`, and allow the properties to be relative
4. Add JSDoc for fields in `FreshConfig`

I can split these into separate PR's if preferred, but all code changes
are very in nearly the same places.

Closes #2913
2025-05-12 09:43:01 +02:00
Christian Svensson d10ea5a89a fix: remove unnecessary config property in init script (#2915)
From what I can see, `fsRoutes` uses the `FreshConfig.root` option by
default, so this property does not need to be specified. I also added
some JSDoc for the `dir` option in `fsRoutes()` as I understood it's
purpose.
2025-05-12 09:42:16 +02:00
Christian Svensson a23596153b fix: allow Data to be inferred from Handler function (#2916)
This PR adds support for single-function GET handler data to be inferred
when using `define.page<typeof handler>()`.

```ts
export const handler = define.handlers((ctx) => {
  return page({ foo: "foo" });
});

export default define.page<typeof handler>((ctx) => {
  ctx.data; // Correctly resolves as { foo: string }
});
```

This PR also adds a test that checks that the types inferred are correct
by type checking.
2025-05-12 09:41:28 +02:00
Marvin Hagemeister f9bfecab8e fix(builder): css hash incorrectly transforming data urls (#2921)
Fixes https://github.com/denoland/fresh/issues/2599
2025-05-12 09:40:35 +02:00
zhizheng 2b0f76be62 docs: improve styling for form submission example (#2899)
![before](https://github.com/user-attachments/assets/3936dcc6-d9f4-49e3-8b53-973a21eaadcd)

![after](https://github.com/user-attachments/assets/8abdb950-6473-4f0a-a27d-4a8b09229a57)

## Changes
- Added border and padding to the search input field for better
visibility
- Added light gray background and border to the search button for better
clickability

## Why
- The original styling makes it difficult to recognize the search input
field and button, as they appear as plain text elements without any
visual distinction.
2025-05-08 11:54:12 +02:00
Asher Gomez 54d18d8bca tests: fix leaks, macOS hangs and utility cleanups (#2897)
1. Upgrades `@astral/astral`
2. Fixes test leaks
3. Fixes `@fresh/init` test hangs
4. Simplifies and cleans up test utilities
2025-05-07 10:53:42 +02:00
Asher Gomez cea7a2a821 chore: update screenshot task script (#2881) 2025-05-05 08:42:09 +02:00
Asher Gomez e0ca9423d9 BREAKING(core): remove Mode type (#2884)
It doesn't seem like it deserves to be it's own type. It can just be an
interface property.
2025-05-05 08:40:34 +02:00
Asher Gomez 49a9c69d9e chore(update): remove unused maybePrependReqVar.ts (#2886) 2025-05-05 08:38:35 +02:00
Asher Gomez 45ce7e3ac0 chore: add doc checker (#2877)
First steps towards #2876
Depends on https://github.com/denoland/std/pull/6632
2025-05-02 10:55:55 +02:00
Asher Gomez 51e4d334af refactor(core): remove unused constants (#2872) 2025-04-30 10:32:19 +02:00
Asher Gomez b582c57e57 refactor(core): use getSnapshotPath() (#2873) 2025-04-30 10:31:47 +02:00
Asher Gomez cfa7fdc6b9 tests: minor cleanups of tests/precompile_test.ts (#2870)
A tiny lesson that `URL` and `import.meta` can be used instead of
`@std/path`. Also, might fix CI thanks to `deno.lock` being updated.
2025-04-29 08:10:17 +02:00
zhizheng ca6493757e fix: upgrade the puppteer version to enable the screenshot.ts (#2863) (#2866)
the ts is not compatible with Deno 2.0 and cannot generate project
screenshots. #2863

the old verison made by 3 year ago.
2025-04-28 15:11:10 +02:00
Asher Gomez d077130b05 refactor(init): avoid network request for downloading of favicon (#2867) 2025-04-28 15:10:03 +02:00
Asher Gomez 7aec5a268e refactor(core): standardize HttpError (#2858)
- Now extends `Error`, so that it satisfies `instanceof Error`
operations.
- Narrows the `status` property to be an actual HTTP status code.
- Outsources default evaluation of the `message` property to
`@std/http/status`, which already implements this functionality.
- Brings the `stack` property to the class, regardless of its status,
which seems like a needless constraint.
2025-04-27 20:01:31 +02:00
Asher Gomez 5876ca7752 chore: remove prettyTime() (#2859)
This isn't used anywhere.
2025-04-27 19:59:07 +02:00
Asher Gomez b8f1be76fc docs: contributing guidelines (#2860)
Outdated and needs work but will suffice.
2025-04-27 19:58:00 +02:00
Luca Casonato b4fd717c6c fix: reset span name and http.route in static file middleware (#2856) 2025-04-23 14:35:39 +02:00
Asher Gomez 149509995e fix(init): define working directory in check task for init script (#2852)
~~This fixes CI for current PRs until
https://github.com/denoland/deno/pull/28655 is added to Deno 2.3.0.~~

This fixes CI until https://github.com/denoland/deno/issues/28923 is
fixed. Then, we can use `Deno.makeTempDir()` and not have to use
`tmp_*/`.
2025-04-22 13:17:05 +02:00
Tim Reichen d87e47d15f chore: remove test tmp files (#2837)
Seems like `tmp` folders were not ignored by git.
2025-03-07 14:37:11 +01:00
Tim Reichen 4e6bed87a1 fix: wrong button type in submit test cases (#2836)
https://github.com/denoland/fresh/pull/2833 breaks some tests where the
button must be of type `submit` rather than `button`. This PR fixes
this.
2025-03-05 23:27:29 +01:00
Tim Reichen bbfea7538b fix: b64encode param type (#2832) 2025-03-05 12:32:24 +01:00
Tim Reichen 0a634bd2d2 chore: fix lint errors (#2833)
This PR fixes current lint errors thrown by `deno lint`.
2025-03-05 12:31:25 +01:00
Marvin Hagemeister f49a3f1d99 docs: fix main dark bg (#2826) 2025-02-17 11:12:55 +01:00
Marvin Hagemeister d7c9ce9bc5 docs: fix dark mode background flash (#2825)
Fixes
https://github.com/denoland/fresh/issues/2823#issuecomment-2661711235
2025-02-17 10:43:59 +01:00
David MonaghanandMarvin Hagemeister b1f2a989a5 www: docs: feat: add dark mode (#2820)
- Added CSS vars for dark/light colors.
- Added dark/light theme toggle as Island

Fixes #2648

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2025-02-04 11:58:05 +01:00
Tugrul Ates adf8b87a03 docs: fix spelling in README (#2814) 2025-01-20 00:13:46 +01:00
Marvin Hagemeister 65c05b2127 2.0.0-alpha.29 (#2812) 2025-01-16 22:43:40 +01:00
Marvin Hagemeister f245471ddf fix: route middleware order with groups (#2811)
This is a follow-up fix to https://github.com/denoland/fresh/pull/2792

The original fix skipped over route groups which lead to them being
mixed with non-grouped routes. This in turn confused the middleware
processing part when building the final routes.
2025-01-16 21:57:42 +01:00
Marvin Hagemeister c7c341b695 2.0.0-alpha.28 (#2810) 2025-01-16 14:24:07 +01:00
Paul Carduner 2baf6dc7a0 fix: middlewares not being used with default GET handlers (#2807)
I noticed a small bug with the default GET handlers where middlewares
were not being run. This pull requests fixes the bug and adds some unit
tests for this behavior.
2025-01-09 00:09:26 +01:00