Commit Graph
1326 Commits
Author SHA1 Message Date
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
Christian Svensson db142115ec feat: support automatic workspace detection in Dev (#2985)
Adds support for [Automatic Workspace
Detection](https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md).

- Avoids 404's or middleware logging when this feature is active (e.g.
Chrome/Edge with DevTools open)
- Generates the same UUID based on root folder path (without writing
anything to disk)
- The middleware is lazy and does nothing until the path is opened for
`com.chrome.devtools.json`
2025-05-21 11:09:43 +02:00
Christian Svensson bc8cdb9c7b fix: convert island filePath to valid variable name (#2984)
I only added a unit test, but maybe it's testing internals too much?
Should I add a more E2E test in `tests/` with real files?


Closes #2971
2025-05-21 11:06:16 +02:00
Brian Knight b6c02b0668 docs: Fix build command in deployment documentation (#2840)
The `Self Contained Executable` instructions in the `Deployment`
documentation contains an error in the sample code.

```sh Terminal
$ deno build
$ deno compile --include static --include _fresh --include deno.json -A main.ts
```

should be:

```sh Terminal
$ deno task build
$ deno compile --include static --include _fresh --include deno.json -A main.ts
```

This PR fixes that.
2025-05-19 13:28:48 +02:00
Sviatoslav M. 1321cda916 docs: update rendering-markdown.md (#2800)
When using deno add @deno/gfm outputs the following:
```
error: @deno/gfm is missing a prefix. Did you mean `deno add jsr:@deno/gfm`?
```
Then when jsr is specified:
```
deno add jsr:@deno/gfm
Add jsr:@deno/gfm@0.10.0
```

deno --version: 2.1.4
2025-05-19 13:20:10 +02:00
Asher Gomez b8c75ec0e3 chore: update dependencies (#2975)
Updates relating to Tailwind CSS v4 can be handled in #2903 or #2829.
2025-05-19 13:17:53 +02:00
Asher Gomez 144ed2e75c refactor(core): minor fresh/compat cleanups (#2880) 2025-05-19 12:05:22 +02:00
Asher Gomez 8953650420 refactor(init): tidy up check task (#2976) 2025-05-19 11:04:52 +02:00
Asher Gomez cc93a1f469 tests(init): remove MockTTY (#2974)
These changes simplify implementation logic of the init workflow and
mock `prompt()` and `console()` functionality in a more direct manner.
This makes things easier to reason about by jumping through fewer mental
hoops.
2025-05-19 10:56:16 +02:00
Asher Gomez 3776ef3154 refactor: centralise imports and cleanup exports (#2900)
The benefits of these changes are:
1. Managing and updating dependencies is easier. One only needs to run
`deno outdated` at the root, instead of in each workspace.
2. The versions of dependencies across workspaces is kept consistent.

Closes #2788
2025-05-19 09:41:06 +02:00
Marvin Hagemeister 3900aa70d4 chore: release alpha 34 (#2967) 2025-05-16 21:36:12 +02:00
zhizhengand李嘉图·M·路 ebe65b035e docs(canary): clean the twind part for canary version (#2966)
## What does this PR do?

This PR cleans all the Twind - related parts in the canary
documentation. Specifically, it removes the Twind - related entries in
the docs/toc.ts file, which streamlines the documentation and eliminates
references to the Twind technology that might no longer be relevant or
in use.

## Problem Being Solved
Outdated Information: Twind removed from fresh v2. Keeping Twind -
related content in the documentation can lead to confusion for new users
who might be using the canary version of Fresh with Tailwind CSS.

## Changes Made
docs/toc.ts:
Removed the "migrating - to - tailwind" entry. 
Removed the "using - twind - v1" entry, which is directly related to
using the Twind v1 version and is no longer needed in the canary
documentation.
Removed the "using - fresh - canary - version" entry, which is no reason
in canary docs

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
2025-05-16 21:35:56 +02:00