sprae 12.2.4 → 12.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/sprae.js CHANGED
@@ -55,43 +55,31 @@ Object.assign(directive, {
55
55
  })
56
56
 
57
57
  Object.assign(modifier, {
58
- debounce: (fn,
59
- _how = 250,
60
- _schedule = _how === "tick" ? queueMicrotask : _how === "raf" ? requestAnimationFrame : _how === "idle" ? requestIdleCallback : ((fn) => setTimeout(fn, _how)),
61
- _count = 0
62
- ) =>
63
- debounce(fn, _schedule),
64
-
65
- throttle: (fn, _how = 250, _schedule = _how === "tick" ? queueMicrotask : _how === "raf" ? requestAnimationFrame : ((fn) => setTimeout(fn, _how))) => (
66
- throttle(fn, _schedule)
67
- ),
68
-
58
+ // timing
59
+ debounce: (fn, _how = 250) => debounce(fn, (_how ||= 0, (fn) => setTimeout(fn, _how))),
60
+ throttle: (fn, _how = 250) => throttle(fn, (_how ||= 0, (fn) => setTimeout(fn, _how))),
61
+ tick: (fn) => (e) => queueMicrotask(() => fn(e)),
62
+ raf: (fn) => (e) => requestAnimationFrame(() => fn(e)),
69
63
  once: (fn, _done, _fn) => Object.assign((e) => !_done && (_done = 1, fn(e)), { once: true }),
70
64
 
71
- // event modifiers
72
- // actions
73
- prevent: (fn) => (e) => (e?.preventDefault(), fn(e)),
74
- stop: (fn) => (e) => (e?.stopPropagation(), fn(e)),
75
- immediate: (fn) => (e) => (e?.stopImmediatePropagation(), fn(e)),
76
-
77
- // options
78
- passive: fn => (fn.passive = true, fn),
79
- capture: fn => (fn.capture = true, fn),
80
-
81
65
  // target
82
66
  window: fn => (fn.target = fn.target.ownerDocument.defaultView, fn),
83
67
  document: fn => (fn.target = fn.target.ownerDocument, fn),
84
68
  root: fn => (fn.target = fn.target.ownerDocument.documentElement, fn),
85
69
  body: fn => (fn.target = fn.target.ownerDocument.body, fn),
86
70
  parent: fn => (fn.target = fn.target.parentNode, fn),
87
-
88
- // testers
89
71
  self: (fn) => (e) => (e.target === fn.target && fn(e)),
90
-
91
72
  outside: (fn) => (e, _target) => (
92
73
  _target = fn.target,
93
74
  !_target.contains(e.target) && e.target.isConnected && (_target.offsetWidth || _target.offsetHeight)
94
75
  ),
76
+
77
+ // events
78
+ prevent: (fn) => (e) => (e?.preventDefault(), fn(e)),
79
+ stop: (fn) => (e) => (e?.stopPropagation(), fn(e)),
80
+ immediate: (fn) => (e) => (e?.stopImmediatePropagation(), fn(e)),
81
+ passive: fn => (fn.passive = true, fn),
82
+ capture: fn => (fn.capture = true, fn),
95
83
  })
96
84
 
97
85
  // key testers
@@ -130,5 +118,8 @@ sprae.directive = directive
130
118
  sprae.modifier = modifier
131
119
  sprae.start = start
132
120
 
121
+ // version placeholder for bundler
122
+ sprae.version = "[VI]{{inject}}[/VI]"
123
+
133
124
  export default sprae
134
125
  export { sprae, store, signal, effect, computed, batch, untracked, start, use }