Commit Graph
215 Commits
Author SHA1 Message Date
Marvin Hagemeister 95fc13a8cc fix: signals not serialized with newer versions (#1348) 2023-06-23 11:58:07 +02:00
arrow2nd ab461cd71d fix: update.ts fails when there is no islands directory (#1327) 2023-06-21 19:11:50 +02:00
EBIBO 9b98e13e29 fix: raise minimum deno version to 1.31.0 (#1333)
Fresh uses `Deno.Command` which is not available in older versions of Deno.
2023-06-21 07:27:18 +00:00
Marvin Hagemeister 1e1257f92f fix: incorrect coloring in ansi256 terminals (#1323) 2023-06-18 22:23:07 +02:00
Luca Casonato 29966ad8bb feat: don't require connInfo in request handler (#1278) 2023-06-18 21:39:11 +02:00
kit 4e2abd67dd feat(init): make project name as default header title (#1275)
default header title should be same as project name
2023-06-18 06:39:37 +02:00
Lino Le Van 4d66f95ef6 feat: serialize bigints for islands (#1317) 2023-06-17 20:31:58 +02:00
Kamil Ogórek 2b11803528 docs: Export missing Plugin types to fix broken links (#1319) 2023-06-17 19:05:14 +02:00
Kamil Ogórek d5a8692b78 feat: Allow passing props to renderNotFound method (#1310) 2023-06-16 17:12:01 +02:00
Luca Casonato 1753ee8620 fix: remove duplicated esbuild imports (#1302)
This somehow snuck in during the src/build/ refactor.
2023-06-16 01:06:49 +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
Asher Gomez 5ef6fa34d9 fix: use await Deno.serve().finished (#1287)
[A recent change in the
runtime](https://github.com/denoland/deno/pull/19485) has changed the
behaviour of `Deno.serve()` such that it throws when called a promise.
The correct way to do it is instead to call `Deno.serve().finished` as a
promise. This PR does that.

Fixes
https://github.com/denoland/fresh/pull/1286#issuecomment-1589987387
2023-06-14 08:23:51 +10: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 5724b73e71 fix(ssr): invalid HTML comment tags (#1260) 2023-06-09 11:21:36 +02:00
Gabe 347e353357 chore: correct misspelled variable (#1258)
Renames `entires` to `entries`.
2023-06-09 15:26:36 +10: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
Igor Brasileiro 273aa2ac5c feat: break island render task into to multiple tasks (#1019)
Each island is now rendered in a separate task. This significantly reduces blocking time.
2023-06-07 12:32:16 +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
Luca Casonato da5d507b77 fix: remove top level <script> imports (#1246)
Instead, rely only on modulepreload for script preloading.
2023-06-05 18:21:08 +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
Luca Casonato 3857a49f1c chore: clean up esbuild builder logic (#1231)
This will allow us to add various caches and similar around the esbuild
builder easily in follow up PRs.

It also makes doing an AOT build-step + load assets from disk much
simpler.
2023-06-03 10:24:15 +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
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
kit b558b6e759 feat: add PageProps to _app (#1229) 2023-05-31 11:13:08 +00:00
Luca Casonato 4e001d5199 fix: buildIdPlugin breaks when Fresh is hosted (#1230)
Only file:// URLs were supported previously, which breaks if you are
importing Fresh via HTTPS URLs.
2023-05-31 10:04:58 +00: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
Asher Gomez 8fc117d000 chore: upgrade to esbuild_deno_loader@0.7.0 (#1228) 2023-05-31 09:04:38 +00:00
Luca Casonato 38e67b0a97 feat: support passing Uint8Array as island props (#1225)
This commit adds support for passing Uint8Array's to islands in
component props.
2023-05-31 08:34:57 +00:00
Luca Casonato e3f9a0df08 feat: support passing signals as island props (#757)
This commit adds support for passing signals to islands in component
props. This is useful for passing around mutable state between islands.
The signal's value needs to be serializable for this to work.
2023-05-31 10:29:46 +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
Octo8080X 675036b33c feat: add createHandler() (#622)
I cut out the function that gets an hundler from fresh.

The purpose is to prepare you to create tests for your application.
The introduction of this feature does not affect fresh.

Example:

```typescript main_test.ts
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />

import { createHandler } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";

import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
import { assertEquals } from "https://deno.land/std@0.148.0/testing/asserts.ts";
import {
  type RequestHandlerLike,
} from "https://deno.land/x/superdeno/src/types.ts";
import {
  Document,
  DOMParser,
} from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";


Deno.test("HTTP assert test.", async (t) => {
  await t.step("#1 GET /", async () => {
    const handler = await createHandler(manifest) as RequestHandlerLike;

    await superdeno(handler)
      .get("/")
      .expect(200);
  });
  await t.step("#2 GET /Foo", async () => {
    const server = await createHandler(manifest) as RequestHandlerLike;

    const r = await superdeno(server)
      .get("/Foo")
      .expect(200);

    const document: Document = new DOMParser().parseFromString(
      r.text,
      "text/html",
    )!;

    assertEquals(document.querySelector("div")?.innerText, "Hello Foo");
  });

  await t.step("#3 GET /Foo/Bar", async () => {
    const server = await createHandler(manifest) as RequestHandlerLike;

    await superdeno(server)
      .get("/Foo/Bar")
      .expect(404);
  });
});
```

```sh
$ deno test -A main_test.ts
Check file:///usr/src/app/my-project/main_test.ts
running 1 test from ./main_test.ts
HTTP assert test. ...
  #1 GET / ... ok (53ms)
  #2 GET /Foo ... ok (50ms)
  #3 GET /Foo/Bar ... ok (45ms)
HTTP assert test. ... ok (154ms)

ok | 1 passed (3 steps) | 0 failed (300ms)
```

This was discussed in a separate pull request, but prepared in a
separate branch based on @lucacasonato suggestion.

[Add a function to get a server class
instance.](https://github.com/denoland/fresh/pull/552)

Thenk you.
2023-05-30 10:29:26 +10:00
Geoff FlarityandAsher Gomez 41a75fe1f5 chore: remove stale workaround in collect() (#1078)
The issue in question, https://github.com/denoland/deno_std/issues/1310,
has been marked complete. Looks like the underlying issue has been
fixed. So this just removes the comment/unnecessary code.

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-05-27 17:44:35 +10:00
Asher Gomez e0cb693c0f chore(deps): update to std@0.189.0 (#1201) 2023-05-27 17:36:15 +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
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
azerumandAsher Gomez 7d23ed5984 fix: conditionally rendered element under fragment in island does not render (#1172)
This might be fixing #502, but I am not sure. All tests pass. I've added
additional test cases for comments from #502

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-05-23 12:24:05 +10:00
CemandAsher Gomez 114c4dbfab dotenv option (#740)
added dotenv option to read environment variables files

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-05-17 09:48:39 +10:00
6feac0d2d8 fix(server): obfuscated deployment id in build id (#1168)
Co-authored-by: John Pope <88814278+innovatedev-john-pope@users.noreply.github.com>

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2023-05-13 11:09:21 +02:00
Luca CasonatoandJohn Pope 96b89d2a05 fix: cleanup pathname with multiple trailing slashes (#1167)
Co-authored-by: John Pope <88814278+innovatedev-john-pope@users.noreply.github.com>
2023-05-12 17:34:45 +02:00