@manta-eu/horns-kit/written
Reference for @manta-eu/horns-kit/written in @manta-eu/horns-kit 0.2.3.
Classes
WrittenViewError
Extends
Error
Constructors
Constructor
new WrittenViewError(
message,options?):WrittenViewError
Parameters
message
string
options?
cause?
unknown
Returns
Overrides
Error.constructor
Properties
cause?
optionalcause?:unknown
Inherited from
Error.cause
message
message:
string
Inherited from
Error.message
name
name:
string
Inherited from
Error.name
stack?
optionalstack?:string
Inherited from
Error.stack
Type Aliases
CompileWrittenOptions
CompileWrittenOptions =
object
Properties
hooks
hooks:
Readonly<Record<string,unknown>>
React’s own hooks, from the host’s React, so a view’s state lives in the same reconciler as the page.
loadSurface
loadSurface: () =>
Promise<WrittenSurface>
Fetches the host’s surface, on demand.
A function rather than the modules themselves so that binding the whole design system costs nothing on a page with no written view — which is every page, most of the time. The host’s loader is where the dynamic import lives, so the bundler can split it out.
Returns
Promise<WrittenSurface>
source
source:
string
WrittenComponent
WrittenComponent = (
props) =>ReactNode
Parameters
props
Returns
ReactNode
WrittenComponentProps
WrittenComponentProps =
object
Properties
columns
columns: readonly
string[]
labels
labels:
Readonly<Record<string,string>>
The display name of every IRI in the rows, so a view shows a thing rather than an address.
links
links:
Readonly<Record<string,WrittenLink>>
Where each IRI opens, for the ones that have a page. Absent means there is nothing to link to.
rows
rows: readonly
Readonly<Record<string,unknown>>[]
WrittenLink
WrittenLink =
object
Where an IRI opens, and what the link says. The host builds the href; a view never composes one.
Properties
href
href:
string
label
label:
string
WrittenSurface
WrittenSurface =
Readonly<Record<string,Readonly<Record<string,unknown>>>>
A module the host binds by specifier: { "@manta-eu/react": mod, "@manta-eu/react/chart": mod }.
WrittenViewProps
WrittenViewProps =
object
Properties
columns
columns: readonly
string[]
fallback?
optionalfallback?:ReactNode
Drawn while the transpiler loads.
hooks
hooks:
Readonly<Record<string,unknown>>
The host’s React hooks, so a view’s state lives in the same reconciler as the page. Also stable.
labels
labels:
Readonly<Record<string,string>>
The snapshot’s names by IRI, so a view can show the thing an IRI points at.
links
links:
Readonly<Record<string,WrittenLink>>
Where each IRI opens, for the ones with a page. The host composes the href; the view never does.
loadSurface
loadSurface: () =>
Promise<WrittenSurface>
Fetches the host’s own modules, by specifier, narrowed to the declared surface before the view sees them. Hold this at module scope: a fresh function every render recompiles the view every render.
Returns
Promise<WrittenSurface>
renderError?
optionalrenderError?: (message) =>ReactNode
Parameters
message
string
Returns
ReactNode
rows
rows: readonly
Readonly<Record<string,unknown>>[]
source
source:
string
The TSX the Studio wrote. Refused by tsxViolations long before it reaches here.
Functions
compileWritten()
compileWritten(
options):Promise<WrittenComponent>
Source to a component, ready to render in the host’s own tree.
Parameters
options
Returns
Promise<WrittenComponent>
createSurfaceLoader()
createSurfaceLoader(
surface,hooks): (specifier) =>Readonly<Record<string,unknown>>
Serves the surface and nothing else, narrowed to the declared exports so a host cannot widen it.
Parameters
surface
hooks
Readonly<Record<string, unknown>>
Returns
(specifier) => Readonly<Record<string, unknown>>
evaluateWritten()
evaluateWritten(
code,load):WrittenComponent
new Function rather than an import: by now the source is CommonJS, and its only way out is require.
Parameters
code
string
load
(specifier) => Readonly<Record<string, unknown>>
Returns
transpileWritten()
transpileWritten(
source):Promise<string>
TSX to CommonJS. Loaded on first use: a Horn with no written view must not pay for the transpiler.
Parameters
source
string
Returns
Promise<string>
WrittenView()
WrittenView(
props):ReactNode
Parameters
props
Returns
ReactNode