Commit Graph
386 Commits
Author SHA1 Message Date
Marvin Hagemeister 75b5854810 fix: nested children slots erroring (#2674)
Fixes https://github.com/denoland/fresh/issues/2624
2024-10-04 05:05:27 +02:00
Marvin Hagemeister 1081aa2eb9 fix: docs markdown smartypants (#2671)
This was a regression introduced in
https://github.com/denoland/fresh/pull/2655

Fixes https://github.com/denoland/fresh/issues/2670
2024-10-02 11:43:47 +02:00
Marvin HagemeisterandLuca Casonato de8f1b0c59 feat: update for Deno 2 (#2655)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2024-09-30 18:30:30 +02:00
Marvin Hagemeister f2fc3f13da fix: process global warning (#2643) 2024-09-06 13:08:18 +02:00
Luca CasonatoandMarvin Hagemeister 1f9fb91c4d fix: add proper cache control headers (#2617)
The whole point of `asset()` is to enable caching. Yet we were not
adding cache control headers... :D

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2024-08-13 14:15:25 +02:00
Marvin Hagemeister 79a262b344 fix: GET partial form submit ignoring multiple checkbox values (#2568)
Fixes https://github.com/denoland/fresh/issues/2567
2024-07-02 22:24:48 +02:00
Marvin Hagemeister fc820e8965 feat: add error messages for missing build cache (#2551) 2024-06-26 15:33:25 +02:00
Marvin Hagemeister 0f6b4f624f chore: remove debug trace logs (#2545) 2024-06-25 10:08:48 +02:00
Marvin Hagemeister 003f2bbb5f fix: incorrect partial url on backwards navigation (#2510) 2024-06-08 09:01:12 +02:00
Adam Gregory 8c5e2b00c9 fix: Include submitter data in partial form data (#2307)
Fixes #2306
2024-06-06 19:02:49 +02:00
Luca Casonato c3ec742a65 feat: import fresh from fresh (#2479)
Instead of importing as `@fresh/core`.
2024-06-05 14:51:35 +02:00
Marvin Hagemeister 19d3e452ac fix: bring back island module preloading (#2503) 2024-06-05 14:41:02 +02:00
Marvin Hagemeister f09130cebf fix: add init background gradient (#2502) 2024-06-05 14:00:57 +02:00
Marvin Hagemeister 2b88f4bf56 fix: falsy f-* attributes not preserved inside island (#2498)
Fixes https://github.com/denoland/fresh/issues/2359
2024-06-05 10:06:53 +02:00
Marvin Hagemeister fba3f2b845 fix: partial form redirect not working (#2497)
Fixes https://github.com/denoland/fresh/issues/2404
2024-06-05 09:42:27 +02:00
Marvin Hagemeister d613c6a6ba fix: islands not working with basePath (#2496) 2024-06-05 09:02:27 +02:00
Marvin Hagemeister f8b60ddd15 fix: wrong url after partial form submission (#2495)
Fixes https://github.com/denoland/fresh/issues/2409
2024-06-05 08:30:28 +02:00
Marvin Hagemeister 9347b84cba feat: inject process.env.NODE_ENV for third party libs (#2481) 2024-05-31 15:18:23 +02:00
Marvin Hagemeister 88c3671a09 fix: error handling in fs routes (#2474)
Ran into an issue where we weren't responding with the correct status
code and passed response headers. This was a bit of a rabbit hole and it
was caused by us wrapping to more error handling middlewares than
necessary.
2024-05-31 14:27:36 +02:00
Luca CasonatoandMarvin Hagemeister d06dad5be6 tests: don't disable all the sanitizers (#2472)
The tests also pass with them enabled for me.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2024-05-27 15:00:40 +02:00
Marvin Hagemeister 287929e4d2 major: import Fresh 2.0 code (#2449)
🎉
2024-05-24 09:40:08 +02:00
Marvin Hagemeister e4981d30ad www: rework docs layout (#2429)
- Re-enable partials
- clean up layout a bit
2024-05-21 17:38:32 +02:00
Marvin Hagemeister 25d4d16a8f www: fully remove component gallery (#2430) 2024-05-17 18:39:32 +02:00
Josh CollinsworthandMarvin Hagemeister e8d1a68b58 www: refresh home page (#2418)
Overhauls the Fresh homepage with a new design, new demos, and new
sections highlighting Fresh's capabilities.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2024-05-17 16:08:55 +02:00
Marvin Hagemeister 40181142d2 fix: ServerhandlerInfo type for newer Deno versions (#2419)
Newer Deno versions have an additional `completed` property in there.
This PR allows Fresh to be used with both old and newer Deno versions
without getting type errors.
2024-05-02 20:41:33 +02:00
Asher Gomez 425032a6dc chore: minor cleanups (#2393)
These changes occur by just running `deno task ok` on `main`.
2024-04-08 13:08:41 +02:00
Luca CasonatoandMarvin Hagemeister 29d582c987 chore: update ahead-of-time build docs for Deno Deploy (#2381)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2024-03-22 22:19:17 +01:00
narumincho 407e4379df doc: Rename _req used to req (#2349)
Where other documents use req, they use the name req instead of _req


https://github.com/denoland/fresh/blob/b7281792a0a5b2674f659514b1e58116fabd6460/docs/latest/concepts/middleware.md?plain=1#L153
2024-03-21 09:32:59 +00:00
Marvin Hagemeister 240252fdb4 Revert "feat: add ctx.redirect() helper (#2358)" (#2372)
Mostly so that it's easier to cut the next patch release for Fresh.

This reverts commit e3508c3054.
2024-03-21 10:27:53 +01:00
Marvin Hagemeister e3508c3054 feat: add ctx.redirect() helper (#2358)
This PR adds a `ctx.redirect(path, status)` helper that aims to reduce
the verbosity of having to manually create a `Response` obejct for a
mere redirect.

```ts
// Before
new Response(null, {
  status: 307,
  headers: {
    Location: "/foo/bar"
  },
})

// After
ctx.redirect("/foo/bar", 307)
```

If the second parameter is not passed, it will default to `302`.
2024-03-12 17:36:34 +01:00
Reed von Redwitz 5ec06350e2 fix: allow multiple set-cookie headers to be set before render (#2357)
closes #2346

The primary issue was the snippet `headers[key] = value`. This caused
only one `set-cookie` to make it through. Switching to a `Headers`
object allowed me to use `append` when appropriate, allowing for
multiple `set-cookie` entries.

I also cleaned up one of the tests to make use of steps, because I
originally broke it and couldn't immediately tell which part was
failing.
2024-03-12 12:04:42 +01:00
Reed von Redwitz 8f3031317b fix: properly prefix all scripts with base path (#2334)
closes https://github.com/denoland/fresh/issues/2326

There was a big misunderstanding on my part -- in particular that a
different server might be listening at the root, so the redirect built
into `context.ts` will never happen. The existing test (as mentioned in
the issue) passes, but only because no one else is listening, and fresh
is able to perform the redirect.

I briefly considered writing a docker container to orchestrate this
properly, but then I didn't want to have docker running in order to run
these tests. (My laptop is old and bad.) So instead the two new tests
very thoroughly assert that scripts included in the html are properly
prefixed with the base path. And yes, they fail if the fix is reverted.

As for the fix itself: I just needed to prepend the asset URL with the
base path.
2024-02-23 13:30:42 +01:00
Marvin Hagemeister a2be1abc6b chore: update Preact to 10.19.6 (#2331) 2024-02-22 10:46:41 +01:00
Reed von Redwitz 82c75f85e9 fix: update dependency recommendations (#2320)
closes https://github.com/denoland/fresh/issues/2319

The issue is because `imports.ts` wasn't changed before releasing. I
thought I would go through and bump some other versions as well. This
handles everything except the esbuild stuff and `tests/`.
2024-02-19 10:33:04 +01:00
Marvin Hagemeister aeca15eeb9 fix: open redirect issue with trailing slash detection (#2313)
Passing a path like `/foo/bar` as the location header is interpreted as
a relative path. But when it contains two leading slashes like
`//evil.com/` it is interpreted as a port relative url. This has the
consequence that the origin of a URL can essentially be replaced:

```ts
new URL("//evil.com", "https://example.com/");
// -> 'https://evil.com/'
```

Our trailing slash detection logic didn't guard against this case. By
normalizing the pathname of the URL and stripping sibling forward
slashes we sidestep this problem.
2024-02-14 15:25:16 +01:00
Roj [roːʒ] d19c22d592 feat: add back twind in init wizard (#2290) 2024-01-30 12:34:38 +01:00
Reed von Redwitz 3f28cc8977 chore: upgrade tailwind to 3.4.1 (#2287) 2024-01-29 14:10:28 +01:00
Reed von Redwitz a83765efaa fix: no-window lint error (#2272)
Latest PR runs are failing with linting errors, e.g.
https://github.com/denoland/fresh/actions/runs/7625625084/job/20770308634?pr=2266

Maybe this shouldn't be happening like this right now, but we'll still
need to clean these up eventually.
2024-01-23 21:51:38 +01:00
Marvin Hagemeister 9f81806c6e fix: __FRSH_STATE potentially being overwritten by user code (#2256)
As outlined in https://github.com/denoland/fresh/issues/2254 it was
possible to overwrite the script tag that is used by Fresh to pass
island props from the server to the client. This could be done by
injecting raw HTML via `dangerouslySetInnerHTML` and simply using the
same id that Fresh was using.

With this PR we generate a unique id per render that cannot be guessed
anymore. It's composed of `__FRSH_STATE_<uuid>`
2024-01-15 19:41:12 +01:00
Luca Casonato 8583394481 fix: prototype pollution in deserializer (#2255)
This is not exploitable in practice unless a user maliciously crafts
serialized values in __FRSH_STATE, because `serializer()` never outputs
serialized representation that would be vulnerable to prototype
pollution. But hey, defense in depth.
2024-01-15 18:03:59 +00:00
Igor Brasileiro e7bf6aca62 fix: Prevent update doc title from partial if not present (#2244)
fixes #2243
2024-01-12 18:47:40 +01:00
Reed von Redwitz ca8338e04d chore: bump std to 0.211.0 and loader to 0.8.3 (#2241) 2024-01-11 15:54:41 +01:00
Marvin Hagemeister d2e9ee99a2 fix: browser url not updated with form partials (#2236)
Fixes https://github.com/denoland/fresh/issues/2173
2024-01-10 15:36:30 +01:00
Marvin Hagemeister 912f3782a3 feat: improve tailwind deployment flow (#2227)
By moving folks from `twind` over to the `tailwind` plugin we have
traded support questions about "how to get twind autocompletion
working?" with "my styles are not showing up in automatic mode". The
tailwind plugin has a hard requirement on having a build step. We have
documented this at various places and have a guide on how to set
everything up, but it's much better if we float those steps from Fresh
itself when we detect this.

With this PR we will prepare a `.github/workflows/deploy.yml` file
already where the user only needs to swap out the project name.

When Fresh is started in production mode, the tailwind plugin is active
and no snapshot files were loaded, then we print a helpful hint to the
console:

```sh
No pre-compiled tailwind styles found.

Did you forget to run "deno task build" prior to starting the production server?
```

When we are running inside Deno Deploy this PR goes one step further.
Since it is the first time many users might use Deno Deploy we'll also
show a simple page that shows how to finish the tailwind setup. I've
intentionally tried to not present this as a warning but rather as a
"finishing" step to avoid scaring users off. It's not the prettiest
page, but it's good enough for now.

<img width="892" alt="Screenshot 2024-01-09 at 23 41 27"
src="https://github.com/denoland/fresh/assets/1062408/9bf2a61b-5551-4d8e-bdf8-b498072f8e98">


Fixes https://github.com/denoland/fresh/issues/2223
2024-01-10 10:35:26 +01:00
Marvin Hagemeister f63752062a chore: change assert to with for import attributes (#2231) 2024-01-10 10:25:07 +01:00
Marvin Hagemeister 598237d5dd fix: json import attribute error in island (#2228)
Fixes https://github.com/denoland/fresh/issues/2214
2024-01-10 00:33:38 +01:00
Marvin Hagemeister 8c4385043c Revert "refactor: use --env CLI arg" (#2212)
Reverts denoland/fresh#2204

The `--env` flag cannot be used by default because it fails when no
`.env` file is present. Therefore this PR accidentally introduced a
breaking change.
2024-01-04 11:53:15 +01:00
Asher Gomez 99eb5435bb refactor: use --env CLI arg (#2204)
This change replaces the use of the Standard Library's `dotenv.load()`
with the native `--env` CLI flag.

The benefits include:
* One less dependency
* More obvious consumption of the `.env` file in the CLI output
2023-12-29 10:47:15 +01:00
Marvin Hagemeister 498aa8c463 fix: don't fallthrough static files in dev (#2156) 2023-12-07 12:23:23 +01:00
Marvin Hagemeister c72f534369 fix: route param fallback not empty string (#2146) 2023-12-06 09:33:36 +01:00