Commit Graph
1337 Commits
Author SHA1 Message Date
31dcbfbb8b fix: hide node_modules and vendor from update output (#3089)
Added logic to filter out files in node_modules and vendor directories
from user-facing logs and migration summaries in the update process.
Updated tests to verify that these files are processed but not shown in
logs.

close #3082

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
Co-authored-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
2025-07-14 15:57:07 +02:00
Zichao Lan 3c43d98a57 docs: update HandlerContext -> FreshContext (#3092)
'HandlerContext' is deprecated.deno-ts(6385)
2025-07-13 23:21:56 +02:00
Marvin Hagemeister e2699923b0 chore: rename tests FreshApp -> App (#3087) 2025-07-10 10:24:39 +02:00
Marvin Hagemeister a941dd33c5 chore: ignore test tmp delete failures on windows (#3088) 2025-07-10 10:21:22 +02:00
zhizheng cfc9a9a601 chore: ensures more stable CI runs on Windows environments. (#3070)
This pull request includes a small but important change to the
`withTmpDir` function in `src/test_utils.ts`. The change adds error
handling to ensure that a `PermissionDenied` error during directory
removal does not interrupt the execution.
2025-07-10 10:09:16 +02:00
Marvin Hagemeister 31434a2cf9 fix: wrong fresh domain used in hash (#3085) 2025-07-09 23:39:39 +02:00
Marvin Hagemeister f7174d0df0 chore: cleanup cors middleware (#3083)
- Remove some indirections
- Make tests self contained
- Switch tests to `Deno.test` as the LSP doesn't yet recognise
`describe/it`
2025-07-09 21:44:57 +02:00
Chris d072dc2fc0 fix: avoid reload for user-code history changes (#3045) (#3048)
The Fresh partials popstate handler causes page reloads when user code
makes use of navigation history state. This can lead to a loss of user
data in a browsing context.
To fix this behavior, FreshHistoryState now has a flag which validates
partials functionality/explicitly opts-in to any partial related
location management.
2025-07-09 20:59:32 +02:00
Asher Gomez 3e211dc7ec fix: import current version of fresh (#3020)
Previously, all packages except `@fresh/core` and even some tests
might've imported `jsr:@fresh/core@^2.0.0-alpha.29` rather than the
latest version of Fresh. This PR fixes that.
2025-07-09 11:03:47 +02:00
Coty ee46263053 feat: Add localhost help text to server address output (#3077)
When binding to `0.0.0.0` or `::`, show localhost equivalent URL for
convenience

Closes #3076

output from fresh www

```
deno task start
Task start deno run -A --watch=static/,routes/,../src,../docs dev.ts
Watcher Process started.

 🍋 Fresh ready
    Local:  http://0.0.0.0:8000/ (http://localhost:8000/)

GA4_MEASUREMENT_ID environment variable not set. Google Analytics reporting disabled.
```
2025-07-09 00:58:04 +02:00
Marvin Hagemeister 0b3546f201 feat: support overwriting default 404 handler (#3081)
Fixes https://github.com/denoland/fresh/issues/1918
2025-07-09 00:40:12 +02:00
Marvin Hagemeister ec2bb17589 chore: release 2.0.0-alpha.37 (#3074) 2025-07-02 12:48:11 +02:00
Marvin Hagemeister b00175fafd fix(core): don't rely on strict esbuild version (#3073) 2025-07-02 12:38:42 +02:00
Marvin Hagemeister 67fd8ccd36 chore: release 2.0.0-alpha.36 (#3072) 2025-06-30 16:39:34 +02:00
Marvin Hagemeister 8416078b6a fix(core): improve island props serialization (#3071) 2025-06-30 16:31:58 +02:00
zhizhengand李嘉图·M·路 8d3b8c53c6 docs: Update Fresh canary usage instructions in docs (#3067)
Revise documentation to clarify how to use the latest Fresh 2 canary,
specific commits, and forks via deno.json. Add instructions for creating
new projects using JSR and local sources, and update references to
current package versions. Include links to the Fresh v2 blog and
migration guide for further reading.

close #3058

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
2025-06-30 12:27:53 +02:00
Asher Gomez 8f813fad90 fix(core): use PageProps instead of FreshContext in define*() compat functions (#3064)
In Fresh 1, define apps used `RouteContext`, which align with
`PageProps` in Fresh 2, rather than `FreshContext`. E.g. before this PR,
one would get a type error if they tried to use `ctx.Component` within
`defineApp()` and now they shouldn't.
2025-06-27 09:54:53 +02:00
Marvin Hagemeister 0b6e62a693 chore: release 2.0.0-alpha.35 (#3062) 2025-06-26 15:53:15 +02:00
Josh Dales b338845c7f fix(init): only add tailwind to imports when selected (#3051)
If you don't install tailwind you shouldn't need the plugin, resolves
https://github.com/denoland/fresh/issues/3050
2025-06-19 19:55:05 +02:00
Asher GomezandMarvin Hagemeister 439ed1e5e5 chore(www): remove @deno/otel package (#3047)
This seems to be no longer needed thanks to
https://github.com/denoland/deno/pull/27541.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2025-06-18 11:22:02 +02:00
Asher Gomez 682368ba30 refactor(src): remove redundant coloring from createCodeFrame() (#3049)
`src/runtime/server/preact_hooks.tsx` is the only place that
`createCodeFrame()` is used which stripped the ANSI codes anyway.
2025-06-18 10:43:56 +02:00
Marvin Hagemeister 85d22e0bb0 fix(core): move to new esbuild deno plugin (#3034)
Move to the new esbuild plugin that leverages `@deno/loader` under the
hood. This is based on the exact same rust crates that Deno itself uses
to do resolution, instead of doing it's own resolution.
2025-06-18 10:42:47 +02:00
Asher Gomez c2b0fe3568 test(www): use @std/expect instead of @std/assert (#3046)
Aligns screenshot tests to the rest of the codebase by using
`@std/expect` instead of `@std/assert`.
2025-06-17 13:50:54 +02:00
75897de196 chore: add tests for fresh/compat imports (#3036)
- `fresh/compat - defineFn mixed return types` - Tests all supported
return types (Response, VNode, null) with both sync and async handlers,
including FreshContext parameter usage

- `fresh/compat - multiple compat imports` - Tests importing multiple
compat functions simultaneously

close #3025 

--patch-1
try to use deno/std Api to replace

--patch-2
make it simple and clean

--patch-3
Convert update_test.ts to .tsx for JSX support
Use static imports instead of dynamic imports for better performance
Switch from @std/assert to @std/expect for consistency
Use ReturnType<> for automatic type inference instead of manual type
definitions

Sincerely grateful to @iuioiua for the guidance and patience.

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2025-06-17 13:06:21 +02:00
Asher Gomez c3c79352b0 fix(core): refine HttpError.status property type (#2890)
As this is property only ever has an error HTTP status code (>400).
2025-06-16 17:57:49 +02:00
Asher Gomez 71b7de4581 fix(core): align defineFn() with previous definition (#3043)
https://github.com/denoland/fresh/blob/990357629e50ef123e5b5ee2b80c250be867534f/src/server/defines.ts#L13-L16

Closes #3042
2025-06-16 11:04:18 +02:00
Asher Gomez 71bec59820 chore: change patch Deno config file option to links (#3030)
Ref: https://github.com/denoland/deno/pull/29677
2025-06-14 09:55:06 +02:00
zhizhengand李嘉图·M·路 dd1721bce6 chore: refactor sreenshot and add test (#3032)
- Refactor screenshot functionality into testable utility functions
- Add comprehensive test suite to catch regressions early
- Ensure functionality doesn't break unexpectedly without notification

--patch-1
based on review, make throw error naturally

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
2025-06-13 20:39:10 +02:00
Asher Gomez e868a924fa fix(update): correct return and argument types for defineFn() (#3023)
Previously, the return union type of the inner function and the function
itself contained a `Request` instead of a `Response`.
2025-06-12 13:25:36 +02:00
zhizhengand李嘉图·M·路 e9cb6486c8 feat(update): use std lib to replace the custom processbar (#3027)
- The constructor of the process-bar in the currently used std/cli
differs from that of the latest version, so the relevant dependencies
have been updated.

- The custom processbar has been replaced with the std lib, and
customization has been carried out to meet the current scenario.

In test env, seem like: 

![bb2868ed3911071ce9915a9c8662786](https://github.com/user-attachments/assets/e4419965-40fc-4ad8-8647-74e30c75ea98)

close #3021

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
2025-06-12 12:32:09 +02:00
zhizhengand李嘉图·M·路 133d4bcfb5 feat(update): delete fresh.gen.ts in @fresh/update (#3028)
delete fresh.gen.ts
close #3022
- before:

![8dd2fb246bc33b206b4f50f3d8f7439](https://github.com/user-attachments/assets/fa45af2f-0241-4ad7-9837-6b14364756ed)



- after:

![50b9512afcd0f522dada0ab3f3b4cc0](https://github.com/user-attachments/assets/56539c41-3ee5-4d3a-a1ac-5c64e5d008b0)

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
2025-06-12 12:30:46 +02:00
zhizhengand李嘉图·M·路 cb402b9839 fix(utils): restore missing dependencies for screenshot utility (#3016)
The relevant dependencies were lost in previous cleanups. This situation
caused the screenshot function to fail.

This PR properly cleans up the functional function and restores its
operation.

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
2025-06-11 17:47:57 +02:00
b2807b7720 feat(update): More logs for update script #2968 (#3010)
Before:

![340fffdbf558fa7a1bc1036972e0679](https://github.com/user-attachments/assets/e20e1c2f-1e1c-4477-82ee-231163d53085)

After:
Case1:

![1adc44294f2001dc43cd411254dfc2d](https://github.com/user-attachments/assets/e7bebd32-1083-4bc1-b00b-346c9ba66d43)
Case2:

![8cd3445877d5311ff8d9b9f66adb30e](https://github.com/user-attachments/assets/596ad777-6f6d-4b62-ae0e-32b82ebefb20)

In Test Env:

![df5b20de6d1437e471c6dcfc1e55178](https://github.com/user-attachments/assets/1eb53cdc-4398-4e61-874d-4c72e037e57f)

Close #2968

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2025-06-11 17:40:52 +02:00
Octo8080XandMarvin Hagemeister 1213aad90d feat: add CORS middleware (#3013)
## Why was this PR initiated?

I opened an issue and held discussions about officially providing
middleware in Fresh by porting middleware from Hono.

https://github.com/denoland/fresh/issues/3011

## What does this PR do? 

I introduced the CORS middleware bundled with Fresh by porting the CORS
middleware from Hono.


I appreciate your review.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2025-06-11 17:34:00 +02:00
zhizheng 10400ff130 fix(www): quotes in markdown image alt causing html issues #3002 (#3003)
## Problem:
The problem was reproduced as described in #3002. Chrome DevTools shows
the following error:

props.js:137 Uncaught (in promise) InvalidCharacterError: Failed to
execute 'setAttribute' on 'Element': 'docs-content""' is not a valid
attribute name.
    at j (props.js:137:8)
    at V (index.js:528:5)
    at O (index.js:326:28)
    at I (children.js:97:16)
    at V (index.js:547:4)
    at O (index.js:326:28)
    at I (children.js:97:16)
    at V (index.js:547:4)
    at O (index.js:326:28)
    at I (children.js:97:16)

## Solution:
The issue was resolved by removing the double quotes around docs-content
in the Markdown image description. After this change, the application
resumed normal operation.

## Test:
Deno task ok and local env check

## Close:
close #3002
2025-06-04 19:32:31 +02:00
zhizheng a85fdf18e2 fix(update): fresh/runtime import specifier updated incorrectly (#3009)
…ports

The original code is shown in the following figure, and there is an
incorrect usage in it.


![1749021630760](https://github.com/user-attachments/assets/2d603bdd-6dd7-4ddf-9dae-8d62b8bdaedf)
2025-06-04 19:24:48 +02:00
zhizhengand李嘉图·M·路 a631ae3876 Fix[docs] correct the broken links and errors in migration-guide (#3008)
Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
2025-06-03 13:30:12 +02:00
Christian Svensson b4c3ff8e98 feat: add flag to FreshContext for partial requests (#2993)
Addresses a gap between [Fresh
v1](https://github.com/denoland/fresh/blob/1.x/src/server/types.ts#L192)
and Fresh v2, by adding `ctx.isPartial` to `FreshContext`.

The same route (e.g. `GET /api/autocomplete`) can be called from both an
Island or a Partial. Returning JSON or HTML depending on the destination
of the code.

Or is the intent that endpoints returning partials and data should be
separated, and this pattern is not to be encouraged in Fresh v2? My use
case in Fresh v1 was an `/routes/api/cart.tsx`, which can either just
toggle a product from the cart (via cookie), but also update UI elements
(e.g. cart icon) based on if called from partial or not.


![image](https://github.com/user-attachments/assets/a1cbcfb1-2446-4d6d-bce5-4c3d6acf9bfd)
2025-05-26 14:15:36 +02:00
zhizhengand李嘉图·M·路 9eaefd5be0 showcase: add zhi's blog build by fresh (#2918)
Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
2025-05-26 14:13:32 +02:00
Mahesh Bansod 1e6f0d69b1 init: update instructions to run project from a fresh scaffold (#2996)
After scaffolding the project with 
```
deno run -Ar jsr:@fresh/init@2.0.0-alpha.34
```
Instruction show up to run the project:
```
Enter your project directory using cd fresh-project.
Run deno task start to start the project. CTRL-C to stop.

Stuck? Join our Discord https://discord.gg/deno
```
these instructions seem to be outdated since running `deno task start`
on this project throws an error.

While this error also hints that you might want to run the dev server, I
think it gives a bad impression that a newly scaffolded project is
throwing an error after running the command that it has specified. Also,
not many people, especially beginners, read the error messages
completely.
2025-05-26 14:12:47 +02:00
zhizheng 50d6f7fd09 fix: improve styling of "Edit on GitHub" link for better visibility in Dark mode (#2994)
change style for dark mode
last:

![image](https://github.com/user-attachments/assets/52ee66b2-4779-406b-b220-ede6a9100c77)
now:

![image](https://github.com/user-attachments/assets/3c822f3b-4e41-4f30-a5e5-dd1a8cf66d2b)
2025-05-23 14:42:39 +02:00
Marvin Hagemeister 76c77e503e docs: Make "Edit on GitHub" link more prominent (#2992)
Folks seem to miss this button
2025-05-22 11:52:52 +02:00
Marvin Hagemeister 613c19221f docs: fix dark mode info background (#2991) 2025-05-22 11:52:33 +02:00
Marvin Hagemeister dbb76623a4 Revert "feat: update the tailwind plugin to suuport tailwindv4 #2819 (#2903)" (#2988)
Reverts tailwind v4 update. Something is wrong with the CSS files on
fresh.deno.dev 😢
2025-05-21 16:07:51 +02:00
40e7747228 feat: update the tailwind plugin to suuport tailwindv4 #2819 (#2903)
Inspired by #2819, #2829, and
https://github.com/pakornv/fresh-plugin-tailwindcss, I made minimal
modifications to the plugin-tailwind, I originally intended to update
based on #2829, but I was informed by the system that I couldn't push.

Due to the breaking changes in Tailwind v4, some PostCSS plugins are no
longer required. Additionally, I updated the syntax in the /www
directory. The /www directory now uses the updated plugin supported by
Tailwind v4.I think this has made initial progress.

# What This PR Solves
The Tailwind plugin has been updated to support Tailwind v4, and it is
currently functioning well both in the repository's www directory and in
the initialized project which for test.

## --patch-1

### 1. Dependency Optimization
- Removed `cssnano` dependency, using Tailwind v4's built-in
optimization(Based on @csvn 's suggestion)
- Removed `autoprefixer` dependency
- Updated `tailwind-plugin` version number
### 2. Build Configuration Adjustments
- Added `--node-modules-dir` parameter to `/www` task for Tailwind v4
support (Based on @marvinhagemeister 's suggestion)
- Added `--allow-scripts` parameter to enable `@tailwindcss/oxide`
execution
### 3. Code Adaptation
- Modified Tailwind-related code in `/www` to support Tailwind v4
- Updated dependency configuration in `deno.json`
### 4. Feature Restoration
- Added `imagescript` and `astral` dependencies to restore screenshot
functionality lost in previous PR updates
- Fixed the issue where the `tailwind-plugin` dependency was incorrectly
pointing to the JSR package instead of the local repository source code
in previous PR.

## --patch-2
- Upgraded Tailwind CSS to the latest version.
- Removed unnecessary dependencies.
- Enabled CSS minification by default when Fresh is in production mode.
- Updated docs/canary/examples/migration-guide.md to support the new
Tailwind plugin format.
- Updated init/src/init.ts to support the new Tailwind version and
plugin version, use new `@import "tailwindcss"`, and generate the new
plugin format.
- Updated init/src/init_test.ts: tests now expect `css` to match
`/tailwindcss/` instead of `/@tailwind/`.
- Removed plugin-tailwindcss/src/types.ts as it is no longer needed, and
updated plugin-tailwindcss/src/mod.ts and www/dev.ts to support the new
format.

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>

## --patch-3
Addressing @marvinhagemeister feedback, this patch reverts the
unintended loss of PR #2960's changes caused by merge conflicts.

## --patch-4

I initialized a project according to the migration documentation and
used @fresh/update to test whether the plugin works properly with
v2-alpha-34. The results show that it works fine.

- The plugin is published at
jsr:@freshpress/fresh-plugin-tailwind@0.0.1-alpha.8.

- The test project is published at
https://github.com/SisyphusZheng/fresh-project-test/tree/main/fresh-project.

# How Testing Was Conducted

## Local Environment Testing
1. Environment Cleanup
```bash
rm -rf ./.cache/deno deno.lock node_modules
```

2. Test Execution
```bash
deno task www
```

3. Result Verification
- Checked functionality in local `/www` environment
- Confirmed all features working properly

## Code Inspection
- Passed `deno task ok` check

## This forked /www website is hosted and running on GitHub Codespaces,
with support for the latest code changes. You can check it out at:
https://silver-trout-pjr4jw7xx5x9299x6-8000.app.github.dev/

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
Co-authored-by: deno-deploy[bot] <75045203+deno-deploy[bot]@users.noreply.github.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2025-05-21 16:01:57 +02:00
Marvin Hagemeister d5a2afd7ac fix(update): Update tasks + lock in deno.json (#2987)
Noticed that we don't update these.
2025-05-21 15:23:41 +02:00
Marvin Hagemeister 750ab35499 fix: add back LayoutConfig (#2982)
~~Makes it easier to upgrade from 1.x .~~

Initially, I assumed it would be just an alias to `RouteConfig`, but
upon closer inspection that has some additional properties that make no
sense for a layout.
2025-05-21 13:44:09 +02:00
Marvin Hagemeister e595d35c44 docs: simplify introduction content (#2978)
The original text is a bit wordy. This shortens the introduction content
a bit in our docs.
2025-05-21 11:32:50 +02:00
Asher GomezandMarvin Hagemeister da8879dede tests: use the same browser instance across tests and better use explicit resource management (#2901)
On my machine, reduces time taken to perform `deno task test` from
~1m20s to ~30s.

Inspired by and supersedes #2110.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2025-05-21 11:32:18 +02:00
Christian Svensson 17257dd1c2 test: use disposable tmp dirs (#2983)
Replaces the patterns below with consistent `AsyncDisposable` and `await
using` resource management for automatic cleanup.

- `await withTmpDir(async (dir) => { ... })` with `finally`
  - Makes code a bit flatter, and reduces callback-hell a bit
- `await Deno.makeTempDir()` + `Deno.remove()`
- `await Deno.makeTempDir()`

Helps be more consistent in removing temporary folders. Among others,
ensures temp folders are removed in the tests below:

- `src/build_cache_test.ts`
- `src/dev/builder_test.ts`
- `src/dev/dev_build_cache_test.ts`

## TODO's

The `Deno.makeTempDir()` method is still used by `buildProd` as well,
but this method is used in the top module scope, where it does not work
correctly with `Deno.test` (it runs before the test methods). I removed
this part from the PR and leave this for later to avoid making the PR
too big.

-
https://github.com/csvn/fresh/blob/test%2Fdisposable-tmp-dirs/tests/test_utils.tsx/#L64
-
https://github.com/csvn/fresh/blob/test%2Fdisposable-tmp-dirs/www/main_test.ts/#L7
2025-05-21 11:13:02 +02:00