Skip to content

Add native data/page composables, richer view transitions, a default component library, and Storybook-based component development#44

Merged
JosunLP merged 24 commits intodevelopmentfrom
copilot/add-new-features-and-component-library
Mar 12, 2026
Merged

Add native data/page composables, richer view transitions, a default component library, and Storybook-based component development#44
JosunLP merged 24 commits intodevelopmentfrom
copilot/add-new-features-and-component-library

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

This PR introduces the requested native composables and page utilities (createUseFetch, useFetch, useAsyncData, useCookie, definePageMeta, useAnnouncer, defineBqueryConfig), improves the view transition API, adds a default dependency-free component library for foundational UI primitives, and replaces the previous playground workflow with Storybook for component development. The changes stay within the project's existing modular architecture and browser-native design.

  • Reactive data composables

    • Added useAsyncData() for signal-backed async state with data, error, status, pending, execute, refresh, clear, and dispose.
      • dispose() tears down reactive watch effects for short-lived consumers and makes later execute() / refresh() return the cached data value instead of re-running the handler.
      • Watch-triggered refreshes run under untrack() so only explicit watch sources retrigger executions, avoiding accidental dependency capture from synchronous signal reads inside handlers.
    • Added useFetch() as a native Fetch wrapper with:
      • query param support
      • body serialization
      • configurable response parsing
      • shared reactive async state shape, including dispose()
    • Added createUseFetch() for preconfigured fetch factories (e.g. base URL, headers).
      • Returned helpers remain generic per invocation, so one configured fetch instance can be reused across endpoints with different response types.
      • When factory defaults include a transform, derived helpers preserve that configured transformed data shape as their default AsyncDataState type while still allowing per-invocation response/data generics to be overridden.
    • Fetch behavior was further hardened so that:
      • relative baseUrl values resolve against the runtime base URL
      • Request inputs preserve their original headers unless explicitly overridden
      • query params are also applied consistently for Request inputs
      • requests with a body default to POST when no method is specified
      • explicit GET / HEAD requests with a body produce a clear reactive error state instead of attempting an invalid fetch
      • rebuilding Request inputs for query updates tolerates already-consumed bodies without throwing
  • Platform utilities

    • Added useCookie() as a reactive cookie signal with typed defaults, serialization/deserialization, and write-through behavior.
      • Auto-deserialization is limited to JSON structures (objects, arrays, quoted strings) to preserve type safety; bare primitives (numbers, booleans, null) are returned as raw strings unless a custom deserialize option is provided.
      • Automatically enforces secure: true when sameSite is set to 'None' to comply with modern browser requirements.
      • Avoids rewriting an existing cookie during read-only initialization.
      • Cookie reads tolerate both ;- and ; -separated cookie strings and gracefully fall back to raw values when percent-decoding fails, so malformed cookie data cannot crash initialization.
    • Added definePageMeta() for document title, meta tags, link tags, and html/body attribute management with cleanup support.
    • Added useAnnouncer() for accessible ARIA live-region announcements with proper reactive effect disposal on destroy.
    • Added defineBqueryConfig() / getBqueryConfig() for global runtime defaults across fetch, cookies, announcer, transitions, page meta, and component prefixing.
      • Config snapshots clone transition arrays and Headers instances to prevent accidental mutation of global state through returned values.
  • Motion / view transitions

    • Extended transition() to support:
      • async DOM updates (both function overload and options object accept Promise<void>)
      • transition classes on the root element
      • optional transition types where supported
      • reduced-motion-aware skipping
      • onReady / onFinish hooks
    • Ignores empty or whitespace-only transition class/type tokens to avoid DOMTokenList errors from misconfiguration.
    • Kept progressive enhancement behavior for browsers without the View Transitions API.
  • Default component library

    • Added registerDefaultComponents() to register a small native baseline component set:
      • button
      • card
      • input
      • textarea
      • checkbox
    • Implemented on top of the existing Web Component system with no external dependencies.
    • Components emit native-friendly custom events and expose stable foundational styling.
    • String props are HTML-entity-escaped before template interpolation to prevent markup injection.
    • Input and textarea components use beforeUpdate to patch control values in-place, preserving focus and caret position during typing instead of triggering full shadow DOM re-renders.
    • Component lifecycle hook typings remain compatible with both this-based handlers and arrow functions that do not use this.
    • Added regression coverage so repeated default-component registration remains safe for repeat dev bootstraps such as Storybook initialization and HMR-style reloads.
  • Component development workflow

    • Replaced the former Vite playground with Storybook as the dedicated component development environment.
    • Added a minimal Storybook setup based on storybook + @storybook/web-components-vite with docs support.
    • Added initial stories for the default component library so the new primitives can be developed and reviewed in isolation.
    • Updated project scripts, contributor docs, agent guidance, and repository metadata to point to Storybook instead of the removed playground workflow.
  • Public API integration

    • Exported the new APIs through the existing reactive, platform, component, root, and full entrypoints so they remain tree-shakeable and consistent with current module boundaries.

Example usage:

import {
  createUseFetch,
  defineBqueryConfig,
  definePageMeta,
  registerDefaultComponents,
  transition,
  useAnnouncer,
  useCookie,
} from '@bquery/bquery';

defineBqueryConfig({
  fetch: { baseUrl: 'https://api.example.com' },
  components: { prefix: 'bq' },
});

definePageMeta({
  title: 'Dashboard',
  description: 'Overview of your account',
});

const theme = useCookie('theme', { defaultValue: 'light' });
const useApiFetch = createUseFetch({ headers: { 'x-client': 'bquery' } });
const profile = useApiFetch('/profile');

const announcer = useAnnouncer();
announcer.announce('Profile loaded');

registerDefaultComponents();

await transition({
  classes: ['is-transitioning'],
  update: () => {
    document.body.dataset.state = 'ready';
  },
});

Screenshot of the new Storybook-based component workflow:


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 3 commits March 12, 2026 13:50
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new features and default component library Add native data/page composables, richer view transitions, and a default component library Mar 12, 2026
@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 12, 2026

@copilot prüfe, inwiefern du https://storybook.js.org/ als Entwicklungsdependency nutzen kannst, um Komponenten Development zu vereinfachen.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot prüfe, inwiefern du https://storybook.js.org/ als Entwicklungsdependency nutzen kannst, um Komponenten Development zu vereinfachen.

Ich habe es geprüft: technisch passt Storybook hier als reine Dev-Dependency gut, am ehesten über @storybook/web-components-vite. Das hätte keinen Runtime-Einfluss auf das Paket. Für dieses Repo würde ich es aktuell trotzdem eher noch nicht ergänzen, weil wir mit playground/ und VitePress bereits zwei passende Wege für Komponentenentwicklung und Doku haben und Storybook sonst ein drittes paralleles System mit zusätzlichem Pflegeaufwand wäre. Sinnvoll würde es vor allem dann, wenn wir isolierte Komponenten-Galerien, Controls/Args oder visuelle Regression gezielt aufbauen wollen. Wenn du möchtest, kann ich als Nächstes eine minimale optionale Storybook-Integration vorbereiten.

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 12, 2026

Ich würde den „Playground“ gerne durch Storybook ersetzen. VitePress ist vollständig für die Dokumentation. Mit Storybooks haben wir einfach eine wesentlich solidere Basis! @copilot

@copilot prüfe, inwiefern du storybook.js.org als Entwicklungsdependency nutzen kannst, um Komponenten Development zu vereinfachen.

Ich habe es geprüft: technisch passt Storybook hier als reine Dev-Dependency gut, am ehesten über @storybook/web-components-vite. Das hätte keinen Runtime-Einfluss auf das Paket. Für dieses Repo würde ich es aktuell trotzdem eher noch nicht ergänzen, weil wir mit playground/ und VitePress bereits zwei passende Wege für Komponentenentwicklung und Doku haben und Storybook sonst ein drittes paralleles System mit zusätzlichem Pflegeaufwand wäre. Sinnvoll würde es vor allem dann, wenn wir isolierte Komponenten-Galerien, Controls/Args oder visuelle Regression gezielt aufbauen wollen. Wenn du möchtest, kann ich als Nächstes eine minimale optionale Storybook-Integration vorbereiten.

Copilot AI and others added 2 commits March 12, 2026 14:24
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 12, 2026

Ich würde den „Playground“ gerne durch Storybook ersetzen. VitePress ist vollständig für die Dokumentation. Mit Storybooks haben wir einfach eine wesentlich solidere Basis! @copilot
...

Umgesetzt in 6af3386. Storybook ersetzt jetzt den bisherigen Playground-Workflow: minimaler @storybook/web-components-vite-Setup, Stories für die Default-Component-Library, aktualisierte Contributor-/Agent-/README-Doku und der alte Playground wurde entfernt. Screenshot: https://github.com/user-attachments/assets/787f127c-632f-49f3-bc45-021f2d3e8808

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • storybook.js.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/b7be834efe44dce2/node_modules/.bin/create-storybook --type web_components --builder vite --skip-install --package-manager npm (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/.npm/_npx/d80003e6561624d3/node_modules/.bin/cli automigrate addon-a11y-addon-test --loglevel silent --skip-doctor --package-manager npm --config-dir .storybook git |\\#�� copilot/add-new-features-and-component-library^{commit} (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/bQuery/bQuery/node_modules/.bin/storybook build dirname /hom�� el silent --skip-doctor --package-manager npm --config-dir .storybook (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add native data/page composables, richer view transitions, and a default component library Add native data/page composables, richer view transitions, a default component library, and Storybook-based component development Mar 12, 2026
@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 12, 2026

@copilot Die Tests schlagen fehl und die Komponenten Vorschau sieht nicht so aus, als würden die Default-Komponenten funktionieren.

Copilot AI and others added 3 commits March 12, 2026 14:55
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot Die Tests schlagen fehl und die Komponenten Vorschau sieht nicht so aus, als würden die Default-Komponenten funktionieren.

Behoben in c587912. Die fehlgeschlagenen Tests kamen vom veralteten bun.lock (bun install --frozen-lockfile ist wieder grün), und die leere Storybook-Vorschau lag daran, dass slot im Shadow-Markup der Default-Komponenten beim Sanitizing entfernt wurde. Zusätzlich ist der Button-Renderpfad jetzt mit einem Regressionstest abgesichert. Screenshot: https://github.com/user-attachments/assets/7b3382f7-1554-4980-93c1-1f3349d518f2

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • storybook.js.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/bQuery/bQuery/node_modules/.bin/storybook build (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/bQuery/bQuery/node_modules/.bin/storybook build m/nvm.sh m/pa�� m/rename_test.sh &lt;20913954&#43;JosunLP@users.noreply.github.com&gt; /bin/java (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/bQuery/bQuery/node_modules/.bin/storybook build npm inst�� --package-lock=f index($0, NVM_DIR) == 1 { path = substr($0, length(NVM_DIR) &#43; 1) if (git l bin/sh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@JosunLP JosunLP marked this pull request as ready for review March 12, 2026 15:32
Copilot AI review requested due to automatic review settings March 12, 2026 15:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 61 out of 64 changed files in this pull request and generated 4 comments.

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 12, 2026

@copilot apply changes based on the comments in this thread

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot apply changes based on the comments in this thread

Umgesetzt in b3d4b65. Die Default-input-, textarea- und checkbox-Komponenten stoppen jetzt das native Shadow-DOM-Event, bevor das Host-Event mit Detail-Payload dispatched wird, sodass Consumer nur noch ein input/change pro Interaktion sehen. Außerdem baut useFetch() Request-Inputs nur noch dann neu auf, wenn Query-Parameter die URL tatsächlich ändern; ohne Query bleibt die originale Request-Instanz erhalten. Dafür gibt es gezielte Regressionstests; validiert mit fokussierten Component/Signal-Tests, Typecheck, Code Review und CodeQL (0 Alerts). Screenshot: https://github.com/user-attachments/assets/cb96156e-821e-46e9-b967-2e88bd09869b

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 61 out of 64 changed files in this pull request and generated 1 comment.

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 12, 2026

@copilot apply changes based on the comments in this thread

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot apply changes based on the comments in this thread

Umgesetzt in 623febf. useFetch() merged globale Fetch-Config-Header jetzt nur noch als Defaults, danach die Header eines übergebenen Request, und zuletzt weiter die per-Call-Header — damit bleiben Request-Header erhalten, außer sie werden explizit im Aufruf überschrieben. Dazu gibt es einen gezielten Regressionstest für Config-vs-Request-Header; validiert mit fokussierten Signal-Tests, Typecheck, Code Review und CodeQL (0 Alerts). Screenshot: https://github.com/user-attachments/assets/cb96156e-821e-46e9-b967-2e88bd09869b

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 61 out of 64 changed files in this pull request and generated 1 comment.

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 12, 2026

@copilot apply changes based on the comments in this thread

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot apply changes based on the comments in this thread

Umgesetzt in fd5be17. createUseFetch() hat jetzt überladene Typ-Signaturen, sodass Factory-Defaults mit transform ihre konfigurierte Datenform standardmäßig in jeden Aufruf übernehmen, während ungeänderte Factories weiter pro Aufruf TData aus TResponse ableiten. Dazu gibt es einen gezielten Regressionstest für transformierte Factory-Defaults; validiert mit fokussierten Signal-Tests, Typecheck, Code Review und CodeQL (0 Alerts). Screenshot: https://github.com/user-attachments/assets/cb96156e-821e-46e9-b967-2e88bd09869b

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 61 out of 64 changed files in this pull request and generated 1 comment.

@JosunLP
Copy link
Copy Markdown
Collaborator

JosunLP commented Mar 12, 2026

@copilot apply changes based on the comments in this thread

…al types and linkedSignal value

Co-authored-by: JosunLP <20913954+JosunLP@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot apply changes based on the comments in this thread

Umgesetzt in 9b8d044. src/full.ts re-exportiert jetzt AsyncWatchSource, FetchInput, LinkedSignal (Typen) und linkedSignal (Wert) aus dem Reactive-Modul, sodass CDN/UMD-Consumer die gleiche API-Oberfläche wie Main-Entrypoint-Nutzer haben. Validiert mit 523 Tests, Typecheck, Code Review und CodeQL (0 Alerts). Screenshot: https://github.com/user-attachments/assets/cb96156e-821e-46e9-b967-2e88bd09869b

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 61 out of 64 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants