File: .lake/packages/proofwidgets/ProofWidgets/Component/Basic.lean

full_name: ProofWidgets.Component
code: /-- A component is a widget module with a `default` or named export which is a
[React component](https://react.dev/learn/your-first-component). Every component definition must
be annotated with `@[widget_module]`. This makes it possible for the infoview to load the component.

## Execution environment

The JS environment in which components execute provides a fixed set of libraries accessible via
direct `import`, notably
[`@leanprover/infoview`](https://www.npmjs.com/package/@leanprover/infoview).
All [React contexts](https://react.dev/learn/passing-data-deeply-with-context) exported from
`@leanprover/infoview` are usable from components.

## Lean encoding of props

`Props` is the Lean representation of the type `JsProps` of
[React props](https://react.dev/learn/passing-props-to-a-component)
that the component expects.
The export of the module specified in `«export»` should then have type
`(props: JsProps & { pos: DocumentPosition }): React.ReactNode`
where `DocumentPosition` is defined in `@leanprover/infoview`.
`Props` is expected to have a `Lean.Server.RpcEncodable` instance
specifying how to encode props as JSON.

Note that by defining a `Component Props` with a specific JS implementation,
you are *asserting* that `Props` is a correct representation of `JsProps`. -/
structure Component (Props : Type) extends Widget.Module where
  /-- Which export of the module to use as the component function. -/
  «export» : String := "default"
goal: Type

full_name: ProofWidgets.Component.export
code: /-- A component is a widget module with a `default` or named export which is a
[React component](https://react.dev/learn/your-first-component). Every component definition must
be annotated with `@[widget_module]`. This makes it possible for the infoview to load the component.

## Execution environment

The JS environment in which components execute provides a fixed set of libraries accessible via
direct `import`, notably
[`@leanprover/infoview`](https://www.npmjs.com/package/@leanprover/infoview).
All [React contexts](https://react.dev/learn/passing-data-deeply-with-context) exported from
`@leanprover/infoview` are usable from components.

## Lean encoding of props

`Props` is the Lean representation of the type `JsProps` of
[React props](https://react.dev/learn/passing-props-to-a-component)
that the component expects.
The export of the module specified in `«export»` should then have type
`(props: JsProps & { pos: DocumentPosition }): React.ReactNode`
where `DocumentPosition` is defined in `@leanprover/infoview`.
`Props` is expected to have a `Lean.Server.RpcEncodable` instance
specifying how to encode props as JSON.

Note that by defining a `Component Props` with a specific JS implementation,
you are *asserting* that `Props` is a correct representation of `JsProps`. -/
structure Component (Props : Type) extends Widget.Module where
  /-- Which export of the module to use as the component function. -/
  «export» : String := "default"
goal: String

full_name: ProofWidgets.instToModuleComponent
code: instance : Widget.ToModule (Component Props) 
goal: Lean.Widget.ToModule (ProofWidgets.Component Props)

full_name: ProofWidgets.InteractiveCodeProps
code: structure InteractiveCodeProps where
  fmt : Widget.CodeWithInfos
  deriving Server.RpcEncodable
goal: Type

full_name: ProofWidgets.InteractiveCodeProps.fmt
code: structure InteractiveCodeProps where
  fmt : Widget.CodeWithInfos
  deriving Server.RpcEncodable
goal: Lean.Widget.CodeWithInfos

full_name: ProofWidgets.ProofWidgets.InteractiveCodeProps.instRpcEncodableInteractiveCodeProps.enc._@..lake.packages.proofwidgets.ProofWidgets.Component.Basic._hyg.44
code: Server.RpcEncodable
goal: ProofWidgets.InteractiveCodeProps → StateM Lean.Server.RpcObjectStore Lean.Json

full_name: ProofWidgets.ProofWidgets.InteractiveCodeProps.RpcEncodablePacket._@..lake.packages.proofwidgets.ProofWidgets.Component.Basic._hyg.44
code: Server.RpcEncodable
goal: Type

full_name: ProofWidgets.ProofWidgets.InteractiveCodeProps.instFromJsonRpcEncodablePacket
code: Server.RpcEncodable
goal: Lean.FromJson ProofWidgets.ProofWidgets.InteractiveCodeProps.RpcEncodablePacket✝

full_name: ProofWidgets.ProofWidgets.InteractiveCodeProps.instToJsonRpcEncodablePacket
code: Server.RpcEncodable
goal: Lean.ToJson ProofWidgets.ProofWidgets.InteractiveCodeProps.RpcEncodablePacket✝

full_name: ProofWidgets.ProofWidgets.InteractiveCodeProps.instRpcEncodableInteractiveCodeProps
code: Server.RpcEncodable
goal: Lean.Server.RpcEncodable ProofWidgets.InteractiveCodeProps

full_name: ProofWidgets.ProofWidgets.InteractiveCodeProps.instRpcEncodableInteractiveCodeProps.dec._@..lake.packages.proofwidgets.ProofWidgets.Component.Basic._hyg.44
code: Server.RpcEncodable
goal: Lean.Json → ExceptT String (ReaderT Lean.Server.RpcObjectStore Id) ProofWidgets.InteractiveCodeProps

full_name: ProofWidgets.InteractiveCode
code: /-- Present pretty-printed code as interactive text.

The most common use case is to instantiate this component from a `Lean.Expr`. To do so, you must
eagerly pretty-print the `Expr` using `Widget.ppExprTagged`. See also `InteractiveExpr`. -/
@[widget_module]
def InteractiveCode : Component InteractiveCodeProps 
goal: ProofWidgets.Component ProofWidgets.InteractiveCodeProps

full_name: ProofWidgets.InteractiveExprProps
code: structure InteractiveExprProps where
  expr : Server.WithRpcRef ExprWithCtx
  deriving Server.RpcEncodable
goal: Type

full_name: ProofWidgets.InteractiveExprProps.expr
code: structure InteractiveExprProps where
  expr : Server.WithRpcRef ExprWithCtx
  deriving Server.RpcEncodable
goal: Lean.Server.WithRpcRef ProofWidgets.ExprWithCtx

full_name: ProofWidgets.ProofWidgets.InteractiveExprProps.instRpcEncodableInteractiveExprProps.enc._@..lake.packages.proofwidgets.ProofWidgets.Component.Basic._hyg.307
code: Server.RpcEncodable
goal: ProofWidgets.InteractiveExprProps → StateM Lean.Server.RpcObjectStore Lean.Json

full_name: ProofWidgets.ProofWidgets.InteractiveExprProps.instFromJsonRpcEncodablePacket
code: Server.RpcEncodable
goal: Lean.FromJson ProofWidgets.ProofWidgets.InteractiveExprProps.RpcEncodablePacket✝

full_name: ProofWidgets.ProofWidgets.InteractiveExprProps.RpcEncodablePacket._@..lake.packages.proofwidgets.ProofWidgets.Component.Basic._hyg.307
code: Server.RpcEncodable
goal: Type

full_name: ProofWidgets.ProofWidgets.InteractiveExprProps.instRpcEncodableInteractiveExprProps.dec._@..lake.packages.proofwidgets.ProofWidgets.Component.Basic._hyg.307
code: Server.RpcEncodable
goal: Lean.Json → ExceptT String (ReaderT Lean.Server.RpcObjectStore Id) ProofWidgets.InteractiveExprProps

full_name: ProofWidgets.ProofWidgets.InteractiveExprProps.instToJsonRpcEncodablePacket
code: Server.RpcEncodable
goal: Lean.ToJson ProofWidgets.ProofWidgets.InteractiveExprProps.RpcEncodablePacket✝

full_name: ProofWidgets.ProofWidgets.InteractiveExprProps.instRpcEncodableInteractiveExprProps
code: Server.RpcEncodable
goal: Lean.Server.RpcEncodable ProofWidgets.InteractiveExprProps

full_name: ProofWidgets.ppExprTagged
code: @[server_rpc_method]
def ppExprTagged : InteractiveExprProps → Server.RequestM (Server.RequestTask Widget.CodeWithInfos)
  
goal: ProofWidgets.InteractiveExprProps → Lean.Server.RequestM (Lean.Server.RequestTask Lean.Widget.CodeWithInfos)

full_name: ProofWidgets.InteractiveExpr
code: /-- Lazily pretty-print and present a `Lean.Expr` as interactive text.

This component is preferrable over `InteractiveCode` when the `Expr` will not necessarily be
displayed in the UI (e.g. it may be hidden by default), in which case laziness saves some work.
On the other hand if the `Expr` will likely be shown and you are in a `MetaM` context, it is
preferrable to use the eager `InteractiveCode` in order to avoid the extra client-server roundtrip
needed for the pretty-printing RPC call. -/
@[widget_module]
def InteractiveExpr : Component InteractiveExprProps 
goal: ProofWidgets.Component ProofWidgets.InteractiveExprProps

full_name: ProofWidgets.InteractiveMessageProps.msg
code: structure InteractiveMessageProps where
  msg : Server.WithRpcRef MessageData
  deriving Server.RpcEncodable
goal: Lean.Server.WithRpcRef Lean.MessageData

full_name: ProofWidgets.InteractiveMessageProps
code: structure InteractiveMessageProps where
  msg : Server.WithRpcRef MessageData
  deriving Server.RpcEncodable
goal: Type

full_name: ProofWidgets.ProofWidgets.InteractiveMessageProps.instRpcEncodableInteractiveMessageProps
code: Server.RpcEncodable
goal: Lean.Server.RpcEncodable ProofWidgets.InteractiveMessageProps

full_name: ProofWidgets.ProofWidgets.InteractiveMessageProps.RpcEncodablePacket._@..lake.packages.proofwidgets.ProofWidgets.Component.Basic._hyg.627
code: Server.RpcEncodable
goal: Type

full_name: ProofWidgets.ProofWidgets.InteractiveMessageProps.instFromJsonRpcEncodablePacket
code: Server.RpcEncodable
goal: Lean.FromJson ProofWidgets.ProofWidgets.InteractiveMessageProps.RpcEncodablePacket✝

full_name: ProofWidgets.ProofWidgets.InteractiveMessageProps.instToJsonRpcEncodablePacket
code: Server.RpcEncodable
goal: Lean.ToJson ProofWidgets.ProofWidgets.InteractiveMessageProps.RpcEncodablePacket✝

full_name: ProofWidgets.ProofWidgets.InteractiveMessageProps.instRpcEncodableInteractiveMessageProps.enc._@..lake.packages.proofwidgets.ProofWidgets.Component.Basic._hyg.627
code: Server.RpcEncodable
goal: ProofWidgets.InteractiveMessageProps → StateM Lean.Server.RpcObjectStore Lean.Json

full_name: ProofWidgets.ProofWidgets.InteractiveMessageProps.instRpcEncodableInteractiveMessageProps.dec._@..lake.packages.proofwidgets.ProofWidgets.Component.Basic._hyg.627
code: Server.RpcEncodable
goal: Lean.Json → ExceptT String (ReaderT Lean.Server.RpcObjectStore Id) ProofWidgets.InteractiveMessageProps

full_name: ProofWidgets.InteractiveMessage
code: /-- Present a structured Lean message. -/
@[widget_module]
def InteractiveMessage : Component InteractiveMessageProps 
goal: ProofWidgets.Component ProofWidgets.InteractiveMessageProps

full_name: Lean.MessageData.ofComponent
code: /-- Construct a structured message from a ProofWidgets component.

For the meaning of `alt`, see `MessageData.ofWidget`. -/
def Lean.MessageData.ofComponent [Server.RpcEncodable Props]
    (c : ProofWidgets.Component Props) (p : Props) (alt : String) : CoreM MessageData 
goal: Lean.CoreM Lean.MessageData