turbo_boost-streams 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,8 +14,6 @@ Turbo.StreamActions.invoke = invoke
14
14
  self.TurboBoost = self.TurboBoost || {}
15
15
  self.TurboBoost.Streams = { invoke, invokeEvents }
16
16
 
17
- console.info(
18
- '@turbo-boost/streams has initialized and registered new stream actions with Turbo.'
19
- )
17
+ console.info('@turbo-boost/streams has initialized and registered new stream actions with Turbo.')
20
18
 
21
19
  export default self.TurboBoost.Streams
@@ -7,7 +7,7 @@ export const invokeEvents = {
7
7
  }
8
8
 
9
9
  // Invokes the callback on a single receiver with before/after events
10
- function withInvokeEvents (receiver, detail, callback) {
10
+ function withInvokeEvents(receiver, detail, callback) {
11
11
  const { object, target } = receiver
12
12
  detail = detail || {}
13
13
  detail = { ...detail, object: receiver.object }
@@ -47,7 +47,7 @@ function withInvokeEvents (receiver, detail, callback) {
47
47
  else execute()
48
48
  }
49
49
 
50
- function invokeDispatchEvent (method, args, receivers) {
50
+ function invokeDispatchEvent(method, args, receivers) {
51
51
  const eventName = args[0]
52
52
  const eventOptions = args[1]
53
53
  const detail = { method, eventName, eventOptions }
@@ -58,41 +58,33 @@ function invokeDispatchEvent (method, args, receivers) {
58
58
  )
59
59
  }
60
60
 
61
- function invokeMorph (method, args, receivers) {
61
+ function invokeMorph(method, args, receivers) {
62
62
  const html = args[0]
63
63
  const detail = { method, html }
64
- receivers.forEach(receiver =>
65
- withInvokeEvents(receiver, detail, object => morph(object, html))
66
- )
64
+ receivers.forEach(receiver => withInvokeEvents(receiver, detail, object => morph(object, html)))
67
65
  }
68
66
 
69
- function invokeAssignment (method, args, receivers) {
67
+ function invokeAssignment(method, args, receivers) {
70
68
  const property = method.slice(0, -1).trim()
71
69
  const value = args[0]
72
70
  const detail = { method, property, value }
73
- receivers.forEach(receiver =>
74
- withInvokeEvents(receiver, detail, object => (object[property] = value))
75
- )
71
+ receivers.forEach(receiver => withInvokeEvents(receiver, detail, object => (object[property] = value)))
76
72
  }
77
73
 
78
- function invokeMethod (method, args, receivers) {
74
+ function invokeMethod(method, args, receivers) {
79
75
  const detail = { method, args }
80
76
  receivers.forEach(receiver =>
81
- withInvokeEvents(receiver, detail, object =>
82
- object[method].apply(object, args)
83
- )
77
+ withInvokeEvents(receiver, detail, object => object[method].apply(object, args))
84
78
  )
85
79
  }
86
80
 
87
81
  // Performs an invocation on all receivers for the given method and args
88
- function performInvoke (method, args, receivers) {
82
+ function performInvoke(method, args, receivers) {
89
83
  // dispatch ................................................................................................
90
- if (method.match(/^dispatch(Event)?$/))
91
- return invokeDispatchEvent(method, args, receivers)
84
+ if (method.match(/^dispatch(Event)?$/)) return invokeDispatchEvent(method, args, receivers)
92
85
 
93
86
  // morph ...................................................................................................
94
- if (method.match(/^morph|mutate$/))
95
- return invokeMorph(method, args, receivers)
87
+ if (method.match(/^morph|mutate$/)) return invokeMorph(method, args, receivers)
96
88
 
97
89
  // assignment ..............................................................................................
98
90
  if (method.endsWith('=')) return invokeAssignment(method, args, receivers)
@@ -101,7 +93,7 @@ function performInvoke (method, args, receivers) {
101
93
  return invokeMethod(method, args, receivers)
102
94
  }
103
95
 
104
- export function invoke () {
96
+ export function invoke() {
105
97
  const payload = JSON.parse(this.templateContent.textContent)
106
98
  const { id, selector, receiver, method, args, delay } = payload
107
99
  let receivers = [{ object: self, target: self }]
@@ -7,17 +7,16 @@ const input = /INPUT/i
7
7
  const inputTypes = /date|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/i
8
8
  const textarea = /TEXTAREA/i
9
9
 
10
- function updating (el, toEl, childrenOnly, skip) {
10
+ function updating(el, toEl, childrenOnly, skip) {
11
11
  if (el.nodeType !== Node.ELEMENT_NODE) return
12
12
  if (el !== document.activeElement) return
13
13
 
14
14
  const protect =
15
- el.tagName.match(textarea) ||
16
- (el.tagName.match(input) && el.getAttribute('type').match(inputTypes))
15
+ el.tagName.match(textarea) || (el.tagName.match(input) && el.getAttribute('type').match(inputTypes))
17
16
 
18
17
  if (protect) return skip()
19
18
  }
20
19
 
21
- export default function morph (element, html) {
20
+ export default function morph(element, html) {
22
21
  alpine.morph(element, html, { updating })
23
22
  }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TurboBoost
4
4
  module Streams
5
- VERSION = "0.0.8"
5
+ VERSION = "0.0.9"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_boost-streams
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Hopkins (hopsoft)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-27 00:00:00.000000000 Z
11
+ date: 2024-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -344,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
344
344
  - !ruby/object:Gem::Version
345
345
  version: '0'
346
346
  requirements: []
347
- rubygems_version: 3.4.1
347
+ rubygems_version: 3.5.3
348
348
  signing_key:
349
349
  specification_version: 4
350
350
  summary: Take full control of the DOM with Turbo Streams