@dazn/kopytko-framework 1.3.2 → 1.3.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazn/kopytko-framework",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "A modern Roku's Brightscript framework",
5
5
  "keywords": [
6
6
  "brightscript",
@@ -3,6 +3,8 @@ function KopytkoDOM() as Object
3
3
 
4
4
  prototype.componentsMapping = {}
5
5
 
6
+ prototype._renderedElements = {}
7
+
6
8
  ' Renders an element based on the given virtual node
7
9
  ' @param {Object} vNode - The virtual node
8
10
  ' @param {Object} parentElement - The parent element where the element will be rendered
@@ -45,6 +47,8 @@ function KopytkoDOM() as Object
45
47
  parentElement.appendChild(element)
46
48
  end if
47
49
 
50
+ m._renderedElements[element.id] = element
51
+
48
52
  m._setElementSelector(element)
49
53
  end sub
50
54
 
@@ -94,7 +98,7 @@ function KopytkoDOM() as Object
94
98
  rootElement = m._getRootComponent()
95
99
 
96
100
  for each elementId in elements
97
- element = rootElement.top.findNode(elementId)
101
+ element = m._renderedElements[elementId]
98
102
 
99
103
  if (element <> Invalid)
100
104
  m._destroyKopytkoElement(element)
@@ -106,6 +110,7 @@ function KopytkoDOM() as Object
106
110
  end if
107
111
 
108
112
  rootElement.delete(elementId)
113
+ m._renderedElements.delete(elementId)
109
114
  end for
110
115
  end sub
111
116
 
@@ -1,4 +1,5 @@
1
1
  ' @import /components/getType.brs from @dazn/kopytko-utils
2
+ ' @import /components/uuid.brs from @dazn/kopytko-utils
2
3
  ' @import /components/utils/KopytkoGlobalNode.brs
3
4
  function StoreFacade() as Object
4
5
  if (m._store <> Invalid)
@@ -15,7 +16,7 @@ function StoreFacade() as Object
15
16
  prototype = {}
16
17
 
17
18
  prototype._store = _global.store
18
- prototype._subscriptions = []
19
+ prototype._subscriptions = {}
19
20
 
20
21
  prototype.updateNode = sub (key as String, value as Dynamic)
21
22
  data = m.get(key)
@@ -94,20 +95,20 @@ function StoreFacade() as Object
94
95
 
95
96
  prototype.subscribeOnce = sub (key as String, callback as Function)
96
97
  m._handleSubscriber(key)
97
- m._subscriptions.push({ key: key, callback: [callback], once: true })
98
+ m._subscriptions[m._getRandomizedKey(key)] = { key: key, callback: [callback], once: true }
98
99
  end sub
99
100
 
100
101
  prototype.subscribe = sub (key as String, callback as Function)
101
102
  m._handleSubscriber(key)
102
- m._subscriptions.push({ key: key, callback: [callback], once: false })
103
+ m._subscriptions[m._getRandomizedKey(key)] = { key: key, callback: [callback], once: false }
103
104
  end sub
104
105
 
105
106
  prototype.unsubscribe = sub (key as String, callback as Function)
106
- for i = 0 to m._subscriptions.count() - 1
107
- listener = m._subscriptions[i]
107
+ for each subscriptionKey in m._subscriptions
108
+ listener = m._subscriptions[subscriptionKey]
108
109
 
109
110
  if (listener <> Invalid AND listener.key = key AND listener.callback[0] = callback)
110
- m._subscriptions.delete(i)
111
+ m._subscriptions.delete(subscriptionKey)
111
112
  end if
112
113
  end for
113
114
  end sub
@@ -139,14 +140,14 @@ function StoreFacade() as Object
139
140
  prototype._notify = sub (key as String, data as Object)
140
141
  value = data.value
141
142
 
142
- for i = 0 to m._subscriptions.count() - 1
143
- listener = m._subscriptions[i]
143
+ for each subscriptionKey in m._subscriptions
144
+ listener = m._subscriptions[subscriptionKey]
144
145
 
145
- if (listener.key = key)
146
+ if (listener <> Invalid AND listener.key = key)
146
147
  listener.callback[0](value)
147
148
 
148
149
  if (listener.once)
149
- m._subscriptions.delete(i)
150
+ m._subscriptions.delete(subscriptionKey)
150
151
  end if
151
152
  end if
152
153
  end for
@@ -164,6 +165,10 @@ function StoreFacade() as Object
164
165
  end if
165
166
  end sub
166
167
 
168
+ prototype._getRandomizedKey = function (key as String) as String
169
+ return key + "_" + uuid()
170
+ end function
171
+
167
172
  m._store = prototype
168
173
 
169
174
  return m._store
package/CHANGELOG.md DELETED
@@ -1,103 +0,0 @@
1
- ## [1.3.2](https://github.com/getndazn/kopytko-framework/compare/v1.3.1...v1.3.2) (2022-09-01)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * Ignoring Invalid elements when calculating elements' index in children array ([#31](https://github.com/getndazn/kopytko-framework/issues/31)) ([73aed6e](https://github.com/getndazn/kopytko-framework/commit/73aed6e2e7ba38b946c81fe18ceecf414f7bbcf2))
7
-
8
- ## [1.3.1](https://github.com/getndazn/kopytko-framework/compare/v1.3.0...v1.3.1) (2022-08-05)
9
-
10
-
11
- ### Bug Fixes
12
-
13
- * update dependencies ([#35](https://github.com/getndazn/kopytko-framework/issues/35)) ([7e317e0](https://github.com/getndazn/kopytko-framework/commit/7e317e0850cec411832318bf1491c8375c219cad))
14
-
15
- # [1.3.0](https://github.com/getndazn/kopytko-framework/compare/v1.2.0...v1.3.0) (2022-08-01)
16
-
17
-
18
- ### Features
19
-
20
- * enhanced destroyKopytkoRoot to call destroyKopytko ([#34](https://github.com/getndazn/kopytko-framework/issues/34)) ([c21c2bb](https://github.com/getndazn/kopytko-framework/commit/c21c2bb61bae0f165d2a68341aa1cfb75d13a6b8))
21
-
22
- # [1.2.0](https://github.com/getndazn/kopytko-framework/compare/v1.1.2...v1.2.0) (2022-08-01)
23
-
24
-
25
- ### Features
26
-
27
- * introduced KopytkoRoot that makes integration easier ([#32](https://github.com/getndazn/kopytko-framework/issues/32)) ([11efb22](https://github.com/getndazn/kopytko-framework/commit/11efb228d1e75d0020e1279f61ef1075dcc0f3e4))
28
-
29
- ## [1.1.2](https://github.com/getndazn/kopytko-framework/compare/v1.1.1...v1.1.2) (2022-07-14)
30
-
31
-
32
- ### Bug Fixes
33
-
34
- * allow to render array of elements in root component ([#30](https://github.com/getndazn/kopytko-framework/issues/30)) ([8609122](https://github.com/getndazn/kopytko-framework/commit/8609122e3008009802eaa1865f5ee7756392afa3))
35
-
36
- ## [1.1.1](https://github.com/getndazn/kopytko-framework/compare/v1.1.0...v1.1.1) (2022-06-02)
37
-
38
-
39
- ### Bug Fixes
40
-
41
- * validating parent when removing children from Kopytko component ([#29](https://github.com/getndazn/kopytko-framework/issues/29)) ([fefe313](https://github.com/getndazn/kopytko-framework/commit/fefe31360aa3d90ab7f97ecd5ac422530fe9351e))
42
-
43
- # [1.1.0](https://github.com/getndazn/kopytko-framework/compare/v1.0.6...v1.1.0) (2022-05-20)
44
-
45
-
46
- ### Features
47
-
48
- * added enqueueUpdate function to reduce number of rerenders ([#28](https://github.com/getndazn/kopytko-framework/issues/28)) ([4c80273](https://github.com/getndazn/kopytko-framework/commit/4c80273af7c20ded4bc41cdb94647142b209695f))
49
-
50
- ## [1.0.6](https://github.com/getndazn/kopytko-framework/compare/v1.0.5...v1.0.6) (2022-05-20)
51
-
52
-
53
- ### Bug Fixes
54
-
55
- * not calling state update callbacks if kopytko is not mounted ([#27](https://github.com/getndazn/kopytko-framework/issues/27)) ([27d5618](https://github.com/getndazn/kopytko-framework/commit/27d5618909e7fd266db71e88acfa63071b037921))
56
-
57
- ## [1.0.5](https://github.com/getndazn/kopytko-framework/compare/v1.0.4...v1.0.5) (2022-05-19)
58
-
59
-
60
- ### Bug Fixes
61
-
62
- * expose response headers in HttpResponse ([#26](https://github.com/getndazn/kopytko-framework/issues/26)) ([5517ff2](https://github.com/getndazn/kopytko-framework/commit/5517ff2eaff9d11a8d81ada9ea390288eb049d15))
63
-
64
- ## [1.0.4](https://github.com/getndazn/kopytko-framework/compare/v1.0.3...v1.0.4) (2022-04-11)
65
-
66
-
67
- ### Bug Fixes
68
-
69
- * active route should skip is omitted in history ([#24](https://github.com/getndazn/kopytko-framework/issues/24)) ([970ff96](https://github.com/getndazn/kopytko-framework/commit/970ff9662376a909f1018b452a04b4cf5378a446))
70
-
71
- ## [1.0.3](https://github.com/getndazn/kopytko-framework/compare/v1.0.2...v1.0.3) (2022-03-04)
72
-
73
-
74
- ### Bug Fixes
75
-
76
- * update dependencies ([#19](https://github.com/getndazn/kopytko-framework/issues/19)) ([4652ec2](https://github.com/getndazn/kopytko-framework/commit/4652ec2201292083b8202acb624674de8cd8275e))
77
-
78
- ## [1.0.2](https://github.com/getndazn/kopytko-framework/compare/v1.0.1...v1.0.2) (2021-12-03)
79
-
80
-
81
- ### Bug Fixes
82
-
83
- * **deps:** Fixed npm urls ([#17](https://github.com/getndazn/kopytko-framework/issues/17)) ([32443a2](https://github.com/getndazn/kopytko-framework/commit/32443a2eb3973640fd2315dcf85b6abc1d54e2d3))
84
-
85
- ## [1.0.1](https://github.com/getndazn/kopytko-framework/compare/v1.0.0...v1.0.1) (2021-10-01)
86
-
87
-
88
- ### Bug Fixes
89
-
90
- * Fixed Modal property ([#16](https://github.com/getndazn/kopytko-framework/issues/16)) ([ed36d04](https://github.com/getndazn/kopytko-framework/commit/ed36d04379b859afaa9411769554ee0ef2b3cd08))
91
-
92
- # 1.0.0 (2021-10-01)
93
-
94
-
95
- ### Bug Fixes
96
-
97
- * Removed ThemeFacade import in ModalComponent ([#8](https://github.com/getndazn/kopytko-framework/issues/8)) ([ad60b1a](https://github.com/getndazn/kopytko-framework/commit/ad60b1a3ad2d0ee77c21d83a92f8b34a62c30e78))
98
-
99
-
100
- ### Features
101
-
102
- * Added Registry docs ([#6](https://github.com/getndazn/kopytko-framework/issues/6)) ([37be695](https://github.com/getndazn/kopytko-framework/commit/37be69596e900ef898f671435fd1311387702b72))
103
- * EventBus docs added ([#11](https://github.com/getndazn/kopytko-framework/issues/11)) ([7c968c3](https://github.com/getndazn/kopytko-framework/commit/7c968c3ef3e53b499543ba5ef5bda733798d8363))