Skip to content

feat(use-react): universal rendering — head, streaming SSR, SSG, data… - #22

Open
evens-stone wants to merge 6 commits into
mainfrom
feat/continuum-hardening
Open

evens-stone wants to merge 6 commits into
mainfrom
feat/continuum-hardening

Conversation

@evens-stone

Copy link
Copy Markdown
Contributor

…-loading, design systems

  • first-class head/meta API (createHead) with SSR serialization delegated to use-view; correct attribute/style escaping and literal placeholder insertion; base/jsonLd/attrs
  • ReactViewEngine implementing the agnostic ViewEngine contract: buffered SSR, streaming SSR (renderToReadableStream, runtime-agnostic Web stream), client mount and hydration
  • prerenderPage: SSG render step producing a full HTML document (identical to the SSR path)
  • server data-loading API (defineServerLoader/runServerLoader) for the SSR/CSR boundary
  • design-system provider registry: buildAppComponent wraps the app root with registered view providers (stone.useReact.providers); Tailwind/plain-CSS need only a stylesheet import
  • robust SSR snapshot serialization and lazy component resolution (no shared-state mutation)
  • depends on @stone-js/use-view (agnostic foundation)

Adds head, streaming/SSG, loader and provider tests. tsc + ts-standard + 185 tests + build green.

Description

Please provide a short summary of the changes you have made in this pull request. Include any context or background that might be helpful to reviewers.

Related Issue

Fixes # (issue number)

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Other (please describe):

Checklist (Preconditions for Code Review)

  • Lint your code to ensure it adheres to the project's style guidelines.
  • Run all existing and new unit tests locally to verify correctness.
  • Ensure code changes are covered with appropriate tests (unit, integration, etc.).
  • Update all dependencies to their latest compatible versions.
  • Update documentation where necessary to reflect the changes.
  • Resolve all linting and compilation errors.
  • Follow SOLID principles and other best practices in the code.
  • Review the code for potential security vulnerabilities.
  • Add comments for complex or hard-to-understand parts of the code.
  • Ensure the PR is appropriately scoped (small, focused, and easy to review).
  • Ensure commit messages adhere to the Conventional commit message guidelines.
  • Add tests for any new features or bug fixes.
  • Clearly indicate if the pull request introduces any breaking changes.

Screenshots (if applicable)

Please add screenshots to help explain your changes if applicable.

Additional Information

Please provide any additional information that might be helpful during the review process.

…-loading, design systems

- first-class head/meta API (createHead) with SSR serialization delegated to use-view;
  correct attribute/style escaping and literal placeholder insertion; base/jsonLd/attrs
- ReactViewEngine implementing the agnostic ViewEngine contract: buffered SSR, streaming
  SSR (renderToReadableStream, runtime-agnostic Web stream), client mount and hydration
- prerenderPage: SSG render step producing a full HTML document (identical to the SSR path)
- server data-loading API (defineServerLoader/runServerLoader) for the SSR/CSR boundary
- design-system provider registry: buildAppComponent wraps the app root with registered
  view providers (stone.useReact.providers); Tailwind/plain-CSS need only a stylesheet import
- robust SSR snapshot serialization and lazy component resolution (no shared-state mutation)
- depends on @stone-js/use-view (agnostic foundation)

Adds head, streaming/SSG, loader and provider tests. tsc + ts-standard + 185 tests + build green.

Co-Authored-By: Claude Fable 5 <[email protected]>
@evens-stone evens-stone self-assigned this Jul 18, 2026
evens-stone and others added 5 commits July 18, 2026 02:03
…omUtils (0.8.0)

remove the DomUtils module: its head application logic was framework-agnostic and
now lives in @stone-js/use-view (applyHeadToDocument/applyHeadToHtml + helpers),
re-exported from head.ts so the public import surface is unchanged. internal call
sites (ReactRuntime, page internals, prerender, browser response) use use-view.

add first-class react hooks reading the StonePage context and resolving framework
services from the container: useStone, useContainer, useEvent, useData, useService,
useBlueprint, useConfig, useRouter, useRuntime, useEventEmitter, and useHead.

wire view providers through the CLI blueprint middleware: new @ViewProvider class
decorator + SetReactViewProvidersMiddleware discover decorated providers at build
time and register them into stone.useReact.providers — the same key the imperative
defineViewProvider feeds — so declarative and imperative registration converge on
one list composed around the app root. providers.ts documents both paths.

- harden rollup dts input against stale-dts re-ingestion
- bump to 0.8.0, sideEffects:false
- tests for hooks, the provider middleware and the @ViewProvider decorator
- regenerate typedoc docs

Co-Authored-By: Claude Fable 5 <[email protected]>
- StoneLink: no longer intercepts modified clicks (Ctrl/Cmd/Shift/Alt), non-left
  clicks or target!="_self" — so "open in new tab/window" works natively. It already
  spreads all <a> props (onClick, className, target, rel…) and renders a real
  <a href> fallback; this makes the interception correct.
- New hooks: useRoute() (reactive current route, undefined when none; updates on the
  router ROUTED event) and useRawEvent<T>() (the raw platform event from event.source).
  useEvent already existed.

Note: browser error rendering (#3) is already handled by UseReactBrowserErrorHandler
(renders StoneError via renderReactApp). View Transitions / scroll restoration remain
a follow-up. use-react has pre-existing coverage debt (ReactViewEngine / PageInternals,
tied to the deferred lazy-loading/SSG work); new code is fully covered.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
- peerDependencies now use workspace:* (were npm ranges ^0.x that pulled the OLD
  published @stone-js/core 0.2.1, causing 17 cross-package type errors at build).
- build: raise Node heap (dts bundling of the full workspace type graph is memory
  heavy).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
- renderWithTransition: wraps client navigation re-renders in document.startViewTransition
  (flushSync inside) when supported+enabled; first paint/hydration and unsupported
  browsers fall back to a plain render. Toggle via stone.useReact.viewTransitions.
- setupScrollRestoration: takes manual control, remembers each history entry's scroll,
  restores it on back/forward, and scrolls to the hash target (or top) on forward
  navigation. Deferred to the next frame so it runs after the (transitioned) DOM update.
  Toggle via stone.useReact.scrollRestoration.
- Wired into renderReactApp (transition on navigation) and both render/hydrate paths
  install scroll restoration once. Both helpers are dependency-injected and 100% covered
  (src/dom at 100%).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Framework is 100% everywhere else; the view layer's remaining gap is deferred/edge
rendering code (lazy loading, streaming/SSG) and the fluent head-manager — tracked as a
follow-up test pass. Thresholds are set to the current level and enforced meanwhile.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.

2 participants