Compare commits
21
Commits
724879d1aa
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e37c2aea7 | ||
|
|
7595cf396f | ||
|
|
0b6be21d14 | ||
|
|
8c552d05d1 | ||
|
|
3866b47741 | ||
|
|
8400c019e0 | ||
|
|
0e6aa1d232 | ||
|
|
dd635e0fbe | ||
|
|
cc42b17dfb | ||
|
|
dda4a30f9c | ||
|
|
8aa05e104d | ||
|
|
216d54a0ae | ||
|
|
ae22ec5276 | ||
|
|
86d6cdeb33 | ||
|
|
56faed1998 | ||
|
|
3afaaf4f78 | ||
|
|
072d09297e | ||
|
|
1fcf2d9ad5 | ||
|
|
acd04e13f8 | ||
|
|
d738f22e02 | ||
|
|
562b82f554 |
@@ -1,128 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
- Demonstrating empathy and kindness toward other people
|
||||
- Being respectful of differing opinions, viewpoints, and experiences
|
||||
- Giving and gracefully accepting constructive feedback
|
||||
- Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
- Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
- The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
- Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at hello@lcas.dev.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
@@ -1,20 +0,0 @@
|
||||
# Contributing Guidelines
|
||||
|
||||
For the full contributing guide, see the
|
||||
[Fresh documentation](https://fresh.deno.dev/docs/latest/contributing).
|
||||
|
||||
## PR title format
|
||||
|
||||
PR titles must be all lowercase and start with one of the following prefixes:
|
||||
|
||||
- `feat:` - new features
|
||||
- `fix:` - bug fixes
|
||||
- `test:` - test additions or changes
|
||||
- `chore:` - maintenance, refactoring, docs
|
||||
- `ci:` - CI/CD changes
|
||||
|
||||
Example: `feat: add middleware compilation`
|
||||
|
||||
## Before submitting
|
||||
|
||||
Run `deno task ok` and ensure it passes.
|
||||
@@ -1,7 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
# Check for updates to GitHub Actions every week
|
||||
interval: "weekly"
|
||||
@@ -1,84 +0,0 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
pr-title:
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Validate PR title
|
||||
env:
|
||||
TITLE: ${{ github.event.pull_request.title }}
|
||||
run: |
|
||||
if ! echo "$TITLE" | grep -qP '^(chore|ci|docs|feat|fix|perf|refactor|test):'; then
|
||||
echo "::error::PR title must start with chore:, ci:, docs:, feat:, fix:, perf:, refactor: or test:"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 15
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
deno: ["v2.x", "canary"]
|
||||
os: [macOS-latest, windows-latest, ubuntu-latest]
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
cache_path: ~/.cache/deno/
|
||||
- os: macos-latest
|
||||
cache_path: ~/Library/Caches/deno/
|
||||
- os: windows-latest
|
||||
cache_path: ~\AppData\Local\deno\
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Deno
|
||||
uses: denoland/setup-deno@v2
|
||||
with:
|
||||
cache: true
|
||||
deno-version: ${{ matrix.deno }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: deno install
|
||||
|
||||
- name: Verify formatting
|
||||
if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x'
|
||||
run: deno fmt --check
|
||||
|
||||
- name: Run linter
|
||||
if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x'
|
||||
run: deno lint
|
||||
|
||||
- name: Spell-check
|
||||
if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x'
|
||||
uses: crate-ci/typos@master
|
||||
|
||||
- name: Type check project
|
||||
run: deno task check:types
|
||||
|
||||
- name: Run tests
|
||||
run: deno task test
|
||||
|
||||
- name: Check docs
|
||||
run: deno task check:docs
|
||||
|
||||
- name: Build fresh.deno.dev
|
||||
if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x'
|
||||
run: deno task build-www
|
||||
|
||||
- name: Check links
|
||||
if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x'
|
||||
run: deno task check:links
|
||||
|
||||
- name: Dry-run publish
|
||||
if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x'
|
||||
run: deno publish --dry-run
|
||||
@@ -1,24 +0,0 @@
|
||||
name: post_publish
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
update-dl-version:
|
||||
name: update dl.deno.land version
|
||||
runs-on: ubuntu-22.04
|
||||
if: github.repository == 'denoland/fresh'
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Upload version file to dl.deno.land
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ vars.S3_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
|
||||
AWS_ENDPOINT_URL_S3: ${{ vars.S3_ENDPOINT }}
|
||||
AWS_DEFAULT_REGION: ${{ vars.S3_REGION }}
|
||||
run: |
|
||||
cat packages/fresh/deno.json | jq -r ".version" > release-latest.txt
|
||||
aws s3 cp release-latest.txt s3://dl-deno-land/fresh/release-latest.txt --cache-control "no-cache"
|
||||
@@ -1,31 +0,0 @@
|
||||
name: Publish JSR
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
# Skip publishing for forks
|
||||
if: github.repository_owner == 'denoland'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install Deno
|
||||
uses: denoland/setup-deno@v2
|
||||
with:
|
||||
cache: true
|
||||
deno-version: canary
|
||||
|
||||
- name: Install dependencies
|
||||
run: deno install
|
||||
|
||||
- name: Publish
|
||||
run: deno publish
|
||||
@@ -7,24 +7,26 @@ with workspace members in `packages/*` and `www/`.
|
||||
|
||||
### Packages
|
||||
|
||||
- **`packages/fresh/`** (`@fresh/core`): Core framework — routing, rendering,
|
||||
islands, build cache, middlewares, and client/server runtime.
|
||||
- **`packages/plugin-vite/`** (`@fresh/plugin-vite`): Vite integration plugin
|
||||
- **`packages/fresh/`** (`@paulaboks/sweet`): Core framework — routing,
|
||||
rendering, islands, build cache, middlewares, and client/server runtime.
|
||||
- **`packages/plugin-vite/`** (`@paulaboks/sweet-vite`): Vite integration plugin
|
||||
with dev server, SSR/client builds, and HMR.
|
||||
- **`packages/init/`** (`@fresh/init`): Project scaffolding
|
||||
(`deno run -Ar jsr:@fresh/init`).
|
||||
- **`packages/init/`** (`@paulaboks/sweet-init`): Project scaffolding
|
||||
(`deno run -Ar jsr:@paulaboks/sweet-init`).
|
||||
- **`packages/update/`** (`@fresh/update`): Automated Fresh 1.x to 2.x migration
|
||||
tool using ts-morph for AST transforms.
|
||||
- **`packages/build-id/`** (`@fresh/build-id`): Build/deployment ID generation.
|
||||
- **`packages/plugin-tailwindcss/`** (`@fresh/plugin-tailwind`): TailwindCSS v4
|
||||
plugin.
|
||||
- **`packages/plugin-tailwindcss-v3/`** (`@fresh/plugin-tailwind-v3`): Legacy
|
||||
- **`packages/build-id/`** (`@paulaboks/sweet-build-id`): Build/deployment ID
|
||||
generation.
|
||||
- **`packages/plugin-tailwindcss/`** (`@paulaboks/sweet-tailwind`): TailwindCSS
|
||||
v4 plugin.
|
||||
- **`packages/plugin-tailwindcss-v3/`** (`@paulaboks/sweet-tailwind-v3`): Legacy
|
||||
TailwindCSS v3 plugin.
|
||||
- **`packages/examples/`** (`@fresh/examples`): Example components for tests.
|
||||
- **`packages/examples/`** (`@paulaboks/sweet-examples`): Example components for
|
||||
tests.
|
||||
|
||||
### Other directories
|
||||
|
||||
- **`www/`**: Documentation website (fresh.deno.dev), built with Fresh + Vite +
|
||||
- **`www/`**: Documentation website (usefresh.dev), built with Fresh + Vite +
|
||||
Tailwind. Has its own routes, islands, and vite.config.ts.
|
||||
- **`docs/`**: Markdown documentation organized by version (`latest/`, `1.x/`,
|
||||
`canary/`).
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
# fresh
|
||||
|
||||
<img align="right" src="https://fresh.deno.dev/logo.svg" height="150px" alt="The Fresh logo: a sliced lemon dripping with juice">
|
||||
<img align="right" src="https://usefresh.dev/logo.svg" height="150px" alt="The Fresh logo: a sliced lemon dripping with juice">
|
||||
|
||||
**Fresh** is a next generation web framework, built for speed, reliability, and
|
||||
simplicity.
|
||||
@@ -18,8 +18,8 @@ Some stand-out features:
|
||||
|
||||
## 📖 Documentation
|
||||
|
||||
The [documentation](https://fresh.deno.dev/docs/introduction) is available on
|
||||
[fresh.deno.dev](https://fresh.deno.dev/).
|
||||
The [documentation](https://usefresh.dev/docs/introduction) is available on
|
||||
[usefresh.dev](https://usefresh.dev/).
|
||||
|
||||
## 🚀 Getting started
|
||||
|
||||
@@ -29,7 +29,7 @@ You can scaffold a new project by running the Fresh init script. To scaffold a
|
||||
project run the following:
|
||||
|
||||
```sh
|
||||
deno run -Ar jsr:@fresh/init
|
||||
deno run -Ar jsr:@paulaboks/sweet-init
|
||||
```
|
||||
|
||||
Then navigate to the newly created project folder:
|
||||
@@ -58,7 +58,7 @@ To deploy the project to the live internet, you can use
|
||||
subdomain with no configuration necessary.
|
||||
|
||||
For a more in-depth getting started guide, visit the
|
||||
[Getting Started](https://fresh.deno.dev/docs/getting-started) page in the Fresh
|
||||
[Getting Started](https://usefresh.dev/docs/getting-started) page in the Fresh
|
||||
docs.
|
||||
|
||||
## Contributing
|
||||
@@ -69,9 +69,8 @@ We appreciate your help! To contribute, please read our
|
||||
## Adding your project to the showcase
|
||||
|
||||
If you feel that your project would be helpful to other Fresh users, please
|
||||
consider putting your project on the
|
||||
[showcase](https://fresh.deno.dev/showcase). However, websites that are just for
|
||||
promotional purposes may not be listed.
|
||||
consider putting your project on the [showcase](https://usefresh.dev/showcase).
|
||||
However, websites that are just for promotional purposes may not be listed.
|
||||
|
||||
To take a screenshot, run the following command.
|
||||
|
||||
@@ -88,15 +87,15 @@ preferably with source code on GitHub, but not required.
|
||||

|
||||
|
||||
```md
|
||||
[](https://fresh.deno.dev)
|
||||
[](https://usefresh.dev)
|
||||
```
|
||||
|
||||
```html
|
||||
<a href="https://fresh.deno.dev">
|
||||
<a href="https://usefresh.dev">
|
||||
<img
|
||||
width="197"
|
||||
height="37"
|
||||
src="https://fresh.deno.dev/fresh-badge.svg"
|
||||
src="https://usefresh.dev/fresh-badge.svg"
|
||||
alt="Made with Fresh"
|
||||
/>
|
||||
</a>
|
||||
@@ -105,15 +104,15 @@ preferably with source code on GitHub, but not required.
|
||||

|
||||
|
||||
```md
|
||||
[](https://fresh.deno.dev)
|
||||
[](https://usefresh.dev)
|
||||
```
|
||||
|
||||
```html
|
||||
<a href="https://fresh.deno.dev">
|
||||
<a href="https://usefresh.dev">
|
||||
<img
|
||||
width="197"
|
||||
height="37"
|
||||
src="https://fresh.deno.dev/fresh-badge-dark.svg"
|
||||
src="https://usefresh.dev/fresh-badge-dark.svg"
|
||||
alt="Made with Fresh"
|
||||
/>
|
||||
</a>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"imports": {
|
||||
"@deno/doc": "jsr:@deno/doc@^0.172.0",
|
||||
"@deno/esbuild-plugin": "jsr:@deno/esbuild-plugin@^1.2.0",
|
||||
"@fresh/build-id": "jsr:@fresh/build-id@^1.0.0",
|
||||
"@paulaboks/sweet-build-id": "jsr:@paulaboks/sweet-build-id@^1.0.0",
|
||||
"@std/cli": "jsr:@std/cli@^1.0.19",
|
||||
"@std/collections": "jsr:@std/collections@^1.1.2",
|
||||
"@std/dotenv": "jsr:@std/dotenv@^0.225.5",
|
||||
@@ -58,7 +58,7 @@
|
||||
"docsearch": "npm:@docsearch/js@^3.5.2",
|
||||
"esbuild": "npm:esbuild@0.25.7",
|
||||
"esbuild-wasm": "npm:esbuild-wasm@0.25.7",
|
||||
"fresh": "jsr:@fresh/core@^2.0.0",
|
||||
"sweet": "jsr:@paulaboks/sweet@^2.0.0",
|
||||
"mime-db": "npm:mime-db@^1.54.0",
|
||||
"preact": "npm:preact@^10.28.2",
|
||||
"preact-render-to-string": "npm:preact-render-to-string@^6.6.5",
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
"jsr:@deno/graph@~0.82.3": "0.82.3",
|
||||
"jsr:@deno/loader@0.4": "0.4.0",
|
||||
"jsr:@deno/loader@~0.3.10": "0.3.14",
|
||||
"jsr:@fresh/build-id@1": "1.0.1",
|
||||
"jsr:@fresh/core@2.3.3": "2.3.3",
|
||||
"jsr:@marvinh-test/fresh-island@^0.0.3": "0.0.3",
|
||||
"jsr:@marvinh-test/import-json@^0.0.1": "0.0.1",
|
||||
"jsr:@matmen/imagescript@^1.3.0": "1.3.1",
|
||||
@@ -71,17 +73,17 @@
|
||||
"jsr:@zip-js/zip-js@^2.7.52": "2.8.24",
|
||||
"npm:@babel/core@^7.28.0": "7.28.5",
|
||||
"npm:@babel/preset-react@^7.27.1": "7.28.5_@babel+core@7.28.5",
|
||||
"npm:@docsearch/js@^3.5.2": "3.9.0_@algolia+client-search@5.50.0_search-insights@2.17.3",
|
||||
"npm:@docsearch/js@^3.5.2": "3.9.0_preact-render-to-string@6.6.7__preact@10.29.8",
|
||||
"npm:@opentelemetry/api@^1.9.0": "1.9.1",
|
||||
"npm:@preact/signals@2": "2.9.0_preact@10.29.1",
|
||||
"npm:@preact/signals@^2.2.1": "2.9.0_preact@10.29.1",
|
||||
"npm:@preact/signals@^2.5.1": "2.9.0_preact@10.29.1",
|
||||
"npm:@prefresh/vite@^2.4.8": "2.4.11_preact@10.29.1_vite@7.3.1__@types+node@24.9.2__picomatch@4.0.3",
|
||||
"npm:@radix-ui/themes@^3.2.1": "3.2.1_react@19.1.1_react-dom@19.1.1__react@19.1.1",
|
||||
"npm:@preact/signals@2": "2.9.0_preact@10.29.8_preact-render-to-string@6.6.7__preact@10.29.8",
|
||||
"npm:@preact/signals@^2.2.1": "2.9.0_preact@10.29.8_preact-render-to-string@6.6.7__preact@10.29.8",
|
||||
"npm:@preact/signals@^2.5.1": "2.9.0_preact@10.29.8_preact-render-to-string@6.6.7__preact@10.29.8",
|
||||
"npm:@prefresh/vite@^2.4.8": "2.4.11_preact@10.29.8_vite@7.3.1_preact-render-to-string@6.6.7__preact@10.29.8",
|
||||
"npm:@radix-ui/themes@^3.2.1": "3.2.1_react@19.1.1_react-dom@19.1.1",
|
||||
"npm:@remix-run/node-fetch-server@0.12": "0.12.0",
|
||||
"npm:@supabase/postgrest-js@^1.21.4": "1.21.4",
|
||||
"npm:@tailwindcss/postcss@^4.1.10": "4.1.16",
|
||||
"npm:@tailwindcss/vite@^4.1.12": "4.1.16_vite@7.3.1__@types+node@24.9.2__picomatch@4.0.3_@types+node@24.9.2",
|
||||
"npm:@tailwindcss/vite@^4.1.12": "4.1.16_vite@7.3.1_@types+node@24.9.2",
|
||||
"npm:@types/babel__core@^7.20.5": "7.20.5",
|
||||
"npm:@types/mime-db@^1.43.6": "1.43.6",
|
||||
"npm:@types/node@^24.1.0": "24.9.2",
|
||||
@@ -106,13 +108,13 @@
|
||||
"npm:pg@^8.16.3": "8.16.3",
|
||||
"npm:postcss@8.5.6": "8.5.6",
|
||||
"npm:postcss@^8.5.6": "8.5.6",
|
||||
"npm:preact-render-to-string@^6.6.3": "6.6.7_preact@10.29.1",
|
||||
"npm:preact-render-to-string@^6.6.5": "6.6.7_preact@10.29.1",
|
||||
"npm:preact@^10.22.0": "10.29.1",
|
||||
"npm:preact@^10.26.9": "10.29.1",
|
||||
"npm:preact@^10.27.0": "10.29.1",
|
||||
"npm:preact@^10.28.2": "10.29.1",
|
||||
"npm:preact@^10.29.1": "10.29.1",
|
||||
"npm:preact-render-to-string@^6.6.3": "6.6.7_preact@10.29.8",
|
||||
"npm:preact-render-to-string@^6.6.5": "6.6.7_preact@10.29.8",
|
||||
"npm:preact@^10.22.0": "10.29.8_preact-render-to-string@6.6.7",
|
||||
"npm:preact@^10.26.9": "10.29.8_preact-render-to-string@6.6.7",
|
||||
"npm:preact@^10.27.0": "10.29.8_preact-render-to-string@6.6.7",
|
||||
"npm:preact@^10.28.2": "10.29.8_preact-render-to-string@6.6.7",
|
||||
"npm:preact@^10.29.8": "10.29.8_preact-render-to-string@6.6.7",
|
||||
"npm:prismjs@^1.29.0": "1.30.0",
|
||||
"npm:qs@^6.14.0": "6.14.0",
|
||||
"npm:redis@^5.8.2": "5.9.0_@redis+client@5.9.0",
|
||||
@@ -122,8 +124,8 @@
|
||||
"npm:tailwindcss@^3.4.17": "3.4.18_postcss@8.5.6_jiti@1.21.7",
|
||||
"npm:tailwindcss@^4.1.10": "4.1.16",
|
||||
"npm:ts-morph@^27.0.2": "27.0.2",
|
||||
"npm:vite-plugin-inspect@^11.3.2": "11.3.3_vite@7.3.1__@types+node@24.9.2__picomatch@4.0.3_@types+node@24.9.2",
|
||||
"npm:vite-plugin-pwa@^1.0.3": "1.2.0_vite@7.3.1__@types+node@24.9.2__picomatch@4.0.3_workbox-build@7.4.0__@types+babel__core@7.20.5_workbox-window@7.4.0_@types+babel__core@7.20.5",
|
||||
"npm:vite-plugin-inspect@^11.3.2": "11.3.3_vite@7.3.1_@types+node@24.9.2",
|
||||
"npm:vite-plugin-pwa@^1.0.3": "1.2.0_vite@7.3.1_workbox-build@7.4.0_workbox-window@7.4.0_@types+babel__core@7.20.5",
|
||||
"npm:vite@^7.1.4": "7.3.1_@types+node@24.9.2_picomatch@4.0.3",
|
||||
"npm:vite@^7.3.1": "7.3.1_@types+node@24.9.2_picomatch@4.0.3"
|
||||
},
|
||||
@@ -194,6 +196,24 @@
|
||||
"@deno/loader@0.4.0": {
|
||||
"integrity": "6c1b18cfa18592740613ce79e15625c24268d60dbfc54bebfb5153bf512c536b"
|
||||
},
|
||||
"@fresh/build-id@1.0.1": {
|
||||
"integrity": "12a2ec25fd52ae9ec68c26848a5696cd1c9b537f7c983c7e56e4fb1e7e816c20",
|
||||
"dependencies": [
|
||||
"jsr:@std/encoding@^1.0.10"
|
||||
]
|
||||
},
|
||||
"@fresh/core@2.3.3": {
|
||||
"integrity": "6c2aad199976644352c89a1d601f3ef331b1d24cdadb53ed469324a303598383",
|
||||
"dependencies": [
|
||||
"jsr:@fresh/build-id",
|
||||
"jsr:@std/fmt@^1.0.8",
|
||||
"jsr:@std/fs@^1.0.19",
|
||||
"jsr:@std/html@^1.0.5",
|
||||
"jsr:@std/http@^1.0.21",
|
||||
"jsr:@std/net",
|
||||
"jsr:@std/path@^1.1.2"
|
||||
]
|
||||
},
|
||||
"@marvinh-test/fresh-island@0.0.3": {
|
||||
"integrity": "6d06b6009b7dfba9bba28e941e03e6ff652c4ef4f2fbfdf4b78741abd6c6c1c6",
|
||||
"dependencies": [
|
||||
@@ -1337,7 +1357,7 @@
|
||||
"@docsearch/css@3.9.0": {
|
||||
"integrity": "sha512-cQbnVbq0rrBwNAKegIac/t6a8nWoUAn8frnkLFW6YARaRmAQr5/Eoe6Ln2fqkUCZ40KpdrKbpSAmgrkviOxuWA=="
|
||||
},
|
||||
"@docsearch/js@3.9.0_@algolia+client-search@5.50.0_search-insights@2.17.3": {
|
||||
"@docsearch/js@3.9.0_preact-render-to-string@6.6.7__preact@10.29.8": {
|
||||
"integrity": "sha512-4bKHcye6EkLgRE8ze0vcdshmEqxeiJM77M0JXjef7lrYZfSlMunrDOCqyLjiZyo1+c0BhUqA2QpFartIjuHIjw==",
|
||||
"dependencies": [
|
||||
"@docsearch/react",
|
||||
@@ -1630,7 +1650,7 @@
|
||||
"@floating-ui/utils"
|
||||
]
|
||||
},
|
||||
"@floating-ui/react-dom@2.1.6_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@floating-ui/react-dom@2.1.6_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-4JX6rEatQEvlmgU80wZyq9RT96HZJa88q8hp0pBd+LrczeDI4o6uA2M+uvxngVHo4Ihr8uibXxH6+70zhAFrVw==",
|
||||
"dependencies": [
|
||||
"@floating-ui/dom",
|
||||
@@ -1721,7 +1741,7 @@
|
||||
"@preact/signals-core@1.14.0": {
|
||||
"integrity": "sha512-AowtCcCU/33lFlh1zRFf/u+12rfrhtNakj7UpaGEsmMwUKpKWMVvcktOGcwBBNiB4lWrZWc01LhiyyzVklJyaQ=="
|
||||
},
|
||||
"@preact/signals@2.9.0_preact@10.29.1": {
|
||||
"@preact/signals@2.9.0_preact@10.29.8_preact-render-to-string@6.6.7__preact@10.29.8": {
|
||||
"integrity": "sha512-hYrY0KyUqkDgOl1qba/JGn6y81pXnurn21PMaxfcMwdncdZ3M/oVdmpTvEnsGjh48dIwDVc7bjWHqIsngSjYug==",
|
||||
"dependencies": [
|
||||
"@preact/signals-core",
|
||||
@@ -1731,7 +1751,7 @@
|
||||
"@prefresh/babel-plugin@0.5.2": {
|
||||
"integrity": "sha512-AOl4HG6dAxWkJ5ndPHBgBa49oo/9bOiJuRDKHLSTyH+Fd9x00shTXpdiTj1W41l6oQIwUOAgJeHMn4QwIDpHkA=="
|
||||
},
|
||||
"@prefresh/core@1.5.8_preact@10.29.1": {
|
||||
"@prefresh/core@1.5.8_preact@10.29.8_preact-render-to-string@6.6.7__preact@10.29.8": {
|
||||
"integrity": "sha512-T7HMpakS1iPVCFZvfDLMGyrWAcO3toUN9/RkJUqqoRr/vNhQrZgHjidfhq3awDzAQtw1emDWH8dsOeu0DWqtgA==",
|
||||
"dependencies": [
|
||||
"preact"
|
||||
@@ -1740,7 +1760,7 @@
|
||||
"@prefresh/utils@1.2.1": {
|
||||
"integrity": "sha512-vq/sIuN5nYfYzvyayXI4C2QkprfNaHUQ9ZX+3xLD8nL3rWyzpxOm1+K7RtMbhd+66QcaISViK7amjnheQ/4WZw=="
|
||||
},
|
||||
"@prefresh/vite@2.4.11_preact@10.29.1_vite@7.3.1__@types+node@24.9.2__picomatch@4.0.3": {
|
||||
"@prefresh/vite@2.4.11_preact@10.29.8_vite@7.3.1_preact-render-to-string@6.6.7__preact@10.29.8": {
|
||||
"integrity": "sha512-/XjURQqdRiCG3NpMmWqE9kJwrg9IchIOWHzulCfqg2sRe/8oQ1g5De7xrk9lbqPIQLn7ntBkKdqWXIj4E9YXyg==",
|
||||
"dependencies": [
|
||||
"@babel/core",
|
||||
@@ -1761,7 +1781,7 @@
|
||||
"@radix-ui/primitive@1.1.3": {
|
||||
"integrity": "sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg=="
|
||||
},
|
||||
"@radix-ui/react-accessible-icon@1.1.7_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-accessible-icon@1.1.7_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-XM+E4WXl0OqUJFovy6GjmxxFyx9opfCAIUku4dlKRd5YEPqt4kALOkQOp0Of6reHuUkJuiPBEc5k0o4z4lTC8A==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-visually-hidden",
|
||||
@@ -1769,7 +1789,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-accordion@1.2.12_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-accordion@1.2.12_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-T4nygeh9YE9dLRPhAHSeOZi7HBXo+0kYIPJXayZfvWOWA0+n3dESrZbjfDPUABkUNym6Hd+f2IR113To8D2GPA==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -1785,7 +1805,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-alert-dialog@1.1.15_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-alert-dialog@1.1.15_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-oTVLkEw5GpdRe29BqJ0LSDFWI3qu0vR1M0mUkOQWDIUnY/QIkLpgDMWuKxP94c2NAC2LGcgVhG1ImF3jkZ5wXw==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -1798,7 +1818,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-arrow@1.1.7_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-arrow@1.1.7_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-F+M1tLhO+mlQaOWspE8Wstg+z6PwxwRd8oQ8IXceWz92kfAmalTRf0EjrouQeo7QssEPfCn05B4Ihs1K9WQ/7w==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-primitive",
|
||||
@@ -1806,7 +1826,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-aspect-ratio@1.1.7_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-aspect-ratio@1.1.7_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-Yq6lvO9HQyPwev1onK1daHCHqXVLzPhSVjmsNjCa2Zcxy2f7uJD2itDtxknv6FzAKCwD1qQkeVDmX/cev13n/g==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-primitive",
|
||||
@@ -1814,7 +1834,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-avatar@1.1.10_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-avatar@1.1.10_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-V8piFfWapM5OmNCXTzVQY+E1rDa53zY+MQ4Y7356v4fFz6vqCyUtIz2rUD44ZEdwg78/jKmMJHj07+C/Z/rcog==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-context",
|
||||
@@ -1826,7 +1846,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-checkbox@1.3.3_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-checkbox@1.3.3_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-wBbpv+NQftHDdG86Qc0pIyXk5IR3tM8Vd0nWLKDcX8nNn4nXFOFwsKuqw2okA/1D/mpaAkmuyndrPJTYDNZtFw==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -1841,7 +1861,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-collapsible@1.1.12_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-collapsible@1.1.12_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-Uu+mSh4agx2ib1uIGPP4/CKNULyajb3p92LsVXmH2EHVMTfZWpll88XJ0j4W0z3f8NK1eYl1+Mf/szHPmcHzyA==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -1856,7 +1876,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-collection@1.1.7_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-collection@1.1.7_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-Fh9rGN0MoI4ZFUNyfFVNU4y9LUz93u9/0K+yLgA2bwRojxM8JU1DyvvMBabnZPBgMWREAJvU2jjVzq+LrFUglw==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-compose-refs",
|
||||
@@ -1873,7 +1893,7 @@
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-context-menu@2.2.16_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-context-menu@2.2.16_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-O8morBEW+HsVG28gYDZPTrT9UUovQUlJue5YO836tiTJhuIWBm/zQHc7j388sHWtdH/xUZurK9olD2+pcqx5ww==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -1892,7 +1912,7 @@
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-dialog@1.1.15_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-dialog@1.1.15_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-TCglVRtzlffRNxRMEyR36DGBLJpeusFcgMVD9PZEzAKnUs1lKCgX5u9BmC2Yg+LL9MgZDugFFs1Vl+Jp4t/PGw==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -1919,7 +1939,7 @@
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-dismissable-layer@1.1.11_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-dismissable-layer@1.1.11_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-Nqcp+t5cTB8BinFkZgXiMJniQH0PsUt2k51FUhbdfeKvc4ACcG2uQniY/8+h1Yv6Kza4Q7lD7PQV0z0oicE0Mg==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -1931,7 +1951,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-dropdown-menu@2.1.16_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-dropdown-menu@2.1.16_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-1PLGQEynI/3OX/ftV54COn+3Sud/Mn8vALg2rWnBLnRaGtJDduNW/22XjlGgPdpcIbiQxjKtb7BkcjP00nqfJw==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -1951,7 +1971,7 @@
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-focus-scope@1.1.7_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-focus-scope@1.1.7_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-t2ODlkXBQyn7jkl6TNaw/MtVEVvIGelJDCG41Okq/KwUsJBwQ4XVZsHAVUkK4mBv3ewiAS3PGuUWuY2BoK4ZUw==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-compose-refs",
|
||||
@@ -1961,7 +1981,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-form@0.1.8_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-form@0.1.8_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-QM70k4Zwjttifr5a4sZFts9fn8FzHYvQ5PiB19O2HsYibaHSVt9fH9rzB0XZo/YcM+b7t/p7lYCT/F5eOeF5yQ==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -1974,7 +1994,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-hover-card@1.1.15_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-hover-card@1.1.15_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-qgTkjNT1CfKMoP0rcasmlH2r1DAiYicWsDsufxl940sT2wHNEWWv6FMWIQXWhVdmC1d/HYfbhQx60KYyAtKxjg==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -1997,7 +2017,7 @@
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-label@2.1.7_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-label@2.1.7_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-YT1GqPSL8kJn20djelMX7/cTRp/Y9w5IZHvfxQTVHrOqa2yMl7i/UfMqKRU5V7mEyKTrUVgJXhNQPVCG8PBLoQ==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-primitive",
|
||||
@@ -2005,7 +2025,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-menu@2.1.16_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-menu@2.1.16_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-72F2T+PLlphrqLcAotYPp0uJMr5SjP5SL01wfEspJbru5Zs5vQaSHb4VB3ZMJPimgHHCHG7gMOeOB9H3Hdmtxg==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2030,7 +2050,7 @@
|
||||
"react-remove-scroll"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-menubar@1.1.16_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-menubar@1.1.16_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-EB1FktTz5xRRi2Er974AUQZWg2yVBb1yjip38/lgwtCVRd3a+maUoGHN/xs9Yv8SY8QwbSEb+YrxGadVWbEutA==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2047,7 +2067,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-navigation-menu@1.2.14_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-navigation-menu@1.2.14_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-YB9mTFQvCOAQMHU+C/jVl96WmuWeltyUEpRJJky51huhds5W2FQr1J8D/16sQlf0ozxkPK8uF3niQMdUwZPv5w==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2068,7 +2088,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-one-time-password-field@0.1.8_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-one-time-password-field@0.1.8_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-ycS4rbwURavDPVjCb5iS3aG4lURFDILi6sKI/WITUMZ13gMmn/xGjpLoqBAalhJaDk8I3UbCM5GzKHrnzwHbvg==",
|
||||
"dependencies": [
|
||||
"@radix-ui/number",
|
||||
@@ -2087,7 +2107,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-password-toggle-field@0.1.3_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-password-toggle-field@0.1.3_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-/UuCrDBWravcaMix4TdT+qlNdVwOM1Nck9kWx/vafXsdfj1ChfhOdfi3cy9SGBpWgTXwYCuboT/oYpJy3clqfw==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2102,7 +2122,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-popover@1.1.15_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-popover@1.1.15_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-kr0X2+6Yy/vJzLYJUPCZEc8SfQcf+1COFoAqauJm74umQhta9M7lNJHP7QQS3vkvcGLQUbWpMzwrXYwrYztHKA==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2124,7 +2144,7 @@
|
||||
"react-remove-scroll"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-popper@1.2.8_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-popper@1.2.8_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-0NJQ4LFFUuWkE7Oxf0htBKS6zLkkjBH+hM1uk7Ng705ReR8m/uelduy1DBo0PyBXPKVnBA6YBlU94MBGXrSBCw==",
|
||||
"dependencies": [
|
||||
"@floating-ui/react-dom",
|
||||
@@ -2141,7 +2161,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-portal@1.1.9_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-portal@1.1.9_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-bpIxvq03if6UNwXZ+HTK71JLh4APvnXntDc6XOX8UVq4XQOVl7lwok0AvIl+b8zgCw3fSaVTZMpAPPagXbKmHQ==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-primitive",
|
||||
@@ -2150,7 +2170,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-presence@1.1.5_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-presence@1.1.5_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-/jfEwNDdQVBCNvjkGit4h6pMOzq8bHkopq458dPt2lMjx+eBQUohZNG9A7DtO/O5ukSbxuaNGXMjHicgwy6rQQ==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-compose-refs",
|
||||
@@ -2159,7 +2179,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-primitive@2.1.3_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-primitive@2.1.3_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-m9gTwRkhy2lvCPe6QJp4d3G1TYEUHn/FzJUtq9MjH46an1wJU+GdoGC5VLof8RX8Ft/DlpshApkhswDLZzHIcQ==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-slot",
|
||||
@@ -2167,7 +2187,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-progress@1.1.7_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-progress@1.1.7_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-vPdg/tF6YC/ynuBIJlk1mm7Le0VgW6ub6J2UWnTQ7/D23KXcPI1qy+0vBkgKgd38RCMJavBXpB83HPNFMTb0Fg==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-context",
|
||||
@@ -2176,7 +2196,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-radio-group@1.3.8_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-radio-group@1.3.8_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-VBKYIYImA5zsxACdisNQ3BjCBfmbGH3kQlnFVqlWU4tXwjy7cGX8ta80BcrO+WJXIn5iBylEH3K6ZTlee//lgQ==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2193,7 +2213,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-roving-focus@1.1.11_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-roving-focus@1.1.11_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-7A6S9jSgm/S+7MdtNDSb+IU859vQqJ/QAtcYQcfFC6W8RS4IxIZDldLR0xqCFZ6DCyrQLjLPsxtTNch5jVA4lA==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2209,7 +2229,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-scroll-area@1.2.10_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-scroll-area@1.2.10_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-tAXIa1g3sM5CGpVT0uIbUx/U3Gs5N8T52IICuCtObaos1S8fzsrPXG5WObkQN3S6NVl6wKgPhAIiBGbWnvc97A==",
|
||||
"dependencies": [
|
||||
"@radix-ui/number",
|
||||
@@ -2225,7 +2245,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-select@2.2.6_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-select@2.2.6_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-I30RydO+bnn2PQztvo25tswPH+wFBjehVGtmagkU78yMdwTwVf12wnAOF+AeP8S2N8xD+5UPbGhkUfPyvT+mwQ==",
|
||||
"dependencies": [
|
||||
"@radix-ui/number",
|
||||
@@ -2253,7 +2273,7 @@
|
||||
"react-remove-scroll"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-separator@1.1.7_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-separator@1.1.7_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-0HEb8R9E8A+jZjvmFCy/J4xhbXy3TV+9XSnGJ3KvTtjlIUy/YQ/p6UYZvi7YbeoeXdyU9+Y3scizK6hkY37baA==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-primitive",
|
||||
@@ -2261,7 +2281,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-slider@1.3.6_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-slider@1.3.6_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-JPYb1GuM1bxfjMRlNLE+BcmBC8onfCi60Blk7OBqi2MLTFdS+8401U4uFjnwkOr49BLmXxLC6JHkvAsx5OJvHw==",
|
||||
"dependencies": [
|
||||
"@radix-ui/number",
|
||||
@@ -2286,7 +2306,7 @@
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-switch@1.2.6_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-switch@1.2.6_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-bByzr1+ep1zk4VubeEVViV592vu2lHE2BZY5OnzehZqOOgogN80+mNtCqPkhn2gklJqOpxWgPoYTSnhBCqpOXQ==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2300,7 +2320,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-tabs@1.1.13_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-tabs@1.1.13_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-7xdcatg7/U+7+Udyoj2zodtI9H/IIopqo+YOIcZOq1nJwXWBZ9p8xiu5llXlekDbZkca79a/fozEYQXIA4sW6A==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2315,7 +2335,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-toast@1.2.15_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-toast@1.2.15_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-3OSz3TacUWy4WtOXV38DggwxoqJK4+eDkNMl5Z/MJZaoUPaP4/9lf81xXMe1I2ReTAptverZUpbPY4wWwWyL5g==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2334,7 +2354,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-toggle-group@1.1.11_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-toggle-group@1.1.11_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-5umnS0T8JQzQT6HbPyO7Hh9dgd82NmS36DQr+X/YJ9ctFNCiiQd6IJAYYZ33LUwm8M+taCz5t2ui29fHZc4Y6Q==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2348,7 +2368,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-toggle@1.1.10_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-toggle@1.1.10_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-lS1odchhFTeZv3xwHH31YPObmJn8gOg7Lq12inrr0+BH/l3Tsq32VfjqH1oh80ARM3mlkfMic15n0kg4sD1poQ==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2358,7 +2378,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-toolbar@1.1.11_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-toolbar@1.1.11_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-4ol06/1bLoFu1nwUqzdD4Y5RZ9oDdKeiHIsntug54Hcr1pgaHiPqHFEaXI1IFP/EsOfROQZ8Mig9VTIRza6Tjg==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2372,7 +2392,7 @@
|
||||
"react-dom"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-tooltip@1.2.8_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-tooltip@1.2.8_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-tY7sVt1yL9ozIxvmbtN5qtmH2krXcBCfjEiCgKGLqunJHvgvZG2Pcl2oQ3kbcZARb1BGEHdkLzcYGO8ynVlieg==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -2452,7 +2472,7 @@
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"@radix-ui/react-visually-hidden@1.2.3_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/react-visually-hidden@1.2.3_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-pzJq12tEaaIhqjbzpCuv/OypJY/BPavOofm+dbab+MHLajy277+1lLm6JFcGgF5eskJ6mquGirhXY2GD/8u8Ug==",
|
||||
"dependencies": [
|
||||
"@radix-ui/react-primitive",
|
||||
@@ -2463,7 +2483,7 @@
|
||||
"@radix-ui/rect@1.1.1": {
|
||||
"integrity": "sha512-HPwpGIzkl28mWyZqG52jiqDJ12waP11Pa1lGoiyUkIEuMLBP0oeK/C89esbXrxsky5we7dfd8U58nm0SgAWpVw=="
|
||||
},
|
||||
"@radix-ui/themes@3.2.1_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"@radix-ui/themes@3.2.1_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-WJL2YKAGItkunwm3O4cLTFKCGJTfAfF6Hmq7f5bCo1ggqC9qJQ/wfg/25AAN72aoEM1yqXZQ+pslsw48AFR0Xg==",
|
||||
"dependencies": [
|
||||
"@radix-ui/colors",
|
||||
@@ -2825,7 +2845,7 @@
|
||||
"tailwindcss@4.1.16"
|
||||
]
|
||||
},
|
||||
"@tailwindcss/vite@4.1.16_vite@7.3.1__@types+node@24.9.2__picomatch@4.0.3_@types+node@24.9.2": {
|
||||
"@tailwindcss/vite@4.1.16_vite@7.3.1_@types+node@24.9.2": {
|
||||
"integrity": "sha512-bbguNBcDxsRmi9nnlWJxhfDWamY3lmcyACHcdO1crxfzuLpOhHLLtEIN/nCbbAtj5rchUgQD17QVAKi1f7IsKg==",
|
||||
"dependencies": [
|
||||
"@tailwindcss/node",
|
||||
@@ -4807,14 +4827,20 @@
|
||||
"xtend"
|
||||
]
|
||||
},
|
||||
"preact-render-to-string@6.6.7_preact@10.29.1": {
|
||||
"preact-render-to-string@6.6.7_preact@10.29.8": {
|
||||
"integrity": "sha512-3XdbsX3+vn9dQW+jJI/FsI9rlkgl6dbeUpqLsChak6jp3j3auFqBCkno7VChbMFs5Q8ylBj6DrUkKRwtVN3nvw==",
|
||||
"dependencies": [
|
||||
"preact"
|
||||
]
|
||||
},
|
||||
"preact@10.29.1": {
|
||||
"integrity": "sha512-gQCLc/vWroE8lIpleXtdJhTFDogTdZG9AjMUpVkDf2iTCNwYNWA+u16dL41TqUDJO4gm2IgrcMv3uTpjd4Pwmg=="
|
||||
"preact@10.29.8_preact-render-to-string@6.6.7": {
|
||||
"integrity": "sha512-ej2aVZ+vZ8WO7tvlQWRM9N63A0KzF9q4mWJfDUHgYaIofWY9hu74QdnQrjoPMmZi2/nZ5gN0bJCQF49xQqx09Q==",
|
||||
"dependencies": [
|
||||
"preact-render-to-string"
|
||||
],
|
||||
"optionalPeers": [
|
||||
"preact-render-to-string"
|
||||
]
|
||||
},
|
||||
"pretty-bytes@5.6.0": {
|
||||
"integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg=="
|
||||
@@ -4837,7 +4863,7 @@
|
||||
"queue-microtask@1.2.3": {
|
||||
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="
|
||||
},
|
||||
"radix-ui@1.4.3_react@19.1.1_react-dom@19.1.1__react@19.1.1": {
|
||||
"radix-ui@1.4.3_react@19.1.1_react-dom@19.1.1": {
|
||||
"integrity": "sha512-aWizCQiyeAenIdUbqEpXgRA1ya65P13NKn/W8rWkcN0OPkRDxdBVLWnIEDsS2RpwCK2nobI7oMUSmexzTDyAmA==",
|
||||
"dependencies": [
|
||||
"@radix-ui/primitive",
|
||||
@@ -5650,7 +5676,7 @@
|
||||
"util-deprecate@1.0.2": {
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
||||
},
|
||||
"vite-dev-rpc@1.1.0_vite@7.3.1__@types+node@24.9.2__picomatch@4.0.3_@types+node@24.9.2": {
|
||||
"vite-dev-rpc@1.1.0_vite@7.3.1_@types+node@24.9.2": {
|
||||
"integrity": "sha512-pKXZlgoXGoE8sEKiKJSng4hI1sQ4wi5YT24FCrwrLt6opmkjlqPPVmiPWWJn8M8byMxRGzp1CrFuqQs4M/Z39A==",
|
||||
"dependencies": [
|
||||
"birpc",
|
||||
@@ -5658,13 +5684,13 @@
|
||||
"vite-hot-client"
|
||||
]
|
||||
},
|
||||
"vite-hot-client@2.1.0_vite@7.3.1__@types+node@24.9.2__picomatch@4.0.3_@types+node@24.9.2": {
|
||||
"vite-hot-client@2.1.0_vite@7.3.1_@types+node@24.9.2": {
|
||||
"integrity": "sha512-7SpgZmU7R+dDnSmvXE1mfDtnHLHQSisdySVR7lO8ceAXvM0otZeuQQ6C8LrS5d/aYyP/QZ0hI0L+dIPrm4YlFQ==",
|
||||
"dependencies": [
|
||||
"vite"
|
||||
]
|
||||
},
|
||||
"vite-plugin-inspect@11.3.3_vite@7.3.1__@types+node@24.9.2__picomatch@4.0.3_@types+node@24.9.2": {
|
||||
"vite-plugin-inspect@11.3.3_vite@7.3.1_@types+node@24.9.2": {
|
||||
"integrity": "sha512-u2eV5La99oHoYPHE6UvbwgEqKKOQGz86wMg40CCosP6q8BkB6e5xPneZfYagK4ojPJSj5anHCrnvC20DpwVdRA==",
|
||||
"dependencies": [
|
||||
"ansis",
|
||||
@@ -5679,7 +5705,7 @@
|
||||
"vite-dev-rpc"
|
||||
]
|
||||
},
|
||||
"vite-plugin-pwa@1.2.0_vite@7.3.1__@types+node@24.9.2__picomatch@4.0.3_workbox-build@7.4.0__@types+babel__core@7.20.5_workbox-window@7.4.0_@types+babel__core@7.20.5": {
|
||||
"vite-plugin-pwa@1.2.0_vite@7.3.1_workbox-build@7.4.0_workbox-window@7.4.0_@types+babel__core@7.20.5": {
|
||||
"integrity": "sha512-a2xld+SJshT9Lgcv8Ji4+srFJL4k/1bVbd1x06JIkvecpQkwkvCncD1+gSzcdm3s+owWLpMJerG3aN5jupJEVw==",
|
||||
"dependencies": [
|
||||
"debug",
|
||||
@@ -5985,10 +6011,10 @@
|
||||
"jsr:@astral/astral@~0.5.6",
|
||||
"jsr:@deno/doc@0.172",
|
||||
"jsr:@deno/esbuild-plugin@^1.2.0",
|
||||
"jsr:@fresh/build-id@1",
|
||||
"jsr:@fresh/core@2",
|
||||
"jsr:@marvinh-test/fresh-island@^0.0.3",
|
||||
"jsr:@matmen/imagescript@^1.3.0",
|
||||
"jsr:@paulaboks/sweet-build-id@1",
|
||||
"jsr:@paulaboks/sweet@2",
|
||||
"jsr:@std/async@^1.0.13",
|
||||
"jsr:@std/cli@^1.0.19",
|
||||
"jsr:@std/collections@^1.1.2",
|
||||
@@ -6042,7 +6068,7 @@
|
||||
},
|
||||
"packages/examples": {
|
||||
"dependencies": [
|
||||
"jsr:@fresh/core@2",
|
||||
"jsr:@paulaboks/sweet@2",
|
||||
"npm:@preact/signals@^2.2.1",
|
||||
"npm:preact@^10.27.0"
|
||||
]
|
||||
@@ -6065,7 +6091,7 @@
|
||||
"npm:@types/node@^24.2.1",
|
||||
"npm:esbuild-wasm@~0.25.11",
|
||||
"npm:preact-render-to-string@^6.6.3",
|
||||
"npm:preact@^10.29.1"
|
||||
"npm:preact@^10.29.8"
|
||||
]
|
||||
},
|
||||
"packages/plugin-tailwindcss-v3": {
|
||||
@@ -6079,8 +6105,8 @@
|
||||
"packages/plugin-vite": {
|
||||
"dependencies": [
|
||||
"jsr:@deno/loader@0.4",
|
||||
"jsr:@fresh/core@2",
|
||||
"jsr:@marvinh-test/import-json@^0.0.1",
|
||||
"jsr:@paulaboks/sweet@2",
|
||||
"npm:@babel/core@^7.28.0",
|
||||
"npm:@babel/preset-react@^7.27.1",
|
||||
"npm:@prefresh/vite@^2.4.8",
|
||||
|
||||
@@ -144,7 +144,7 @@ for a `route`, as opposed to something like `http://localhost:8001/favicon.ico`.
|
||||
|
||||
### Example
|
||||
|
||||
Initiate a new Fresh project (`deno run -A -r https://fresh.deno.dev/`) and then
|
||||
Initiate a new Fresh project (`deno run -A -r https://usefresh.dev/`) and then
|
||||
create a `_middleware.ts` file in the `routes` folder like this:
|
||||
|
||||
```ts routes/_middleware.ts
|
||||
|
||||
@@ -42,7 +42,7 @@ To run the auto updater, run the following command from the root of your
|
||||
project:
|
||||
|
||||
```sh Terminal
|
||||
$ deno run -A -r https://fresh.deno.dev/update
|
||||
$ deno run -A -r https://usefresh.dev/update
|
||||
```
|
||||
|
||||
You will be prompted to confirm the changes that will be made to your project.
|
||||
|
||||
@@ -24,7 +24,7 @@ The purpose of the example app we're building here is to showcase the basic
|
||||
building blocks of an implementation. As such, it is limited in functionality
|
||||
and purposefully leaves out things like
|
||||
[password resets](https://supabase.com/docs/guides/auth/server-side/email-based-auth-with-pkce-flow-for-ssr),
|
||||
[proper error handling](https://fresh.deno.dev/docs/1.x/concepts/error-pages) as
|
||||
[proper error handling](https://usefresh.dev/docs/1.x/concepts/error-pages) as
|
||||
well as validating input form data. You can find the
|
||||
[full code here](https://github.com/morlinbrot/supa-fresh-pkce), where the
|
||||
missing functionality is implemented.
|
||||
@@ -226,7 +226,7 @@ we are writing next.
|
||||
|
||||
We can now write a middleware that will check the auth status of any request,
|
||||
guarding any protected routes. You can read up on middlewares and where to put
|
||||
them [in the docs](https://fresh.deno.dev/docs/1.x/concepts/middleware).
|
||||
them [in the docs](https://usefresh.dev/docs/1.x/concepts/middleware).
|
||||
|
||||
```ts routes/_middleware.ts
|
||||
import { FreshContext } from "$fresh/server.ts";
|
||||
|
||||
@@ -3,8 +3,8 @@ description: |
|
||||
Change the source directory to effectively manage your project.
|
||||
---
|
||||
|
||||
When you initialize a project with `deno run -A -r https://fresh.deno.dev`,
|
||||
you'll end up with a project like the following:
|
||||
When you initialize a project with `deno run -A -r https://usefresh.dev`, you'll
|
||||
end up with a project like the following:
|
||||
|
||||
```txt-files Project Structure
|
||||
<project root>
|
||||
|
||||
@@ -11,7 +11,7 @@ possibilities:
|
||||
3. the markdown is on a file
|
||||
|
||||
The following file uses
|
||||
[dynamic routing](https://fresh.deno.dev/docs/getting-started/dynamic-routes) to
|
||||
[dynamic routing](https://usefresh.dev/docs/getting-started/dynamic-routes) to
|
||||
handle the three cases. It's assumed this file is called `[slug].tsx`:
|
||||
|
||||
```ts routes/[slug].tsx
|
||||
|
||||
@@ -3,8 +3,8 @@ description: |
|
||||
Set the lang attribute in the <html> tag.
|
||||
---
|
||||
|
||||
When you initialize a project with `deno run -A -r https://fresh.deno.dev`,
|
||||
you'll end up with a `main.ts` like the following:
|
||||
When you initialize a project with `deno run -A -r https://usefresh.dev`, you'll
|
||||
end up with a `main.ts` like the following:
|
||||
|
||||
```ts main.ts
|
||||
/// <reference no-default-lib="true" />
|
||||
|
||||
@@ -29,7 +29,7 @@ If you need a particular commit (for testing specific fixes or features):
|
||||
"update": "deno run -A -r jsr:@fresh/update ."
|
||||
},
|
||||
"imports": {
|
||||
- "$fresh/": "jsr:@fresh/core@^2.0.0",
|
||||
- "$fresh/": "jsr:@paulaboks/sweet@^2.0.0",
|
||||
+ "$fresh/": "https://raw.githubusercontent.com/denoland/fresh/your-commit-hash/",
|
||||
"preact": "npm:preact@^10.26.9",
|
||||
"@preact/signals": "npm:@preact/signals@^2.2.0"
|
||||
@@ -59,7 +59,7 @@ For testing your own fork or PR:
|
||||
### Using JSR
|
||||
|
||||
```sh Terminal
|
||||
deno run -A -r jsr:@fresh/init@2.0.0-alpha.35
|
||||
deno run -A -r jsr:@paulaboks/sweet-init@2.0.0-alpha.35
|
||||
```
|
||||
|
||||
### From local source
|
||||
|
||||
@@ -3,8 +3,8 @@ description: |
|
||||
With a few tweaks one can use twind v1
|
||||
---
|
||||
|
||||
When you initialize a project with `deno run -A -r https://fresh.deno.dev`,
|
||||
you'll end up with a `main.ts` like the following:
|
||||
When you initialize a project with `deno run -A -r https://usefresh.dev`, you'll
|
||||
end up with a `main.ts` like the following:
|
||||
|
||||
```ts main.ts
|
||||
/// <reference no-default-lib="true" />
|
||||
|
||||
@@ -10,7 +10,7 @@ will scaffold out a new project with some example files to get you started.
|
||||
To create a new project, run:
|
||||
|
||||
```sh Terminal
|
||||
deno run -A -r https://fresh.deno.dev
|
||||
deno run -A -r https://usefresh.dev
|
||||
cd fresh-project
|
||||
deno task start
|
||||
```
|
||||
|
||||
@@ -6,51 +6,51 @@ description: |
|
||||
This page lists all public exports from Fresh's entry points.
|
||||
|
||||
> [info]: You can also explore Fresh's full API documentation on JSR:
|
||||
> [`@fresh/core`](https://jsr.io/@fresh/core/doc)
|
||||
> [`@paulaboks/sweet`](https://jsr.io/@paulaboks/sweet/doc)
|
||||
|
||||
## `fresh`
|
||||
|
||||
The main entry point for server-side code.
|
||||
|
||||
```ts
|
||||
import { App, createDefine, HttpError, page, staticFiles } from "fresh";
|
||||
import { App, createDefine, HttpError, page, staticFiles } from "sweet";
|
||||
```
|
||||
|
||||
| Export | Kind | Description |
|
||||
| --------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------- |
|
||||
| [`App`](https://jsr.io/@fresh/core/doc/~/App) | Class | The main application class. See [App](/docs/concepts/app). |
|
||||
| [`staticFiles`](https://jsr.io/@fresh/core/doc/~/staticFiles) | Function | Middleware for serving static files. See [Static Files](/docs/concepts/static-files). |
|
||||
| [`createDefine`](https://jsr.io/@fresh/core/doc/~/createDefine) | Function | Create type-safe `define.*` helpers. See [Define Helpers](/docs/advanced/define). |
|
||||
| [`page`](https://jsr.io/@fresh/core/doc/~/page) | Function | Return data from a handler to a page component. See [Data Fetching](/docs/concepts/data-fetching). |
|
||||
| [`HttpError`](https://jsr.io/@fresh/core/doc/~/HttpError) | Class | Throw HTTP errors with status codes. See [Error Handling](/docs/advanced/error-handling). |
|
||||
| [`cors`](https://jsr.io/@fresh/core/doc/~/cors) | Function | CORS middleware. See [cors](/docs/plugins/cors). |
|
||||
| [`csrf`](https://jsr.io/@fresh/core/doc/~/csrf) | Function | CSRF protection middleware. See [csrf](/docs/plugins/csrf). |
|
||||
| [`csp`](https://jsr.io/@fresh/core/doc/~/csp) | Function | Content Security Policy middleware. See [csp](/docs/plugins/csp). |
|
||||
| [`trailingSlashes`](https://jsr.io/@fresh/core/doc/~/trailingSlashes) | Function | Trailing slash enforcement middleware. See [trailingSlashes](/docs/plugins/trailing-slashes). |
|
||||
| Export | Kind | Description |
|
||||
| -------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------- |
|
||||
| [`App`](https://jsr.io/@paulaboks/sweet/doc/~/App) | Class | The main application class. See [App](/docs/concepts/app). |
|
||||
| [`staticFiles`](https://jsr.io/@paulaboks/sweet/doc/~/staticFiles) | Function | Middleware for serving static files. See [Static Files](/docs/concepts/static-files). |
|
||||
| [`createDefine`](https://jsr.io/@paulaboks/sweet/doc/~/createDefine) | Function | Create type-safe `define.*` helpers. See [Define Helpers](/docs/advanced/define). |
|
||||
| [`page`](https://jsr.io/@paulaboks/sweet/doc/~/page) | Function | Return data from a handler to a page component. See [Data Fetching](/docs/concepts/data-fetching). |
|
||||
| [`HttpError`](https://jsr.io/@paulaboks/sweet/doc/~/HttpError) | Class | Throw HTTP errors with status codes. See [Error Handling](/docs/advanced/error-handling). |
|
||||
| [`cors`](https://jsr.io/@paulaboks/sweet/doc/~/cors) | Function | CORS middleware. See [cors](/docs/plugins/cors). |
|
||||
| [`csrf`](https://jsr.io/@paulaboks/sweet/doc/~/csrf) | Function | CSRF protection middleware. See [csrf](/docs/plugins/csrf). |
|
||||
| [`csp`](https://jsr.io/@paulaboks/sweet/doc/~/csp) | Function | Content Security Policy middleware. See [csp](/docs/plugins/csp). |
|
||||
| [`trailingSlashes`](https://jsr.io/@paulaboks/sweet/doc/~/trailingSlashes) | Function | Trailing slash enforcement middleware. See [trailingSlashes](/docs/plugins/trailing-slashes). |
|
||||
|
||||
**Types:**
|
||||
|
||||
| Export | Kind | Description |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------- | --------- | --------------------------------------------------------------------------- |
|
||||
| [`Context`](https://jsr.io/@fresh/core/doc/~/Context) / [`FreshContext`](https://jsr.io/@fresh/core/doc/~/FreshContext) | Interface | The request context passed to all middlewares and handlers. |
|
||||
| [`PageProps`](https://jsr.io/@fresh/core/doc/~/PageProps) | Type | Props received by page components (`data`, `url`, `params`, `state`, etc.). |
|
||||
| [`Middleware`](https://jsr.io/@fresh/core/doc/~/Middleware) / [`MiddlewareFn`](https://jsr.io/@fresh/core/doc/~/MiddlewareFn) | Type | Middleware function type. |
|
||||
| [`HandlerFn`](https://jsr.io/@fresh/core/doc/~/HandlerFn) | Type | Single handler function type. |
|
||||
| [`HandlerByMethod`](https://jsr.io/@fresh/core/doc/~/HandlerByMethod) | Type | Object with per-method handler functions. |
|
||||
| [`RouteHandler`](https://jsr.io/@fresh/core/doc/~/RouteHandler) | Type | Union of `HandlerFn` and `HandlerByMethod`. |
|
||||
| [`PageResponse`](https://jsr.io/@fresh/core/doc/~/PageResponse) | Type | Return type of `page()`. |
|
||||
| [`RouteConfig`](https://jsr.io/@fresh/core/doc/~/RouteConfig) | Interface | Route configuration (`routeOverride`, `skipInheritedLayouts`, etc.). |
|
||||
| [`LayoutConfig`](https://jsr.io/@fresh/core/doc/~/LayoutConfig) | Interface | Layout configuration (`skipInheritedLayouts`, `skipAppWrapper`). |
|
||||
| [`Define`](https://jsr.io/@fresh/core/doc/~/Define) | Interface | Type of the object returned by `createDefine()`. |
|
||||
| [`FreshConfig`](https://jsr.io/@fresh/core/doc/~/FreshConfig) / [`ResolvedFreshConfig`](https://jsr.io/@fresh/core/doc/~/ResolvedFreshConfig) | Interface | App configuration types. |
|
||||
| [`ListenOptions`](https://jsr.io/@fresh/core/doc/~/ListenOptions) | Interface | Options for `app.listen()`. |
|
||||
| [`Island`](https://jsr.io/@fresh/core/doc/~/Island) | Type | Island component type. |
|
||||
| [`Method`](https://jsr.io/@fresh/core/doc/~/Method) | Type | HTTP method union type. |
|
||||
| [`RouteData`](https://jsr.io/@fresh/core/doc/~/RouteData) | Type | Data type returned by route handlers via `page()`. |
|
||||
| [`Lazy`](https://jsr.io/@fresh/core/doc/~/Lazy) / [`MaybeLazy`](https://jsr.io/@fresh/core/doc/~/MaybeLazy) | Type | Utility types for lazily-loaded routes and middleware. |
|
||||
| [`CORSOptions`](https://jsr.io/@fresh/core/doc/~/CORSOptions) | Interface | Options for `cors()`. |
|
||||
| [`CsrfOptions`](https://jsr.io/@fresh/core/doc/~/CsrfOptions) | Interface | Options for `csrf()`. |
|
||||
| [`CSPOptions`](https://jsr.io/@fresh/core/doc/~/CSPOptions) | Interface | Options for `csp()`. |
|
||||
| Export | Kind | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | --------------------------------------------------------------------------- |
|
||||
| [`Context`](https://jsr.io/@paulaboks/sweet/doc/~/Context) / [`FreshContext`](https://jsr.io/@paulaboks/sweet/doc/~/FreshContext) | Interface | The request context passed to all middlewares and handlers. |
|
||||
| [`PageProps`](https://jsr.io/@paulaboks/sweet/doc/~/PageProps) | Type | Props received by page components (`data`, `url`, `params`, `state`, etc.). |
|
||||
| [`Middleware`](https://jsr.io/@paulaboks/sweet/doc/~/Middleware) / [`MiddlewareFn`](https://jsr.io/@paulaboks/sweet/doc/~/MiddlewareFn) | Type | Middleware function type. |
|
||||
| [`HandlerFn`](https://jsr.io/@paulaboks/sweet/doc/~/HandlerFn) | Type | Single handler function type. |
|
||||
| [`HandlerByMethod`](https://jsr.io/@paulaboks/sweet/doc/~/HandlerByMethod) | Type | Object with per-method handler functions. |
|
||||
| [`RouteHandler`](https://jsr.io/@paulaboks/sweet/doc/~/RouteHandler) | Type | Union of `HandlerFn` and `HandlerByMethod`. |
|
||||
| [`PageResponse`](https://jsr.io/@paulaboks/sweet/doc/~/PageResponse) | Type | Return type of `page()`. |
|
||||
| [`RouteConfig`](https://jsr.io/@paulaboks/sweet/doc/~/RouteConfig) | Interface | Route configuration (`routeOverride`, `skipInheritedLayouts`, etc.). |
|
||||
| [`LayoutConfig`](https://jsr.io/@paulaboks/sweet/doc/~/LayoutConfig) | Interface | Layout configuration (`skipInheritedLayouts`, `skipAppWrapper`). |
|
||||
| [`Define`](https://jsr.io/@paulaboks/sweet/doc/~/Define) | Interface | Type of the object returned by `createDefine()`. |
|
||||
| [`FreshConfig`](https://jsr.io/@paulaboks/sweet/doc/~/FreshConfig) / [`ResolvedFreshConfig`](https://jsr.io/@paulaboks/sweet/doc/~/ResolvedFreshConfig) | Interface | App configuration types. |
|
||||
| [`ListenOptions`](https://jsr.io/@paulaboks/sweet/doc/~/ListenOptions) | Interface | Options for `app.listen()`. |
|
||||
| [`Island`](https://jsr.io/@paulaboks/sweet/doc/~/Island) | Type | Island component type. |
|
||||
| [`Method`](https://jsr.io/@paulaboks/sweet/doc/~/Method) | Type | HTTP method union type. |
|
||||
| [`RouteData`](https://jsr.io/@paulaboks/sweet/doc/~/RouteData) | Type | Data type returned by route handlers via `page()`. |
|
||||
| [`Lazy`](https://jsr.io/@paulaboks/sweet/doc/~/Lazy) / [`MaybeLazy`](https://jsr.io/@paulaboks/sweet/doc/~/MaybeLazy) | Type | Utility types for lazily-loaded routes and middleware. |
|
||||
| [`CORSOptions`](https://jsr.io/@paulaboks/sweet/doc/~/CORSOptions) | Interface | Options for `cors()`. |
|
||||
| [`CsrfOptions`](https://jsr.io/@paulaboks/sweet/doc/~/CsrfOptions) | Interface | Options for `csrf()`. |
|
||||
| [`CSPOptions`](https://jsr.io/@paulaboks/sweet/doc/~/CSPOptions) | Interface | Options for `csp()`. |
|
||||
|
||||
## `fresh/runtime`
|
||||
|
||||
@@ -65,34 +65,34 @@ import {
|
||||
HttpError,
|
||||
IS_BROWSER,
|
||||
Partial,
|
||||
} from "fresh/runtime";
|
||||
} from "sweet/runtime";
|
||||
```
|
||||
|
||||
| Export | Kind | Description |
|
||||
| --------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------- |
|
||||
| [`IS_BROWSER`](https://jsr.io/@fresh/core/doc/runtime/~/IS_BROWSER) | Constant | `true` in the browser, `false` on the server. Use to guard browser-only code. |
|
||||
| [`asset`](https://jsr.io/@fresh/core/doc/runtime/~/asset) | Function | Add cache-busting query params to asset URLs. See [Static Files](/docs/concepts/static-files). |
|
||||
| [`assetSrcSet`](https://jsr.io/@fresh/core/doc/runtime/~/assetSrcSet) | Function | Apply `asset()` to all URLs in a `srcset` string. |
|
||||
| [`Partial`](https://jsr.io/@fresh/core/doc/runtime/~/Partial) | Component | Mark a region for partial updates. See [Partials](/docs/advanced/partials). |
|
||||
| [`Head`](https://jsr.io/@fresh/core/doc/runtime/~/Head) | Component | Add elements to the document `<head>`. See [<head> element](/docs/advanced/head). |
|
||||
| [`HttpError`](https://jsr.io/@fresh/core/doc/runtime/~/HttpError) | Class | HTTP error class (re-exported from `fresh`). |
|
||||
| Export | Kind | Description |
|
||||
| -------------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------- |
|
||||
| [`IS_BROWSER`](https://jsr.io/@paulaboks/sweet/doc/runtime/~/IS_BROWSER) | Constant | `true` in the browser, `false` on the server. Use to guard browser-only code. |
|
||||
| [`asset`](https://jsr.io/@paulaboks/sweet/doc/runtime/~/asset) | Function | Add cache-busting query params to asset URLs. See [Static Files](/docs/concepts/static-files). |
|
||||
| [`assetSrcSet`](https://jsr.io/@paulaboks/sweet/doc/runtime/~/assetSrcSet) | Function | Apply `asset()` to all URLs in a `srcset` string. |
|
||||
| [`Partial`](https://jsr.io/@paulaboks/sweet/doc/runtime/~/Partial) | Component | Mark a region for partial updates. See [Partials](/docs/advanced/partials). |
|
||||
| [`Head`](https://jsr.io/@paulaboks/sweet/doc/runtime/~/Head) | Component | Add elements to the document `<head>`. See [<head> element](/docs/advanced/head). |
|
||||
| [`HttpError`](https://jsr.io/@paulaboks/sweet/doc/runtime/~/HttpError) | Class | HTTP error class (re-exported from `fresh`). |
|
||||
|
||||
## `fresh/dev`
|
||||
|
||||
Development and build tools. Only used in `dev.ts` (legacy) or build scripts.
|
||||
|
||||
```ts
|
||||
import { Builder } from "fresh/dev";
|
||||
import { Builder } from "sweet/dev";
|
||||
```
|
||||
|
||||
| Export | Kind | Description |
|
||||
| --------------------------------------------------------- | ----- | ---------------------------------------------------------------------- |
|
||||
| [`Builder`](https://jsr.io/@fresh/core/doc/dev/~/Builder) | Class | Pre-Vite build system (legacy). See [Builder](/docs/advanced/builder). |
|
||||
| Export | Kind | Description |
|
||||
| -------------------------------------------------------------- | ----- | ---------------------------------------------------------------------- |
|
||||
| [`Builder`](https://jsr.io/@paulaboks/sweet/doc/dev/~/Builder) | Class | Pre-Vite build system (legacy). See [Builder](/docs/advanced/builder). |
|
||||
|
||||
**Types:**
|
||||
|
||||
| Export | Kind | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------------------------- |
|
||||
| [`BuildOptions`](https://jsr.io/@fresh/core/doc/dev/~/BuildOptions) | Interface | Options for `new Builder()`. |
|
||||
| [`ResolvedBuildConfig`](https://jsr.io/@fresh/core/doc/dev/~/ResolvedBuildConfig) | Interface | Resolved build configuration. |
|
||||
| [`OnTransformArgs`](https://jsr.io/@fresh/core/doc/dev/~/OnTransformArgs) / [`OnTransformOptions`](https://jsr.io/@fresh/core/doc/dev/~/OnTransformOptions) / [`TransformFn`](https://jsr.io/@fresh/core/doc/dev/~/TransformFn) | Type | Build plugin hook types. |
|
||||
| Export | Kind | Description |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------------------------- |
|
||||
| [`BuildOptions`](https://jsr.io/@paulaboks/sweet/doc/dev/~/BuildOptions) | Interface | Options for `new Builder()`. |
|
||||
| [`ResolvedBuildConfig`](https://jsr.io/@paulaboks/sweet/doc/dev/~/ResolvedBuildConfig) | Interface | Resolved build configuration. |
|
||||
| [`OnTransformArgs`](https://jsr.io/@paulaboks/sweet/doc/dev/~/OnTransformArgs) / [`OnTransformOptions`](https://jsr.io/@paulaboks/sweet/doc/dev/~/OnTransformOptions) / [`TransformFn`](https://jsr.io/@paulaboks/sweet/doc/dev/~/TransformFn) | Type | Build plugin hook types. |
|
||||
|
||||
@@ -111,7 +111,7 @@ routes that return JSON, or pages that need a completely different HTML
|
||||
structure. Use `skipAppWrapper` in the route config:
|
||||
|
||||
```tsx routes/embed.tsx
|
||||
import { type RouteConfig } from "fresh";
|
||||
import { type RouteConfig } from "sweet";
|
||||
import { define } from "../utils.ts";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
|
||||
@@ -11,7 +11,7 @@ The `Builder` class is used to generate production assets of your app. You'll
|
||||
typically find it being created inside your project's `dev.ts` file.
|
||||
|
||||
```ts dev.ts
|
||||
import { Builder } from "fresh/dev";
|
||||
import { Builder } from "sweet/dev";
|
||||
|
||||
const builder = new Builder({ target: "safari12" });
|
||||
|
||||
@@ -167,12 +167,12 @@ that.
|
||||
}
|
||||
```
|
||||
|
||||
2. Run `deno install jsr:@fresh/plugin-tailwind`
|
||||
2. Run `deno install jsr:@paulaboks/sweet-tailwind`
|
||||
3. Update `dev.ts`:
|
||||
|
||||
```diff dev.ts
|
||||
import { Builder } from "fresh/dev";
|
||||
+ import { tailwind } from "@fresh/plugin-tailwind";
|
||||
import { Builder } from "sweet/dev";
|
||||
+ import { tailwind } from "@paulaboks/sweet-tailwind";
|
||||
|
||||
const builder = new Builder();
|
||||
+ tailwind(builder);
|
||||
@@ -205,8 +205,8 @@ If you can't update to the current version of tailwindcss we have a dedicated
|
||||
decided on your own when it's best to update to v4.
|
||||
|
||||
```ts dev.ts
|
||||
import { Builder } from "fresh/dev";
|
||||
import { tailwind } from "@fresh/plugin-tailwind-v3";
|
||||
import { Builder } from "sweet/dev";
|
||||
import { tailwind } from "@paulaboks/sweet-tailwind-v3";
|
||||
|
||||
tailwind(builder, {});
|
||||
```
|
||||
|
||||
@@ -30,7 +30,7 @@ export async function otherMiddleware(ctx: Context<State>): Promise<Response> {
|
||||
With define helpers:
|
||||
|
||||
```ts util.ts
|
||||
import { createDefine } from "fresh";
|
||||
import { createDefine } from "sweet";
|
||||
|
||||
// Setup, do this once in a file and import it everywhere else.
|
||||
export const define = createDefine<{ foo: string }>();
|
||||
|
||||
@@ -21,7 +21,7 @@ Fresh supports two kind of error pages:
|
||||
To add an error page use [`app.onError()`](/docs/concepts/app#onerror).
|
||||
|
||||
```ts main.ts
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.onError("*", (ctx) => {
|
||||
@@ -77,13 +77,13 @@ If you need to bail out of execution and need to respond with a particular HTTP
|
||||
error code, you can use Fresh's `HttpError` class:
|
||||
|
||||
```ts
|
||||
import { HttpError } from "fresh";
|
||||
import { HttpError } from "sweet";
|
||||
```
|
||||
|
||||
`HttpError` takes a status code and an optional message:
|
||||
|
||||
```ts middleware/auth.ts
|
||||
import { HttpError } from "fresh";
|
||||
import { HttpError } from "sweet";
|
||||
|
||||
async function authMiddleware(ctx) {
|
||||
const user = ctx.state.user;
|
||||
@@ -106,7 +106,7 @@ When an `HttpError` is thrown, Fresh catches it and invokes the error handler.
|
||||
You can check the status code in your error handler:
|
||||
|
||||
```ts
|
||||
import { HttpError } from "fresh";
|
||||
import { HttpError } from "sweet";
|
||||
|
||||
app.onError("*", (ctx) => {
|
||||
if (ctx.error instanceof HttpError) {
|
||||
|
||||
@@ -102,6 +102,12 @@ export default define.page<typeof handler>(function Upload(props) {
|
||||
});
|
||||
```
|
||||
|
||||
## Other HTTP methods
|
||||
|
||||
Browsers can only submit forms as `GET` or `POST`. To submit a form as `DELETE`,
|
||||
`PATCH` or `PUT` and update part of the page with the response, use
|
||||
[Partials](/docs/advanced/partials#using-other-http-methods).
|
||||
|
||||
## A note of caution
|
||||
|
||||
These examples are simplified to demonstrate how Deno and Fresh handle HTTP
|
||||
|
||||
@@ -44,7 +44,7 @@ For more complex scenarios, or to set page metadata from
|
||||
[islands](/docs/concepts/islands), Fresh ships with the `<Head>`-component.
|
||||
|
||||
```tsx routes/about.tsx
|
||||
import { Head } from "fresh/runtime";
|
||||
import { Head } from "sweet/runtime";
|
||||
|
||||
export default define.page((ctx) => {
|
||||
return (
|
||||
@@ -66,7 +66,7 @@ component state changes, the document head is updated automatically:
|
||||
|
||||
```tsx islands/MetaUpdater.tsx
|
||||
import { useState } from "preact/hooks";
|
||||
import { Head } from "fresh/runtime";
|
||||
import { Head } from "sweet/runtime";
|
||||
|
||||
export default function MetaUpdater() {
|
||||
const [title, setTitle] = useState("Welcome");
|
||||
|
||||
@@ -19,7 +19,7 @@ The quickest way to get started is to enable partials for every page in
|
||||
|
||||
```diff routes/_app.tsx
|
||||
import { define } from "../utils.ts";
|
||||
+ import { Partial } from "fresh/runtime";
|
||||
+ import { Partial } from "sweet/runtime";
|
||||
|
||||
export default define.page(function App({ Component }) {
|
||||
return (
|
||||
@@ -105,7 +105,7 @@ the sidebar might look like this respectively.
|
||||
|
||||
```tsx routes/partials/docs/[id].tsx
|
||||
import { define } from "../utils.ts";
|
||||
import { Partial } from "fresh/runtime";
|
||||
import { Partial } from "sweet/runtime";
|
||||
|
||||
// We only want to render the content, so disable
|
||||
// the `_app.tsx` template as well as any potentially
|
||||
@@ -145,6 +145,201 @@ two links and _only_ load the content rendered by our optimized partial route.
|
||||
> Currently, `f-partial` is scoped to `<a>`, `<button>` and `<form>` elements.
|
||||
> This might be extended to more elements in the future.
|
||||
|
||||
## Submitting forms
|
||||
|
||||
Forms inside an `f-client-nav` element can be submitted as a partial request.
|
||||
For `GET` and `POST` forms, this happens when the form opts in through one of
|
||||
these attributes:
|
||||
|
||||
- an `action` attribute on the `<form>`
|
||||
- an `f-partial` attribute on the `<form>`
|
||||
- a `formaction` or `f-partial` attribute on the submit button
|
||||
|
||||
A `GET` form sends its fields as URL search parameters. Every other method sends
|
||||
them as a `multipart/form-data` request body. If the submit button has a `name`,
|
||||
its value is included too.
|
||||
|
||||
A `GET` or `POST` form without any of these attributes is submitted the normal
|
||||
way, with a full page load. Forms with `method="dialog"` are never intercepted.
|
||||
|
||||
### Using other HTTP methods
|
||||
|
||||
Browsers can only submit forms as `GET` or `POST`. Fresh lets forms inside
|
||||
`f-client-nav` use any other method too, like `DELETE`, `PATCH` or `PUT`. You
|
||||
set it with the `method` attribute on the form or the `formmethod` attribute on
|
||||
a submit button, and Fresh sends the request with `fetch()`.
|
||||
|
||||
```tsx routes/index.tsx
|
||||
import { Partial } from "sweet/runtime";
|
||||
import { define } from "../utils.ts";
|
||||
|
||||
export const handler = define.handlers({
|
||||
POST(ctx) {
|
||||
return ctx.render(<Partial name="body">post!</Partial>);
|
||||
},
|
||||
DELETE(ctx) {
|
||||
return ctx.render(<Partial name="body">delete!</Partial>);
|
||||
},
|
||||
PATCH(ctx) {
|
||||
return ctx.render(<Partial name="body">patch!</Partial>);
|
||||
},
|
||||
});
|
||||
|
||||
export default define.page(function Home() {
|
||||
return (
|
||||
<div f-client-nav>
|
||||
<form action="/">
|
||||
<button type="submit" formmethod="POST">post</button>
|
||||
<button type="submit" formmethod="DELETE">delete</button>
|
||||
<button type="submit" formmethod="PATCH">patch</button>
|
||||
</form>
|
||||
<Partial name="body">nothing submitted yet</Partial>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
A form that uses another method is always submitted as a partial request. It
|
||||
doesn't need an `action` or `f-partial` attribute. Without them, the request
|
||||
goes to the current page. You can write the method in any case: Fresh converts
|
||||
it to uppercase, so `formmethod="patch"` reaches your `PATCH` handler.
|
||||
|
||||
The `POST` button above only submits as a partial because the form has an
|
||||
`action` attribute. Without it, `POST` would cause a full page load, while the
|
||||
`DELETE` and `PATCH` buttons would still work as partials.
|
||||
|
||||
Keep the following in mind when using other methods:
|
||||
|
||||
- **The URL doesn't change:** Unlike `GET` and `POST`, these methods leave the
|
||||
URL in the address bar as it is. See
|
||||
[Controlling the URL](#controlling-the-url).
|
||||
- **Redirects:** To redirect after a `DELETE`, `PATCH` or `PUT`, respond with
|
||||
status `303 See Other`. With a `301` or `302`, `fetch()` sends the request to
|
||||
the new URL again with the same method. The partials from the redirect target
|
||||
are applied, but the URL only changes to it if you set `f-update-url="true"`.
|
||||
- **Without JavaScript:** If JavaScript isn't loaded, the browser doesn't
|
||||
recognize the method and submits the form as a `GET` request instead, with the
|
||||
fields in the URL. If a form has to work without JavaScript, use `POST`.
|
||||
- **CSRF protection:** The [CSRF middleware](/docs/plugins/csrf) treats these
|
||||
methods like `POST`, so they get the same checks.
|
||||
|
||||
### Controlling the URL
|
||||
|
||||
When a `GET` or `POST` form is submitted as a partial, Fresh replaces the URL in
|
||||
the address bar with the form's action URL, or with the URL it was redirected
|
||||
to. Other methods leave the URL as it is, so a `DELETE` to `/items/1` doesn't
|
||||
leave `/items/1` in the address bar.
|
||||
|
||||
To change this, set `f-update-url` on the form or on the submit button. The
|
||||
button's value wins if both have one.
|
||||
|
||||
- `f-update-url="true"` updates the URL, for any method
|
||||
- `f-update-url="false"` leaves the URL as it is, for any method
|
||||
|
||||
```tsx
|
||||
<form action="/search" f-update-url="false">
|
||||
<input name="q" />
|
||||
<button type="submit">Search</button>
|
||||
</form>;
|
||||
```
|
||||
|
||||
> [info]: Use the strings `"true"` and `"false"`. Preact leaves the attribute
|
||||
> out when you pass the boolean `{false}`, so Fresh falls back to the default.
|
||||
|
||||
### Sending requests from buttons
|
||||
|
||||
A `<button>` with an `f-partial` attribute also triggers a partial request on
|
||||
its own. This applies to buttons outside a form and to buttons with
|
||||
`type="button"`. Submit buttons inside a form submit the form instead, as
|
||||
described above. By default, the button sends a `GET` request to the `f-partial`
|
||||
URL and applies the partials in the response. Unlike links, buttons don't change
|
||||
the URL in the address bar.
|
||||
|
||||
To use another method, add an `f-method` attribute. This is handy for actions
|
||||
like deleting an item from a list, where wrapping each button in a `<form>`
|
||||
would be awkward.
|
||||
|
||||
```tsx routes/todos.tsx
|
||||
import { Partial } from "sweet/runtime";
|
||||
import { define } from "../utils.ts";
|
||||
|
||||
export const handler = define.handlers({
|
||||
async DELETE(ctx) {
|
||||
const form = await ctx.req.formData();
|
||||
await deleteTodo(String(form.get("id")));
|
||||
return ctx.render(<TodoList todos={await getTodos()} />);
|
||||
},
|
||||
});
|
||||
|
||||
function TodoList(props: { todos: Todo[] }) {
|
||||
return (
|
||||
<Partial name="todos">
|
||||
<ul>
|
||||
{props.todos.map((todo) => (
|
||||
<li key={todo.id}>
|
||||
{todo.title}
|
||||
<button
|
||||
type="button"
|
||||
f-partial="/todos"
|
||||
f-method="DELETE"
|
||||
name="id"
|
||||
value={todo.id}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Partial>
|
||||
);
|
||||
}
|
||||
|
||||
export default define.page(async () => {
|
||||
const todos = await getTodos();
|
||||
return (
|
||||
<div f-client-nav>
|
||||
<TodoList todos={todos} />
|
||||
</div>
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
When `f-method` is set to something other than `GET`, the request body is
|
||||
`multipart/form-data` and contains:
|
||||
|
||||
- the button's own `name` and `value`, if it has a `name`
|
||||
- every field of the surrounding form, if the button is a `type="button"` inside
|
||||
a `<form>`
|
||||
|
||||
A `GET` button doesn't send any data. Like with forms, you can write the method
|
||||
in any case.
|
||||
|
||||
To ask for confirmation first, call `preventDefault()` on the click event in an
|
||||
island. Fresh won't send the request when the event was cancelled.
|
||||
|
||||
```tsx islands/DeleteButton.tsx
|
||||
export function DeleteButton(props: { id: string }) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
f-partial="/todos"
|
||||
f-method="DELETE"
|
||||
name="id"
|
||||
value={props.id}
|
||||
onClick={(e) => {
|
||||
if (!confirm("Delete this todo?")) e.preventDefault();
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
[Loading indicators](#loading-indicators) work on these buttons too, and the
|
||||
same advice about redirects applies. Buttons with `f-partial` rely on
|
||||
JavaScript, so they do nothing if JavaScript isn't loaded.
|
||||
|
||||
## Sending multiple Partials at the same time
|
||||
|
||||
A neat aspect of partials in Fresh is that a response can return as many
|
||||
|
||||
@@ -32,9 +32,9 @@ command.
|
||||
## Update Fresh
|
||||
|
||||
The easiest way to resolve most issues is to ensure that you're on the
|
||||
[latest version](https://jsr.io/@fresh/core/versions) of Fresh. We continuously
|
||||
work on Fresh and there is a good chance that the issue you're running into has
|
||||
already been resolved in the latest version of Fresh.
|
||||
[latest version](https://jsr.io/@paulaboks/sweet/versions) of Fresh. We
|
||||
continuously work on Fresh and there is a good chance that the issue you're
|
||||
running into has already been resolved in the latest version of Fresh.
|
||||
|
||||
## Don't use esm.sh
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ The Fresh Vite plugin can be configured in `vite.config.ts`:
|
||||
|
||||
```ts vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@@ -49,7 +49,7 @@ generally come first:
|
||||
|
||||
```ts vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
|
||||
export default defineConfig({
|
||||
@@ -85,6 +85,158 @@ changes to components, islands, and CSS are reflected in the browser instantly
|
||||
without a full page reload. This is powered by Prefresh, Preact's fast refresh
|
||||
implementation.
|
||||
|
||||
## Migrating from the Builder to Vite
|
||||
|
||||
If your Fresh 2 project was created with `--builder` (or predates the Vite
|
||||
plugin), it uses the legacy [`Builder`](/docs/advanced/builder) class wired up
|
||||
in `dev.ts`. Migrating to Vite is mostly a matter of swapping `dev.ts` for a
|
||||
`vite.config.ts`, moving CSS into the module graph, and updating `deno.json`.
|
||||
|
||||
### 1. Update `deno.json`
|
||||
|
||||
Add the Vite plugin and `vite` itself to your imports, drop the Builder-only
|
||||
Tailwind packages (if any), and point `compilerOptions.types` at Vite's client
|
||||
types so HMR and asset imports type-check:
|
||||
|
||||
```diff deno.json
|
||||
{
|
||||
"nodeModulesDir": "manual",
|
||||
"tasks": {
|
||||
- "dev": "deno run -A --watch=static/,routes/ dev.ts",
|
||||
- "build": "deno run -A dev.ts build",
|
||||
+ "dev": "vite",
|
||||
+ "build": "vite build",
|
||||
"start": "deno serve -A _fresh/server.js"
|
||||
},
|
||||
"imports": {
|
||||
"sweet": "jsr:@paulaboks/sweet@^2",
|
||||
"preact": "npm:preact@^10",
|
||||
"@preact/signals": "npm:@preact/signals@^2",
|
||||
+ "@paulaboks/sweet-vite": "jsr:@paulaboks/sweet-vite@^1",
|
||||
+ "vite": "npm:vite@^7",
|
||||
+ "@types/babel__core": "npm:@types/babel__core@^7"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "precompile",
|
||||
"jsxImportSource": "preact",
|
||||
+ "types": ["vite/client"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you were using `@paulaboks/sweet-tailwind` / `@fresh/plugin-tailwindcss-v3`,
|
||||
remove those imports — Vite has a first-party Tailwind plugin (see step 4).
|
||||
|
||||
### 2. Replace `dev.ts` with `vite.config.ts`
|
||||
|
||||
Delete `dev.ts` and create a `vite.config.ts` at the project root:
|
||||
|
||||
```ts vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [fresh()],
|
||||
});
|
||||
```
|
||||
|
||||
If you passed options to `new Builder({ ... })` (custom `serverEntry`,
|
||||
`islandDir`, `routeDir`, `staticDir`, `ignore`), pass the equivalent options to
|
||||
`fresh({ ... })` — the names match. See [Configuration](#configuration) above.
|
||||
|
||||
Any `builder.registerIsland("jsr:@scope/pkg/Island.tsx")` calls become
|
||||
`fresh({ islandSpecifiers: ["jsr:@scope/pkg/Island.tsx"] })`.
|
||||
|
||||
### 3. Add a `client.ts` entry
|
||||
|
||||
The Builder discovered CSS by scanning `static/`. Vite needs CSS to be part of
|
||||
the module graph so it can hash, bundle, and hot-reload it. Move your stylesheet
|
||||
out of `static/` and import it from a new `client.ts` file:
|
||||
|
||||
```diff Project structure
|
||||
<project root>
|
||||
- ├── static/styles.css
|
||||
+ ├── assets/styles.css
|
||||
+ ├── client.ts
|
||||
├── vite.config.ts
|
||||
└── main.ts
|
||||
```
|
||||
|
||||
```ts client.ts
|
||||
// Import CSS files here for hot module reloading to work.
|
||||
import "./assets/styles.css";
|
||||
```
|
||||
|
||||
Then remove the manual `<link>` from your app wrapper — Vite injects the
|
||||
stylesheet for you:
|
||||
|
||||
```diff routes/_app.tsx
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>My App</title>
|
||||
- <link rel="stylesheet" href="/styles.css" />
|
||||
</head>
|
||||
```
|
||||
|
||||
Static assets that are not part of the JS/CSS graph (favicons, images served by
|
||||
URL, robots.txt, …) stay in `static/`.
|
||||
|
||||
### 4. Switch the Tailwind plugin (if applicable)
|
||||
|
||||
Replace the Builder-side Tailwind plugin with the official Vite plugin:
|
||||
|
||||
```diff deno.json
|
||||
"imports": {
|
||||
- "@paulaboks/sweet-tailwind": "jsr:@paulaboks/sweet-tailwind@^1",
|
||||
- "@tailwindcss/postcss": "npm:@tailwindcss/postcss@^4",
|
||||
- "postcss": "npm:postcss@^8",
|
||||
+ "@tailwindcss/vite": "npm:@tailwindcss/vite@^4",
|
||||
"tailwindcss": "npm:tailwindcss@^4"
|
||||
}
|
||||
```
|
||||
|
||||
```ts vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [fresh(), tailwindcss()],
|
||||
});
|
||||
```
|
||||
|
||||
Make sure your stylesheet starts with `@import "tailwindcss";` and is imported
|
||||
from `client.ts`.
|
||||
|
||||
### 5. Verify
|
||||
|
||||
Run `deno install` to pull in the new npm packages, then:
|
||||
|
||||
```sh Terminal
|
||||
deno task dev # starts Vite with HMR
|
||||
deno task build # writes _fresh/server.js and client assets
|
||||
deno task start # deno serve -A _fresh/server.js
|
||||
```
|
||||
|
||||
The output layout under `_fresh/` is the same as the Builder produced, so
|
||||
deployment configuration (Deno Deploy, Docker, `deno compile`) does not need to
|
||||
change.
|
||||
|
||||
### Checklist
|
||||
|
||||
- [ ] `dev.ts` removed, `vite.config.ts` added
|
||||
- [ ] `client.ts` created and imports your CSS
|
||||
- [ ] Stylesheet moved out of `static/` and the `<link>` removed from `_app.tsx`
|
||||
- [ ] `deno.json` tasks point at `vite` / `vite build`
|
||||
- [ ] `@paulaboks/sweet-vite`, `vite`, and `@types/babel__core` in `imports`
|
||||
- [ ] `"vite/client"` in `compilerOptions.types`
|
||||
- [ ] Tailwind (if used) switched to `@tailwindcss/vite`
|
||||
|
||||
> [info]: If you get stuck, run `deno run -Ar jsr:@paulaboks/sweet-init` in a
|
||||
> scratch directory and diff the generated project against yours — the generator
|
||||
> is the source of truth for a working Vite-based Fresh setup.
|
||||
|
||||
## Debugging
|
||||
|
||||
To debug Vite resolution issues, run Vite with the `--debug` flag:
|
||||
@@ -98,7 +250,7 @@ To inspect plugin transformations, use
|
||||
|
||||
```ts vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
import inspect from "vite-plugin-inspect";
|
||||
|
||||
export default defineConfig({
|
||||
|
||||
@@ -6,12 +6,30 @@ description: |
|
||||
Fresh provides built-in helpers for upgrading HTTP connections to WebSockets.
|
||||
There are two main approaches depending on your use case.
|
||||
|
||||
> [info]: WebSocket upgrades under the Vite dev server (`deno task dev`) require
|
||||
> **Fresh 2.4+** and **Deno 2.8+**. On older versions `Deno.upgradeWebSocket()`
|
||||
> cannot complete the 101 handshake for requests Vite forwards from its Node
|
||||
> HTTP server, so `ctx.upgrade()` and `app.ws()` silently hang and the `open`
|
||||
> handler is never invoked.
|
||||
>
|
||||
> If you're stuck on an older Deno or Fresh, exercise WebSocket endpoints with a
|
||||
> production-style build instead:
|
||||
>
|
||||
> ```sh
|
||||
> deno task build && deno task start
|
||||
> ```
|
||||
>
|
||||
> This runs `deno serve` directly, so `Deno.upgradeWebSocket()` works as
|
||||
> expected. Alternatively, run a separate Deno entry point (e.g.
|
||||
> `deno serve -A main.ts`) alongside Vite, or host the WebSocket server as a
|
||||
> sidecar on its own port.
|
||||
|
||||
## Quick start with `app.ws()`
|
||||
|
||||
The simplest way to add a WebSocket endpoint:
|
||||
|
||||
```ts main.ts
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.ws("/ws", {
|
||||
|
||||
@@ -13,7 +13,7 @@ A handler fetches data and returns it with `page()`. The page component receives
|
||||
it in `props.data`:
|
||||
|
||||
```tsx routes/projects/[id].tsx
|
||||
import { HttpError, page } from "fresh";
|
||||
import { HttpError, page } from "sweet";
|
||||
import { define } from "@/utils.ts";
|
||||
|
||||
interface Data {
|
||||
@@ -60,7 +60,7 @@ For simpler cases, you can fetch data directly in an async component without a
|
||||
separate handler:
|
||||
|
||||
```tsx routes/projects/[id].tsx
|
||||
import { HttpError } from "fresh";
|
||||
import { HttpError } from "sweet";
|
||||
import { define } from "@/utils.ts";
|
||||
|
||||
export default define.page(async (ctx) => {
|
||||
@@ -97,7 +97,7 @@ export default define.middleware(async (ctx) => {
|
||||
```
|
||||
|
||||
```tsx routes/dashboard.tsx
|
||||
import { page } from "fresh";
|
||||
import { page } from "sweet";
|
||||
import { define } from "@/utils.ts";
|
||||
|
||||
export const handler = define.handlers({
|
||||
|
||||
@@ -11,7 +11,7 @@ in `vite.config.ts`). When you add a new file there, it will register a new
|
||||
route automatically.
|
||||
|
||||
```ts main.ts
|
||||
import { App, staticFiles } from "fresh";
|
||||
import { App, staticFiles } from "sweet";
|
||||
|
||||
const app = new App({ basePath: "/foo" })
|
||||
.use(staticFiles())
|
||||
@@ -85,7 +85,7 @@ A custom [URL pattern][urlpattern] can be specified in the route configuration.
|
||||
This pattern will be used instead of the file path based pattern:
|
||||
|
||||
```ts routes/my-route.ts
|
||||
import { RouteConfig } from "fresh";
|
||||
import { RouteConfig } from "sweet";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
routeOverride: "/x/:module@:version/:path*",
|
||||
|
||||
@@ -29,7 +29,7 @@ An island can be used anywhere like a regular Preact component. Fresh will take
|
||||
care of making it interactive on the client.
|
||||
|
||||
```tsx main.tsx
|
||||
import { App, staticFiles } from "fresh";
|
||||
import { App, staticFiles } from "sweet";
|
||||
import MyIsland from "./islands/my-island.tsx";
|
||||
|
||||
const app = new App()
|
||||
@@ -77,7 +77,7 @@ A powerful feature of Fresh is that you can pass server-rendered JSX to an
|
||||
island via props.
|
||||
|
||||
```tsx routes/index.tsx
|
||||
import { staticFiles } from "fresh";
|
||||
import { staticFiles } from "sweet";
|
||||
import MyIsland from "../islands/my-island.tsx";
|
||||
|
||||
const app = new App()
|
||||
@@ -126,7 +126,7 @@ constant from `fresh/runtime` to guard browser-only code. It is `false` on the
|
||||
server and `true` in the browser:
|
||||
|
||||
```tsx islands/my-island.tsx
|
||||
import { IS_BROWSER } from "fresh/runtime";
|
||||
import { IS_BROWSER } from "sweet/runtime";
|
||||
|
||||
export function MyIsland() {
|
||||
// Return any prerenderable JSX here which makes sense for your island
|
||||
@@ -150,7 +150,7 @@ Use an island to register and render custom elements:
|
||||
|
||||
```tsx islands/MyElement.tsx
|
||||
import { useEffect } from "preact/hooks";
|
||||
import { IS_BROWSER } from "fresh/runtime";
|
||||
import { IS_BROWSER } from "sweet/runtime";
|
||||
|
||||
export function MyElement() {
|
||||
useEffect(() => {
|
||||
@@ -182,7 +182,7 @@ inside an island:
|
||||
|
||||
```tsx islands/ThirdPartyElement.tsx
|
||||
import { useEffect } from "preact/hooks";
|
||||
import { IS_BROWSER } from "fresh/runtime";
|
||||
import { IS_BROWSER } from "sweet/runtime";
|
||||
|
||||
export function ShoelaceButton() {
|
||||
useEffect(() => {
|
||||
|
||||
@@ -103,7 +103,7 @@ full-screen dashboard, or a print view. Use `skipInheritedLayouts` in the route
|
||||
config to skip all layouts inherited from parent directories:
|
||||
|
||||
```tsx routes/login.tsx
|
||||
import { type RouteConfig } from "fresh";
|
||||
import { type RouteConfig } from "sweet";
|
||||
import { define } from "../utils.ts";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
@@ -128,7 +128,7 @@ You can also skip inherited layouts from within a layout file itself. This is
|
||||
useful when a section of your site needs a completely different shell:
|
||||
|
||||
```tsx routes/admin/_layout.tsx
|
||||
import { type LayoutConfig } from "fresh";
|
||||
import { type LayoutConfig } from "sweet";
|
||||
import { define } from "../../utils.ts";
|
||||
|
||||
export const config: LayoutConfig = {
|
||||
|
||||
@@ -7,7 +7,7 @@ Routing defines which middlewares and routes should respond to a particular
|
||||
request.
|
||||
|
||||
```ts main.ts
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.get("/", () => new Response("hello")) // Responds to: GET /
|
||||
|
||||
@@ -10,7 +10,7 @@ disk for optimal performance with
|
||||
headers.
|
||||
|
||||
```ts main.ts
|
||||
import { staticFiles } from "fresh";
|
||||
import { staticFiles } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(staticFiles());
|
||||
@@ -55,7 +55,7 @@ first directory in the array takes precedence.
|
||||
|
||||
```ts vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@@ -99,7 +99,7 @@ Use the `asset()` function to add caching headers manually. It will be served
|
||||
with a cache lifetime of one year.
|
||||
|
||||
```tsx routes/about.tsx
|
||||
import { asset } from "fresh/runtime";
|
||||
import { asset } from "sweet/runtime";
|
||||
|
||||
export default function About() {
|
||||
// Adding caching headers manually
|
||||
@@ -110,7 +110,7 @@ export default function About() {
|
||||
For `<img>` tags with a `srcset` attribute, use `assetSrcSet()`:
|
||||
|
||||
```tsx routes/gallery.tsx
|
||||
import { assetSrcSet } from "fresh/runtime";
|
||||
import { assetSrcSet } from "sweet/runtime";
|
||||
|
||||
export default function Gallery() {
|
||||
return (
|
||||
@@ -139,7 +139,7 @@ deno add -D npm:vite-imagetools
|
||||
|
||||
```ts vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
import { imagetools } from "vite-imagetools";
|
||||
|
||||
export default defineConfig({
|
||||
|
||||
@@ -7,13 +7,14 @@ description: |
|
||||
|
||||
Fresh is organized as a monorepo with multiple packages:
|
||||
|
||||
- **`packages/fresh/`** - Core Fresh framework (`@fresh/core`)
|
||||
- **`packages/plugin-vite/`** - Vite integration plugin (`@fresh/plugin-vite`)
|
||||
- **`packages/fresh/`** - Core Fresh framework (`@paulaboks/sweet`)
|
||||
- **`packages/plugin-vite/`** - Vite integration plugin
|
||||
(`@paulaboks/sweet-vite`)
|
||||
- **`packages/plugin-tailwindcss/`** - Tailwind CSS v4 plugin
|
||||
- **`packages/plugin-tailwindcss-v3/`** - Tailwind CSS v3 plugin
|
||||
- **`packages/init/`** - Project scaffolding tool
|
||||
- **`packages/update/`** - Fresh update utilities
|
||||
- **`www/`** - Documentation website (fresh.deno.dev)
|
||||
- **`www/`** - Documentation website (usefresh.dev)
|
||||
|
||||
## Getting Started
|
||||
|
||||
@@ -31,7 +32,7 @@ Run it before submitting any pull request.
|
||||
The repository uses Deno
|
||||
[workspaces](https://docs.deno.com/runtime/fundamentals/workspaces/) so all
|
||||
packages in `packages/` are automatically available to each other using their
|
||||
published names (`@fresh/core`, `@fresh/plugin-vite`, etc.).
|
||||
published names (`@paulaboks/sweet`, `@paulaboks/sweet-vite`, etc.).
|
||||
|
||||
## Development
|
||||
|
||||
@@ -56,8 +57,8 @@ the project's `deno.json`:
|
||||
```json deno.json
|
||||
{
|
||||
"imports": {
|
||||
"@fresh/core": "jsr:@fresh/core@^2.0.0",
|
||||
"@fresh/plugin-vite": "jsr:@fresh/plugin-vite@^1.0.0"
|
||||
"@paulaboks/sweet": "jsr:@paulaboks/sweet@^2.0.0",
|
||||
"@paulaboks/sweet-vite": "jsr:@paulaboks/sweet-vite@^1.0.0"
|
||||
},
|
||||
"links": [
|
||||
"../path/to/fresh/packages/fresh",
|
||||
|
||||
@@ -10,7 +10,7 @@ Deploy Fresh to Cloudflare Workers by following these instructions:
|
||||
|
||||
```diff vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
+ import { cloudflare } from "@cloudflare/vite-plugin";
|
||||
|
||||
export default defineConfig({
|
||||
|
||||
@@ -55,7 +55,7 @@ export default define.middleware((ctx) => {
|
||||
Return different formats based on the `Accept` header:
|
||||
|
||||
```ts routes/api/users/[id].ts
|
||||
import { HttpError } from "fresh";
|
||||
import { HttpError } from "sweet";
|
||||
import { define } from "@/utils.ts";
|
||||
|
||||
export const handler = define.handlers({
|
||||
@@ -110,7 +110,7 @@ session example.
|
||||
Access URL search params from the context:
|
||||
|
||||
```ts routes/search.tsx
|
||||
import { page } from "fresh";
|
||||
import { page } from "sweet";
|
||||
import { define } from "@/utils.ts";
|
||||
|
||||
export const handler = define.handlers({
|
||||
@@ -141,7 +141,7 @@ export default define.middleware(async (ctx) => {
|
||||
Or set headers on a specific route using `page()`:
|
||||
|
||||
```ts
|
||||
import { page } from "fresh";
|
||||
import { page } from "sweet";
|
||||
|
||||
return page(data, {
|
||||
headers: { "Cache-Control": "public, max-age=3600" },
|
||||
|
||||
@@ -9,7 +9,7 @@ Let's set up your first Fresh project. To create a new project, run this
|
||||
command:
|
||||
|
||||
```sh Terminal
|
||||
deno run -Ar jsr:@fresh/init
|
||||
deno run -Ar jsr:@paulaboks/sweet-init
|
||||
```
|
||||
|
||||
This will spawn a short wizard that guides you through the setup, like the
|
||||
|
||||
@@ -10,7 +10,7 @@ Standards. It's designed for building high-quality, performant, and personalized
|
||||
web applications.
|
||||
|
||||
```tsx main.ts
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.get("/", () => new Response("hello world"))
|
||||
@@ -24,7 +24,7 @@ app.listen();
|
||||
Create a new Fresh app by running:
|
||||
|
||||
```sh Terminal
|
||||
deno run -Ar jsr:@fresh/init
|
||||
deno run -Ar jsr:@paulaboks/sweet-init
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
@@ -50,7 +50,7 @@ Fresh configuration to the [fresh vite plugin](/docs/advanced/vite).
|
||||
|
||||
```ts vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
|
||||
export default defineConfig({
|
||||
@@ -86,7 +86,7 @@ Similarly, configuration related to running Fresh in production can be passed to
|
||||
`new App()`:
|
||||
|
||||
```ts main.ts
|
||||
import { App, staticFiles } from "fresh";
|
||||
import { App, staticFiles } from "sweet";
|
||||
|
||||
export const app = new App()
|
||||
// Add static file serving middleware
|
||||
@@ -158,11 +158,11 @@ accordingly.
|
||||
|
||||
## Update imports
|
||||
|
||||
Add `jsr:@fresh/plugin-vite` and `npm:vite` to `imports` in your `deno.json`
|
||||
Add `jsr:@paulaboks/sweet-vite` and `npm:vite` to `imports` in your `deno.json`
|
||||
file, either manually or with this command:
|
||||
|
||||
```shell
|
||||
deno install npm:vite jsr:@fresh/plugin-vite
|
||||
deno install npm:vite jsr:@paulaboks/sweet-vite
|
||||
```
|
||||
|
||||
This should be enough in most cases. If you still encounter problems, you may
|
||||
@@ -188,8 +188,8 @@ you can add if needed. This middleware can be used to ensure that URLs always
|
||||
have a trailing slash at the end or that they will never have one.
|
||||
|
||||
```diff main.ts
|
||||
- import { App, staticFiles } from "fresh";
|
||||
+ import { App, staticFiles, trailingSlashes } from "fresh";
|
||||
- import { App, staticFiles } from "sweet";
|
||||
+ import { App, staticFiles, trailingSlashes } from "sweet";
|
||||
|
||||
export const app = new App({ root: import.meta.url })
|
||||
.use(staticFiles())
|
||||
@@ -314,7 +314,8 @@ to [update the command](/docs/deployment/deno-compile) to generate the binary.
|
||||
If you run into problems with upgrading your app, first, try starting a new
|
||||
Fresh 2 project and looking at the new structure.
|
||||
|
||||
eg. `mkdir fresh2-demo && cd fresh2-demo && deno run -Ar jsr:@fresh/init`
|
||||
eg.
|
||||
`mkdir fresh2-demo && cd fresh2-demo && deno run -Ar jsr:@paulaboks/sweet-init`
|
||||
|
||||
### 2. Document
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ to HTTP requests. These allow the server to indicate which origins (domains,
|
||||
scheme or port) other than its own is permitted to load resources from.
|
||||
|
||||
```ts main.ts
|
||||
import { cors } from "fresh";
|
||||
import { cors } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(cors({
|
||||
@@ -24,5 +24,5 @@ const app = new App()
|
||||
|
||||
## Options
|
||||
|
||||
See the [API docs](https://jsr.io/@fresh/core/doc/~/cors) for a list of all
|
||||
See the [API docs](https://jsr.io/@paulaboks/sweet/doc/~/cors) for a list of all
|
||||
supported options
|
||||
|
||||
@@ -7,7 +7,7 @@ The `csp()` middleware can be used to add
|
||||
to HTTP requests. These restrict which resources a document is allowed to load.
|
||||
|
||||
```ts main.ts
|
||||
import { csp } from "fresh";
|
||||
import { csp } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(csp({
|
||||
@@ -32,7 +32,7 @@ This ensures only inline `<script>` and `<style>` tags rendered by Fresh are
|
||||
allowed to execute.
|
||||
|
||||
```ts main.ts
|
||||
import { csp } from "fresh";
|
||||
import { csp } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(csp({ useNonce: true }))
|
||||
@@ -70,5 +70,5 @@ When `useNonce` is enabled:
|
||||
|
||||
## Options
|
||||
|
||||
See the [API docs](https://jsr.io/@fresh/core/doc/~/csp) for a list of all
|
||||
See the [API docs](https://jsr.io/@paulaboks/sweet/doc/~/csp) for a list of all
|
||||
supported options.
|
||||
|
||||
@@ -12,7 +12,7 @@ and
|
||||
headers. Requests from untrusted origins are rejected.
|
||||
|
||||
```ts main.ts
|
||||
import { App, csrf } from "fresh";
|
||||
import { App, csrf } from "sweet";
|
||||
|
||||
const app = new App();
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ Since Fresh plugins are just middlewares and route handlers, creating a reusable
|
||||
plugin is as simple as exporting a function that returns a middleware:
|
||||
|
||||
```ts plugins/request-id.ts
|
||||
import type { MiddlewareFn } from "fresh";
|
||||
import type { MiddlewareFn } from "sweet";
|
||||
|
||||
export function requestId(): MiddlewareFn<{ requestId: string }> {
|
||||
return async (ctx) => {
|
||||
@@ -41,7 +41,7 @@ export function requestId(): MiddlewareFn<{ requestId: string }> {
|
||||
```
|
||||
|
||||
```ts main.ts
|
||||
import { App, staticFiles } from "fresh";
|
||||
import { App, staticFiles } from "sweet";
|
||||
import { requestId } from "./plugins/request-id.ts";
|
||||
|
||||
const app = new App()
|
||||
|
||||
@@ -7,7 +7,7 @@ It supports deny lists, allow lists, and CIDR subnet matching. Deny rules always
|
||||
take precedence over allow rules.
|
||||
|
||||
```ts main.ts
|
||||
import { App, ipFilter } from "fresh";
|
||||
import { App, ipFilter } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(ipFilter({
|
||||
@@ -23,7 +23,7 @@ Block specific IPs or subnets. Any request from a matching address receives a
|
||||
403 Forbidden response:
|
||||
|
||||
```ts main.ts
|
||||
import { App, ipFilter } from "fresh";
|
||||
import { App, ipFilter } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(ipFilter({
|
||||
@@ -37,7 +37,7 @@ When an allow list is provided, only matching IPs are permitted. All other
|
||||
addresses are blocked:
|
||||
|
||||
```ts main.ts
|
||||
import { App, ipFilter } from "fresh";
|
||||
import { App, ipFilter } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(ipFilter({
|
||||
@@ -51,7 +51,7 @@ When both lists are provided, deny rules are checked first. An IP that appears
|
||||
in both lists is blocked:
|
||||
|
||||
```ts main.ts
|
||||
import { App, ipFilter } from "fresh";
|
||||
import { App, ipFilter } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(ipFilter({
|
||||
@@ -68,7 +68,7 @@ By default, blocked requests receive a `403 Forbidden` response. Use the
|
||||
`onBlocked` callback to customize this:
|
||||
|
||||
```ts main.ts
|
||||
import { App, ipFilter } from "fresh";
|
||||
import { App, ipFilter } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(ipFilter({
|
||||
|
||||
@@ -7,7 +7,7 @@ end with a slash character or will never end with one. It redirects the user's
|
||||
request respectively.
|
||||
|
||||
```ts main.ts
|
||||
import { trailingSlashes } from "fresh";
|
||||
import { trailingSlashes } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(trailingSlashes("never"))
|
||||
@@ -17,7 +17,7 @@ const app = new App()
|
||||
Always append a trailing slash:
|
||||
|
||||
```ts main.ts
|
||||
import { trailingSlashes } from "fresh";
|
||||
import { trailingSlashes } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(trailingSlashes("always"))
|
||||
|
||||
@@ -16,7 +16,7 @@ test assumes the `State` object in `utils.ts` has `text` property.
|
||||
|
||||
```ts tests/middleware.test.ts
|
||||
import { expect } from "@std/expect";
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
import { define, type State } from "../utils.ts";
|
||||
|
||||
const middleware = define.middleware((ctx) => {
|
||||
@@ -49,7 +49,7 @@ Both the [app wrapper](/docs/advanced/app-wrapper) component and
|
||||
|
||||
```tsx tests/appWrapper.test.tsx
|
||||
import { expect } from "@std/expect";
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
import { define, type State } from "../utils.ts";
|
||||
|
||||
const AppWrapper = define.layout(function AppWrapper({ Component }) {
|
||||
@@ -84,7 +84,7 @@ Same can be done for layouts.
|
||||
|
||||
```tsx tests/layout.test.tsx
|
||||
import { expect } from "@std/expect";
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
import { define, type State } from "../utils.ts";
|
||||
|
||||
const MyLayout = define.layout(function MyLayout({ Component }) {
|
||||
@@ -119,7 +119,7 @@ handler:
|
||||
|
||||
```ts tests/routes.test.ts
|
||||
import { expect } from "@std/expect";
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
import { type State } from "../utils.ts";
|
||||
|
||||
// Import actual route handlers
|
||||
@@ -150,7 +150,7 @@ to use JSX:
|
||||
|
||||
```tsx tests/island-ssr.test.tsx
|
||||
import { expect } from "@std/expect";
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
import { useSignal } from "@preact/signals";
|
||||
import { type State } from "../utils.ts";
|
||||
import Counter from "../islands/Counter.tsx";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@fresh/build-id",
|
||||
"name": "@paulaboks/sweet-build-id",
|
||||
"version": "1.0.1",
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* // `BUILD_ID` is based on the `DENO_DEPLOYMENT_ID` environment variable.
|
||||
* ```
|
||||
*
|
||||
* @see https://fresh.deno.dev/docs/deployment/docker
|
||||
* @see https://usefresh.dev/docs/deployment/docker
|
||||
*
|
||||
* @module
|
||||
* @private
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
This package contains examples for using Fresh with [JSR](https://jsr.io/).
|
||||
|
||||
Learn more about the Fresh framework here:
|
||||
[https://fresh.deno.dev/](https://fresh.deno.dev/)
|
||||
[https://usefresh.dev/](https://usefresh.dev/)
|
||||
|
||||
## Usage: Island example
|
||||
|
||||
```tsx
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
// Import the island function
|
||||
import { DemoIsland } from "jsr:@fresh/examples/island";
|
||||
import { DemoIsland } from "jsr:@paulaboks/sweet-examples/island";
|
||||
|
||||
export const app = new App({ root: import.meta.url })
|
||||
.use(staticFiles());
|
||||
@@ -24,10 +24,10 @@ await app.listen();
|
||||
## Usage: App1 or App2 example
|
||||
|
||||
```tsx
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
// Import the example apps
|
||||
import { app1 } from "jsr:@fresh/examples/app1";
|
||||
import { app2 } from "jsr:@fresh/examples/app2";
|
||||
import { app1 } from "jsr:@paulaboks/sweet-examples/app1";
|
||||
import { app2 } from "jsr:@paulaboks/sweet-examples/app2";
|
||||
|
||||
export const app = new App({ root: import.meta.url })
|
||||
.use(staticFiles());
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "@fresh/examples",
|
||||
"name": "@paulaboks/sweet-examples",
|
||||
"version": "1.0.1",
|
||||
"license": "MIT",
|
||||
"imports": {
|
||||
"fresh": "jsr:@fresh/core@^2.0.0",
|
||||
"sweet": "jsr:@paulaboks/sweet@^2.0.0",
|
||||
"preact": "npm:preact@^10.27.0",
|
||||
"@preact/signals": "npm:@preact/signals@^2.2.1"
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
import { Doc } from "./shared.tsx";
|
||||
|
||||
/** App that renders a sample HTML document */
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
import { Doc } from "./shared.tsx";
|
||||
|
||||
/** App that renders a sample HTML document */
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* import { App } from "fresh";
|
||||
* import { DemoIsland } from "jsr:@fresh/examples/island";
|
||||
* import { App } from "sweet";
|
||||
* import { DemoIsland } from "jsr:@paulaboks/sweet-examples/island";
|
||||
*
|
||||
* const app = new App();
|
||||
*
|
||||
|
||||
@@ -4,21 +4,21 @@ Fresh is a small, fast and extensible full stack web framework built on Web
|
||||
Standards. It’s designed for building high-quality, performant, and personalized
|
||||
web applications.
|
||||
|
||||
[Learn more about Fresh](https://fresh.deno.dev/)
|
||||
[Learn more about Fresh](https://usefresh.dev/)
|
||||
|
||||
## Usage
|
||||
|
||||
Generate a new Fresh project with `@fresh/init`:
|
||||
Generate a new Fresh project with `@paulaboks/sweet-init`:
|
||||
|
||||
```sh
|
||||
deno run -Ar jsr:@fresh/init
|
||||
deno run -Ar jsr:@paulaboks/sweet-init
|
||||
```
|
||||
|
||||
Add middleware, routes, & endpoints as needed via the `routes/` folder or
|
||||
directly on the `App` instance.
|
||||
|
||||
```tsx
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.get("/", () => new Response("hello world"))
|
||||
@@ -28,4 +28,4 @@ app.listen();
|
||||
```
|
||||
|
||||
For more information on getting started with Fresh, head on over to the
|
||||
[documentation](https://fresh.deno.dev/docs/introduction).
|
||||
[documentation](https://usefresh.dev/docs/introduction).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@fresh/core",
|
||||
"version": "2.3.3",
|
||||
"name": "@paulaboks/sweet",
|
||||
"version": "2.3.7",
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
".": "./src/mod.ts",
|
||||
@@ -27,7 +27,7 @@
|
||||
"@std/uuid": "jsr:@std/uuid@^1.0.9",
|
||||
"@types/node": "npm:@types/node@^24.2.1",
|
||||
"esbuild-wasm": "npm:esbuild-wasm@^0.25.11",
|
||||
"preact": "npm:preact@^10.29.1",
|
||||
"preact": "npm:preact@^10.29.8",
|
||||
"preact-render-to-string": "npm:preact-render-to-string@^6.6.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { trace } from "@opentelemetry/api";
|
||||
|
||||
import { DENO_DEPLOYMENT_ID } from "@fresh/build-id";
|
||||
import { DENO_DEPLOYMENT_ID } from "@paulaboks/sweet-build-id";
|
||||
import * as colors from "@std/fmt/colors";
|
||||
import type { MaybeLazyMiddleware, Middleware } from "./middlewares/mod.ts";
|
||||
import {
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from "./context.ts";
|
||||
import { mergePath, type Method, UrlPatternRouter } from "./router.ts";
|
||||
import type { FreshConfig, ResolvedFreshConfig } from "./config.ts";
|
||||
import type { BuildCache } from "./build_cache.ts";
|
||||
import { type BuildCache, MockBuildCache } from "./build_cache.ts";
|
||||
import { HttpError } from "./error.ts";
|
||||
import { STATUS_TEXT } from "@std/http/status";
|
||||
import type { LayoutConfig, MaybeLazy, Route, RouteConfig } from "./types.ts";
|
||||
@@ -29,7 +29,6 @@ import {
|
||||
newNotFoundCmd,
|
||||
newRouteCmd,
|
||||
} from "./commands.ts";
|
||||
import { MockBuildCache } from "./test_utils.ts";
|
||||
|
||||
// TODO: Completed type clashes in older Deno versions
|
||||
// deno-lint-ignore no-explicit-any
|
||||
@@ -100,7 +99,7 @@ export function createOnListen(
|
||||
console.log();
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
colors.bgRgb8(colors.rgb8(" 🍋 Fresh ready ", 0), 121),
|
||||
colors.bgRgb8(colors.rgb8(" 🍬 Sweet ready ", 0), 121),
|
||||
);
|
||||
const sep = options.remoteAddress ? "" : "\n";
|
||||
const space = options.remoteAddress ? " " : "";
|
||||
|
||||
@@ -217,6 +217,33 @@ Deno.test("App - wrong method match", async () => {
|
||||
expect(await res.text()).toEqual("ok");
|
||||
});
|
||||
|
||||
Deno.test("App - non-standard method does not crash handler", async () => {
|
||||
// Regression test for https://github.com/denoland/fresh/issues/3804
|
||||
// WebDAV scanners (and other clients) routinely send verbs outside the
|
||||
// seven methods Fresh's router declares (GET/POST/PATCH/PUT/DELETE/HEAD/
|
||||
// OPTIONS). Those used to surface as `methodMatch: true` with an
|
||||
// `undefined` item, throwing "handler2 is not a function" in production.
|
||||
const app = new App()
|
||||
.get("/", () => new Response("ok"))
|
||||
.get("/books/:id", (ctx) => new Response(ctx.params.id));
|
||||
|
||||
const server = new FakeServer(app.handler());
|
||||
|
||||
// Static route
|
||||
let res = await server.request(
|
||||
new Request("http://localhost/", { method: "PROPFIND" }),
|
||||
);
|
||||
expect(res.status).toEqual(405);
|
||||
expect(await res.text()).toEqual("Method Not Allowed");
|
||||
|
||||
// Dynamic route
|
||||
res = await server.request(
|
||||
new Request("http://localhost/books/123", { method: "PROPFIND" }),
|
||||
);
|
||||
expect(res.status).toEqual(405);
|
||||
expect(await res.text()).toEqual("Method Not Allowed");
|
||||
});
|
||||
|
||||
Deno.test("App - methods with middleware", async () => {
|
||||
const app = new App<{ text: string }>()
|
||||
.use((ctx) => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { fsItemsToCommands, type FsRouteFile } from "./fs_routes.ts";
|
||||
import type { ServerIslandRegistry } from "./context.ts";
|
||||
import type { AnyComponent } from "preact";
|
||||
import { UniqueNamer } from "./utils.ts";
|
||||
import { setBuildId } from "@fresh/build-id";
|
||||
import { setBuildId } from "@paulaboks/sweet-build-id";
|
||||
|
||||
export interface FileSnapshot {
|
||||
name: string;
|
||||
@@ -17,6 +17,12 @@ export interface FileSnapshot {
|
||||
export interface BuildSnapshot<State> {
|
||||
version: string;
|
||||
clientEntry: string;
|
||||
/**
|
||||
* When defined, forces the boot script to be emitted in dev so HMR
|
||||
* listeners attach even on island-free pages. The value itself is
|
||||
* currently unused — only its presence matters. Undefined outside of dev.
|
||||
*/
|
||||
hmrClientEntry?: string;
|
||||
fsRoutes: FsRouteFile<State>[];
|
||||
staticFiles: Map<string, FileSnapshot>;
|
||||
islands: ServerIslandRegistry;
|
||||
@@ -51,6 +57,7 @@ export class ProdBuildCache<State> implements BuildCache<State> {
|
||||
#snapshot: BuildSnapshot<State>;
|
||||
islandRegistry: ServerIslandRegistry;
|
||||
clientEntry: string;
|
||||
hmrClientEntry: string | undefined;
|
||||
features = { errorOverlay: false };
|
||||
|
||||
constructor(public root: string, snapshot: BuildSnapshot<State>) {
|
||||
@@ -58,6 +65,7 @@ export class ProdBuildCache<State> implements BuildCache<State> {
|
||||
this.#snapshot = snapshot;
|
||||
this.islandRegistry = snapshot.islands;
|
||||
this.clientEntry = snapshot.clientEntry;
|
||||
this.hmrClientEntry = snapshot.hmrClientEntry;
|
||||
}
|
||||
|
||||
getEntryAssets(): string[] {
|
||||
@@ -94,6 +102,32 @@ export class ProdBuildCache<State> implements BuildCache<State> {
|
||||
}
|
||||
}
|
||||
|
||||
/** Fallback build cache for when there's no build output (and for tests). */
|
||||
export class MockBuildCache<State> implements BuildCache<State> {
|
||||
#files: FsRouteFile<State>[];
|
||||
root = "";
|
||||
clientEntry = "";
|
||||
islandRegistry: ServerIslandRegistry = new Map();
|
||||
features = { errorOverlay: false };
|
||||
|
||||
constructor(files: FsRouteFile<State>[], mode: "development" | "production") {
|
||||
this.features.errorOverlay = mode === "development";
|
||||
this.#files = files;
|
||||
}
|
||||
|
||||
getEntryAssets(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
getFsRoutes(): Command<State>[] {
|
||||
return fsItemsToCommands(this.#files);
|
||||
}
|
||||
|
||||
readFile(_pathname: string): Promise<StaticFile | null> {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
export class IslandPreparer {
|
||||
#namer = new UniqueNamer();
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { setAdditionalStyles } from "./context.ts";
|
||||
import { HttpError } from "./error.ts";
|
||||
import { isHandlerByMethod, type PageResponse } from "./handlers.ts";
|
||||
import {
|
||||
@@ -74,11 +73,13 @@ export function newErrorCmd<State>(
|
||||
export interface AppCommand<State> {
|
||||
type: CommandType.App;
|
||||
component: RouteComponent<State>;
|
||||
css?: string[];
|
||||
}
|
||||
export function newAppCmd<State>(
|
||||
component: RouteComponent<State>,
|
||||
css?: string[],
|
||||
): AppCommand<State> {
|
||||
return { type: CommandType.App, component };
|
||||
return { type: CommandType.App, component, css };
|
||||
}
|
||||
|
||||
export interface LayoutCommand<State> {
|
||||
@@ -86,6 +87,7 @@ export interface LayoutCommand<State> {
|
||||
pattern: string;
|
||||
component: RouteComponent<State>;
|
||||
config?: LayoutConfig;
|
||||
css?: string[];
|
||||
includeLastSegment: boolean;
|
||||
}
|
||||
export function newLayoutCmd<State>(
|
||||
@@ -93,12 +95,14 @@ export function newLayoutCmd<State>(
|
||||
component: RouteComponent<State>,
|
||||
config: LayoutConfig | undefined,
|
||||
includeLastSegment: boolean,
|
||||
css?: string[],
|
||||
): LayoutCommand<State> {
|
||||
return {
|
||||
type: CommandType.Layout,
|
||||
pattern,
|
||||
component,
|
||||
config,
|
||||
css,
|
||||
includeLastSegment,
|
||||
};
|
||||
}
|
||||
@@ -253,7 +257,7 @@ function applyCommandsInner<State>(
|
||||
break;
|
||||
}
|
||||
case CommandType.App: {
|
||||
root.app = cmd.component;
|
||||
root.app = { component: cmd.component, css: cmd.css ?? null };
|
||||
break;
|
||||
}
|
||||
case CommandType.Layout: {
|
||||
@@ -265,6 +269,7 @@ function applyCommandsInner<State>(
|
||||
segment.layout = {
|
||||
component: cmd.component,
|
||||
config: cmd.config ?? null,
|
||||
css: cmd.css ?? null,
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -290,10 +295,6 @@ function applyCommandsInner<State>(
|
||||
def = await route();
|
||||
}
|
||||
|
||||
if (def.css !== undefined) {
|
||||
setAdditionalStyles(ctx, def.css);
|
||||
}
|
||||
|
||||
return renderRoute(ctx, def);
|
||||
});
|
||||
|
||||
|
||||
@@ -58,6 +58,28 @@ export interface WebSocketUpgradeOptions {
|
||||
protocol?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Side channel used by `@paulaboks/sweet-vite` (and any other adapter sitting on
|
||||
* top of `node:http`) to hand a raw socket + buffered head to `ctx.upgrade()`.
|
||||
* `Deno.upgradeWebSocket()` normally pulls these off the request handled by
|
||||
* `Deno.serve`, but a request synthesized from `node:http` carries neither, so
|
||||
* the adapter stashes them here and `ctx.upgrade()` forwards them to Deno.
|
||||
*
|
||||
* Stored on `globalThis` so a single WeakMap is shared even when this module
|
||||
* is evaluated more than once (e.g. once by Deno for the Vite plugin and once
|
||||
* by Vite's SSR runner for the user's server code).
|
||||
*/
|
||||
const UPGRADE_SOURCE_KEY: unique symbol = Symbol.for(
|
||||
"fresh.upgradeSourceMap",
|
||||
) as typeof UPGRADE_SOURCE_KEY;
|
||||
// deno-lint-ignore no-explicit-any
|
||||
type UpgradeSource = { socket: any; head: any };
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const globalAny = globalThis as any;
|
||||
export const upgradeSourceMap: WeakMap<Request, UpgradeSource> =
|
||||
globalAny[UPGRADE_SOURCE_KEY] ??
|
||||
(globalAny[UPGRADE_SOURCE_KEY] = new WeakMap<Request, UpgradeSource>());
|
||||
|
||||
/**
|
||||
* Duck-type check: treats the argument as managed-mode handlers when at least
|
||||
* one of the handler keys (`open`, `message`, `close`, `error`) is a
|
||||
@@ -98,8 +120,11 @@ export type ServerIslandRegistry = Map<ComponentType, Island>;
|
||||
export const internals: unique symbol = Symbol("fresh_internal");
|
||||
|
||||
export interface UiTree<Data, State> {
|
||||
app: AnyComponent<PageProps<Data, State>> | null;
|
||||
layouts: ComponentDef<Data, State>[];
|
||||
app: {
|
||||
component: AnyComponent<PageProps<Data, State>>;
|
||||
css: string[] | null;
|
||||
} | null;
|
||||
layouts: (ComponentDef<Data, State> & { css: string[] | null })[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +134,10 @@ export type FreshContext<State = unknown> = Context<State>;
|
||||
|
||||
export let getBuildCache: <T>(ctx: Context<T>) => BuildCache<T>;
|
||||
export let getInternals: <T>(ctx: Context<T>) => UiTree<unknown, T>;
|
||||
export let setAdditionalStyles: <T>(ctx: Context<T>, css: string[]) => void;
|
||||
export let setAdditionalStyles: <T>(
|
||||
ctx: Context<T>,
|
||||
css: string[] | null | undefined,
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* The context passed to every middleware. It is unique for every request.
|
||||
@@ -182,8 +210,23 @@ export class Context<State> {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
getInternals = <T>(ctx: Context<T>) => ctx.#internal as any;
|
||||
getBuildCache = <T>(ctx: Context<T>) => ctx.#buildCache;
|
||||
setAdditionalStyles = <T>(ctx: Context<T>, css: string[]) =>
|
||||
ctx.#additionalStyles = css;
|
||||
setAdditionalStyles = <T>(
|
||||
ctx: Context<T>,
|
||||
css: string[] | null | undefined,
|
||||
) => {
|
||||
if (css == null) return;
|
||||
|
||||
if (ctx.#additionalStyles === null) {
|
||||
ctx.#additionalStyles = css.slice();
|
||||
return;
|
||||
}
|
||||
|
||||
for (const href of css) {
|
||||
if (!ctx.#additionalStyles.includes(href)) {
|
||||
ctx.#additionalStyles.push(href);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
constructor(
|
||||
@@ -283,6 +326,7 @@ export class Context<State> {
|
||||
props.Component = () => child;
|
||||
|
||||
const def = defs[i];
|
||||
setAdditionalStyles(this, def.css);
|
||||
|
||||
const result = await renderRouteComponent(this, def, () => child);
|
||||
if (result instanceof Response) {
|
||||
@@ -298,16 +342,20 @@ export class Context<State> {
|
||||
|
||||
let hasApp = true;
|
||||
|
||||
if (isAsyncAnyComponent(appDef)) {
|
||||
if (appDef !== null) {
|
||||
setAdditionalStyles(this, appDef.css);
|
||||
}
|
||||
|
||||
if (appDef !== null && isAsyncAnyComponent(appDef.component)) {
|
||||
props.Component = () => appChild;
|
||||
const result = await renderAsyncAnyComponent(appDef, props);
|
||||
const result = await renderAsyncAnyComponent(appDef.component, props);
|
||||
if (result instanceof Response) {
|
||||
return result;
|
||||
}
|
||||
|
||||
appVNode = result;
|
||||
} else if (appDef !== null) {
|
||||
appVNode = h(appDef, {
|
||||
appVNode = h(appDef.component, {
|
||||
Component: () => appChild,
|
||||
config: this.config,
|
||||
data: null,
|
||||
@@ -595,7 +643,16 @@ export class Context<State> {
|
||||
throw new HttpError(400, "Expected a WebSocket upgrade request");
|
||||
}
|
||||
|
||||
const { socket, response } = Deno.upgradeWebSocket(this.req, options);
|
||||
const source = upgradeSourceMap.get(this.req);
|
||||
if (source !== undefined) upgradeSourceMap.delete(this.req);
|
||||
const upgradeOptions = source
|
||||
? { ...options, socket: source.socket, head: source.head }
|
||||
: options;
|
||||
const { socket, response } = Deno.upgradeWebSocket(
|
||||
this.req,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
upgradeOptions as any,
|
||||
);
|
||||
|
||||
if (handlers === undefined) {
|
||||
return { socket, response };
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { expect } from "@std/expect";
|
||||
import { Context } from "./context.ts";
|
||||
import { App } from "fresh";
|
||||
import { asset } from "fresh/runtime";
|
||||
import { App } from "sweet";
|
||||
import { asset } from "sweet/runtime";
|
||||
import { FakeServer } from "./test_utils.ts";
|
||||
import { BUILD_ID } from "@fresh/build-id";
|
||||
import { BUILD_ID } from "@paulaboks/sweet-build-id";
|
||||
import { parseHtml } from "../tests/test_utils.tsx";
|
||||
|
||||
Deno.test("FreshReqContext.prototype.redirect", () => {
|
||||
|
||||
@@ -34,7 +34,7 @@ export interface Define<State> {
|
||||
* returned from the handler is of the correct type:
|
||||
*
|
||||
* ```ts
|
||||
* import { page } from "fresh";
|
||||
* import { page } from "sweet";
|
||||
* import { define } from "../utils.ts";
|
||||
*
|
||||
* export const handler = define.handlers<{ slug: string }>({
|
||||
@@ -80,7 +80,7 @@ export interface Define<State> {
|
||||
* return type of the handler method.
|
||||
*
|
||||
* ```ts
|
||||
* import { page } from "fresh";
|
||||
* import { page } from "sweet";
|
||||
* import { define } from "../utils.ts";
|
||||
*
|
||||
* export const handler = define.handlers({
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
type FsRoute,
|
||||
MemoryBuildCache,
|
||||
} from "./dev_build_cache.ts";
|
||||
import { BUILD_ID } from "@fresh/build-id";
|
||||
import { BUILD_ID } from "@paulaboks/sweet-build-id";
|
||||
import { updateCheck } from "./update_check.ts";
|
||||
import { devErrorOverlay } from "./middlewares/error_overlay/middleware.tsx";
|
||||
import { automaticWorkspaceFolders } from "./middlewares/automatic_workspace_folders.ts";
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as path from "@std/path";
|
||||
import { Builder, specToName } from "./builder.ts";
|
||||
import { App } from "../app.ts";
|
||||
import { DEV_ERROR_OVERLAY_URL } from "../constants.ts";
|
||||
import { BUILD_ID } from "@fresh/build-id";
|
||||
import { BUILD_ID } from "@paulaboks/sweet-build-id";
|
||||
import { integrationTest, withTmpDir, writeFiles } from "../test_utils.ts";
|
||||
import {
|
||||
getStdOutput,
|
||||
@@ -285,7 +285,7 @@ integrationTest("Builder - write prod routePattern", async () => {
|
||||
|
||||
await writeFiles(tmp, {
|
||||
"routes/foo/index.ts": `export const handler = () => new Response("ok")`,
|
||||
"main.ts": `import { App } from "fresh";
|
||||
"main.ts": `import { App } from "sweet";
|
||||
export const app = new App().fsRoutes()`,
|
||||
});
|
||||
|
||||
@@ -317,7 +317,7 @@ integrationTest("Builder - file:// islands", async () => {
|
||||
"other/Foo.tsx": `export default () => <h1>ok</h1>;`,
|
||||
"routes/index.tsx": `import Foo from "../other/Foo.tsx";
|
||||
export default () => <Foo />;`,
|
||||
"main.ts": `import { App } from "fresh";
|
||||
"main.ts": `import { App } from "sweet";
|
||||
export const app = new App().fsRoutes()`,
|
||||
});
|
||||
|
||||
@@ -470,7 +470,7 @@ integrationTest(
|
||||
const tmp = _tmp.dir;
|
||||
|
||||
await writeFiles(tmp, {
|
||||
"main.ts": `import { App, staticFiles } from "fresh";
|
||||
"main.ts": `import { App, staticFiles } from "sweet";
|
||||
export const app = new App()
|
||||
.use(staticFiles());`,
|
||||
"static/foo.txt": "ok",
|
||||
@@ -559,7 +559,7 @@ integrationTest(
|
||||
const tmp = _tmp.dir;
|
||||
|
||||
await writeFiles(tmp, {
|
||||
"main.ts": `import { App, staticFiles } from "fresh";
|
||||
"main.ts": `import { App, staticFiles } from "sweet";
|
||||
export const app = new App()
|
||||
.use(staticFiles());`,
|
||||
"static_a/a.txt": "from a",
|
||||
@@ -598,7 +598,7 @@ integrationTest("Builder - custom server entry", async () => {
|
||||
const tmp = _tmp.dir;
|
||||
|
||||
await writeFiles(tmp, {
|
||||
"other.ts": `import { App, staticFiles } from "fresh";
|
||||
"other.ts": `import { App, staticFiles } from "sweet";
|
||||
export const app = new App()
|
||||
.get("/", () => new Response("ok"));`,
|
||||
});
|
||||
@@ -666,7 +666,7 @@ integrationTest({
|
||||
"other/Foo.tsx": `export default () => <h1>ok</h1>;`,
|
||||
"routes/index.tsx": `import Foo from "foo-island";
|
||||
export default () => <Foo />;`,
|
||||
"main.ts": `import { App } from "fresh";
|
||||
"main.ts": `import { App } from "sweet";
|
||||
export const app = new App().fsRoutes()`,
|
||||
"deno.json": JSON.stringify({
|
||||
imports: { "foo-island": "other/Foo.tsx" },
|
||||
@@ -702,7 +702,7 @@ integrationTest("Builder - source maps", async () => {
|
||||
await writeFiles(tmp, {
|
||||
"islands/Foo.tsx": `export const Foo = () => <h1>hello</h1>`,
|
||||
"routes/index.ts": `export const handler = () => new Response("ok")`,
|
||||
"main.ts": `import { App } from "fresh";
|
||||
"main.ts": `import { App } from "sweet";
|
||||
export const app = new App().fsRoutes()`,
|
||||
});
|
||||
|
||||
@@ -761,7 +761,7 @@ integrationTest("Builder - compile entry", async () => {
|
||||
jsxImportSource: "preact",
|
||||
},
|
||||
imports: {
|
||||
"fresh": "jsr:@fresh/core@*",
|
||||
"sweet": "jsr:@paulaboks/sweet@*",
|
||||
"preact": "npm:preact@*",
|
||||
"@preact/signals": "npm:@preact/signals@*",
|
||||
},
|
||||
@@ -769,7 +769,7 @@ integrationTest("Builder - compile entry", async () => {
|
||||
"islands/Foo.tsx": `export const Foo = () => <h1>hello</h1>`,
|
||||
"routes/index.ts": `export const handler = () => new Response("ok")`,
|
||||
"static/foo.txt": "ok",
|
||||
"main.ts": `import { App, staticFiles } from "fresh";
|
||||
"main.ts": `import { App, staticFiles } from "sweet";
|
||||
export const app = new App()
|
||||
.use(staticFiles())
|
||||
.fsRoutes();`,
|
||||
@@ -835,7 +835,7 @@ integrationTest("Builder - island that imports json entry", async () => {
|
||||
jsxImportSource: "preact",
|
||||
},
|
||||
imports: {
|
||||
"fresh": "jsr:@fresh/core@*",
|
||||
"sweet": "jsr:@paulaboks/sweet@*",
|
||||
"preact": "npm:preact@*",
|
||||
"@preact/signals": "npm:@preact/signals@*",
|
||||
"mime-db": "npm:mime-db@*",
|
||||
@@ -847,7 +847,7 @@ export const Foo = () => {
|
||||
return <h1>ok</h1>
|
||||
}`,
|
||||
"routes/index.ts": `export default () => <Foo />`,
|
||||
"main.ts": `import { App, staticFiles } from "fresh";
|
||||
"main.ts": `import { App, staticFiles } from "sweet";
|
||||
export const app = new App()
|
||||
.use(staticFiles())
|
||||
.fsRoutes();`,
|
||||
@@ -943,7 +943,7 @@ export default function Map() {
|
||||
}`,
|
||||
"routes/index.tsx": `import Map from "../islands/Map.tsx";
|
||||
export default () => <Map />;`,
|
||||
"main.ts": `import { App } from "fresh";
|
||||
"main.ts": `import { App } from "sweet";
|
||||
export const app = new App().fsRoutes();`,
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as pathWin32 from "@std/path/windows";
|
||||
import { encodeHex } from "@std/encoding/hex";
|
||||
import { fsAdapter } from "../fs.ts";
|
||||
import type { FileTransformer } from "./file_transformer.ts";
|
||||
import { assertInDir, pathToSpec } from "../utils.ts";
|
||||
import { assertInDir, pathToSpec, toPosix } from "../utils.ts";
|
||||
import type { ResolvedBuildConfig } from "./builder.ts";
|
||||
import { fsItemsToCommands, type FsRouteFile } from "../fs_routes.ts";
|
||||
import type { Command } from "../commands.ts";
|
||||
@@ -17,13 +17,6 @@ import { contentType as getStdContentType } from "@std/media-types/content-type"
|
||||
|
||||
const WINDOWS_SEPARATOR = pathWin32.SEPARATOR;
|
||||
|
||||
/** Normalize a path to use forward slashes so that generated files
|
||||
* are portable across operating systems (e.g. build on Windows,
|
||||
* deploy on Linux). */
|
||||
function toPosix(p: string): string {
|
||||
return p.replaceAll(WINDOWS_SEPARATOR, "/");
|
||||
}
|
||||
|
||||
export interface MemoryFile {
|
||||
hash: string | null;
|
||||
contentType: string;
|
||||
@@ -458,6 +451,7 @@ export async function generateSnapshotServer(
|
||||
outDir: string;
|
||||
buildId: string;
|
||||
clientEntry: string;
|
||||
hmrClientEntry?: string;
|
||||
islands: IslandModChunk[];
|
||||
// deno-lint-ignore no-explicit-any
|
||||
fsRoutesFiles: FsRouteFileNoMod<any>[];
|
||||
@@ -524,12 +518,17 @@ export async function generateSnapshotServer(
|
||||
const entryAssets = options.entryAssets.map((url) => JSON.stringify(url))
|
||||
.join(",\n");
|
||||
|
||||
const hmrClientEntryDecl = options.hmrClientEntry !== undefined
|
||||
? `export const hmrClientEntry = ${JSON.stringify(options.hmrClientEntry)}`
|
||||
: "";
|
||||
|
||||
return `${EDIT_WARNING}
|
||||
import { IslandPreparer } from "fresh/internal";
|
||||
import { IslandPreparer } from "sweet/internal";
|
||||
${islandImports}
|
||||
${fsRouteImports}
|
||||
|
||||
export const clientEntry = ${JSON.stringify(options.clientEntry)}
|
||||
${hmrClientEntryDecl}
|
||||
export const version = ${JSON.stringify(options.buildId)}
|
||||
|
||||
export const islands = new Map();
|
||||
@@ -609,7 +608,7 @@ export function generateServerEntry(
|
||||
}
|
||||
|
||||
return `${EDIT_WARNING}
|
||||
import { setBuildCache, ProdBuildCache, path } from "fresh/internal";
|
||||
import { setBuildCache, ProdBuildCache, path } from "sweet/internal";
|
||||
import * as snapshot from "${snapshotSpecifier}";
|
||||
import { app } from "${serverEntry}";
|
||||
|
||||
|
||||
@@ -170,12 +170,15 @@ function buildIdPlugin(buildId: string): EsbuildPlugin {
|
||||
return {
|
||||
name: "fresh-build-id",
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /^(jsr:)?@fresh\/build-id/ }, (args) => {
|
||||
return {
|
||||
path: args.path,
|
||||
namespace: "fresh-internal-build-id",
|
||||
};
|
||||
});
|
||||
build.onResolve(
|
||||
{ filter: /^(jsr:)?@paulaboks\/sweet-build-id/ },
|
||||
(args) => {
|
||||
return {
|
||||
path: args.path,
|
||||
namespace: "fresh-internal-build-id",
|
||||
};
|
||||
},
|
||||
);
|
||||
build.onLoad({
|
||||
filter: /.*/,
|
||||
namespace: "fresh-internal-build-id",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { globToRegExp, isGlob } from "@std/path";
|
||||
import type { FsAdapter } from "../fs.ts";
|
||||
import { BUILD_ID } from "@fresh/build-id";
|
||||
import { BUILD_ID } from "@paulaboks/sweet-build-id";
|
||||
import { assetInternal } from "../runtime/shared_internal.ts";
|
||||
|
||||
export type TransformMode = "development" | "production";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { type FsAdapter, fsAdapter } from "../fs.ts";
|
||||
import type { WalkEntry } from "@std/fs/walk";
|
||||
import type { FsRouteFileNoMod } from "./dev_build_cache.ts";
|
||||
import { toPosix } from "../utils.ts";
|
||||
import * as path from "@std/path";
|
||||
import { pathToPattern } from "../router.ts";
|
||||
import { CommandType } from "../commands.ts";
|
||||
@@ -86,7 +87,7 @@ export async function crawlRouteDir<State>(
|
||||
|
||||
files.push({
|
||||
id,
|
||||
filePath: entry.path,
|
||||
filePath: toPosix(entry.path),
|
||||
type,
|
||||
pattern,
|
||||
routePattern,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { expect } from "@std/expect/expect";
|
||||
import { createFakeFs } from "../test_utils.ts";
|
||||
import { walkDir } from "./fs_crawl.ts";
|
||||
import { crawlRouteDir, walkDir } from "./fs_crawl.ts";
|
||||
|
||||
Deno.test("walkDir - ", async () => {
|
||||
const fs = createFakeFs({
|
||||
@@ -43,3 +43,25 @@ Deno.test("walkDir - respects skip patterns", async () => {
|
||||
"routes/api/users.ts",
|
||||
]);
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "crawlRouteDir.filePath - normalized Windows paths",
|
||||
ignore: Deno.build.os !== "windows",
|
||||
fn: async () => {
|
||||
const fs = createFakeFs({
|
||||
"foo\\bar\\baz.txt": "foo",
|
||||
"D:\\foo\\bar.tsx": "foo",
|
||||
});
|
||||
|
||||
const rawFiles = await crawlRouteDir(fs, "foo", [], () => {});
|
||||
|
||||
expect(rawFiles).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
filePath: "foo/bar/baz.txt",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
filePath: "D:/foo/bar.tsx",
|
||||
}),
|
||||
]));
|
||||
},
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ export function automaticWorkspaceFolders<T>(root: string): Middleware<T> {
|
||||
uuid ??= await generate(
|
||||
NAMESPACE_URL,
|
||||
new TextEncoder().encode(
|
||||
`https://fresh.deno.dev?root=${encodeURIComponent(root)}&v=${0}`,
|
||||
`https://usefresh.dev?root=${encodeURIComponent(root)}&v=${0}`,
|
||||
),
|
||||
);
|
||||
content ??= JSON.stringify({ workspace: { root, uuid } }, undefined, 2);
|
||||
|
||||
@@ -36,14 +36,15 @@ function getHomeDir(): string | null {
|
||||
|
||||
function getFreshCacheDir(): string | null {
|
||||
const home = getHomeDir();
|
||||
if (home) return path.join(home, "fresh");
|
||||
if (home) return path.join(home, "sweet");
|
||||
return null;
|
||||
}
|
||||
|
||||
async function fetchLatestVersion(): Promise<string> {
|
||||
const res = await fetch("https://dl.deno.land/fresh/release-latest.txt");
|
||||
const res = await fetch("https://jsr.io/@paulaboks/sweet/meta.json");
|
||||
if (res.ok) {
|
||||
return (await res.text()).trim().replace(/^v/, "");
|
||||
const meta = (await res.json()) as { latest: string | null };
|
||||
if (meta.latest) return meta.latest;
|
||||
}
|
||||
|
||||
throw new Error(`Could not fetch latest version.`);
|
||||
@@ -128,11 +129,11 @@ export async function updateCheck(
|
||||
const latest = colors.bold(colors.rgb8(checkFile.latest_version, 121));
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
` Fresh ${latest} is available. You're on ${current}`,
|
||||
` Sweet ${latest} is available. You're on ${current}`,
|
||||
);
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
` To upgrade, run: deno run -A -r jsr:@fresh/update`,
|
||||
` To upgrade, bump the "sweet" version in your deno.json`,
|
||||
);
|
||||
// deno-lint-ignore no-console
|
||||
console.log();
|
||||
|
||||
@@ -10,7 +10,7 @@ export type { ErrorStatus };
|
||||
*
|
||||
* @example Basic usage
|
||||
* ```ts
|
||||
* import { App, HttpError } from "fresh";
|
||||
* import { App, HttpError } from "sweet";
|
||||
* import { expect } from "@std/expect";
|
||||
*
|
||||
* const app = new App()
|
||||
@@ -36,7 +36,7 @@ export class HttpError extends Error {
|
||||
*
|
||||
* @example Basic usage
|
||||
* ```ts
|
||||
* import { App, HttpError } from "fresh";
|
||||
* import { App, HttpError } from "sweet";
|
||||
* import { expect } from "@std/expect";
|
||||
*
|
||||
* const app = new App()
|
||||
|
||||
@@ -106,7 +106,9 @@ export function fsItemsToCommands<State>(
|
||||
}
|
||||
if (!mod.default) continue;
|
||||
|
||||
commands.push(newLayoutCmd(pattern, mod.default, mod.config, true));
|
||||
commands.push(
|
||||
newLayoutCmd(pattern, mod.default, mod.config, true, mod.css),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
case CommandType.Error: {
|
||||
@@ -116,6 +118,7 @@ export function fsItemsToCommands<State>(
|
||||
{
|
||||
component: mod.default ?? undefined,
|
||||
config: mod.config ?? undefined,
|
||||
css: mod.css,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
handler: (handlers as any) ?? undefined,
|
||||
},
|
||||
@@ -128,6 +131,7 @@ export function fsItemsToCommands<State>(
|
||||
commands.push(newNotFoundCmd({
|
||||
config: mod.config,
|
||||
component: mod.default,
|
||||
css: mod.css,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
handler: handlers as any ?? undefined,
|
||||
}));
|
||||
@@ -137,7 +141,7 @@ export function fsItemsToCommands<State>(
|
||||
const { mod } = validateFsMod<State>(filePath, rawMod, type);
|
||||
if (mod.default === undefined) continue;
|
||||
|
||||
commands.push(newAppCmd(mod.default));
|
||||
commands.push(newAppCmd(mod.default, mod.css));
|
||||
continue;
|
||||
}
|
||||
case CommandType.Route: {
|
||||
|
||||
@@ -4,3 +4,4 @@ export { setBuildCache, setErrorInterceptor } from "./app.ts";
|
||||
export { IslandPreparer, ProdBuildCache } from "./build_cache.ts";
|
||||
export { path };
|
||||
export { ASSET_CACHE_BUST_KEY } from "./constants.ts";
|
||||
export { upgradeSourceMap } from "./context.ts";
|
||||
|
||||
@@ -10,6 +10,6 @@ export {
|
||||
writeCompiledEntry,
|
||||
} from "./dev/dev_build_cache.ts";
|
||||
export { specToName } from "./dev/builder.ts";
|
||||
export { pathToSpec, UniqueNamer } from "./utils.ts";
|
||||
export { pathToSpec, toPosix, UniqueNamer } from "./utils.ts";
|
||||
export { updateCheck } from "./dev/update_check.ts";
|
||||
export { TEST_FILE_PATTERN, UPDATE_INTERVAL } from "./constants.ts";
|
||||
|
||||
@@ -40,7 +40,7 @@ snapshot[`round trip - { a: 1, b: null, c: -2 } 1`] = `'[{"a":1,"b":-2,"c":2},1,
|
||||
|
||||
snapshot[`round trip - Uint8Array(3) [ 1, 2, 3 ] 1`] = `'[["Uint8Array","AQID"]]'`;
|
||||
|
||||
snapshot[`round trip - URL {\\n href: 'https://fresh.deno.dev/',\\n origin: 'https://fresh.deno.dev',\\n protocol: 'https:',\\n username: '',\\n password: '',\\n host: 'fresh.deno.dev',\\n hostname: 'fresh.deno.dev',\\n port: '',\\n pathname: '/',\\n hash: '',\\n search: ''\\n} 1`] = `'[["URL","https://fresh.deno.dev/"]]'`;
|
||||
snapshot[`round trip - URL {\\n href: 'https://usefresh.dev/',\\n origin: 'https://usefresh.dev',\\n protocol: 'https:',\\n username: '',\\n password: '',\\n host: 'usefresh.dev',\\n hostname: 'usefresh.dev',\\n port: '',\\n pathname: '/',\\n hash: '',\\n search: ''\\n} 1`] = `'[["URL","https://usefresh.dev/"]]'`;
|
||||
|
||||
snapshot[`round trip - 1990-05-31T00:00:00.000Z 1`] = `'[["Date","1990-05-31T00:00:00.000Z"]]'`;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ const TESTS = [
|
||||
[null, undefined, -2],
|
||||
{ a: 1, b: null, c: -2 },
|
||||
new Uint8Array([1, 2, 3]),
|
||||
new URL("https://fresh.deno.dev"),
|
||||
new URL("https://usefresh.dev"),
|
||||
new Date("1990-05-31"),
|
||||
new Date("Invalid Date"),
|
||||
new Map([[1, null], [undefined, -2]]),
|
||||
|
||||
@@ -40,7 +40,7 @@ export type CORSOptions<State> = {
|
||||
* @example Basic usage
|
||||
* ```ts
|
||||
* // main.ts or routes/_middleware.ts
|
||||
* import { cors } from 'fresh';
|
||||
* import { cors } from 'sweet';
|
||||
*
|
||||
* export const handler = [
|
||||
* cors({ origin: '*' }), // Allow all origins
|
||||
|
||||
@@ -99,12 +99,25 @@ export function csp<State>(options: CSPOptions = {}): Middleware<State> {
|
||||
? "Content-Security-Policy-Report-Only"
|
||||
: "Content-Security-Policy";
|
||||
|
||||
// Upgrading requests only makes sense when the page itself was served over
|
||||
// HTTPS. On plain HTTP (e.g. local dev) it breaks things like partial
|
||||
// redirects by upgrading them to an https:// URL the server doesn't serve.
|
||||
// Behind a TLS-terminating proxy, enable `trustProxy` so the protocol is
|
||||
// detected correctly.
|
||||
const insecureMerged = merged.filter((d) =>
|
||||
d !== "upgrade-insecure-requests"
|
||||
);
|
||||
|
||||
if (!useNonce) {
|
||||
// Static CSP — no per-request nonce
|
||||
const cspString = merged.join("; ");
|
||||
const insecureCspString = insecureMerged.join("; ");
|
||||
return async (ctx) => {
|
||||
const res = await ctx.next();
|
||||
res.headers.set(headerName, cspString);
|
||||
res.headers.set(
|
||||
headerName,
|
||||
ctx.url.protocol === "https:" ? cspString : insecureCspString,
|
||||
);
|
||||
if (reportTo) {
|
||||
res.headers.set("Reporting-Endpoints", `csp-endpoint="${reportTo}"`);
|
||||
}
|
||||
@@ -117,10 +130,11 @@ export function csp<State>(options: CSPOptions = {}): Middleware<State> {
|
||||
const res = await ctx.next();
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const nonce = (res as any)[NONCE_SYMBOL] as string | undefined;
|
||||
const base = ctx.url.protocol === "https:" ? merged : insecureMerged;
|
||||
|
||||
let directives: string[];
|
||||
if (nonce) {
|
||||
directives = merged.map((d) => {
|
||||
directives = base.map((d) => {
|
||||
const spaceIdx = d.indexOf(" ");
|
||||
const name = spaceIdx === -1 ? d : d.slice(0, spaceIdx);
|
||||
if (INLINE_DIRECTIVES.has(name) && d.includes("'unsafe-inline'")) {
|
||||
@@ -129,7 +143,7 @@ export function csp<State>(options: CSPOptions = {}): Middleware<State> {
|
||||
return d;
|
||||
});
|
||||
} else {
|
||||
directives = merged;
|
||||
directives = base;
|
||||
}
|
||||
|
||||
res.headers.set(headerName, directives.join("; "));
|
||||
|
||||
@@ -17,6 +17,47 @@ Deno.test("CSP - GET default", async () => {
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("CSP - omits upgrade-insecure-requests over http", async () => {
|
||||
const handler = new App()
|
||||
.use(csp())
|
||||
.get("/", () => new Response("ok"))
|
||||
.handler();
|
||||
const res = await handler(new Request("http://localhost/"));
|
||||
const header = res.headers.get("Content-Security-Policy")!;
|
||||
expect(header).toContain("default-src 'self'");
|
||||
expect(header).not.toContain("upgrade-insecure-requests");
|
||||
});
|
||||
|
||||
Deno.test("CSP - useNonce omits upgrade-insecure-requests over http", async () => {
|
||||
const handler = new App()
|
||||
.use(csp({ useNonce: true }))
|
||||
.get("/", () => new Response("ok"))
|
||||
.handler();
|
||||
const resHttp = await handler(new Request("http://localhost/"));
|
||||
expect(resHttp.headers.get("Content-Security-Policy")).not.toContain(
|
||||
"upgrade-insecure-requests",
|
||||
);
|
||||
const resHttps = await handler(new Request("https://localhost/"));
|
||||
expect(resHttps.headers.get("Content-Security-Policy")).toContain(
|
||||
"upgrade-insecure-requests",
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("CSP - keeps upgrade-insecure-requests with trusted x-forwarded-proto https", async () => {
|
||||
const handler = new App({ trustProxy: true })
|
||||
.use(csp())
|
||||
.get("/", () => new Response("ok"))
|
||||
.handler();
|
||||
const res = await handler(
|
||||
new Request("http://localhost/", {
|
||||
headers: { "x-forwarded-proto": "https" },
|
||||
}),
|
||||
);
|
||||
expect(res.headers.get("Content-Security-Policy")).toContain(
|
||||
"upgrade-insecure-requests",
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("CSP - GET with override options", async () => {
|
||||
const handler = new App()
|
||||
.use(csp({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Middleware } from "./mod.ts";
|
||||
import { ASSET_CACHE_BUST_KEY } from "../constants.ts";
|
||||
import { BUILD_ID } from "@fresh/build-id";
|
||||
import { BUILD_ID } from "@paulaboks/sweet-build-id";
|
||||
import { tracer } from "../otel.ts";
|
||||
import { getBuildCache } from "../context.ts";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { FakeServer, serveMiddleware } from "../test_utils.ts";
|
||||
import type { BuildCache, StaticFile } from "../build_cache.ts";
|
||||
import { expect } from "@std/expect";
|
||||
import { ASSET_CACHE_BUST_KEY } from "../constants.ts";
|
||||
import { BUILD_ID } from "@fresh/build-id";
|
||||
import { BUILD_ID } from "@paulaboks/sweet-build-id";
|
||||
import type { Command } from "../commands.ts";
|
||||
import type { ServerIslandRegistry } from "../context.ts";
|
||||
import {
|
||||
|
||||
@@ -139,7 +139,11 @@ export class UrlPatternRouter<T> implements Router<T> {
|
||||
if (staticMatch !== undefined) {
|
||||
result.pattern = pathname;
|
||||
|
||||
let item = staticMatch.byMethod[method];
|
||||
// `byMethod[method]` is `undefined` for non-standard HTTP verbs
|
||||
// (e.g. PROPFIND from WebDAV scanners). Normalize to `null` so the
|
||||
// not-allowed-method path is taken instead of returning a bogus
|
||||
// `methodMatch: true` with `item: undefined`.
|
||||
let item: T | null = staticMatch.byMethod[method] ?? null;
|
||||
if (method === "HEAD" && item === null) {
|
||||
item = staticMatch.byMethod.GET;
|
||||
}
|
||||
@@ -159,7 +163,7 @@ export class UrlPatternRouter<T> implements Router<T> {
|
||||
|
||||
result.pattern = route.pattern.pathname;
|
||||
|
||||
let item = route.byMethod[method];
|
||||
let item: T | null = route.byMethod[method] ?? null;
|
||||
if (method === "HEAD" && item === null) {
|
||||
item = route.byMethod.GET;
|
||||
}
|
||||
|
||||
@@ -286,3 +286,36 @@ Deno.test("UrlPatternRouter - duplicate registration different methods", () => {
|
||||
const postRes = router.match("POST", new URL("/foo", "http://localhost"));
|
||||
expect(postRes.item).toBe(postHandler);
|
||||
});
|
||||
|
||||
Deno.test("UrlPatternRouter - non-standard method on static route", () => {
|
||||
const router = new UrlPatternRouter();
|
||||
const A = () => {};
|
||||
router.add("GET", "/foo", A);
|
||||
|
||||
// Methods outside the seven known verbs (here PROPFIND, common from
|
||||
// WebDAV scanners) must surface as `methodMatch: false` with a `null`
|
||||
// item rather than returning `undefined` and crashing the handler.
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const res = router.match("PROPFIND" as any, new URL("/foo", "http://x"));
|
||||
expect(res).toEqual({
|
||||
params: Object.create(null),
|
||||
item: null,
|
||||
methodMatch: false,
|
||||
pattern: "/foo",
|
||||
});
|
||||
});
|
||||
|
||||
Deno.test("UrlPatternRouter - non-standard method on dynamic route", () => {
|
||||
const router = new UrlPatternRouter();
|
||||
const A = () => {};
|
||||
router.add("GET", "/books/:id", A);
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const res = router.match("PROPFIND" as any, new URL("/books/1", "http://x"));
|
||||
expect(res).toEqual({
|
||||
params: Object.create(null),
|
||||
item: null,
|
||||
methodMatch: false,
|
||||
pattern: "/books/:id",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ function reconnect() {
|
||||
if (backoffIdx === 0) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
`%c Fresh %c Connection closed. Trying to reconnect...`,
|
||||
`%c Sweet %c Connection closed. Trying to reconnect...`,
|
||||
"background-color: #86efac; color: black",
|
||||
"color: inherit",
|
||||
);
|
||||
@@ -85,7 +85,7 @@ function handleMessage(e: MessageEvent) {
|
||||
if (revision === 0) {
|
||||
// deno-lint-ignore no-console
|
||||
console.log(
|
||||
`%c Fresh %c Connected to development server.`,
|
||||
`%c Sweet %c Connected to development server.`,
|
||||
"background-color: #86efac; color: black",
|
||||
"color: inherit",
|
||||
);
|
||||
|
||||
@@ -25,6 +25,8 @@ import { parse } from "../../jsonify/parse.ts";
|
||||
import { INTERNAL_PREFIX, PARTIAL_SEARCH_PARAM } from "../../constants.ts";
|
||||
|
||||
export const PARTIAL_ATTR = "f-partial";
|
||||
export const METHOD_ATTR = "f-method";
|
||||
export const UPDATE_URL_ATTR = "f-update-url";
|
||||
|
||||
class NoPartialsError extends Error {}
|
||||
|
||||
@@ -112,6 +114,12 @@ function maybeReplaceHistory(nextUrl: URL) {
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeMethod(raw: string | null | undefined): string {
|
||||
const method = (raw || "get").toUpperCase();
|
||||
// Browsers submit invalid methods like HEAD as GET
|
||||
return method === "HEAD" ? "GET" : method;
|
||||
}
|
||||
|
||||
document.addEventListener("click", async (e) => {
|
||||
let el = e.target;
|
||||
if (el && (el instanceof HTMLElement || el instanceof SVGElement)) {
|
||||
@@ -178,20 +186,38 @@ document.addEventListener("click", async (e) => {
|
||||
}
|
||||
} else if (
|
||||
el && el instanceof HTMLButtonElement &&
|
||||
(el.type !== "submit" || el.form === null)
|
||||
(el.type !== "submit" || el.form === null) &&
|
||||
!e.defaultPrevented
|
||||
) {
|
||||
const partial = el.getAttribute(PARTIAL_ATTR);
|
||||
if (partial === null || !checkClientNavEnabled(el)) return;
|
||||
|
||||
// Check if the user opted out of client side navigation.
|
||||
if (partial === null || !checkClientNavEnabled(el)) {
|
||||
return;
|
||||
const method = normalizeMethod(el.getAttribute(METHOD_ATTR));
|
||||
const partialUrl = new URL(partial, location.href);
|
||||
|
||||
let init: RequestInit | undefined;
|
||||
if (method !== "GET") {
|
||||
const body = el.form ? new FormData(el.form) : new FormData();
|
||||
if (el.name) {
|
||||
body.append(el.name, el.value);
|
||||
}
|
||||
init = { method, body };
|
||||
}
|
||||
|
||||
const partialUrl = new URL(
|
||||
partial,
|
||||
location.href,
|
||||
);
|
||||
await fetchPartials(partialUrl, partialUrl, false);
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const indicator = (el as any)._freshIndicator;
|
||||
if (indicator !== undefined) {
|
||||
indicator.value = true;
|
||||
}
|
||||
try {
|
||||
await withViewTransition(() =>
|
||||
fetchPartials(partialUrl, partialUrl, false, init)
|
||||
);
|
||||
} finally {
|
||||
if (indicator !== undefined) {
|
||||
indicator.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -262,14 +288,18 @@ document.addEventListener("submit", async (e) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const lowerMethod =
|
||||
e.submitter?.getAttribute("formmethod")?.toLowerCase() ??
|
||||
el.method.toLowerCase();
|
||||
if (lowerMethod !== "get" && lowerMethod !== "post") {
|
||||
const method = normalizeMethod(
|
||||
e.submitter?.getAttribute("formmethod") || el.getAttribute("method"),
|
||||
);
|
||||
|
||||
if (method === "DIALOG") {
|
||||
return;
|
||||
}
|
||||
|
||||
const hasExplicitPartial = e.submitter?.hasAttribute(PARTIAL_ATTR) ||
|
||||
const isCustomMethod = method !== "GET" && method !== "POST";
|
||||
|
||||
const hasExplicitPartial = isCustomMethod ||
|
||||
e.submitter?.hasAttribute(PARTIAL_ATTR) ||
|
||||
e.submitter?.hasAttribute("formaction") ||
|
||||
el.hasAttribute(PARTIAL_ATTR) ||
|
||||
el.hasAttribute("action");
|
||||
@@ -300,18 +330,28 @@ document.addEventListener("submit", async (e) => {
|
||||
let init: RequestInit | undefined;
|
||||
|
||||
// GET method appends form data via url search params
|
||||
if (lowerMethod === "get") {
|
||||
if (method === "GET") {
|
||||
// TODO: Looks like constructor type for URLSearchParam is wrong
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const qs = new URLSearchParams(new FormData(el, e.submitter) as any);
|
||||
qs.forEach((value, key) => partialUrl.searchParams.append(key, value));
|
||||
} else {
|
||||
init = { body: new FormData(el, e.submitter), method: lowerMethod };
|
||||
init = {
|
||||
body: new FormData(el, e.submitter),
|
||||
method,
|
||||
};
|
||||
}
|
||||
|
||||
// GET and POST update the URL by default, other methods don't
|
||||
const updateUrl = e.submitter?.getAttribute(UPDATE_URL_ATTR) ??
|
||||
el.getAttribute(UPDATE_URL_ATTR);
|
||||
const shouldNavigate = updateUrl === null
|
||||
? !isCustomMethod
|
||||
: updateUrl !== "false";
|
||||
|
||||
try {
|
||||
await withViewTransition(async () => {
|
||||
await fetchPartials(actionUrl, partialUrl, true, init);
|
||||
await fetchPartials(actionUrl, partialUrl, shouldNavigate, init);
|
||||
});
|
||||
} finally {
|
||||
if (indicator !== undefined) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
type InternalPreactOptions,
|
||||
OptionsType,
|
||||
} from "../shared_internal.ts";
|
||||
import { BUILD_ID } from "@fresh/build-id";
|
||||
import { BUILD_ID } from "@paulaboks/sweet-build-id";
|
||||
import { renderToString } from "preact-render-to-string";
|
||||
import { useContext, useEffect } from "preact/hooks";
|
||||
import { HeadContext } from "../head.ts";
|
||||
|
||||
@@ -176,7 +176,7 @@ export function boot(
|
||||
: `partial "${root.name}"`;
|
||||
// deno-lint-ignore no-console
|
||||
console.error(
|
||||
`Fresh hydration error: the ${label} has invalid HTML nesting. ` +
|
||||
`Sweet hydration error: the ${label} has invalid HTML nesting. ` +
|
||||
`Its start and end markers were reparented by the browser into ` +
|
||||
`different DOM nodes. This is usually caused by placing a ` +
|
||||
`block-level element (like <div>) inside an inline element ` +
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
setActiveUrl,
|
||||
} from "../shared_internal.ts";
|
||||
import type { BuildCache } from "../../build_cache.ts";
|
||||
import { BUILD_ID } from "@fresh/build-id";
|
||||
import { BUILD_ID } from "@paulaboks/sweet-build-id";
|
||||
import {
|
||||
DEV_ERROR_OVERLAY_URL,
|
||||
PARTIAL_SEARCH_PARAM,
|
||||
@@ -203,6 +203,14 @@ options[OptionsType.ATTR] = (name, value) => {
|
||||
|
||||
const PATCHED = new WeakSet<VNode>();
|
||||
|
||||
// Link rels whose presence is conceptually singleton: a `<Head>` override
|
||||
// should replace the existing tag regardless of its href. Other rels
|
||||
// (stylesheet, preload, alternate, ...) can legitimately appear multiple
|
||||
// times with different hrefs, so href must remain part of the cache key.
|
||||
function isSingletonLinkRel(rel: unknown): boolean {
|
||||
return rel === "canonical" || rel === "manifest";
|
||||
}
|
||||
|
||||
function normalizeKey(key: unknown): string {
|
||||
const value = key ?? "";
|
||||
const s = (typeof value !== "string") ? String(value) : value;
|
||||
@@ -406,7 +414,10 @@ options[OptionsType.DIFF] = (vnode) => {
|
||||
continue;
|
||||
} else if (originalType === "meta" && key === "content") {
|
||||
continue;
|
||||
} else if (originalType === "link" && key === "href") {
|
||||
} else if (
|
||||
originalType === "link" && key === "href" &&
|
||||
isSingletonLinkRel(props.rel)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ComponentChildren, VNode } from "preact";
|
||||
import { BUILD_ID } from "@fresh/build-id";
|
||||
import { BUILD_ID } from "@paulaboks/sweet-build-id";
|
||||
import { assetInternal, assetSrcSetInternal } from "./shared_internal.ts";
|
||||
|
||||
export { HttpError } from "../error.ts";
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { AnyComponent } from "preact";
|
||||
import type { MaybeLazyMiddleware, Middleware } from "./middlewares/mod.ts";
|
||||
import { type Method, patternToSegments } from "./router.ts";
|
||||
import type { LayoutConfig, Route } from "./types.ts";
|
||||
import { type Context, getInternals } from "./context.ts";
|
||||
import { type Context, getInternals, setAdditionalStyles } from "./context.ts";
|
||||
import { recordSpanError, tracer } from "./otel.ts";
|
||||
import { type HandlerFn, isHandlerByMethod } from "./handlers.ts";
|
||||
import {
|
||||
@@ -22,10 +22,14 @@ export interface Segment<State> {
|
||||
layout: {
|
||||
component: RouteComponent<State>;
|
||||
config: LayoutConfig | null;
|
||||
css: string[] | null;
|
||||
} | null;
|
||||
errorRoute: Route<State> | null;
|
||||
notFound: Middleware<State> | null;
|
||||
app: RouteComponent<State> | null;
|
||||
app: {
|
||||
component: RouteComponent<State>;
|
||||
css: string[] | null;
|
||||
} | null;
|
||||
children: Map<string, Segment<State>>;
|
||||
parent: Segment<State> | null;
|
||||
}
|
||||
@@ -105,7 +109,11 @@ export function segmentToMiddlewares<State>(
|
||||
internals.app = null;
|
||||
}
|
||||
|
||||
const def = { props: null, component: layout.component };
|
||||
const def = {
|
||||
props: null,
|
||||
component: layout.component,
|
||||
css: layout.css,
|
||||
};
|
||||
if (layout.config?.skipInheritedLayouts) {
|
||||
internals.layouts = [def];
|
||||
} else {
|
||||
@@ -145,6 +153,8 @@ export async function renderRoute<State>(
|
||||
route: Route<State>,
|
||||
status = 200,
|
||||
): Promise<Response> {
|
||||
setAdditionalStyles(ctx, route.css);
|
||||
|
||||
const internals = getInternals(ctx);
|
||||
if (route.config?.skipAppWrapper) {
|
||||
internals.app = null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const LINK = "https://fresh.deno.dev/docs/concepts/ahead-of-time-builds";
|
||||
const LINK = "https://usefresh.dev/docs/concepts/ahead-of-time-builds";
|
||||
|
||||
export default function TailwindErrorPage() {
|
||||
return (
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Context, type ServerIslandRegistry } from "./context.ts";
|
||||
import { Context } from "./context.ts";
|
||||
import type { FsAdapter } from "./fs.ts";
|
||||
import type { BuildCache, StaticFile } from "./build_cache.ts";
|
||||
import { type BuildCache, MockBuildCache } from "./build_cache.ts";
|
||||
import type { ResolvedFreshConfig } from "./config.ts";
|
||||
import type { WalkEntry } from "@std/fs/walk";
|
||||
import { DEFAULT_CONN_INFO } from "./app.ts";
|
||||
import type { Command } from "./commands.ts";
|
||||
import { fsItemsToCommands, type FsRouteFile } from "./fs_routes.ts";
|
||||
import * as path from "@std/path";
|
||||
import { toPosix } from "./utils.ts";
|
||||
|
||||
const STUB = {} as unknown as Deno.ServeHandlerInfo;
|
||||
|
||||
@@ -123,7 +122,10 @@ export function createFakeFs(files: Record<string, unknown>): FsAdapter {
|
||||
},
|
||||
// deno-lint-ignore require-await
|
||||
async isDirectory(dir) {
|
||||
return Object.keys(files).some((file) => file.startsWith(dir + "/"));
|
||||
return Object.keys(files).some((file) =>
|
||||
// normalize path to posix before comparing
|
||||
toPosix(file).startsWith(dir + "/")
|
||||
);
|
||||
},
|
||||
async mkdirp(_dir: string) {
|
||||
},
|
||||
@@ -158,30 +160,7 @@ export async function withTmpDir(
|
||||
};
|
||||
}
|
||||
|
||||
export class MockBuildCache<State> implements BuildCache<State> {
|
||||
#files: FsRouteFile<State>[];
|
||||
root = "";
|
||||
clientEntry = "";
|
||||
islandRegistry: ServerIslandRegistry = new Map();
|
||||
features = { errorOverlay: false };
|
||||
|
||||
constructor(files: FsRouteFile<State>[], mode: "development" | "production") {
|
||||
this.features.errorOverlay = mode === "development";
|
||||
this.#files = files;
|
||||
}
|
||||
|
||||
getEntryAssets(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
getFsRoutes(): Command<State>[] {
|
||||
return fsItemsToCommands(this.#files);
|
||||
}
|
||||
|
||||
readFile(_pathname: string): Promise<StaticFile | null> {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
export { MockBuildCache };
|
||||
|
||||
/**
|
||||
* Wrapper around `Deno.test` for integration tests that disables sanitizers.
|
||||
|
||||
@@ -2,6 +2,13 @@ import * as path from "@std/path";
|
||||
import type { Lazy, MaybeLazy } from "./types.ts";
|
||||
import { pathToFileUrl, relativeUrl } from "./file_url.ts";
|
||||
|
||||
/** Normalize a path to use forward slashes so that generated files
|
||||
* are portable across operating systems (e.g. build on Windows,
|
||||
* deploy on Linux). */
|
||||
export function toPosix(p: string): string {
|
||||
return p.replaceAll("\\", "/");
|
||||
}
|
||||
|
||||
export function assertInDir(
|
||||
filePath: string,
|
||||
dir: string,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { App, staticFiles } from "fresh";
|
||||
import { App, staticFiles } from "sweet";
|
||||
import {
|
||||
ALL_ISLAND_DIR,
|
||||
assertNotSelector,
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from "./test_utils.tsx";
|
||||
|
||||
import { FakeServer } from "../src/test_utils.ts";
|
||||
import { Partial } from "fresh/runtime";
|
||||
import { Partial } from "sweet/runtime";
|
||||
|
||||
const allIslandCache = await buildProd({ islandDir: ALL_ISLAND_DIR });
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ Deno.test("Docs Code example checks", async () => {
|
||||
const denoJson = {
|
||||
lock: false,
|
||||
imports: {
|
||||
fresh: `jsr:@fresh/core@${FRESH_VERSION}`,
|
||||
"@fresh/plugin-tailwind-v3":
|
||||
`jsr:@fresh/plugin-tailwind@^${twDenoJson.version}`,
|
||||
"@fresh/plugin-tailwind":
|
||||
`jsr:@fresh/plugin-tailwind@^${twDenoJson.version}`,
|
||||
fresh: `jsr:@paulaboks/sweet@${FRESH_VERSION}`,
|
||||
"@paulaboks/sweet-tailwind-v3":
|
||||
`jsr:@paulaboks/sweet-tailwind@^${twDenoJson.version}`,
|
||||
"@paulaboks/sweet-tailwind":
|
||||
`jsr:@paulaboks/sweet-tailwind@^${twDenoJson.version}`,
|
||||
preact: `npm:preact@^${PREACT_VERSION}`,
|
||||
"@deno/gfm": "jsr:@deno/gfm@^0.11.0",
|
||||
"@std/expect": "jsr:@std/expect@^1.0.16",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
import { Head } from "fresh/runtime";
|
||||
import { Head } from "sweet/runtime";
|
||||
|
||||
export function DynamicMetaIsland() {
|
||||
const [count, setCount] = useState(0);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user