From aba1aa9d4748de792175bdbeb8f93eaed0ae98bc Mon Sep 17 00:00:00 2001 From: Sebastien Ringrose Date: Sat, 9 Mar 2024 15:05:31 +0000 Subject: [PATCH] feat: v2.2.0 refactor --- .github/workflows/CI.yml | 26 +- {examples => example}/auth/app.ts | 0 .../preactSSR}/assets/favicon.png | Bin .../preactSSR}/assets/lighthouse-score.png | Bin .../preactSSR}/assets/logo_dark_alpha.png | Bin .../preactSSR}/assets/logo_dark_alpha.webp | Bin .../preactSSR}/assets/logo_dark_bg.png | Bin .../preactSSR}/assets/logo_dark_bg.webp | Bin .../preactSSR}/assets/logo_light_alpha.png | Bin .../preactSSR}/assets/logo_light_bg.png | Bin .../preactSSR}/assets/twemoji_chick.svg | 0 .../preact => example/preactSSR}/document.ts | 28 +- example/preactSSR/router.ts | 162 ++ .../preactSSR/src/components/App.ts | 10 +- .../preactSSR/src/components/Layout.ts | 12 +- .../preactSSR/src/components/List.ts | 4 +- .../preactSSR/src/hooks/localstate.ts | 10 +- .../preactSSR/src/pages/About.ts | 6 +- .../preactSSR/src/pages/Home.ts | 5 +- examples/preact/assets/DALL-Echu.png | Bin 1309536 -> 0 bytes examples/preact/assets/DALL-Echu.webp | Bin 17854 -> 0 bytes examples/preact/assets/Untitled_Artwork.png | Bin 1554757 -> 0 bytes examples/preact/assets/favicon.ico | Bin 15406 -> 0 bytes examples/preact/assets/twemoji_chicken.svg | 1 - examples/preact/router.ts | 15 - examples/preact/routes/APIs.ts | 28 - examples/preact/routes/pages.ts | 79 - lib/Router.ts | 194 +-- lib/handlers/static.ts | 12 +- lib/utils/CacheItem.ts | 26 +- lib/utils/Cascade.ts | 44 +- lib/utils/Profiler.ts | 80 +- package-lock.json | 1320 ----------------- package.json | 16 +- pnpm-lock.yaml | 1120 ++++++++++++++ scripts/{bun.ts => bun/main.ts} | 4 +- scripts/bun/profile.ts | 30 + scripts/deno-auth.ts | 5 - scripts/{deno.ts => deno/main.ts} | 2 +- scripts/deno/profile.ts | 32 + scripts/profile.ts | 47 - scripts/{cfw.ts => wrangler/main.ts} | 2 +- scripts/wrangler/profile.ts | 22 + scripts/wrangler/testApp.ts | 9 + tests/handlers/static_test.ts | 6 +- tests/mocks/middleware.ts | 64 +- tests/mocks/profileRouter.ts | 17 + wrangler.toml | 2 +- 48 files changed, 1711 insertions(+), 1729 deletions(-) rename {examples => example}/auth/app.ts (100%) rename {examples/preact => example/preactSSR}/assets/favicon.png (100%) rename {examples/preact => example/preactSSR}/assets/lighthouse-score.png (100%) rename {examples/preact => example/preactSSR}/assets/logo_dark_alpha.png (100%) rename {examples/preact => example/preactSSR}/assets/logo_dark_alpha.webp (100%) rename {examples/preact => example/preactSSR}/assets/logo_dark_bg.png (100%) rename {examples/preact => example/preactSSR}/assets/logo_dark_bg.webp (100%) rename {examples/preact => example/preactSSR}/assets/logo_light_alpha.png (100%) rename {examples/preact => example/preactSSR}/assets/logo_light_bg.png (100%) rename {examples/preact => example/preactSSR}/assets/twemoji_chick.svg (100%) rename {examples/preact => example/preactSSR}/document.ts (55%) create mode 100644 example/preactSSR/router.ts rename examples/preact/src/components/App.js => example/preactSSR/src/components/App.ts (82%) rename examples/preact/src/components/Layout.js => example/preactSSR/src/components/Layout.ts (93%) rename examples/preact/src/components/List.js => example/preactSSR/src/components/List.ts (88%) rename examples/preact/src/hooks/localstate.js => example/preactSSR/src/hooks/localstate.ts (87%) rename examples/preact/src/pages/About.js => example/preactSSR/src/pages/About.ts (88%) rename examples/preact/src/pages/Home.js => example/preactSSR/src/pages/Home.ts (85%) delete mode 100644 examples/preact/assets/DALL-Echu.png delete mode 100644 examples/preact/assets/DALL-Echu.webp delete mode 100644 examples/preact/assets/Untitled_Artwork.png delete mode 100644 examples/preact/assets/favicon.ico delete mode 100644 examples/preact/assets/twemoji_chicken.svg delete mode 100644 examples/preact/router.ts delete mode 100644 examples/preact/routes/APIs.ts delete mode 100644 examples/preact/routes/pages.ts delete mode 100644 package-lock.json rename scripts/{bun.ts => bun/main.ts} (63%) create mode 100644 scripts/bun/profile.ts delete mode 100644 scripts/deno-auth.ts rename scripts/{deno.ts => deno/main.ts} (71%) create mode 100644 scripts/deno/profile.ts delete mode 100644 scripts/profile.ts rename scripts/{cfw.ts => wrangler/main.ts} (76%) create mode 100644 scripts/wrangler/profile.ts create mode 100644 scripts/wrangler/testApp.ts create mode 100644 tests/mocks/profileRouter.ts diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 96bc88cd..8e5dccb7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -18,6 +18,21 @@ permissions: contents: read jobs: + profile-deno: + runs-on: ubuntu-latest + + steps: + - name: setup repo + uses: actions/checkout@v3 + + - name: setup Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Run profile + run: deno task profile + unit-test-deno: runs-on: ubuntu-latest @@ -39,9 +54,6 @@ jobs: - name: run tests run: deno task test - # - name: Run profile - # run: deno task profile - test-run-bun: runs-on: ubuntu-latest @@ -58,7 +70,9 @@ jobs: run: bun install - name: bun run - run: npm run test:bun && kill -9 <(lsof -i :7777 -t) + run: npm run test:bun + after_script: + - pkill bun test-run-wrangler: runs-on: ubuntu-latest @@ -74,4 +88,6 @@ jobs: run: npm install -g wrangler - name: wrangler dev - run: npm run test:cfw && kill -9 <(lsof -i :7777 -t) + run: npm run test:cfw + after_script: + - pkill node diff --git a/examples/auth/app.ts b/example/auth/app.ts similarity index 100% rename from examples/auth/app.ts rename to example/auth/app.ts diff --git a/examples/preact/assets/favicon.png b/example/preactSSR/assets/favicon.png similarity index 100% rename from examples/preact/assets/favicon.png rename to example/preactSSR/assets/favicon.png diff --git a/examples/preact/assets/lighthouse-score.png b/example/preactSSR/assets/lighthouse-score.png similarity index 100% rename from examples/preact/assets/lighthouse-score.png rename to example/preactSSR/assets/lighthouse-score.png diff --git a/examples/preact/assets/logo_dark_alpha.png b/example/preactSSR/assets/logo_dark_alpha.png similarity index 100% rename from examples/preact/assets/logo_dark_alpha.png rename to example/preactSSR/assets/logo_dark_alpha.png diff --git a/examples/preact/assets/logo_dark_alpha.webp b/example/preactSSR/assets/logo_dark_alpha.webp similarity index 100% rename from examples/preact/assets/logo_dark_alpha.webp rename to example/preactSSR/assets/logo_dark_alpha.webp diff --git a/examples/preact/assets/logo_dark_bg.png b/example/preactSSR/assets/logo_dark_bg.png similarity index 100% rename from examples/preact/assets/logo_dark_bg.png rename to example/preactSSR/assets/logo_dark_bg.png diff --git a/examples/preact/assets/logo_dark_bg.webp b/example/preactSSR/assets/logo_dark_bg.webp similarity index 100% rename from examples/preact/assets/logo_dark_bg.webp rename to example/preactSSR/assets/logo_dark_bg.webp diff --git a/examples/preact/assets/logo_light_alpha.png b/example/preactSSR/assets/logo_light_alpha.png similarity index 100% rename from examples/preact/assets/logo_light_alpha.png rename to example/preactSSR/assets/logo_light_alpha.png diff --git a/examples/preact/assets/logo_light_bg.png b/example/preactSSR/assets/logo_light_bg.png similarity index 100% rename from examples/preact/assets/logo_light_bg.png rename to example/preactSSR/assets/logo_light_bg.png diff --git a/examples/preact/assets/twemoji_chick.svg b/example/preactSSR/assets/twemoji_chick.svg similarity index 100% rename from examples/preact/assets/twemoji_chick.svg rename to example/preactSSR/assets/twemoji_chick.svg diff --git a/examples/preact/document.ts b/example/preactSSR/document.ts similarity index 55% rename from examples/preact/document.ts rename to example/preactSSR/document.ts index 19336f6c..3ef50783 100644 --- a/examples/preact/document.ts +++ b/example/preactSSR/document.ts @@ -1,4 +1,9 @@ -export default (tags: Record) => ` +export default (input: { + title: string; + entrypoint: string; + ssrHTML: string; + serverState?: Record; +}) => ` @@ -6,10 +11,13 @@ export default (tags: Record) => ` - ${tags && tags.title} - + ${input.title} + + - ${tags && tags.modulepreload} +