From 3fbe9c66d2b6dbd2786e352748e5426e0fb34589 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Thu, 22 Aug 2024 13:37:32 +0100 Subject: [PATCH] added features for every function. fixes #152 --- Cargo.toml | 399 +++++++++++++----- examples/on_click_outside/Cargo.toml | 2 +- examples/signal_debounced/Cargo.toml | 2 +- examples/signal_throttled/Cargo.toml | 2 +- examples/ssr/Cargo.toml | 15 +- examples/sync_signal/Cargo.toml | 2 +- examples/use_active_element/Cargo.toml | 2 +- examples/use_breakpoints/Cargo.toml | 2 +- examples/use_broadcast_channel/Cargo.toml | 2 +- examples/use_clipboard/Cargo.toml | 2 +- examples/use_color_mode/Cargo.toml | 2 +- examples/use_cookie/Cargo.toml | 2 +- examples/use_css_var/Cargo.toml | 2 +- examples/use_cycle_list/Cargo.toml | 2 +- examples/use_debounce_fn/Cargo.toml | 2 +- examples/use_device_orientation/Cargo.toml | 2 +- examples/use_device_pixel_ratio/Cargo.toml | 2 +- examples/use_display_media/Cargo.toml | 2 +- examples/use_document_visibility/Cargo.toml | 2 +- examples/use_draggable/Cargo.toml | 2 +- examples/use_drop_zone/Cargo.toml | 2 +- examples/use_element_bounding/Cargo.toml | 2 +- examples/use_element_hover/Cargo.toml | 2 +- examples/use_element_size/Cargo.toml | 2 +- examples/use_element_visibility/Cargo.toml | 2 +- examples/use_event_listener/Cargo.toml | 2 +- examples/use_favicon/Cargo.toml | 2 +- examples/use_geolocation/Cargo.toml | 2 +- examples/use_idle/Cargo.toml | 2 +- examples/use_infinite_scroll/Cargo.toml | 2 +- examples/use_intersection_observer/Cargo.toml | 2 +- examples/use_interval/Cargo.toml | 2 +- examples/use_interval_fn/Cargo.toml | 2 +- examples/use_intl_number_format/Cargo.toml | 2 +- examples/use_locale/Cargo.toml | 2 +- examples/use_locales/Cargo.toml | 2 +- examples/use_media_query/Cargo.toml | 2 +- examples/use_mouse/Cargo.toml | 2 +- examples/use_mouse_in_element/Cargo.toml | 2 +- examples/use_mutation_observer/Cargo.toml | 2 +- examples/use_permission/Cargo.toml | 2 +- .../use_prefers_reduced_motion/Cargo.toml | 2 +- examples/use_raf_fn/Cargo.toml | 2 +- examples/use_resize_observer/Cargo.toml | 2 +- examples/use_scroll/Cargo.toml | 2 +- examples/use_service_worker/Cargo.toml | 2 +- examples/use_sorted/Cargo.toml | 2 +- examples/use_storage/Cargo.toml | 2 +- examples/use_throttle_fn/Cargo.toml | 2 +- examples/use_timeout_fn/Cargo.toml | 2 +- examples/use_timestamp/Cargo.toml | 2 +- examples/use_user_media/Cargo.toml | 2 +- examples/use_web_notification/Cargo.toml | 2 +- examples/use_websocket/Cargo.toml | 2 +- examples/use_webtransport/Cargo.toml | 2 +- examples/use_window_focus/Cargo.toml | 2 +- examples/use_window_scroll/Cargo.toml | 2 +- examples/watch_debounced/Cargo.toml | 2 +- examples/watch_pausable/Cargo.toml | 2 +- examples/watch_throttled/Cargo.toml | 2 +- src/core/mod.rs | 10 +- src/core/reconnect_limit.rs | 20 + src/core/ssr_safe_method.rs | 2 + src/core/storage.rs | 21 - src/lib.rs | 141 +++++++ src/storage/mod.rs | 23 +- src/storage/use_storage.rs | 5 +- src/use_color_mode.rs | 3 +- src/use_websocket.rs | 22 +- src/utils/header_macro.rs | 2 + src/utils/js_value_from_to_string.rs | 2 + src/utils/mod.rs | 5 + src/utils/signal_filtered.rs | 2 + src/watch_debounced.rs | 2 +- src/watch_throttled.rs | 2 +- 75 files changed, 580 insertions(+), 212 deletions(-) create mode 100644 src/core/reconnect_limit.rs delete mode 100644 src/core/storage.rs diff --git a/Cargo.toml b/Cargo.toml index 9ec4f61..de5940a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,14 +14,14 @@ homepage = "https://leptos-use.rs" [dependencies] actix-web = { version = "4", optional = true, default-features = false } -async-trait = "0.1" +async-trait = { version = "0.1", optional = true } cfg-if = "1" -codee = "0.1" -cookie = { version = "0.18", features = ["percent-encode"] } +codee = { version = "0.1", optional = true } +cookie = { version = "0.18", features = ["percent-encode"], optional = true } default-struct-builder = "0.5" -futures-util = "0.3" -gloo-timers = { version = "0.3.0", features = ["futures"] } -gloo-utils = { version = "0.2.0" } +futures-util = { version = "0.3", optional = true } +gloo-timers = { version = "0.3.0", optional = true, features = ["futures"] } +gloo-utils = { version = "0.2.0", optional = true } http1 = { version = "1", optional = true, package = "http" } http0_2 = { version = "0.2", optional = true, package = "http" } js-sys = "0.3" @@ -33,101 +33,10 @@ leptos-spin = { version = "0.1", optional = true } num = { version = "0.4", optional = true } paste = "1" thiserror = "1" -unic-langid = "0.9" +unic-langid = { version = "0.9", optional = true } wasm-bindgen = "=0.2.93" wasm-bindgen-futures = "0.4" - -[dependencies.web-sys] -version = "=0.3.70" -features = [ - "AddEventListenerOptions", - "BinaryType", - "BroadcastChannel", - "Coordinates", - "Clipboard", - "CloseEvent", - "CssStyleDeclaration", - "CustomEvent", - "CustomEventInit", - "DisplayMediaStreamConstraints", - "DomRect", - "DomRectReadOnly", - "DataTransfer", - "DragEvent", - "Element", - "EventListener", - "EventListenerOptions", - "EventSource", - "EventSourceInit", - "EventTarget", - "File", - "FileList", - "Geolocation", - "HtmlDocument", - "HtmlElement", - "HtmlLinkElement", - "HtmlStyleElement", - "IntersectionObserver", - "IntersectionObserverInit", - "IntersectionObserverEntry", - "Location", - "MediaDevices", - "MediaQueryList", - "MediaStream", - "MediaStreamConstraints", - "MediaStreamTrack", - "MessageEvent", - "MouseEvent", - "MutationObserver", - "MutationObserverInit", - "MutationRecord", - "Navigator", - "NodeList", - "Notification", - "NotificationDirection", - "NotificationOptions", - "NotificationPermission", - "Permissions", - "PermissionState", - "PermissionStatus", - "PointerEvent", - "Position", - "PositionError", - "PositionOptions", - "ReadableStream", - "ReadableStreamDefaultReader", - "ReadableStreamGetReaderOptions", - "ReadableStreamReaderMode", - "ResizeObserver", - "ResizeObserverBoxOptions", - "ResizeObserverEntry", - "ResizeObserverOptions", - "ResizeObserverSize", - "ScrollBehavior", - "ScrollToOptions", - "ServiceWorker", - "ServiceWorkerContainer", - "ServiceWorkerRegistration", - "ServiceWorkerState", - "Storage", - "StorageEvent", - "Touch", - "TouchEvent", - "TouchList", - "Url", - "UrlSearchParams", - "VisibilityState", - "WebSocket", - "WebTransport", - "WebTransportOptions", - "WebTransportDatagramDuplexStream", - "WebTransportBidirectionalStream", - "Window", - "WebTransportReceiveStream", - "WebTransportSendStream", - "WritableStream", - "WritableStreamDefaultWriter", -] +web-sys = { version = "=0.3.70", optional = true } [dev-dependencies] codee = { version = "0.1", features = ["json_serde", "msgpack_serde", "base64", "prost"] } @@ -138,13 +47,303 @@ serde = { version = "1", features = ["derive"] } unic-langid = { version = "0.9", features = ["macros"] } [features] +default = [ + "is_err", + "is_none", + "is_ok", + "is_some", + "on_click_outside", + "signal_debounced", + "signal_throttled", + "storage", + "sync_signal", + "use_active_element", + "use_breakpoints", + "use_broadcast_channel", + "use_clipboard", + "use_color_mode", + "use_cookie", + "use_css_var", + "use_cycle_list", + "use_debounce_fn", + "use_device_orientation", + "use_device_pixel_ratio", + "use_display_media", + "use_document", + "use_document_visibility", + "use_draggable", + "use_drop_zone", + "use_element_bounding", + "use_element_hover", + "use_element_size", + "use_element_visibility", + "use_event_listener", + "use_event_source", + "use_favicon", + "use_geolocation", + "use_idle", + "use_infinite_scroll", + "use_intersection_observer", + "use_interval", + "use_interval_fn", + "use_intl_number_format", + "use_locale", + "use_locales", + "use_media_query", + "use_mouse", + "use_mouse_in_element", + "use_mutation_observer", + "use_permission", + "use_preferred_contrast", + "use_preferred_dark", + "use_prefers_reduced_motion", + "use_raf_fn", + "use_resize_observer", + "use_scroll", + "use_service_worker", + "use_sorted", + "use_supported", + "use_throttle_fn", + "use_timeout_fn", + "use_timestamp", + "use_to_string", + "use_user_media", + "use_web_notification", + "use_websocket", + "use_window", + "use_window_focus", + "use_window_scroll", + "watch_debounced", + "watch_pausable", + "watch_throttled", + "watch_with_options", + "whenever" +] actix = ["dep:actix-web", "dep:leptos_actix", "dep:http0_2"] axum = ["dep:leptos_axum", "dep:http1"] -docs = [] +docs = ["dep:web-sys"] +element = ["use_document", "use_window", "dep:web-sys", "web-sys/EventTarget"] +is = ["use_window"] +is_err = [] +is_none = [] +is_ok = [] +is_some = [] math = ["num"] +on_click_outside = ["use_event_listener", "is"] +signal_debounced = ["use_debounce_fn"] +signal_throttled = ["use_throttle_fn"] spin = ["dep:leptos-spin", "dep:http1"] ssr = [] +storage = [ + "use_event_listener", + "use_window", + "watch_with_options", + "dep:web-sys", + "dep:codee", + "web-sys/CustomEventInit", + "web-sys/Storage" +] +sync_signal = [] +use_active_element = ["use_event_listener"] +use_breakpoints = ["use_media_query"] +use_broadcast_channel = [ + "use_event_listener", + "use_supported", + "dep:codee", + "web-sys/BroadcastChannel", +] +use_clipboard = [ + "use_event_listener", + "use_permission", + "use_supported", + "use_timeout_fn", + "web-sys/Clipboard", +] +use_color_mode = [ + "use_cookie", + "use_cycle_list", + "use_preferred_dark", + "storage", + "sync_signal" +] +use_cookie = [ + "use_broadcast_channel", + "watch_pausable", + "dep:cookie", + "web-sys/HtmlDocument", +] +use_css_var = [ + "use_mutation_observer", + "watch_with_options", +] +use_cycle_list = [] +use_debounce_fn = [] +use_device_orientation = ["use_event_listener", "use_supported"] +use_device_pixel_ratio = ["use_event_listener", "web-sys/MediaQueryList"] +use_display_media = [ + "use_window", + "web-sys/DisplayMediaStreamConstraints", + "web-sys/MediaDevices", + "web-sys/MediaStream", + "web-sys/MediaStreamTrack", +] +use_document = [ + "dep:web-sys", + "web-sys/VisibilityState", +] +use_document_visibility = ["use_event_listener", "web-sys/VisibilityState"] +use_draggable = ["use_event_listener", "web-sys/DomRect"] +use_drop_zone = [ + "use_event_listener", + "web-sys/DataTransfer", + "web-sys/File", + "web-sys/FileList" +] +use_element_bounding = [ + "use_event_listener", + "use_resize_observer", + "web-sys/DomRect", +] +use_element_hover = ["use_event_listener"] +use_element_size = [ + "use_resize_observer", + "watch_with_options", + "web-sys/ResizeObserverSize", +] +use_element_visibility = [ + "use_intersection_observer", + "web-sys/DomRect", +] +use_event_listener = [ + "element", + "watch_with_options", + "dep:web-sys", + "web-sys/EventTarget", + "web-sys/EventListenerOptions" +] +use_event_source = [ + "use_event_listener", + "web-sys/EventSource", + "web-sys/EventSourceInit", + "dep:codee", +] +use_favicon = [] +use_geolocation = [ + "use_window", + "web-sys/Coordinates", + "web-sys/Geolocation", + "web-sys/Position", + "web-sys/PositionError", + "web-sys/PositionOptions", +] +use_idle = [ + "use_event_listener", + "use_document", + "use_timestamp", +] +use_infinite_scroll = [ + "use_element_visibility", + "use_scroll", + "dep:gloo-timers", + "dep:futures-util", +] +use_intersection_observer = [ + "element", + "watch_with_options", + "web-sys/IntersectionObserver", + "web-sys/IntersectionObserverEntry", + "web-sys/IntersectionObserverInit", +] +use_interval = ["use_interval_fn"] +use_interval_fn = [] +use_intl_number_format = [] +use_locale = ["use_locales", "dep:unic-langid"] +use_locales = ["use_event_listener", "use_window"] +use_media_query = ["use_event_listener"] +use_mouse = [ + "element", + "use_event_listener", + "use_window", + "web-sys/Touch", + "web-sys/TouchList", +] +use_mouse_in_element = [ + "use_mouse", + "web-sys/DomRect", +] +use_mutation_observer = [ + "element", + "use_supported", + "web-sys/MutationObserver", + "web-sys/MutationObserverInit", + "web-sys/MutationRecord", +] +use_permission = [ + "use_event_listener", + "web-sys/Permissions", + "web-sys/PermissionState", + "web-sys/PermissionStatus", +] +use_preferred_contrast = ["use_media_query"] +use_preferred_dark = ["use_media_query"] +use_prefers_reduced_motion = ["use_media_query"] +use_raf_fn = [] +use_resize_observer = [ + "element", + "use_supported", + "web-sys/DomRectReadOnly", + "web-sys/ResizeObserver", + "web-sys/ResizeObserverBoxOptions", + "web-sys/ResizeObserverEntry", + "web-sys/ResizeObserverOptions", +] +use_scroll = [ + "element", + "use_event_listener", + "use_debounce_fn", + "use_throttle_fn", + "web-sys/ScrollBehavior", + "web-sys/ScrollToOptions", +] +use_service_worker = [ + "use_window", + "web-sys/ServiceWorker", + "web-sys/ServiceWorkerContainer", + "web-sys/ServiceWorkerRegistration" +] +use_sorted = [] +use_supported = [] +use_throttle_fn = [] +use_timeout_fn = [] +use_timestamp = ["use_interval_fn", "use_raf_fn"] +use_to_string = [] +use_user_media = [ + "use_window", + "web-sys/MediaDevices", + "web-sys/MediaStream", + "web-sys/MediaStreamConstraints", + "web-sys/MediaStreamTrack", +] +use_web_notification = [ + "use_supported", + "use_window", + "use_event_listener", + "web-sys/Notification", + "web-sys/NotificationOptions", + "web-sys/NotificationPermission", + "web-sys/NotificationDirection", + "web-sys/VisibilityState" +] +use_websocket = ["dep:codee"] +use_window = ["use_document", "dep:web-sys", "web-sys/Navigator", "web-sys/MediaQueryList"] +use_window_focus = ["use_event_listener"] +use_window_scroll = ["use_event_listener", "use_window"] wasm_ssr = [] +watch_debounced = ["watch_with_options"] +watch_pausable = ["watch_with_options"] +watch_throttled = ["watch_with_options"] +watch_with_options = [] +whenever = [] [package.metadata.docs.rs] features = ["math", "docs", "ssr"] diff --git a/examples/on_click_outside/Cargo.toml b/examples/on_click_outside/Cargo.toml index 3313bf8..c6d6279 100644 --- a/examples/on_click_outside/Cargo.toml +++ b/examples/on_click_outside/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["on_click_outside", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/signal_debounced/Cargo.toml b/examples/signal_debounced/Cargo.toml index 6f85a28..9411da3 100644 --- a/examples/signal_debounced/Cargo.toml +++ b/examples/signal_debounced/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["signal_debounced", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/signal_throttled/Cargo.toml b/examples/signal_throttled/Cargo.toml index 73b2b91..2a14d8a 100644 --- a/examples/signal_throttled/Cargo.toml +++ b/examples/signal_throttled/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["signal_throttled", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/ssr/Cargo.toml b/examples/ssr/Cargo.toml index 533ce90..33e9575 100644 --- a/examples/ssr/Cargo.toml +++ b/examples/ssr/Cargo.toml @@ -16,7 +16,6 @@ leptos = { version = "0.6", features = ["nightly"] } leptos_axum = { version = "0.6", optional = true } leptos_meta = { version = "0.6", features = ["nightly"] } leptos_router = { version = "0.6", features = ["nightly"] } -leptos-use = { path = "../.." } log = "0.4" simple_logger = "4" tokio = { version = "1", features = ["full"], optional = true } @@ -28,6 +27,20 @@ thiserror = "1.0.38" tracing = { version = "0.1.37", optional = true } http = "1" +[dependencies.leptos-use] +path = "../.." +features = [ + "use_cookie", + "use_color_mode", + "use_debounce_fn", + "use_event_listener", + "use_interval", + "use_intl_number_format", + "use_locales", + "use_timestamp", + "storage" +] + [features] hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"] ssr = [ diff --git a/examples/sync_signal/Cargo.toml b/examples/sync_signal/Cargo.toml index 0eae2b1..c072a2b 100644 --- a/examples/sync_signal/Cargo.toml +++ b/examples/sync_signal/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["sync_signal", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_active_element/Cargo.toml b/examples/use_active_element/Cargo.toml index c19c400..e5c31a5 100644 --- a/examples/use_active_element/Cargo.toml +++ b/examples/use_active_element/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_active_element", "docs"] } web-sys = { version = "0.3", features = ["HtmlElement", "DomStringMap"] } [dev-dependencies] diff --git a/examples/use_breakpoints/Cargo.toml b/examples/use_breakpoints/Cargo.toml index 22b894b..b022945 100644 --- a/examples/use_breakpoints/Cargo.toml +++ b/examples/use_breakpoints/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_breakpoints", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_broadcast_channel/Cargo.toml b/examples/use_broadcast_channel/Cargo.toml index a7bf756..3cfcd3f 100644 --- a/examples/use_broadcast_channel/Cargo.toml +++ b/examples/use_broadcast_channel/Cargo.toml @@ -9,7 +9,7 @@ codee = "0.1" console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_broadcast_channel", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_clipboard/Cargo.toml b/examples/use_clipboard/Cargo.toml index d85ad83..43cba10 100644 --- a/examples/use_clipboard/Cargo.toml +++ b/examples/use_clipboard/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_clipboard", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_color_mode/Cargo.toml b/examples/use_color_mode/Cargo.toml index ead2ef6..26874f0 100644 --- a/examples/use_color_mode/Cargo.toml +++ b/examples/use_color_mode/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_color_mode", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_cookie/Cargo.toml b/examples/use_cookie/Cargo.toml index c645550..2974155 100644 --- a/examples/use_cookie/Cargo.toml +++ b/examples/use_cookie/Cargo.toml @@ -9,7 +9,7 @@ codee = "0.1" console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_cookie", "docs"] } rand = "0.8" getrandom = { version = "0.2", features = ["js"] } web-sys = "0.3" diff --git a/examples/use_css_var/Cargo.toml b/examples/use_css_var/Cargo.toml index 267c40e..97d6fa6 100644 --- a/examples/use_css_var/Cargo.toml +++ b/examples/use_css_var/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_css_var", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_cycle_list/Cargo.toml b/examples/use_cycle_list/Cargo.toml index c59b61c..77f6c25 100644 --- a/examples/use_cycle_list/Cargo.toml +++ b/examples/use_cycle_list/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_cycle_list", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_debounce_fn/Cargo.toml b/examples/use_debounce_fn/Cargo.toml index d5f4621..c3f7b9e 100644 --- a/examples/use_debounce_fn/Cargo.toml +++ b/examples/use_debounce_fn/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_debounce_fn", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_device_orientation/Cargo.toml b/examples/use_device_orientation/Cargo.toml index 9a4c64a..5fec238 100644 --- a/examples/use_device_orientation/Cargo.toml +++ b/examples/use_device_orientation/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_device_orientation", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_device_pixel_ratio/Cargo.toml b/examples/use_device_pixel_ratio/Cargo.toml index 5874c65..98efdde 100644 --- a/examples/use_device_pixel_ratio/Cargo.toml +++ b/examples/use_device_pixel_ratio/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_device_pixel_ratio", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_display_media/Cargo.toml b/examples/use_display_media/Cargo.toml index c7ffe6a..f5f4b79 100644 --- a/examples/use_display_media/Cargo.toml +++ b/examples/use_display_media/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_display_media", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_document_visibility/Cargo.toml b/examples/use_document_visibility/Cargo.toml index cb9b8f1..8d5b019 100644 --- a/examples/use_document_visibility/Cargo.toml +++ b/examples/use_document_visibility/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_document_visibility", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_draggable/Cargo.toml b/examples/use_draggable/Cargo.toml index e2e9a61..8427afb 100644 --- a/examples/use_draggable/Cargo.toml +++ b/examples/use_draggable/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_draggable", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_drop_zone/Cargo.toml b/examples/use_drop_zone/Cargo.toml index 115dc9d..aa05fca 100644 --- a/examples/use_drop_zone/Cargo.toml +++ b/examples/use_drop_zone/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_drop_zone", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_element_bounding/Cargo.toml b/examples/use_element_bounding/Cargo.toml index 7620bcd..8ef72c3 100644 --- a/examples/use_element_bounding/Cargo.toml +++ b/examples/use_element_bounding/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_element_bounding", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_element_hover/Cargo.toml b/examples/use_element_hover/Cargo.toml index 9d90e62..9be576c 100644 --- a/examples/use_element_hover/Cargo.toml +++ b/examples/use_element_hover/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_element_hover", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_element_size/Cargo.toml b/examples/use_element_size/Cargo.toml index daf02f0..4e71f62 100644 --- a/examples/use_element_size/Cargo.toml +++ b/examples/use_element_size/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_element_size", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_element_visibility/Cargo.toml b/examples/use_element_visibility/Cargo.toml index 50ba543..3506775 100644 --- a/examples/use_element_visibility/Cargo.toml +++ b/examples/use_element_visibility/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_element_visibility", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_event_listener/Cargo.toml b/examples/use_event_listener/Cargo.toml index 653bb76..d0e75c1 100644 --- a/examples/use_event_listener/Cargo.toml +++ b/examples/use_event_listener/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../.." } +leptos-use = { path = "../..", features = ["use_event_listener"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_favicon/Cargo.toml b/examples/use_favicon/Cargo.toml index 260413a..38d4f05 100644 --- a/examples/use_favicon/Cargo.toml +++ b/examples/use_favicon/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_favicon", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_geolocation/Cargo.toml b/examples/use_geolocation/Cargo.toml index bb7c93e..4ded1d2 100644 --- a/examples/use_geolocation/Cargo.toml +++ b/examples/use_geolocation/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_geolocation", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_idle/Cargo.toml b/examples/use_idle/Cargo.toml index 1b412b4..0e8d92a 100644 --- a/examples/use_idle/Cargo.toml +++ b/examples/use_idle/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_idle", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_infinite_scroll/Cargo.toml b/examples/use_infinite_scroll/Cargo.toml index e55811a..52cafcb 100644 --- a/examples/use_infinite_scroll/Cargo.toml +++ b/examples/use_infinite_scroll/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_infinite_scroll", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_intersection_observer/Cargo.toml b/examples/use_intersection_observer/Cargo.toml index b401615..b8c5d1a 100644 --- a/examples/use_intersection_observer/Cargo.toml +++ b/examples/use_intersection_observer/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_intersection_observer", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_interval/Cargo.toml b/examples/use_interval/Cargo.toml index a49f0cd..cd02ec5 100644 --- a/examples/use_interval/Cargo.toml +++ b/examples/use_interval/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_interval", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_interval_fn/Cargo.toml b/examples/use_interval_fn/Cargo.toml index 86bc8b2..96de322 100644 --- a/examples/use_interval_fn/Cargo.toml +++ b/examples/use_interval_fn/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs", "math"] } +leptos-use = { path = "../..", features = ["use_interval_fn", "docs", "math"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_intl_number_format/Cargo.toml b/examples/use_intl_number_format/Cargo.toml index 7eadd70..5ed97da 100644 --- a/examples/use_intl_number_format/Cargo.toml +++ b/examples/use_intl_number_format/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_intl_number_format", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_locale/Cargo.toml b/examples/use_locale/Cargo.toml index 1a2555a..1c592fe 100644 --- a/examples/use_locale/Cargo.toml +++ b/examples/use_locale/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_locale", "docs"] } unic-langid = { version = "0.9", features = ["macros"] } web-sys = "0.3" diff --git a/examples/use_locales/Cargo.toml b/examples/use_locales/Cargo.toml index 05b5bc9..c98524c 100644 --- a/examples/use_locales/Cargo.toml +++ b/examples/use_locales/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_locales", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_media_query/Cargo.toml b/examples/use_media_query/Cargo.toml index 345aa87..a57d7fe 100644 --- a/examples/use_media_query/Cargo.toml +++ b/examples/use_media_query/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_media_query", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_mouse/Cargo.toml b/examples/use_mouse/Cargo.toml index 1c91a04..cb2dea3 100644 --- a/examples/use_mouse/Cargo.toml +++ b/examples/use_mouse/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_mouse", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_mouse_in_element/Cargo.toml b/examples/use_mouse_in_element/Cargo.toml index ac23964..2823591 100644 --- a/examples/use_mouse_in_element/Cargo.toml +++ b/examples/use_mouse_in_element/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_mouse_in_element", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_mutation_observer/Cargo.toml b/examples/use_mutation_observer/Cargo.toml index fcf12fd..c85533a 100644 --- a/examples/use_mutation_observer/Cargo.toml +++ b/examples/use_mutation_observer/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_mutation_observer", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_permission/Cargo.toml b/examples/use_permission/Cargo.toml index 17f2388..f03e633 100644 --- a/examples/use_permission/Cargo.toml +++ b/examples/use_permission/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_permission", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_prefers_reduced_motion/Cargo.toml b/examples/use_prefers_reduced_motion/Cargo.toml index 4b0d55a..3cdeb8d 100644 --- a/examples/use_prefers_reduced_motion/Cargo.toml +++ b/examples/use_prefers_reduced_motion/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_prefers_reduced_motion", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_raf_fn/Cargo.toml b/examples/use_raf_fn/Cargo.toml index 48b8cd9..e9c4c57 100644 --- a/examples/use_raf_fn/Cargo.toml +++ b/examples/use_raf_fn/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_raf_fn", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_resize_observer/Cargo.toml b/examples/use_resize_observer/Cargo.toml index 0ce7f4c..8ba4ed2 100644 --- a/examples/use_resize_observer/Cargo.toml +++ b/examples/use_resize_observer/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_resize_observer", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_scroll/Cargo.toml b/examples/use_scroll/Cargo.toml index ccb133a..25874cd 100644 --- a/examples/use_scroll/Cargo.toml +++ b/examples/use_scroll/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_scroll", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_service_worker/Cargo.toml b/examples/use_service_worker/Cargo.toml index 8e3b8c7..f074dd0 100644 --- a/examples/use_service_worker/Cargo.toml +++ b/examples/use_service_worker/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_service_worker", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_sorted/Cargo.toml b/examples/use_sorted/Cargo.toml index 05462ac..8ff335f 100644 --- a/examples/use_sorted/Cargo.toml +++ b/examples/use_sorted/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_sorted", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_storage/Cargo.toml b/examples/use_storage/Cargo.toml index 5174789..b8b2285 100644 --- a/examples/use_storage/Cargo.toml +++ b/examples/use_storage/Cargo.toml @@ -8,7 +8,7 @@ codee = { version = "0.1", features = ["json_serde"] } console_error_panic_hook = "0.1" console_log = "1" leptos = { version = "0.6", features = ["nightly", "csr"] } -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["storage", "docs"] } log = "0.4" serde = "1.0.163" web-sys = "0.3" diff --git a/examples/use_throttle_fn/Cargo.toml b/examples/use_throttle_fn/Cargo.toml index 04d6006..d39fc8d 100644 --- a/examples/use_throttle_fn/Cargo.toml +++ b/examples/use_throttle_fn/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_throttle_fn", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_timeout_fn/Cargo.toml b/examples/use_timeout_fn/Cargo.toml index 9b0cfa4..608afac 100644 --- a/examples/use_timeout_fn/Cargo.toml +++ b/examples/use_timeout_fn/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_timeout_fn", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_timestamp/Cargo.toml b/examples/use_timestamp/Cargo.toml index a065eb4..5e0a16f 100644 --- a/examples/use_timestamp/Cargo.toml +++ b/examples/use_timestamp/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_timestamp", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_user_media/Cargo.toml b/examples/use_user_media/Cargo.toml index ffd38b8..170c4af 100644 --- a/examples/use_user_media/Cargo.toml +++ b/examples/use_user_media/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_user_media", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_web_notification/Cargo.toml b/examples/use_web_notification/Cargo.toml index 216f31e..f499927 100644 --- a/examples/use_web_notification/Cargo.toml +++ b/examples/use_web_notification/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_web_notification", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_websocket/Cargo.toml b/examples/use_websocket/Cargo.toml index 2eb5095..26ed9a6 100644 --- a/examples/use_websocket/Cargo.toml +++ b/examples/use_websocket/Cargo.toml @@ -9,7 +9,7 @@ codee = { version = "0.1", features = ["msgpack_serde"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_websocket", "docs"] } serde = { version = "1", features = ["derive"] } web-sys = "0.3" diff --git a/examples/use_webtransport/Cargo.toml b/examples/use_webtransport/Cargo.toml index 5291647..680dc93 100644 --- a/examples/use_webtransport/Cargo.toml +++ b/examples/use_webtransport/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_web_notification", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_window_focus/Cargo.toml b/examples/use_window_focus/Cargo.toml index d157e75..ff9224a 100644 --- a/examples/use_window_focus/Cargo.toml +++ b/examples/use_window_focus/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_window_focus", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/use_window_scroll/Cargo.toml b/examples/use_window_scroll/Cargo.toml index d8a1c48..43092e2 100644 --- a/examples/use_window_scroll/Cargo.toml +++ b/examples/use_window_scroll/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["use_window_scroll", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/watch_debounced/Cargo.toml b/examples/watch_debounced/Cargo.toml index 8af3c77..b7d1872 100644 --- a/examples/watch_debounced/Cargo.toml +++ b/examples/watch_debounced/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["watch_debounced", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/watch_pausable/Cargo.toml b/examples/watch_pausable/Cargo.toml index a14897d..548f01a 100644 --- a/examples/watch_pausable/Cargo.toml +++ b/examples/watch_pausable/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["watch_pausable", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/examples/watch_throttled/Cargo.toml b/examples/watch_throttled/Cargo.toml index e711c4f..d69a67a 100644 --- a/examples/watch_throttled/Cargo.toml +++ b/examples/watch_throttled/Cargo.toml @@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = { path = "../..", features = ["docs"] } +leptos-use = { path = "../..", features = ["watch_throttled", "docs"] } web-sys = "0.3" [dev-dependencies] diff --git a/src/core/mod.rs b/src/core/mod.rs index 3fe5ca3..0b51baa 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -1,26 +1,32 @@ mod connection_ready_state; mod datetime; mod direction; +#[cfg(feature = "element")] mod element_maybe_signal; +#[cfg(feature = "element")] mod elements_maybe_signal; mod maybe_rw_signal; mod pointer_type; mod position; +mod reconnect_limit; mod size; mod ssr_safe_method; -mod storage; +#[cfg(feature = "use_color_mode")] pub(crate) mod url; mod use_rw_signal; pub use connection_ready_state::*; pub(crate) use datetime::*; pub use direction::*; +#[cfg(feature = "element")] pub use element_maybe_signal::*; +#[cfg(feature = "element")] pub use elements_maybe_signal::*; pub use maybe_rw_signal::*; pub use pointer_type::*; pub use position::*; +pub use reconnect_limit::*; pub use size::*; +#[allow(unused_imports)] pub(crate) use ssr_safe_method::*; -pub use storage::*; pub use use_rw_signal::*; diff --git a/src/core/reconnect_limit.rs b/src/core/reconnect_limit.rs new file mode 100644 index 0000000..5d28b2c --- /dev/null +++ b/src/core/reconnect_limit.rs @@ -0,0 +1,20 @@ +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub enum ReconnectLimit { + Infinite, + Limited(u64), +} + +impl Default for ReconnectLimit { + fn default() -> Self { + ReconnectLimit::Limited(3) + } +} + +impl ReconnectLimit { + pub fn is_exceeded_by(self, times: u64) -> bool { + match self { + ReconnectLimit::Infinite => false, + ReconnectLimit::Limited(limit) => times >= limit, + } + } +} diff --git a/src/core/ssr_safe_method.rs b/src/core/ssr_safe_method.rs index 9ffa513..da46452 100644 --- a/src/core/ssr_safe_method.rs +++ b/src/core/ssr_safe_method.rs @@ -1,3 +1,5 @@ +#![allow(unused_macros, unused_imports)] + macro_rules! impl_ssr_safe_method { ( $(#[$attr:meta])* diff --git a/src/core/storage.rs b/src/core/storage.rs deleted file mode 100644 index 8390217..0000000 --- a/src/core/storage.rs +++ /dev/null @@ -1,21 +0,0 @@ -use leptos::window; -use wasm_bindgen::JsValue; - -/// Local or session storage or a custom store that is a `web_sys::Storage`. -#[derive(Default)] -pub enum StorageType { - #[default] - Local, - Session, - Custom(web_sys::Storage), -} - -impl StorageType { - pub fn into_storage(self) -> Result, JsValue> { - match self { - StorageType::Local => window().local_storage(), - StorageType::Session => window().session_storage(), - StorageType::Custom(storage) => Ok(Some(storage)), - } - } -} diff --git a/src/lib.rs b/src/lib.rs index 0e43a6b..1b18ab1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,150 +7,291 @@ pub mod core; pub mod docs; #[cfg(feature = "math")] pub mod math; +#[cfg(feature = "storage")] pub mod storage; pub mod utils; +pub use core::ReconnectLimit; + // #[cfg(web_sys_unstable_apis)] // mod use_webtransport; // #[cfg(web_sys_unstable_apis)] // pub use use_webtransport::*; +#[cfg(feature = "is_err")] mod is_err; +#[cfg(feature = "is_none")] mod is_none; +#[cfg(feature = "is_ok")] mod is_ok; +#[cfg(feature = "is_some")] mod is_some; +#[cfg(feature = "on_click_outside")] mod on_click_outside; +#[cfg(feature = "signal_debounced")] mod signal_debounced; +#[cfg(feature = "signal_throttled")] mod signal_throttled; +#[cfg(feature = "sync_signal")] mod sync_signal; +#[cfg(feature = "use_active_element")] mod use_active_element; +#[cfg(feature = "use_breakpoints")] mod use_breakpoints; +#[cfg(feature = "use_broadcast_channel")] mod use_broadcast_channel; +#[cfg(feature = "use_clipboard")] mod use_clipboard; +#[cfg(feature = "use_color_mode")] mod use_color_mode; +#[cfg(feature = "use_cookie")] mod use_cookie; +#[cfg(feature = "use_css_var")] mod use_css_var; +#[cfg(feature = "use_cycle_list")] mod use_cycle_list; +#[cfg(feature = "use_debounce_fn")] mod use_debounce_fn; +#[cfg(feature = "use_device_orientation")] mod use_device_orientation; +#[cfg(feature = "use_device_pixel_ratio")] mod use_device_pixel_ratio; +#[cfg(feature = "use_display_media")] mod use_display_media; +#[cfg(feature = "use_document")] mod use_document; +#[cfg(feature = "use_document_visibility")] mod use_document_visibility; +#[cfg(feature = "use_draggable")] mod use_draggable; +#[cfg(feature = "use_drop_zone")] mod use_drop_zone; +#[cfg(feature = "use_element_bounding")] mod use_element_bounding; +#[cfg(feature = "use_element_hover")] mod use_element_hover; +#[cfg(feature = "use_element_size")] mod use_element_size; +#[cfg(feature = "use_element_visibility")] mod use_element_visibility; +#[cfg(feature = "use_event_listener")] mod use_event_listener; +#[cfg(feature = "use_event_source")] mod use_event_source; +#[cfg(feature = "use_favicon")] mod use_favicon; +#[cfg(feature = "use_geolocation")] mod use_geolocation; +#[cfg(feature = "use_idle")] mod use_idle; +#[cfg(feature = "use_infinite_scroll")] mod use_infinite_scroll; +#[cfg(feature = "use_intersection_observer")] mod use_intersection_observer; +#[cfg(feature = "use_interval")] mod use_interval; +#[cfg(feature = "use_interval_fn")] mod use_interval_fn; +#[cfg(feature = "use_intl_number_format")] mod use_intl_number_format; +#[cfg(feature = "use_locale")] mod use_locale; +#[cfg(feature = "use_locales")] mod use_locales; +#[cfg(feature = "use_media_query")] mod use_media_query; +#[cfg(feature = "use_mouse")] mod use_mouse; +#[cfg(feature = "use_mouse_in_element")] mod use_mouse_in_element; +#[cfg(feature = "use_mutation_observer")] mod use_mutation_observer; +#[cfg(feature = "use_permission")] mod use_permission; +#[cfg(feature = "use_preferred_contrast")] mod use_preferred_contrast; +#[cfg(feature = "use_preferred_dark")] mod use_preferred_dark; +#[cfg(feature = "use_prefers_reduced_motion")] mod use_prefers_reduced_motion; +#[cfg(feature = "use_raf_fn")] mod use_raf_fn; +#[cfg(feature = "use_resize_observer")] mod use_resize_observer; +#[cfg(feature = "use_scroll")] mod use_scroll; +#[cfg(feature = "use_service_worker")] mod use_service_worker; +#[cfg(feature = "use_sorted")] mod use_sorted; +#[cfg(feature = "use_supported")] mod use_supported; +#[cfg(feature = "use_throttle_fn")] mod use_throttle_fn; +#[cfg(feature = "use_timeout_fn")] mod use_timeout_fn; +#[cfg(feature = "use_timestamp")] mod use_timestamp; +#[cfg(feature = "use_to_string")] mod use_to_string; +#[cfg(feature = "use_user_media")] mod use_user_media; +#[cfg(feature = "use_web_notification")] mod use_web_notification; +#[cfg(feature = "use_websocket")] mod use_websocket; +#[cfg(feature = "use_window")] mod use_window; +#[cfg(feature = "use_window_focus")] mod use_window_focus; +#[cfg(feature = "use_window_scroll")] mod use_window_scroll; +#[cfg(feature = "watch_debounced")] mod watch_debounced; +#[cfg(feature = "watch_pausable")] mod watch_pausable; +#[cfg(feature = "watch_throttled")] mod watch_throttled; +#[cfg(feature = "watch_with_options")] mod watch_with_options; +#[cfg(feature = "whenever")] mod whenever; +#[cfg(feature = "is_err")] pub use is_err::*; +#[cfg(feature = "is_none")] pub use is_none::*; +#[cfg(feature = "is_ok")] pub use is_ok::*; +#[cfg(feature = "is_some")] pub use is_some::*; +#[cfg(feature = "on_click_outside")] pub use on_click_outside::*; +#[cfg(feature = "signal_debounced")] pub use signal_debounced::*; +#[cfg(feature = "signal_throttled")] pub use signal_throttled::*; +#[cfg(feature = "sync_signal")] pub use sync_signal::*; +#[cfg(feature = "use_active_element")] pub use use_active_element::*; +#[cfg(feature = "use_breakpoints")] pub use use_breakpoints::*; +#[cfg(feature = "use_broadcast_channel")] pub use use_broadcast_channel::*; +#[cfg(feature = "use_clipboard")] pub use use_clipboard::*; +#[cfg(feature = "use_color_mode")] pub use use_color_mode::*; +#[cfg(feature = "use_cookie")] pub use use_cookie::*; +#[cfg(feature = "use_css_var")] pub use use_css_var::*; +#[cfg(feature = "use_cycle_list")] pub use use_cycle_list::*; +#[cfg(feature = "use_debounce_fn")] pub use use_debounce_fn::*; +#[cfg(feature = "use_device_orientation")] pub use use_device_orientation::*; +#[cfg(feature = "use_device_pixel_ratio")] pub use use_device_pixel_ratio::*; +#[cfg(feature = "use_display_media")] pub use use_display_media::*; +#[cfg(feature = "use_document")] pub use use_document::*; +#[cfg(feature = "use_document_visibility")] pub use use_document_visibility::*; +#[cfg(feature = "use_draggable")] pub use use_draggable::*; +#[cfg(feature = "use_drop_zone")] pub use use_drop_zone::*; +#[cfg(feature = "use_element_bounding")] pub use use_element_bounding::*; +#[cfg(feature = "use_element_hover")] pub use use_element_hover::*; +#[cfg(feature = "use_element_size")] pub use use_element_size::*; +#[cfg(feature = "use_element_visibility")] pub use use_element_visibility::*; +#[cfg(feature = "use_event_listener")] pub use use_event_listener::*; +#[cfg(feature = "use_event_source")] pub use use_event_source::*; +#[cfg(feature = "use_favicon")] pub use use_favicon::*; +#[cfg(feature = "use_geolocation")] pub use use_geolocation::*; +#[cfg(feature = "use_idle")] pub use use_idle::*; +#[cfg(feature = "use_infinite_scroll")] pub use use_infinite_scroll::*; +#[cfg(feature = "use_intersection_observer")] pub use use_intersection_observer::*; +#[cfg(feature = "use_interval")] pub use use_interval::*; +#[cfg(feature = "use_interval_fn")] pub use use_interval_fn::*; +#[cfg(feature = "use_intl_number_format")] pub use use_intl_number_format::*; +#[cfg(feature = "use_locale")] pub use use_locale::*; +#[cfg(feature = "use_locales")] pub use use_locales::*; +#[cfg(feature = "use_media_query")] pub use use_media_query::*; +#[cfg(feature = "use_mouse")] pub use use_mouse::*; +#[cfg(feature = "use_mouse_in_element")] pub use use_mouse_in_element::*; +#[cfg(feature = "use_mutation_observer")] pub use use_mutation_observer::*; +#[cfg(feature = "use_permission")] pub use use_permission::*; +#[cfg(feature = "use_preferred_contrast")] pub use use_preferred_contrast::*; +#[cfg(feature = "use_preferred_dark")] pub use use_preferred_dark::*; +#[cfg(feature = "use_prefers_reduced_motion")] pub use use_prefers_reduced_motion::*; +#[cfg(feature = "use_raf_fn")] pub use use_raf_fn::*; +#[cfg(feature = "use_resize_observer")] pub use use_resize_observer::*; +#[cfg(feature = "use_scroll")] pub use use_scroll::*; +#[cfg(feature = "use_service_worker")] pub use use_service_worker::*; +#[cfg(feature = "use_sorted")] pub use use_sorted::*; +#[cfg(feature = "use_supported")] pub use use_supported::*; +#[cfg(feature = "use_throttle_fn")] pub use use_throttle_fn::*; +#[cfg(feature = "use_timeout_fn")] pub use use_timeout_fn::*; +#[cfg(feature = "use_timestamp")] pub use use_timestamp::*; +#[cfg(feature = "use_to_string")] pub use use_to_string::*; +#[cfg(feature = "use_user_media")] pub use use_user_media::*; +#[cfg(feature = "use_web_notification")] pub use use_web_notification::*; +#[cfg(feature = "use_websocket")] pub use use_websocket::*; +#[cfg(feature = "use_window")] pub use use_window::*; +#[cfg(feature = "use_window_focus")] pub use use_window_focus::*; +#[cfg(feature = "use_window_scroll")] pub use use_window_scroll::*; +#[cfg(feature = "watch_debounced")] pub use watch_debounced::*; +#[cfg(feature = "watch_pausable")] pub use watch_pausable::*; +#[cfg(feature = "watch_throttled")] pub use watch_throttled::*; +#[cfg(feature = "watch_with_options")] pub use watch_with_options::*; +#[cfg(feature = "whenever")] pub use whenever::*; diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 54f79db..5930028 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -2,7 +2,28 @@ mod use_local_storage; mod use_session_storage; mod use_storage; -pub use crate::core::StorageType; pub use use_local_storage::*; pub use use_session_storage::*; pub use use_storage::*; + +use leptos::window; +use wasm_bindgen::JsValue; + +/// Local or session storage or a custom store that is a `web_sys::Storage`. +#[derive(Default)] +pub enum StorageType { + #[default] + Local, + Session, + Custom(web_sys::Storage), +} + +impl StorageType { + pub fn into_storage(self) -> Result, JsValue> { + match self { + StorageType::Local => window().local_storage(), + StorageType::Session => window().session_storage(), + StorageType::Custom(storage) => Ok(Some(storage)), + } + } +} diff --git a/src/storage/use_storage.rs b/src/storage/use_storage.rs index 91b56c0..86705e9 100644 --- a/src/storage/use_storage.rs +++ b/src/storage/use_storage.rs @@ -1,7 +1,4 @@ -use crate::{ - core::{MaybeRwSignal, StorageType}, - utils::FilterOptions, -}; +use crate::{core::MaybeRwSignal, storage::StorageType, utils::FilterOptions}; use codee::{CodecError, Decoder, Encoder}; use default_struct_builder::DefaultBuilder; use leptos::*; diff --git a/src/use_color_mode.rs b/src/use_color_mode.rs index 9f3719e..28ded80 100644 --- a/src/use_color_mode.rs +++ b/src/use_color_mode.rs @@ -1,7 +1,6 @@ use crate::core::url; -use crate::core::StorageType; use crate::core::{ElementMaybeSignal, MaybeRwSignal}; -use crate::storage::{use_storage_with_options, UseStorageOptions}; +use crate::storage::{use_storage_with_options, StorageType, UseStorageOptions}; use crate::utils::get_header; use crate::{ sync_signal_with_options, use_cookie, use_preferred_dark_with_options, SyncSignalOptions, diff --git a/src/use_websocket.rs b/src/use_websocket.rs index 48a9596..51910e7 100644 --- a/src/use_websocket.rs +++ b/src/use_websocket.rs @@ -7,7 +7,7 @@ use std::rc::Rc; use std::time::Duration; use thiserror::Error; -use crate::core::ConnectionReadyState; +use crate::{core::ConnectionReadyState, ReconnectLimit}; use codee::{ CodecError, Decoder, Encoder, HybridCoderError, HybridDecoder, HybridEncoder, IsBinary, }; @@ -608,26 +608,6 @@ where send, } } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub enum ReconnectLimit { - Infinite, - Limited(u64), -} - -impl Default for ReconnectLimit { - fn default() -> Self { - ReconnectLimit::Limited(3) - } -} - -impl ReconnectLimit { - pub fn is_exceeded_by(self, times: u64) -> bool { - match self { - ReconnectLimit::Infinite => false, - ReconnectLimit::Limited(limit) => times >= limit, - } - } -} type RcFnBytes = Rc; diff --git a/src/utils/header_macro.rs b/src/utils/header_macro.rs index 4f6f087..2664f78 100644 --- a/src/utils/header_macro.rs +++ b/src/utils/header_macro.rs @@ -1,3 +1,5 @@ +#![allow(unused_macros, unused_imports)] + macro_rules! get_header { ( $header_name:expr, diff --git a/src/utils/js_value_from_to_string.rs b/src/utils/js_value_from_to_string.rs index f371c96..4149c4c 100644 --- a/src/utils/js_value_from_to_string.rs +++ b/src/utils/js_value_from_to_string.rs @@ -1,3 +1,5 @@ +#![allow(unused_macros, unused_imports)] + macro_rules! js_value_from_to_string { ($name:ident) => { impl From<$name> for JsValue { diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 32d43b0..76b179a 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -5,6 +5,7 @@ mod filters; ))] mod header; mod header_macro; +#[cfg(feature = "is")] mod is; mod js; mod js_value_from_to_string; @@ -18,8 +19,12 @@ pub use filters::*; any(feature = "axum", feature = "actix", feature = "spin") ))] pub use header::*; +#[allow(unused_imports)] pub(crate) use header_macro::*; +#[cfg(feature = "is")] pub use is::*; +#[allow(unused_imports)] pub(crate) use js_value_from_to_string::*; pub use pausable::*; +#[allow(unused_imports)] pub(crate) use signal_filtered::*; diff --git a/src/utils/signal_filtered.rs b/src/utils/signal_filtered.rs index 1e7ad03..365c871 100644 --- a/src/utils/signal_filtered.rs +++ b/src/utils/signal_filtered.rs @@ -1,3 +1,5 @@ +#![allow(unused_macros, unused_imports)] + macro_rules! signal_filtered { ( $(#[$outer:meta])* diff --git a/src/watch_debounced.rs b/src/watch_debounced.rs index 2dbe3ef..c0b12a1 100644 --- a/src/watch_debounced.rs +++ b/src/watch_debounced.rs @@ -1,4 +1,4 @@ -use crate::{watch_with_options, DebounceOptions, WatchOptions}; +use crate::{watch_with_options, utils::DebounceOptions, WatchOptions}; use default_struct_builder::DefaultBuilder; use leptos::*; diff --git a/src/watch_throttled.rs b/src/watch_throttled.rs index 5fd585f..e70f5e0 100644 --- a/src/watch_throttled.rs +++ b/src/watch_throttled.rs @@ -1,4 +1,4 @@ -use crate::{watch_with_options, ThrottleOptions, WatchOptions}; +use crate::{watch_with_options, utils::ThrottleOptions, WatchOptions}; use default_struct_builder::DefaultBuilder; /// A throttled version of `leptos::watch`.