From 354948d6981de92a8ae5837d740c91f2d7108490 Mon Sep 17 00:00:00 2001 From: Luiz Ferraz Date: Tue, 1 Oct 2024 02:09:38 -0300 Subject: [PATCH] --wip-- [skip ci] --- examples/request-nanostores/astro.config.ts | 3 +- examples/request-nanostores/package.json | 1 + .../src/components/AddToCartForm.tsx | 12 +- .../src/layouts/Layout.astro | 140 +++++++++--------- packages/portal-gun/package.json | 14 +- packages/portal-gun/src/index.ts | 24 ++- packages/portal-gun/src/runtime/middleware.ts | 63 ++++++++ packages/portal-gun/src/runtime/sample.ts | 2 - packages/portal-gun/virtual.d.ts | 21 ++- pnpm-lock.yaml | 37 +++++ pnpm-workspace.yaml | 4 + 11 files changed, 239 insertions(+), 82 deletions(-) create mode 100644 packages/portal-gun/src/runtime/middleware.ts delete mode 100644 packages/portal-gun/src/runtime/sample.ts diff --git a/examples/request-nanostores/astro.config.ts b/examples/request-nanostores/astro.config.ts index 0d297f17..3c554be6 100644 --- a/examples/request-nanostores/astro.config.ts +++ b/examples/request-nanostores/astro.config.ts @@ -1,13 +1,14 @@ import { defineConfig } from 'astro/config'; import preact from '@astrojs/preact'; import requestNanostores from '@inox-tools/request-nanostores'; +import portalGun from '@inox-tools/portal-gun'; import node from '@astrojs/node'; // https://astro.build/config export default defineConfig({ // Enable many frameworks to support all different kinds of components. - integrations: [preact(), requestNanostores()], + integrations: [preact(), requestNanostores(), portalGun()], compressHTML: false, output: 'server', adapter: node({ diff --git a/examples/request-nanostores/package.json b/examples/request-nanostores/package.json index 25d49fe4..86aa89e3 100644 --- a/examples/request-nanostores/package.json +++ b/examples/request-nanostores/package.json @@ -15,6 +15,7 @@ "@astrojs/node": "^8.3.4", "@astrojs/preact": "^3.5.3", "@inox-tools/request-nanostores": "workspace:^", + "@inox-tools/portal-gun": "workspace:^", "@nanostores/preact": "^0.5.2", "astro": "^4.15.9", "nanostores": "^0.11.3", diff --git a/examples/request-nanostores/src/components/AddToCartForm.tsx b/examples/request-nanostores/src/components/AddToCartForm.tsx index 90a4cdad..ea3bf5f6 100644 --- a/examples/request-nanostores/src/components/AddToCartForm.tsx +++ b/examples/request-nanostores/src/components/AddToCartForm.tsx @@ -14,5 +14,15 @@ export default function AddToCartForm({ item, children }: Props) { addCartItem(item); } - return
{children}
; + return ( + <> + +

Adding to the header

+
+ + + +
{children}
; + + ); } diff --git a/examples/request-nanostores/src/layouts/Layout.astro b/examples/request-nanostores/src/layouts/Layout.astro index 86ba11a6..584991d1 100644 --- a/examples/request-nanostores/src/layouts/Layout.astro +++ b/examples/request-nanostores/src/layouts/Layout.astro @@ -17,9 +17,11 @@ const { title } = Astro.props; {title} +
+