lib.rs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #![doc = include_str!("../README.md")]
  2. #![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
  3. #![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
  4. #![warn(missing_docs)]
  5. mod any_props;
  6. mod arena;
  7. mod diff;
  8. mod effect;
  9. mod error_boundary;
  10. mod events;
  11. mod fragment;
  12. mod generational_box;
  13. mod global_context;
  14. mod launch;
  15. mod mutations;
  16. mod nodes;
  17. mod properties;
  18. mod reactive_context;
  19. mod render_error;
  20. mod root_wrapper;
  21. mod runtime;
  22. mod scheduler;
  23. mod scope_arena;
  24. mod scope_context;
  25. mod scopes;
  26. mod suspense;
  27. mod tasks;
  28. mod virtual_dom;
  29. mod hotreload_utils;
  30. /// Items exported from this module are used in macros and should not be used directly.
  31. #[doc(hidden)]
  32. pub mod internal {
  33. #[doc(hidden)]
  34. pub use crate::hotreload_utils::{
  35. DynamicLiteralPool, DynamicValuePool, FmtSegment, FmtedSegments, HotReloadAttributeValue,
  36. HotReloadDynamicAttribute, HotReloadDynamicNode, HotReloadLiteral,
  37. HotReloadTemplateWithLocation, HotReloadedTemplate, HotreloadedLiteral, NamedAttribute,
  38. TemplateGlobalKey,
  39. };
  40. #[doc(hidden)]
  41. pub use generational_box;
  42. }
  43. pub(crate) mod innerlude {
  44. pub(crate) use crate::any_props::*;
  45. pub use crate::arena::*;
  46. pub(crate) use crate::effect::*;
  47. pub use crate::error_boundary::*;
  48. pub use crate::events::*;
  49. pub use crate::fragment::*;
  50. pub use crate::generational_box::*;
  51. pub use crate::global_context::*;
  52. pub use crate::launch::*;
  53. pub use crate::mutations::*;
  54. pub use crate::nodes::*;
  55. pub use crate::properties::*;
  56. pub use crate::reactive_context::*;
  57. pub use crate::render_error::*;
  58. pub use crate::runtime::{Runtime, RuntimeGuard};
  59. pub use crate::scheduler::*;
  60. pub use crate::scopes::*;
  61. pub use crate::suspense::*;
  62. pub use crate::tasks::*;
  63. pub use crate::virtual_dom::*;
  64. /// An [`Element`] is a possibly-none [`VNode`] created by calling `render` on [`ScopeId`] or [`ScopeState`].
  65. ///
  66. /// An Errored [`Element`] will propagate the error to the nearest error boundary.
  67. pub type Element = std::result::Result<VNode, RenderError>;
  68. /// A [`Component`] is a function that takes [`Properties`] and returns an [`Element`].
  69. pub type Component<P = ()> = fn(P) -> Element;
  70. }
  71. pub use crate::innerlude::{
  72. fc_to_builder, generation, schedule_update, schedule_update_any, use_hook, vdom_is_rendering,
  73. AnyValue, Attribute, AttributeValue, CapturedError, Component, ComponentFunction, DynamicNode,
  74. Element, ElementId, Event, Fragment, HasAttributes, IntoDynNode, LaunchConfig, MarkerWrapper,
  75. Mutation, Mutations, NoOpMutations, Ok, Properties, Result, Runtime, ScopeId, ScopeState,
  76. SpawnIfAsync, Task, Template, TemplateAttribute, TemplateNode, VComponent, VNode, VNodeInner,
  77. VPlaceholder, VText, VirtualDom, WriteMutations,
  78. };
  79. /// The purpose of this module is to alleviate imports of many common types
  80. ///
  81. /// This includes types like [`Element`], and [`Component`].
  82. pub mod prelude {
  83. pub use crate::innerlude::{
  84. consume_context, consume_context_from_scope, current_owner, current_scope_id,
  85. fc_to_builder, force_all_dirty, generation, has_context, needs_update, needs_update_any,
  86. parent_scope, provide_context, provide_error_boundary, provide_root_context, queue_effect,
  87. remove_future, spawn, spawn_forever, spawn_isomorphic, suspend, suspense_context,
  88. throw_error, try_consume_context, use_after_render, use_before_render, use_drop, use_hook,
  89. use_hook_with_cleanup, with_owner, AnyValue, Attribute, Callback, Component,
  90. ComponentFunction, Context, Element, ErrorBoundary, ErrorContext, Event, EventHandler,
  91. Fragment, HasAttributes, IntoAttributeValue, IntoDynNode, OptionStringFromMarker,
  92. Properties, ReactiveContext, RenderError, Runtime, RuntimeGuard, ScopeId, ScopeState,
  93. SuperFrom, SuperInto, SuspendedFuture, SuspenseBoundary, SuspenseBoundaryProps,
  94. SuspenseContext, SuspenseExtension, Task, Template, TemplateAttribute, TemplateNode, VNode,
  95. VNodeInner, VirtualDom,
  96. };
  97. }
  98. pub use const_format;