[]previous and next page

@shadow-js/web/extend

The 32 exports of @shadow-js/web/extend: 19 functions, 6 interfaces, 1 type and 6 consts.

Everything @shadow-js/web/extend exports, from the TSDoc of its entry point.

Functions#

  • bindRegion: Keeps a region in sync with value.
  • childScope: Creates a fresh scope for an isolated part of the tree, such as a Suspense boundary's content or fallback, or a portal's content: its keys depend only on key, not on the siblings around it.
  • claimElement: Adopts the server's element for a hydration key while hydrate() runs: the step that lets a custom template reuse server markup instead of creating new nodes.
  • claimPortal: Adopts the server block of a portal while hydrate() runs.
  • createRegion: Creates the state of a region in parent.
  • createRootScope: Creates the scope a render or a hydration starts from: what renderToString and hydrate() put in effect around the app.
  • currentScope: Returns the hydration scope in effect.
  • element: Creates one HTML element from a tag name and a props object, without the generic prop runtime of spread and Dynamic: for a library that renders one fixed element (a link, a button) and wants to pay only for what it binds.
  • enterComponent: Runs a component call in a scope of its own, so the keys it draws depend only on its position among its parent's calls: what createComponent does on the client and on the server.
  • isClaiming: Reports whether a hydrate() pass is claiming server DOM right now: a custom renderer reads it to decide between adopting server nodes and building fresh ones.
  • isUnsafeUrlAttribute: Reports whether writing value to the attribute name would run script: the URL check that setAttribute, the head registry and the server renderer share.
  • nextKey: Draws the key of the next template root in the current scope: what template() and ssrHydrationKey() call, in the same order on the server and the client.
  • reconcileNodes: Updates one region of parent's children from the nodes prev to the nodes next, keeping every node that stays and moving as few as possible: the list reconciliation insert performs for arrays (and so for For).
  • removeRegion: Removes a region's nodes from its parent.
  • resourceKey: Returns the key a resource's value is stored under in the server data, the same on the server and the client: the explicit key when there is one, else one drawn from the current scope.
  • takeRegion: Adopts the server content of the next region of a claimed parent while hydrate() runs: the nodes that sat between the region's markers are put back before anchorNode and returned, so a custom region can bind to them instead of inserting new nodes.
  • warnOnce: Prints a development warning as [shadow CODE] detail, at most once per code for the life of the page or process (the same pattern as core's warn): for a custom renderer that refuses a value the way the built-in ones do.
  • withoutClaiming: Runs fn with claiming switched off, so the templates it builds are created fresh instead of claimed from the server markup.
  • withScope: Runs fn with scope in effect, so the keys fn draws come from it.

Interfaces#

  • Claims: The claiming half of hydration, as a hook.
  • HydrationScope: A hydration scope: the deterministic source of hydration keys shared by the server renderer and the client hydrator.
  • PortalSink: Receives the markup of the portals a server render produces: what PortalContext provides when the render was given a portals collector.
  • Region: State of one dynamic child region.
  • StreamBoundary: A Suspense boundary whose content was not ready when the shell rendered: renderToStream calls rebuild again each time a resource settles, and streams the markup once it is complete.
  • StreamSink: Receives the boundaries that are still pending during a streaming render: what StreamContext provides.

Types#

  • WebWarningCode: The diagnostic codes of the DOM runtime: UNSAFE_URL_BLOCKED (a URL attribute that would run script was not written), INVALID_ATTRIBUTE_NAME (a name that cannot appear in markup) and DUPLICATE_CLASS_ATTRIBUTE (one element carries class and className, so the parser drops one).

Constants#

  • claims: The claims in effect.
  • HTML_NS: The XHTML namespace URI: the namespaceURI of ordinary HTML elements.
  • MATHML_NS: The MathML namespace URI, for createElementNS and namespaceURI checks.
  • PortalContext: The context through which a server render hands portals their collector: the renderers provide it when they are given a portals option (see createServerPortals).
  • StreamContext: The context through which renderToStream lets a Suspense-like boundary defer its content: a boundary that is pending in the shell renders its fallback between <!--[b:ID--> and <!--]--> and defers a StreamBoundary to the sink.
  • SVG_NS: The SVG namespace URI, for createElementNS and namespaceURI checks.