Commit Graph
152 Commits
Author SHA1 Message Date
Reed von Redwitz a3f7c212f4 feat(server): multiple island exports (#1397) 2023-07-03 09:59:38 +02:00
Marvin Hagemeister 16be99e69b fix: change MultiHandler back to Handlers (#1396) 2023-07-03 09:57:46 +02:00
Reed von RedwitzandLino Le Van eb53d53ab8 fix(server): properly sanitize island names (#1393)
Co-authored-by: Lino Le Van <11367844+lino-levan@users.noreply.github.com>
2023-07-03 02:08:47 +02:00
Marvin Hagemeister ced2215446 chore: extract withPageName util (#1389) 2023-07-02 13:14:53 +02:00
Reed von Redwitz 70e9c556c3 feat(starter): always initialize _app.tsx (#1380) 2023-07-01 12:59:10 +02:00
Reed von Redwitz 0db3a0911a feat: pass middleware state in props (#1264) 2023-06-28 14:53:42 +02:00
Aushwin 851f8d60aa refactor: changed Handlers type to MultiHandler (#1360) 2023-06-28 12:52:48 +00:00
Reed von Redwitz a30c6bdf5c fix(test): cli_test now retries to move files (#1372) 2023-06-28 14:47:26 +02:00
Kamil Ogórek aff31c0f15 fix: Use custom 500 page for *all* handlers if present (#1362) 2023-06-27 11:05:05 +02:00
Marvin Hagemeister 2b92b1c526 fix: conditional sibling islands DOM order (#1324) 2023-06-26 13:57:05 +02:00
Reed von Redwitz ae984924e5 fix: update script broken when using src dir (#1353)
closes https://github.com/denoland/fresh/issues/1338

This is more complex than first expected. It turns out the head of main
no longer has this error, because we started swallowing errors in
https://github.com/denoland/fresh/pull/1327. I'm not sure this is the
right implementation. It seems like we should explicitly check for the
`islands` folder instead of ignoring errors. But the obvious approach
(https://deno.land/std@0.192.0/fs/mod.ts?s=exists) is apparently
forbidden, due to some sort of nonsense with race conditions. Well, not
being able to find `islands` because it doesn't exist at all is
definitely different than it being buried in a source directory, so
we'll need to sort this out at some point.

I suppose that's now some technical debt to deal with, and not related
to this issue. The latest "error" when running `update` and using a
source directory is the following:
```
deno run -A -r file:///Users/reed/code/fresh/update.ts .
The manifest has been generated for 0 routes and 0 islands.
```
i.e. it just doesn't do anything. (To be fair, it does generate a
`fresh.gen.ts` in the incorrect location, so I suppose it does
_something_.)

But of course this isn't what we want. So we'll hunt for a source
directory, as defined by the precense of `main.ts`.

The fix for this is relatively straightforward. The test implements the
user's actions, i.e. init a project, move things, and then try to
update.
2023-06-24 13:28:05 +02:00
Marvin Hagemeister 124c597112 chore: remove stray console.log in tests (#1351) 2023-06-23 13:41:31 +00:00
Reed von Redwitz 03dbbd4f8e fix: update script supports deno.jsonc files (#1349) 2023-06-23 14:26:22 +02:00
Marvin Hagemeister 76d838cf10 chore: add index layout to island tests (#1340) 2023-06-22 16:23:05 +02:00
arrow2nd ab461cd71d fix: update.ts fails when there is no islands directory (#1327) 2023-06-21 19:11:50 +02:00
Marvin Hagemeister 3a83c5974d chore: simplify folder tests (#1337) 2023-06-21 14:02:25 +02:00
Marvin Hagemeister 87b15885aa feat(starter): add 404 page template (#1336) 2023-06-21 11:01:48 +02:00
Luca Casonato 29966ad8bb feat: don't require connInfo in request handler (#1278) 2023-06-18 21:39:11 +02:00
Marvin Hagemeister ea6a74237d feat: improve starter template design (#1320) 2023-06-17 20:31:08 +02:00
Kamil Ogórek d5a8692b78 feat: Allow passing props to renderNotFound method (#1310) 2023-06-16 17:12:01 +02:00
Reed von Redwitz f5f8928c89 feat(server): trailing slash configuration (#1291) 2023-06-15 19:01:07 +02:00
Marvin Hagemeister 80306563d2 fix: rendering islands inside other islands (#1295) 2023-06-15 17:55:17 +02:00
Marvin Hagemeister ce0eda7654 feat: allow passing JSX children to island + nested islands (#1285) 2023-06-15 10:08:48 +02:00
Marvin Hagemeister 36d56a9878 feat(server): pick free port if none specified (#1274) 2023-06-12 13:18:52 +02:00
Marvin Hagemeister 69f4fecf5a feat(server): make startup message easier to see (#1273) 2023-06-12 10:42:17 +02:00
Marvin Hagemeister 48de711df4 chore(tests): don't cancel child process stream (#1262) 2023-06-09 13:44:11 +02:00
Marvin Hagemeister 894f56b9c9 chore(tests): use to spin up server (#1261) 2023-06-09 11:27:56 +02:00
Marvin Hagemeister 5724b73e71 fix(ssr): invalid HTML comment tags (#1260) 2023-06-09 11:21:36 +02:00
Marvin HagemeisterandAsher Gomez be08573a95 feat(debug): show rendering issues during SSR (#1256)
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-06-08 08:53:14 +02:00
Luca Casonato bb48f7b8eb feat: limited npm: specifier support (#1245)
This commit adds limited support for `npm:` specifiers. Right now,
`npm:` specifiers are unsupported on Deno Deploy.

Towards #978
2023-06-06 17:41:29 +02:00
Tom dd4e584a3e feat: async plugin rendering (#745)
An async render hook is added to plugins that enables injecting stylesheets and scripts based on the rendered HTML text.
2023-06-06 12:36:04 +02:00
Marvin Hagemeister cd760b90d4 chore(test): extract shared start server code (#1250)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
2023-06-05 18:52:22 +02:00
Savin Angel-MarioandAsher Gomez 6e1874ccca feat: use PORT environment variable to change port (#468)
This can be useful when deploying to other providers.

Also more convenient for projects with multiple developers with port
preferences

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-06-05 09:08:46 +02:00
ayame113 b51f83b42d fix: actually preload all necessary files (#1242) 2023-06-03 22:07:01 +02:00
Asher GomezandLuca Casonato 1b6678951a feat: support embedded import map in deno.json (#1188)
One can now inline the `imports` and `scopes` from the import map directly into deno.json.

For new projects, `import_map.json` is not generated anymore.

Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-06-03 10:46:40 +02:00
Lino Le VanandAsher Gomez 736c5524d5 chore: upgrade preact to 10.15.1 and std to 0.190.0 (#1237)
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-06-03 10:04:23 +10:00
Asher Gomez 02dec2f483 chore: upgrade preact-render-to-string to 6.0.3 (#1236) 2023-06-02 16:24:14 +02:00
Asher Gomez 8fa4141e06 refactor: replace useState() with useSignal() (#1234) 2023-06-02 06:43:01 +10:00
ayame113andLuca Casonato 7b35cb07d4 feat: preloading JavaScript files (#1189)
close #1187

## points

- use `<link rel="modulepreload">` tag and `Link: rel="modulepreload"`
header to preload dependencies
- No preloading at all for pages that don't use JavaScript at all.
- Information about preloading is delivered only when the JS file has
already been built. If the JS file hasn't finished building, it will
respond without preload information instead of waiting for the build and
then returning the HTML.

## performance comparison

I've deployed this branch to https://fresh-module-preload.deno.dev/ so
you can try it out and see how it behaves.

When I accessed [fresh.deno.dev](https://fresh.deno.dev/) and
[fresh-module-preload.deno.dev](https://fresh-module-preload.deno.dev/)
20 times each and measured the DOMContentLoaded time, it was 24% faster
(157.3ms -> 118.95ms) in my environment (Nagano City, Japan).

<details>
<summary>Actual measured data</summary>

(Don't forget to check `Disable Cache` in devtools)

 | afeter (ms) | before (ms)
-- | -- | --
0 | 180 | 152
1 | 82 | 144
2 | 78 | 186
3 | 156 | 196
4 | 88 | 211
5 | 85 | 123
6 | 162 | 209
7 | 154 | 110
8 | 86 | 175
9 | 135 | 109
10 | 183 | 117
11 | 115 | 159
12 | 99 | 173
13 | 83 | 131
14 | 82 | 142
15 | 135 | 160
16 | 120 | 125
17 | 148 | 152
18 | 118 | 229
19 | 90 | 143
average | 118.95 | 157.3

</details>

## screen shots


![image](https://github.com/denoland/fresh/assets/40050810/c8f6d46b-77da-4e20-b29c-3b0219907872)


![image](https://github.com/denoland/fresh/assets/40050810/3159904c-07f0-45ee-a9ca-7bed35a292ca)

---------

Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-06-01 11:18:28 +10:00
Khang Nguyen DuyandLuca Casonato a49e2d04e3 feat: remove hardcoded deno.json path (#1208)
`deno.json` files can now be placed in a parent directory of the file
containing `fresh.gen.ts`.

Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-05-31 12:02:28 +02:00
Luca Casonato a6852fa58f feat: more advanced prop serializer for islands (#1224)
This commit adds support for an advanced (de)serializer that is used
for page state (island props and plugin state). This new serializer
supports maintaining references (thus supporting circular objects,
and multi-referenced objects).

This is a pre-requisite for allowing to pass signals, JSX, Uint8Arrays,
Date, and many other "advanced" values.
2023-05-31 10:12:07 +02:00
Leo Kettmeir 060e2bb50d feat: add status and headers overwrite for HandlerContext.render (#725) 2023-05-31 10:09:53 +02:00
Asher Gomez b5532aeb69 feat: island sub-directories (#1185) 2023-05-31 05:29:56 +10:00
Luca Casonato 96ba036c12 fix: better HEAD handling with less special casing (#1206)
We now add a default HEAD handler to the server, rather than special
casing HEAD requests elsewhere. Static files now get their own optimized
HEAD handler that does not read the file contents.
2023-05-30 17:22:18 +10:00
Luca CasonatoandAsher Gomez 87b087e358 fix: __FRSH_BUILD_ID is not defined (#1207)
This could happen if the runtime/utils.ts coe was loaded
prior to server/constants.ts, because they had some shared state on
`globalThis`.

I have mitigated this by not relying on global state anymore.

Fixes #1191

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-05-30 10:46:44 +10:00
Asher Gomez e0cb693c0f chore(deps): update to std@0.189.0 (#1201) 2023-05-27 17:36:15 +10:00
7f3fd51cca Optimise images size (#1101)
Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
Co-authored-by: Jheyson Saavedra <hello@jheysaav.me>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-05-25 19:45:01 +10:00
Luca CasonatoandAsher Gomez f95f7586f5 fix: don't change scheme on redirect (#1024)
Fixes #1015

This scenario can happen when a user has a proxy sitting in front of
Fresh, that does TLS termination, while Fresh is running on plain text
HTTP.

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-05-25 18:40:40 +10:00
azerum 1a456444e4 add test case covering islands that return null (#1203)
Just a small addition to my previous PR. It wasn't obvious for me that
PR #1172 also fixed #1129. I guess that issue should be covered by a
separate test
2023-05-25 09:40:49 +10:00
Kamil OgórekandAsher Gomez e86a126c0a feat(server): Allow for custom HEAD method implementations (#1175)
Fixes https://github.com/denoland/fresh/issues/1115
Fixes https://github.com/denoland/fresh/issues/1165

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-05-25 08:55:09 +10:00