added features for every function.

fixes #152
This commit is contained in:
Maccesch 2024-08-22 13:37:32 +01:00
parent 480b1fa4ee
commit b07b6b7cfd
75 changed files with 580 additions and 212 deletions

View file

@ -14,14 +14,14 @@ homepage = "https://leptos-use.rs"
[dependencies] [dependencies]
actix-web = { version = "4", optional = true, default-features = false } actix-web = { version = "4", optional = true, default-features = false }
async-trait = "0.1" async-trait = { version = "0.1", optional = true }
cfg-if = "1" cfg-if = "1"
codee = "0.1" codee = { version = "0.1", optional = true }
cookie = { version = "0.18", features = ["percent-encode"] } cookie = { version = "0.18", features = ["percent-encode"], optional = true }
default-struct-builder = "0.5" default-struct-builder = "0.5"
futures-util = "0.3" futures-util = { version = "0.3", optional = true }
gloo-timers = { version = "0.3.0", features = ["futures"] } gloo-timers = { version = "0.3.0", optional = true, features = ["futures"] }
gloo-utils = { version = "0.2.0" } gloo-utils = { version = "0.2.0", optional = true }
http1 = { version = "1", optional = true, package = "http" } http1 = { version = "1", optional = true, package = "http" }
http0_2 = { version = "0.2", optional = true, package = "http" } http0_2 = { version = "0.2", optional = true, package = "http" }
js-sys = "0.3" js-sys = "0.3"
@ -33,101 +33,10 @@ leptos-spin = { version = "0.1", optional = true }
num = { version = "0.4", optional = true } num = { version = "0.4", optional = true }
paste = "1" paste = "1"
thiserror = "1" thiserror = "1"
unic-langid = "0.9" unic-langid = { version = "0.9", optional = true }
wasm-bindgen = "=0.2.93" wasm-bindgen = "=0.2.93"
wasm-bindgen-futures = "0.4" wasm-bindgen-futures = "0.4"
web-sys = { version = "=0.3.70", optional = true }
[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",
]
[dev-dependencies] [dev-dependencies]
codee = { version = "0.1", features = ["json_serde", "msgpack_serde", "base64", "prost"] } 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"] } unic-langid = { version = "0.9", features = ["macros"] }
[features] [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"] actix = ["dep:actix-web", "dep:leptos_actix", "dep:http0_2"]
axum = ["dep:leptos_axum", "dep:http1"] 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"] 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"] spin = ["dep:leptos-spin", "dep:http1"]
ssr = [] 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 = [] 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] [package.metadata.docs.rs]
features = ["math", "docs", "ssr"] features = ["math", "docs", "ssr"]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["on_click_outside", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["signal_debounced", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["signal_throttled", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -16,7 +16,6 @@ leptos = { version = "0.6", features = ["nightly"] }
leptos_axum = { version = "0.6", optional = true } leptos_axum = { version = "0.6", optional = true }
leptos_meta = { version = "0.6", features = ["nightly"] } leptos_meta = { version = "0.6", features = ["nightly"] }
leptos_router = { version = "0.6", features = ["nightly"] } leptos_router = { version = "0.6", features = ["nightly"] }
leptos-use = { path = "../.." }
log = "0.4" log = "0.4"
simple_logger = "4" simple_logger = "4"
tokio = { version = "1", features = ["full"], optional = true } tokio = { version = "1", features = ["full"], optional = true }
@ -28,6 +27,20 @@ thiserror = "1.0.38"
tracing = { version = "0.1.37", optional = true } tracing = { version = "0.1.37", optional = true }
http = "1" 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] [features]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"] hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"]
ssr = [ ssr = [

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["sync_signal", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_active_element", "docs"] }
web-sys = { version = "0.3", features = ["HtmlElement", "DomStringMap"] } web-sys = { version = "0.3", features = ["HtmlElement", "DomStringMap"] }
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_breakpoints", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -9,7 +9,7 @@ codee = "0.1"
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_broadcast_channel", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_clipboard", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_color_mode", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -9,7 +9,7 @@ codee = "0.1"
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_cookie", "docs"] }
rand = "0.8" rand = "0.8"
getrandom = { version = "0.2", features = ["js"] } getrandom = { version = "0.2", features = ["js"] }
web-sys = "0.3" web-sys = "0.3"

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_css_var", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_cycle_list", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_debounce_fn", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_device_orientation", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_device_pixel_ratio", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_display_media", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_document_visibility", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_draggable", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_drop_zone", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_element_bounding", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_element_hover", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_element_size", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_element_visibility", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../.." } leptos-use = { path = "../..", features = ["use_event_listener"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_favicon", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_geolocation", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_idle", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_infinite_scroll", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_intersection_observer", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_interval", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs", "math"] } leptos-use = { path = "../..", features = ["use_interval_fn", "docs", "math"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_intl_number_format", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_locale", "docs"] }
unic-langid = { version = "0.9", features = ["macros"] } unic-langid = { version = "0.9", features = ["macros"] }
web-sys = "0.3" web-sys = "0.3"

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_locales", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_media_query", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_mouse", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_mouse_in_element", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_mutation_observer", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_permission", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_prefers_reduced_motion", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_raf_fn", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_resize_observer", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_scroll", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_service_worker", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_sorted", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ codee = { version = "0.1", features = ["json_serde"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
leptos = { version = "0.6", features = ["nightly", "csr"] } leptos = { version = "0.6", features = ["nightly", "csr"] }
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["storage", "docs"] }
log = "0.4" log = "0.4"
serde = "1.0.163" serde = "1.0.163"
web-sys = "0.3" web-sys = "0.3"

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_throttle_fn", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_timeout_fn", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_timestamp", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_user_media", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_web_notification", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -9,7 +9,7 @@ codee = { version = "0.1", features = ["msgpack_serde"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_websocket", "docs"] }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
web-sys = "0.3" web-sys = "0.3"

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_web_notification", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_window_focus", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["use_window_scroll", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["watch_debounced", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["watch_pausable", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -8,7 +8,7 @@ leptos = { version = "0.6", features = ["nightly", "csr"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
console_log = "1" console_log = "1"
log = "0.4" log = "0.4"
leptos-use = { path = "../..", features = ["docs"] } leptos-use = { path = "../..", features = ["watch_throttled", "docs"] }
web-sys = "0.3" web-sys = "0.3"
[dev-dependencies] [dev-dependencies]

View file

@ -1,26 +1,32 @@
mod connection_ready_state; mod connection_ready_state;
mod datetime; mod datetime;
mod direction; mod direction;
#[cfg(feature = "element")]
mod element_maybe_signal; mod element_maybe_signal;
#[cfg(feature = "element")]
mod elements_maybe_signal; mod elements_maybe_signal;
mod maybe_rw_signal; mod maybe_rw_signal;
mod pointer_type; mod pointer_type;
mod position; mod position;
mod reconnect_limit;
mod size; mod size;
mod ssr_safe_method; mod ssr_safe_method;
mod storage; #[cfg(feature = "use_color_mode")]
pub(crate) mod url; pub(crate) mod url;
mod use_rw_signal; mod use_rw_signal;
pub use connection_ready_state::*; pub use connection_ready_state::*;
pub(crate) use datetime::*; pub(crate) use datetime::*;
pub use direction::*; pub use direction::*;
#[cfg(feature = "element")]
pub use element_maybe_signal::*; pub use element_maybe_signal::*;
#[cfg(feature = "element")]
pub use elements_maybe_signal::*; pub use elements_maybe_signal::*;
pub use maybe_rw_signal::*; pub use maybe_rw_signal::*;
pub use pointer_type::*; pub use pointer_type::*;
pub use position::*; pub use position::*;
pub use reconnect_limit::*;
pub use size::*; pub use size::*;
#[allow(unused_imports)]
pub(crate) use ssr_safe_method::*; pub(crate) use ssr_safe_method::*;
pub use storage::*;
pub use use_rw_signal::*; pub use use_rw_signal::*;

View file

@ -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,
}
}
}

View file

@ -1,3 +1,5 @@
#![allow(unused_macros, unused_imports)]
macro_rules! impl_ssr_safe_method { macro_rules! impl_ssr_safe_method {
( (
$(#[$attr:meta])* $(#[$attr:meta])*

View file

@ -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<Option<web_sys::Storage>, JsValue> {
match self {
StorageType::Local => window().local_storage(),
StorageType::Session => window().session_storage(),
StorageType::Custom(storage) => Ok(Some(storage)),
}
}
}

View file

@ -7,150 +7,291 @@ pub mod core;
pub mod docs; pub mod docs;
#[cfg(feature = "math")] #[cfg(feature = "math")]
pub mod math; pub mod math;
#[cfg(feature = "storage")]
pub mod storage; pub mod storage;
pub mod utils; pub mod utils;
pub use core::ReconnectLimit;
// #[cfg(web_sys_unstable_apis)] // #[cfg(web_sys_unstable_apis)]
// mod use_webtransport; // mod use_webtransport;
// #[cfg(web_sys_unstable_apis)] // #[cfg(web_sys_unstable_apis)]
// pub use use_webtransport::*; // pub use use_webtransport::*;
#[cfg(feature = "is_err")]
mod is_err; mod is_err;
#[cfg(feature = "is_none")]
mod is_none; mod is_none;
#[cfg(feature = "is_ok")]
mod is_ok; mod is_ok;
#[cfg(feature = "is_some")]
mod is_some; mod is_some;
#[cfg(feature = "on_click_outside")]
mod on_click_outside; mod on_click_outside;
#[cfg(feature = "signal_debounced")]
mod signal_debounced; mod signal_debounced;
#[cfg(feature = "signal_throttled")]
mod signal_throttled; mod signal_throttled;
#[cfg(feature = "sync_signal")]
mod sync_signal; mod sync_signal;
#[cfg(feature = "use_active_element")]
mod use_active_element; mod use_active_element;
#[cfg(feature = "use_breakpoints")]
mod use_breakpoints; mod use_breakpoints;
#[cfg(feature = "use_broadcast_channel")]
mod use_broadcast_channel; mod use_broadcast_channel;
#[cfg(feature = "use_clipboard")]
mod use_clipboard; mod use_clipboard;
#[cfg(feature = "use_color_mode")]
mod use_color_mode; mod use_color_mode;
#[cfg(feature = "use_cookie")]
mod use_cookie; mod use_cookie;
#[cfg(feature = "use_css_var")]
mod use_css_var; mod use_css_var;
#[cfg(feature = "use_cycle_list")]
mod use_cycle_list; mod use_cycle_list;
#[cfg(feature = "use_debounce_fn")]
mod use_debounce_fn; mod use_debounce_fn;
#[cfg(feature = "use_device_orientation")]
mod use_device_orientation; mod use_device_orientation;
#[cfg(feature = "use_device_pixel_ratio")]
mod use_device_pixel_ratio; mod use_device_pixel_ratio;
#[cfg(feature = "use_display_media")]
mod use_display_media; mod use_display_media;
#[cfg(feature = "use_document")]
mod use_document; mod use_document;
#[cfg(feature = "use_document_visibility")]
mod use_document_visibility; mod use_document_visibility;
#[cfg(feature = "use_draggable")]
mod use_draggable; mod use_draggable;
#[cfg(feature = "use_drop_zone")]
mod use_drop_zone; mod use_drop_zone;
#[cfg(feature = "use_element_bounding")]
mod use_element_bounding; mod use_element_bounding;
#[cfg(feature = "use_element_hover")]
mod use_element_hover; mod use_element_hover;
#[cfg(feature = "use_element_size")]
mod use_element_size; mod use_element_size;
#[cfg(feature = "use_element_visibility")]
mod use_element_visibility; mod use_element_visibility;
#[cfg(feature = "use_event_listener")]
mod use_event_listener; mod use_event_listener;
#[cfg(feature = "use_event_source")]
mod use_event_source; mod use_event_source;
#[cfg(feature = "use_favicon")]
mod use_favicon; mod use_favicon;
#[cfg(feature = "use_geolocation")]
mod use_geolocation; mod use_geolocation;
#[cfg(feature = "use_idle")]
mod use_idle; mod use_idle;
#[cfg(feature = "use_infinite_scroll")]
mod use_infinite_scroll; mod use_infinite_scroll;
#[cfg(feature = "use_intersection_observer")]
mod use_intersection_observer; mod use_intersection_observer;
#[cfg(feature = "use_interval")]
mod use_interval; mod use_interval;
#[cfg(feature = "use_interval_fn")]
mod use_interval_fn; mod use_interval_fn;
#[cfg(feature = "use_intl_number_format")]
mod use_intl_number_format; mod use_intl_number_format;
#[cfg(feature = "use_locale")]
mod use_locale; mod use_locale;
#[cfg(feature = "use_locales")]
mod use_locales; mod use_locales;
#[cfg(feature = "use_media_query")]
mod use_media_query; mod use_media_query;
#[cfg(feature = "use_mouse")]
mod use_mouse; mod use_mouse;
#[cfg(feature = "use_mouse_in_element")]
mod use_mouse_in_element; mod use_mouse_in_element;
#[cfg(feature = "use_mutation_observer")]
mod use_mutation_observer; mod use_mutation_observer;
#[cfg(feature = "use_permission")]
mod use_permission; mod use_permission;
#[cfg(feature = "use_preferred_contrast")]
mod use_preferred_contrast; mod use_preferred_contrast;
#[cfg(feature = "use_preferred_dark")]
mod use_preferred_dark; mod use_preferred_dark;
#[cfg(feature = "use_prefers_reduced_motion")]
mod use_prefers_reduced_motion; mod use_prefers_reduced_motion;
#[cfg(feature = "use_raf_fn")]
mod use_raf_fn; mod use_raf_fn;
#[cfg(feature = "use_resize_observer")]
mod use_resize_observer; mod use_resize_observer;
#[cfg(feature = "use_scroll")]
mod use_scroll; mod use_scroll;
#[cfg(feature = "use_service_worker")]
mod use_service_worker; mod use_service_worker;
#[cfg(feature = "use_sorted")]
mod use_sorted; mod use_sorted;
#[cfg(feature = "use_supported")]
mod use_supported; mod use_supported;
#[cfg(feature = "use_throttle_fn")]
mod use_throttle_fn; mod use_throttle_fn;
#[cfg(feature = "use_timeout_fn")]
mod use_timeout_fn; mod use_timeout_fn;
#[cfg(feature = "use_timestamp")]
mod use_timestamp; mod use_timestamp;
#[cfg(feature = "use_to_string")]
mod use_to_string; mod use_to_string;
#[cfg(feature = "use_user_media")]
mod use_user_media; mod use_user_media;
#[cfg(feature = "use_web_notification")]
mod use_web_notification; mod use_web_notification;
#[cfg(feature = "use_websocket")]
mod use_websocket; mod use_websocket;
#[cfg(feature = "use_window")]
mod use_window; mod use_window;
#[cfg(feature = "use_window_focus")]
mod use_window_focus; mod use_window_focus;
#[cfg(feature = "use_window_scroll")]
mod use_window_scroll; mod use_window_scroll;
#[cfg(feature = "watch_debounced")]
mod watch_debounced; mod watch_debounced;
#[cfg(feature = "watch_pausable")]
mod watch_pausable; mod watch_pausable;
#[cfg(feature = "watch_throttled")]
mod watch_throttled; mod watch_throttled;
#[cfg(feature = "watch_with_options")]
mod watch_with_options; mod watch_with_options;
#[cfg(feature = "whenever")]
mod whenever; mod whenever;
#[cfg(feature = "is_err")]
pub use is_err::*; pub use is_err::*;
#[cfg(feature = "is_none")]
pub use is_none::*; pub use is_none::*;
#[cfg(feature = "is_ok")]
pub use is_ok::*; pub use is_ok::*;
#[cfg(feature = "is_some")]
pub use is_some::*; pub use is_some::*;
#[cfg(feature = "on_click_outside")]
pub use on_click_outside::*; pub use on_click_outside::*;
#[cfg(feature = "signal_debounced")]
pub use signal_debounced::*; pub use signal_debounced::*;
#[cfg(feature = "signal_throttled")]
pub use signal_throttled::*; pub use signal_throttled::*;
#[cfg(feature = "sync_signal")]
pub use sync_signal::*; pub use sync_signal::*;
#[cfg(feature = "use_active_element")]
pub use use_active_element::*; pub use use_active_element::*;
#[cfg(feature = "use_breakpoints")]
pub use use_breakpoints::*; pub use use_breakpoints::*;
#[cfg(feature = "use_broadcast_channel")]
pub use use_broadcast_channel::*; pub use use_broadcast_channel::*;
#[cfg(feature = "use_clipboard")]
pub use use_clipboard::*; pub use use_clipboard::*;
#[cfg(feature = "use_color_mode")]
pub use use_color_mode::*; pub use use_color_mode::*;
#[cfg(feature = "use_cookie")]
pub use use_cookie::*; pub use use_cookie::*;
#[cfg(feature = "use_css_var")]
pub use use_css_var::*; pub use use_css_var::*;
#[cfg(feature = "use_cycle_list")]
pub use use_cycle_list::*; pub use use_cycle_list::*;
#[cfg(feature = "use_debounce_fn")]
pub use use_debounce_fn::*; pub use use_debounce_fn::*;
#[cfg(feature = "use_device_orientation")]
pub use use_device_orientation::*; pub use use_device_orientation::*;
#[cfg(feature = "use_device_pixel_ratio")]
pub use use_device_pixel_ratio::*; pub use use_device_pixel_ratio::*;
#[cfg(feature = "use_display_media")]
pub use use_display_media::*; pub use use_display_media::*;
#[cfg(feature = "use_document")]
pub use use_document::*; pub use use_document::*;
#[cfg(feature = "use_document_visibility")]
pub use use_document_visibility::*; pub use use_document_visibility::*;
#[cfg(feature = "use_draggable")]
pub use use_draggable::*; pub use use_draggable::*;
#[cfg(feature = "use_drop_zone")]
pub use use_drop_zone::*; pub use use_drop_zone::*;
#[cfg(feature = "use_element_bounding")]
pub use use_element_bounding::*; pub use use_element_bounding::*;
#[cfg(feature = "use_element_hover")]
pub use use_element_hover::*; pub use use_element_hover::*;
#[cfg(feature = "use_element_size")]
pub use use_element_size::*; pub use use_element_size::*;
#[cfg(feature = "use_element_visibility")]
pub use use_element_visibility::*; pub use use_element_visibility::*;
#[cfg(feature = "use_event_listener")]
pub use use_event_listener::*; pub use use_event_listener::*;
#[cfg(feature = "use_event_source")]
pub use use_event_source::*; pub use use_event_source::*;
#[cfg(feature = "use_favicon")]
pub use use_favicon::*; pub use use_favicon::*;
#[cfg(feature = "use_geolocation")]
pub use use_geolocation::*; pub use use_geolocation::*;
#[cfg(feature = "use_idle")]
pub use use_idle::*; pub use use_idle::*;
#[cfg(feature = "use_infinite_scroll")]
pub use use_infinite_scroll::*; pub use use_infinite_scroll::*;
#[cfg(feature = "use_intersection_observer")]
pub use use_intersection_observer::*; pub use use_intersection_observer::*;
#[cfg(feature = "use_interval")]
pub use use_interval::*; pub use use_interval::*;
#[cfg(feature = "use_interval_fn")]
pub use use_interval_fn::*; pub use use_interval_fn::*;
#[cfg(feature = "use_intl_number_format")]
pub use use_intl_number_format::*; pub use use_intl_number_format::*;
#[cfg(feature = "use_locale")]
pub use use_locale::*; pub use use_locale::*;
#[cfg(feature = "use_locales")]
pub use use_locales::*; pub use use_locales::*;
#[cfg(feature = "use_media_query")]
pub use use_media_query::*; pub use use_media_query::*;
#[cfg(feature = "use_mouse")]
pub use use_mouse::*; pub use use_mouse::*;
#[cfg(feature = "use_mouse_in_element")]
pub use use_mouse_in_element::*; pub use use_mouse_in_element::*;
#[cfg(feature = "use_mutation_observer")]
pub use use_mutation_observer::*; pub use use_mutation_observer::*;
#[cfg(feature = "use_permission")]
pub use use_permission::*; pub use use_permission::*;
#[cfg(feature = "use_preferred_contrast")]
pub use use_preferred_contrast::*; pub use use_preferred_contrast::*;
#[cfg(feature = "use_preferred_dark")]
pub use use_preferred_dark::*; pub use use_preferred_dark::*;
#[cfg(feature = "use_prefers_reduced_motion")]
pub use use_prefers_reduced_motion::*; pub use use_prefers_reduced_motion::*;
#[cfg(feature = "use_raf_fn")]
pub use use_raf_fn::*; pub use use_raf_fn::*;
#[cfg(feature = "use_resize_observer")]
pub use use_resize_observer::*; pub use use_resize_observer::*;
#[cfg(feature = "use_scroll")]
pub use use_scroll::*; pub use use_scroll::*;
#[cfg(feature = "use_service_worker")]
pub use use_service_worker::*; pub use use_service_worker::*;
#[cfg(feature = "use_sorted")]
pub use use_sorted::*; pub use use_sorted::*;
#[cfg(feature = "use_supported")]
pub use use_supported::*; pub use use_supported::*;
#[cfg(feature = "use_throttle_fn")]
pub use use_throttle_fn::*; pub use use_throttle_fn::*;
#[cfg(feature = "use_timeout_fn")]
pub use use_timeout_fn::*; pub use use_timeout_fn::*;
#[cfg(feature = "use_timestamp")]
pub use use_timestamp::*; pub use use_timestamp::*;
#[cfg(feature = "use_to_string")]
pub use use_to_string::*; pub use use_to_string::*;
#[cfg(feature = "use_user_media")]
pub use use_user_media::*; pub use use_user_media::*;
#[cfg(feature = "use_web_notification")]
pub use use_web_notification::*; pub use use_web_notification::*;
#[cfg(feature = "use_websocket")]
pub use use_websocket::*; pub use use_websocket::*;
#[cfg(feature = "use_window")]
pub use use_window::*; pub use use_window::*;
#[cfg(feature = "use_window_focus")]
pub use use_window_focus::*; pub use use_window_focus::*;
#[cfg(feature = "use_window_scroll")]
pub use use_window_scroll::*; pub use use_window_scroll::*;
#[cfg(feature = "watch_debounced")]
pub use watch_debounced::*; pub use watch_debounced::*;
#[cfg(feature = "watch_pausable")]
pub use watch_pausable::*; pub use watch_pausable::*;
#[cfg(feature = "watch_throttled")]
pub use watch_throttled::*; pub use watch_throttled::*;
#[cfg(feature = "watch_with_options")]
pub use watch_with_options::*; pub use watch_with_options::*;
#[cfg(feature = "whenever")]
pub use whenever::*; pub use whenever::*;

View file

@ -2,7 +2,28 @@ mod use_local_storage;
mod use_session_storage; mod use_session_storage;
mod use_storage; mod use_storage;
pub use crate::core::StorageType;
pub use use_local_storage::*; pub use use_local_storage::*;
pub use use_session_storage::*; pub use use_session_storage::*;
pub use use_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<Option<web_sys::Storage>, JsValue> {
match self {
StorageType::Local => window().local_storage(),
StorageType::Session => window().session_storage(),
StorageType::Custom(storage) => Ok(Some(storage)),
}
}
}

View file

@ -1,7 +1,4 @@
use crate::{ use crate::{core::MaybeRwSignal, storage::StorageType, utils::FilterOptions};
core::{MaybeRwSignal, StorageType},
utils::FilterOptions,
};
use codee::{CodecError, Decoder, Encoder}; use codee::{CodecError, Decoder, Encoder};
use default_struct_builder::DefaultBuilder; use default_struct_builder::DefaultBuilder;
use leptos::*; use leptos::*;

View file

@ -1,7 +1,6 @@
use crate::core::url; use crate::core::url;
use crate::core::StorageType;
use crate::core::{ElementMaybeSignal, MaybeRwSignal}; 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::utils::get_header;
use crate::{ use crate::{
sync_signal_with_options, use_cookie, use_preferred_dark_with_options, SyncSignalOptions, sync_signal_with_options, use_cookie, use_preferred_dark_with_options, SyncSignalOptions,

View file

@ -7,7 +7,7 @@ use std::rc::Rc;
use std::time::Duration; use std::time::Duration;
use thiserror::Error; use thiserror::Error;
use crate::core::ConnectionReadyState; use crate::{core::ConnectionReadyState, ReconnectLimit};
use codee::{ use codee::{
CodecError, Decoder, Encoder, HybridCoderError, HybridDecoder, HybridEncoder, IsBinary, CodecError, Decoder, Encoder, HybridCoderError, HybridDecoder, HybridEncoder, IsBinary,
}; };
@ -608,26 +608,6 @@ where
send, 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<dyn Fn(&[u8])>; type RcFnBytes = Rc<dyn Fn(&[u8])>;

View file

@ -1,3 +1,5 @@
#![allow(unused_macros, unused_imports)]
macro_rules! get_header { macro_rules! get_header {
( (
$header_name:expr, $header_name:expr,

View file

@ -1,3 +1,5 @@
#![allow(unused_macros, unused_imports)]
macro_rules! js_value_from_to_string { macro_rules! js_value_from_to_string {
($name:ident) => { ($name:ident) => {
impl From<$name> for JsValue { impl From<$name> for JsValue {

View file

@ -5,6 +5,7 @@ mod filters;
))] ))]
mod header; mod header;
mod header_macro; mod header_macro;
#[cfg(feature = "is")]
mod is; mod is;
mod js; mod js;
mod js_value_from_to_string; mod js_value_from_to_string;
@ -18,8 +19,12 @@ pub use filters::*;
any(feature = "axum", feature = "actix", feature = "spin") any(feature = "axum", feature = "actix", feature = "spin")
))] ))]
pub use header::*; pub use header::*;
#[allow(unused_imports)]
pub(crate) use header_macro::*; pub(crate) use header_macro::*;
#[cfg(feature = "is")]
pub use is::*; pub use is::*;
#[allow(unused_imports)]
pub(crate) use js_value_from_to_string::*; pub(crate) use js_value_from_to_string::*;
pub use pausable::*; pub use pausable::*;
#[allow(unused_imports)]
pub(crate) use signal_filtered::*; pub(crate) use signal_filtered::*;

View file

@ -1,3 +1,5 @@
#![allow(unused_macros, unused_imports)]
macro_rules! signal_filtered { macro_rules! signal_filtered {
( (
$(#[$outer:meta])* $(#[$outer:meta])*

View file

@ -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 default_struct_builder::DefaultBuilder;
use leptos::*; use leptos::*;

View file

@ -1,4 +1,4 @@
use crate::{watch_with_options, ThrottleOptions, WatchOptions}; use crate::{watch_with_options, utils::ThrottleOptions, WatchOptions};
use default_struct_builder::DefaultBuilder; use default_struct_builder::DefaultBuilder;
/// A throttled version of `leptos::watch`. /// A throttled version of `leptos::watch`.