@akylas/nativescript 8.2.3 → 8.3.0-alpha.2

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.
Files changed (187) hide show
  1. package/accessibility/index.ios.js +1 -1
  2. package/accessibility/index.ios.js.map +1 -1
  3. package/application/application-common.js.map +1 -1
  4. package/application/index.android.js.map +1 -1
  5. package/application/index.ios.d.ts +2 -0
  6. package/application/index.ios.js +7 -1
  7. package/application/index.ios.js.map +1 -1
  8. package/cli-hooks/before-checkForChanges.js +21 -16
  9. package/color/color-common.js +15 -9
  10. package/color/color-common.js.map +1 -1
  11. package/connectivity/index.android.js +11 -10
  12. package/connectivity/index.android.js.map +1 -1
  13. package/core-types/index.d.ts +1 -0
  14. package/core-types/index.js.map +1 -1
  15. package/css/LICENSE +9 -0
  16. package/css/Readme.md +278 -0
  17. package/css-value/LICENSE +9 -0
  18. package/css-value/Readme.md +45 -0
  19. package/css-value/UPGRADING.md +26 -0
  20. package/fetch/LICENSE +20 -0
  21. package/fetch/README.md +1 -0
  22. package/image-source/index.android.js +4 -7
  23. package/image-source/index.android.js.map +1 -1
  24. package/image-source/index.ios.js +3 -9
  25. package/image-source/index.ios.js.map +1 -1
  26. package/index.d.ts +8 -2
  27. package/index.js +13 -2
  28. package/index.js.map +1 -1
  29. package/jest.config.d.ts +5 -0
  30. package/jest.config.js.map +1 -0
  31. package/js-libs/easysax/LICENSE +20 -0
  32. package/js-libs/easysax/README.md +46 -0
  33. package/js-libs/esprima/LICENSE.BSD +19 -0
  34. package/js-libs/esprima/README.md +24 -0
  35. package/js-libs/polymer-expressions/LICENSE +27 -0
  36. package/js-libs/polymer-expressions/README.md +0 -0
  37. package/package.json +5 -13
  38. package/platforms/README.md +1 -0
  39. package/platforms/android/widgets-release.aar +0 -0
  40. package/platforms/ios/TNSWidgets.xcframework/Info.plist +17 -0
  41. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Info.plist +0 -0
  42. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/TNSWidgets +0 -0
  43. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  44. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSData+Async.h +24 -0
  45. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/NSString+Async.h +25 -0
  46. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSLabel.h +16 -0
  47. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSProcess.h +29 -0
  48. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/TNSWidgets.h +24 -0
  49. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/UIImage+TNSBlocks.h +26 -0
  50. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Headers/UIView+PassThroughParent.h +17 -0
  51. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Modules/module.modulemap +6 -0
  52. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/PrivateHeaders/NSObject+Swizzling.h +17 -0
  53. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/PrivateHeaders/UIView+PropertyBag.h +18 -0
  54. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Resources/Info.plist +52 -0
  55. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/TNSWidgets +0 -0
  56. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSData+Async.h +24 -0
  57. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/NSString+Async.h +25 -0
  58. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSLabel.h +16 -0
  59. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSProcess.h +29 -0
  60. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/TNSWidgets.h +24 -0
  61. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/UIImage+TNSBlocks.h +26 -0
  62. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Headers/UIView+PassThroughParent.h +17 -0
  63. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Modules/module.modulemap +6 -0
  64. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/PrivateHeaders/NSObject+Swizzling.h +17 -0
  65. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/PrivateHeaders/UIView+PropertyBag.h +18 -0
  66. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Resources/Info.plist +52 -0
  67. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/TNSWidgets +0 -0
  68. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/TNSWidgets +0 -0
  69. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Info.plist +20 -0
  70. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  71. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
  72. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
  73. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +1 -1
  74. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  75. package/ui/animation/animation-common.d.ts +7 -4
  76. package/ui/animation/animation-common.js +55 -117
  77. package/ui/animation/animation-common.js.map +1 -1
  78. package/ui/animation/animation-interfaces.d.ts +3 -2
  79. package/ui/animation/index.android.d.ts +15 -14
  80. package/ui/animation/index.android.js +94 -20
  81. package/ui/animation/index.android.js.map +1 -1
  82. package/ui/animation/index.ios.d.ts +33 -16
  83. package/ui/animation/index.ios.js +256 -202
  84. package/ui/animation/index.ios.js.map +1 -1
  85. package/ui/animation/keyframe-animation.d.ts +0 -1
  86. package/ui/animation/keyframe-animation.js +51 -51
  87. package/ui/animation/keyframe-animation.js.map +1 -1
  88. package/ui/button/index.ios.js +1 -1
  89. package/ui/button/index.ios.js.map +1 -1
  90. package/ui/core/properties/index.d.ts +37 -6
  91. package/ui/core/properties/index.js +434 -643
  92. package/ui/core/properties/index.js.map +1 -1
  93. package/ui/core/view/index.d.ts +5 -0
  94. package/ui/core/view/index.ios.d.ts +4 -2
  95. package/ui/core/view/index.ios.js +33 -10
  96. package/ui/core/view/index.ios.js.map +1 -1
  97. package/ui/core/view/view-common.d.ts +1 -0
  98. package/ui/core/view/view-common.js +6 -3
  99. package/ui/core/view/view-common.js.map +1 -1
  100. package/ui/core/view/view-helper/index.ios.d.ts +2 -0
  101. package/ui/core/view/view-helper/index.ios.js +13 -4
  102. package/ui/core/view/view-helper/index.ios.js.map +1 -1
  103. package/ui/core/view-base/index.js +4 -5
  104. package/ui/core/view-base/index.js.map +1 -1
  105. package/ui/editable-text-base/editable-text-base-common.js +2 -1
  106. package/ui/editable-text-base/editable-text-base-common.js.map +1 -1
  107. package/ui/frame/frame-common.d.ts +1 -1
  108. package/ui/frame/frame-common.js +17 -17
  109. package/ui/frame/frame-common.js.map +1 -1
  110. package/ui/frame/index.android.js +6 -2
  111. package/ui/frame/index.android.js.map +1 -1
  112. package/ui/frame/index.ios.js +2 -0
  113. package/ui/frame/index.ios.js.map +1 -1
  114. package/ui/html-view/html-view-common.js +2 -1
  115. package/ui/html-view/html-view-common.js.map +1 -1
  116. package/ui/image/image-common.js +2 -2
  117. package/ui/image/image-common.js.map +1 -1
  118. package/ui/label/index.ios.js +2 -2
  119. package/ui/label/index.ios.js.map +1 -1
  120. package/ui/layouts/root-layout/root-layout-common.js +6 -4
  121. package/ui/layouts/root-layout/root-layout-common.js.map +1 -1
  122. package/ui/list-view/list-view-common.js +2 -2
  123. package/ui/list-view/list-view-common.js.map +1 -1
  124. package/ui/page/index.ios.d.ts +1 -0
  125. package/ui/page/index.ios.js +5 -0
  126. package/ui/page/index.ios.js.map +1 -1
  127. package/ui/page/page-common.js +2 -1
  128. package/ui/page/page-common.js.map +1 -1
  129. package/ui/proxy-view-container/index.d.ts +2 -0
  130. package/ui/proxy-view-container/index.js +28 -0
  131. package/ui/proxy-view-container/index.js.map +1 -1
  132. package/ui/search-bar/search-bar-common.js +3 -2
  133. package/ui/search-bar/search-bar-common.js.map +1 -1
  134. package/ui/segmented-bar/segmented-bar-common.js +2 -1
  135. package/ui/segmented-bar/segmented-bar-common.js.map +1 -1
  136. package/ui/styling/css-animation-parser.js +3 -2
  137. package/ui/styling/css-animation-parser.js.map +1 -1
  138. package/ui/styling/font.ios.js +23 -2
  139. package/ui/styling/font.ios.js.map +1 -1
  140. package/ui/styling/style/index.d.ts +3 -1
  141. package/ui/styling/style/index.js +6 -0
  142. package/ui/styling/style/index.js.map +1 -1
  143. package/ui/styling/style-properties.d.ts +1 -0
  144. package/ui/styling/style-properties.js +57 -69
  145. package/ui/styling/style-properties.js.map +1 -1
  146. package/ui/styling/style-scope.js +4 -10
  147. package/ui/styling/style-scope.js.map +1 -1
  148. package/ui/switch/index.android.js +8 -6
  149. package/ui/switch/index.android.js.map +1 -1
  150. package/ui/switch/switch-common.js +2 -1
  151. package/ui/switch/switch-common.js.map +1 -1
  152. package/ui/tab-view/index.ios.d.ts +1 -0
  153. package/ui/tab-view/index.ios.js +54 -24
  154. package/ui/tab-view/index.ios.js.map +1 -1
  155. package/ui/tab-view/tab-view-common.js +5 -4
  156. package/ui/tab-view/tab-view-common.js.map +1 -1
  157. package/ui/text-base/index.android.js +1 -1
  158. package/ui/text-base/index.android.js.map +1 -1
  159. package/ui/text-base/index.d.ts +5 -0
  160. package/ui/text-base/index.ios.js +4 -3
  161. package/ui/text-base/index.ios.js.map +1 -1
  162. package/ui/text-base/text-base-common.d.ts +3 -3
  163. package/ui/text-base/text-base-common.js +1 -1
  164. package/ui/text-base/text-base-common.js.map +1 -1
  165. package/ui/web-view/index.android.js +4 -2
  166. package/ui/web-view/index.android.js.map +1 -1
  167. package/utils/index.android.d.ts +1 -1
  168. package/utils/index.android.js +1 -1
  169. package/utils/index.android.js.map +1 -1
  170. package/utils/index.ios.d.ts +1 -1
  171. package/utils/index.ios.js +1 -1
  172. package/utils/index.ios.js.map +1 -1
  173. package/utils/mainthread-helper.ios.d.ts +1 -1
  174. package/utils/mainthread-helper.ios.js +7 -9
  175. package/utils/mainthread-helper.ios.js.map +1 -1
  176. package/utils/native-helper.android.d.ts +2 -0
  177. package/utils/native-helper.android.js +127 -0
  178. package/utils/native-helper.android.js.map +1 -1
  179. package/utils/native-helper.d.ts +22 -0
  180. package/utils/native-helper.ios.d.ts +3 -0
  181. package/utils/native-helper.ios.js +90 -0
  182. package/utils/native-helper.ios.js.map +1 -1
  183. package/utils/types.d.ts +2 -0
  184. package/utils/types.js +6 -0
  185. package/utils/types.js.map +1 -1
  186. package/platforms/android/core.aar +0 -0
  187. package/platforms/android/nativescript.aar +0 -0
@@ -11,19 +11,6 @@ const symbolPropertyMap = {};
11
11
  const cssSymbolPropertyMap = {};
12
12
  const inheritableProperties = new Array();
13
13
  const inheritableCssProperties = new Array();
14
- function print(map) {
15
- const symbols = Object.getOwnPropertySymbols(map);
16
- for (const symbol of symbols) {
17
- const prop = map[symbol];
18
- if (!prop.registered) {
19
- console.log(`Property ${prop.name} not Registered!!!!!`);
20
- }
21
- }
22
- }
23
- export function _printUnregisteredProperties() {
24
- print(symbolPropertyMap);
25
- print(cssSymbolPropertyMap);
26
- }
27
14
  export function _getProperties() {
28
15
  return getPropertiesFromMap(symbolPropertyMap);
29
16
  }
@@ -94,155 +81,186 @@ function getPropertiesFromMap(map) {
94
81
  Object.getOwnPropertySymbols(map).forEach((symbol) => props.push(map[symbol]));
95
82
  return props;
96
83
  }
97
- export class Property {
98
- constructor(options) {
99
- this.enumerable = true;
100
- this.configurable = true;
101
- const propertyName = options.name;
102
- this.name = propertyName;
103
- const key = Symbol(propertyName + ':propertyKey');
104
- this.key = key;
105
- const getDefault = Symbol(propertyName + ':getDefault');
106
- this.getDefault = getDefault;
107
- const setNative = Symbol(propertyName + ':setNative');
108
- this.setNative = setNative;
109
- const defaultValueKey = Symbol(propertyName + ':nativeDefaultValue');
110
- this.defaultValueKey = defaultValueKey;
111
- const defaultValue = options.defaultValue;
112
- this.defaultValue = defaultValue;
113
- const eventName = propertyName + 'Change';
114
- let equalityComparer = options.equalityComparer;
115
- let affectsLayout = options.affectsLayout;
116
- let valueChanged = options.valueChanged;
117
- let valueConverter = options.valueConverter;
118
- this.overrideHandlers = function (options) {
119
- if (typeof options.equalityComparer !== 'undefined') {
120
- equalityComparer = options.equalityComparer;
121
- }
122
- if (typeof options.affectsLayout !== 'undefined') {
123
- affectsLayout = options.affectsLayout;
84
+ function overrideHandlers(property) {
85
+ return function (options) {
86
+ if (property instanceof CssAnimationProperty || property instanceof CssProperty || property instanceof ShorthandProperty) {
87
+ Object.keys(options).forEach((key) => {
88
+ if (key === 'cssName') {
89
+ if (options[key] !== undefined) {
90
+ //@ts-ignore ignore readonly
91
+ property.cssName = 'css:' + options[key];
92
+ //@ts-ignore ignore readonly
93
+ property.cssLocalName = options[key];
94
+ }
95
+ }
96
+ else if (options[key] !== undefined) {
97
+ property[key] = options[key];
98
+ }
99
+ });
100
+ }
101
+ else {
102
+ Object.keys(options).forEach((key) => {
103
+ if (options[key] !== undefined) {
104
+ property[key] = options[key];
105
+ }
106
+ });
107
+ }
108
+ };
109
+ }
110
+ function getPropertySetter(property) {
111
+ return function (boxedValue) {
112
+ const reset = boxedValue === unsetValue;
113
+ let value;
114
+ let wrapped;
115
+ const key = property.key;
116
+ const defaultValue = property.defaultValue;
117
+ if (reset) {
118
+ value = property.defaultValue;
119
+ if (property instanceof CoercibleProperty) {
120
+ delete this[property.coerceKey];
124
121
  }
125
- if (typeof options.valueChanged !== 'undefined') {
126
- valueChanged = options.valueChanged;
122
+ }
123
+ else {
124
+ wrapped = boxedValue && boxedValue.wrapped;
125
+ value = wrapped ? WrappedValue.unwrap(boxedValue) : boxedValue;
126
+ if (property.valueConverter && typeof value === 'string') {
127
+ value = property.valueConverter(value);
127
128
  }
128
- if (typeof options.valueConverter !== 'undefined') {
129
- valueConverter = options.valueConverter;
129
+ if (property instanceof CoercibleProperty) {
130
+ this[property.coerceKey] = value;
131
+ value = property.coerceValue(this, value);
130
132
  }
131
- };
132
- const property = this;
133
- this.set = function (boxedValue) {
134
- const reset = boxedValue === unsetValue;
135
- let value;
136
- let wrapped;
133
+ }
134
+ const oldValue = key in this ? this[key] : defaultValue;
135
+ const changed = property.equalityComparer ? !property.equalityComparer(oldValue, value) : oldValue !== value;
136
+ if (wrapped || changed) {
137
+ const defaultValueKey = property.defaultValueKey;
138
+ const setNative = property.setNative;
139
+ const valueChanged = property.valueChanged;
140
+ const getDefault = property.getDefault;
141
+ const eventName = property.eventName;
142
+ const propertyName = property.name;
137
143
  if (reset) {
138
- value = defaultValue;
139
- }
140
- else {
141
- wrapped = boxedValue && boxedValue.wrapped;
142
- value = wrapped ? WrappedValue.unwrap(boxedValue) : boxedValue;
143
- if (valueConverter && typeof value === 'string') {
144
- value = valueConverter(value);
145
- }
146
- }
147
- const oldValue = key in this ? this[key] : defaultValue;
148
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
149
- if (wrapped || changed) {
150
- if (affectsLayout) {
151
- this.requestLayout();
144
+ delete this[key];
145
+ if (valueChanged) {
146
+ valueChanged(this, oldValue, value);
152
147
  }
153
- if (reset) {
154
- delete this[key];
155
- if (valueChanged) {
156
- valueChanged(this, oldValue, value);
157
- }
158
- if (this[setNative]) {
159
- if (this._suspendNativeUpdatesCount) {
160
- if (this._suspendedUpdates) {
161
- this._suspendedUpdates[propertyName] = property;
162
- }
163
- }
164
- else {
165
- if (defaultValueKey in this) {
166
- this[setNative](this[defaultValueKey]);
167
- delete this[defaultValueKey];
168
- }
169
- else {
170
- this[setNative](defaultValue);
171
- }
148
+ if (this[setNative]) {
149
+ if (this._suspendNativeUpdatesCount) {
150
+ if (this._suspendedUpdates) {
151
+ this._suspendedUpdates[propertyName] = property;
172
152
  }
173
153
  }
174
- }
175
- else {
176
- this[key] = value;
177
- if (valueChanged) {
178
- valueChanged(this, oldValue, value);
179
- }
180
- if (this[setNative]) {
181
- if (this._suspendNativeUpdatesCount) {
182
- if (this._suspendedUpdates) {
183
- this._suspendedUpdates[propertyName] = property;
184
- }
154
+ else {
155
+ if (defaultValueKey in this) {
156
+ this[setNative](this[defaultValueKey]);
157
+ delete this[defaultValueKey];
185
158
  }
186
159
  else {
187
- if (!(defaultValueKey in this)) {
188
- this[defaultValueKey] = this[getDefault] ? this[getDefault]() : defaultValue;
189
- }
190
- this[setNative](value);
160
+ this[setNative](defaultValue);
191
161
  }
192
162
  }
193
163
  }
194
- if (this.hasListeners(eventName)) {
195
- this.notify({
196
- object: this,
197
- eventName,
198
- propertyName,
199
- value,
200
- oldValue,
201
- });
164
+ }
165
+ else {
166
+ this[key] = value;
167
+ if (valueChanged) {
168
+ valueChanged(this, oldValue, value);
202
169
  }
203
- if (this.domNode) {
204
- if (reset) {
205
- this.domNode.attributeRemoved(propertyName);
170
+ if (this[setNative]) {
171
+ if (this._suspendNativeUpdatesCount) {
172
+ if (this._suspendedUpdates) {
173
+ this._suspendedUpdates[propertyName] = property;
174
+ }
206
175
  }
207
176
  else {
208
- this.domNode.attributeModified(propertyName, value);
177
+ if (!(defaultValueKey in this)) {
178
+ this[defaultValueKey] = this[getDefault] ? this[getDefault]() : defaultValue;
179
+ }
180
+ this[setNative](value);
209
181
  }
210
182
  }
211
183
  }
212
- };
213
- this.get = function () {
214
- return key in this ? this[key] : defaultValue;
215
- };
216
- this.nativeValueChange = function (owner, value) {
217
- const oldValue = key in owner ? owner[key] : defaultValue;
218
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
219
- if (changed) {
220
- owner[key] = value;
221
- if (valueChanged) {
222
- valueChanged(owner, oldValue, value);
223
- }
224
- if (owner.nativeViewProtected && !(defaultValueKey in owner)) {
225
- owner[defaultValueKey] = owner[getDefault] ? owner[getDefault]() : defaultValue;
226
- }
227
- if (owner.hasListeners(eventName)) {
228
- owner.notify({
229
- object: owner,
230
- eventName,
231
- propertyName,
232
- value,
233
- oldValue,
234
- });
235
- }
236
- if (affectsLayout) {
237
- owner.requestLayout();
184
+ if (this.hasListeners(eventName)) {
185
+ this.notify({
186
+ object: this,
187
+ eventName,
188
+ propertyName,
189
+ value,
190
+ oldValue,
191
+ });
192
+ }
193
+ if (property.affectsLayout) {
194
+ this.requestLayout();
195
+ }
196
+ if (this.domNode) {
197
+ if (reset) {
198
+ this.domNode.attributeRemoved(propertyName);
238
199
  }
239
- if (owner.domNode) {
240
- owner.domNode.attributeModified(propertyName, value);
200
+ else {
201
+ this.domNode.attributeModified(propertyName, value);
241
202
  }
242
203
  }
204
+ }
205
+ };
206
+ }
207
+ export class Property {
208
+ constructor(options) {
209
+ this.enumerable = true;
210
+ this.configurable = true;
211
+ this.overrideHandlers = overrideHandlers(this);
212
+ this.overrideHandlers(options);
213
+ const propertyName = this.name;
214
+ const key = Symbol(propertyName + ':propertyKey');
215
+ this.key = key;
216
+ const getDefault = Symbol(propertyName + ':getDefault');
217
+ this.getDefault = getDefault;
218
+ const setNative = Symbol(propertyName + ':setNative');
219
+ this.setNative = setNative;
220
+ const defaultValueKey = Symbol(propertyName + ':nativeDefaultValue');
221
+ this.defaultValueKey = defaultValueKey;
222
+ this.eventName = propertyName + 'Change';
223
+ const property = this;
224
+ this.set = getPropertySetter(this);
225
+ this.get = function () {
226
+ return key in this ? this[key] : property.defaultValue;
243
227
  };
244
228
  symbolPropertyMap[key] = this;
245
229
  }
230
+ nativeValueChange(owner, value) {
231
+ const key = this.key;
232
+ const defaultValue = this.defaultValue;
233
+ const oldValue = key in owner ? owner[key] : defaultValue;
234
+ const changed = this.equalityComparer ? !this.equalityComparer(oldValue, value) : oldValue !== value;
235
+ if (changed) {
236
+ const defaultValueKey = this.defaultValueKey;
237
+ const getDefault = this.getDefault;
238
+ const eventName = this.eventName;
239
+ const propertyName = this.name;
240
+ owner[key] = value;
241
+ if (this.valueChanged) {
242
+ this.valueChanged(owner, oldValue, value);
243
+ }
244
+ if (owner.nativeViewProtected && !(defaultValueKey in owner)) {
245
+ owner[defaultValueKey] = owner[getDefault] ? owner[getDefault]() : defaultValue;
246
+ }
247
+ if (owner.hasListeners(eventName)) {
248
+ owner.notify({
249
+ object: owner,
250
+ eventName,
251
+ propertyName,
252
+ value,
253
+ oldValue,
254
+ });
255
+ }
256
+ if (this.affectsLayout) {
257
+ owner.requestLayout();
258
+ }
259
+ if (owner.domNode) {
260
+ owner.domNode.attributeModified(propertyName, value);
261
+ }
262
+ }
263
+ }
246
264
  register(cls) {
247
265
  if (this.registered) {
248
266
  throw new Error(`Property ${this.name} already registered.`);
@@ -258,136 +276,22 @@ Property.prototype.isStyleProperty = false;
258
276
  export class CoercibleProperty extends Property {
259
277
  constructor(options) {
260
278
  super(options);
261
- const propertyName = options.name;
262
- const key = this.key;
263
- const getDefault = this.getDefault;
264
- const setNative = this.setNative;
265
- const defaultValueKey = this.defaultValueKey;
266
- const defaultValue = this.defaultValue;
267
- const coerceKey = Symbol(propertyName + ':coerceKey');
268
- const eventName = propertyName + 'Change';
269
- let affectsLayout = options.affectsLayout;
270
- let equalityComparer = options.equalityComparer;
271
- let valueChanged = options.valueChanged;
272
- let valueConverter = options.valueConverter;
273
- let coerceCallback = options.coerceValue;
274
- const property = this;
275
- this.overrideHandlers = function (options) {
276
- if (typeof options.equalityComparer !== 'undefined') {
277
- equalityComparer = options.equalityComparer;
278
- }
279
- if (typeof options.affectsLayout !== 'undefined') {
280
- affectsLayout = options.affectsLayout;
281
- }
282
- if (typeof options.valueChanged !== 'undefined') {
283
- valueChanged = options.valueChanged;
284
- }
285
- if (typeof options.valueConverter !== 'undefined') {
286
- valueConverter = options.valueConverter;
287
- }
288
- if (typeof options.coerceValue !== 'undefined') {
289
- coerceCallback = options.coerceValue;
290
- }
291
- };
292
- this.coerce = function (target) {
293
- const originalValue = coerceKey in target ? target[coerceKey] : defaultValue;
294
- // need that to make coercing but also fire change events
295
- target[propertyName] = originalValue;
296
- };
297
- this.set = function (boxedValue) {
298
- const reset = boxedValue === unsetValue;
299
- let value;
300
- let wrapped;
301
- if (reset) {
302
- value = defaultValue;
303
- delete this[coerceKey];
304
- }
305
- else {
306
- wrapped = boxedValue && boxedValue.wrapped;
307
- value = wrapped ? WrappedValue.unwrap(boxedValue) : boxedValue;
308
- if (valueConverter && typeof value === 'string') {
309
- value = valueConverter(value);
310
- }
311
- this[coerceKey] = value;
312
- value = coerceCallback(this, value);
313
- }
314
- const oldValue = key in this ? this[key] : defaultValue;
315
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
316
- if (wrapped || changed) {
317
- if (reset) {
318
- delete this[key];
319
- if (valueChanged) {
320
- valueChanged(this, oldValue, value);
321
- }
322
- if (this[setNative]) {
323
- if (this._suspendNativeUpdatesCount) {
324
- if (this._suspendedUpdates) {
325
- this._suspendedUpdates[propertyName] = property;
326
- }
327
- }
328
- else {
329
- if (defaultValueKey in this) {
330
- this[setNative](this[defaultValueKey]);
331
- delete this[defaultValueKey];
332
- }
333
- else {
334
- this[setNative](defaultValue);
335
- }
336
- }
337
- }
338
- }
339
- else {
340
- this[key] = value;
341
- if (valueChanged) {
342
- valueChanged(this, oldValue, value);
343
- }
344
- if (this[setNative]) {
345
- if (this._suspendNativeUpdatesCount) {
346
- if (this._suspendedUpdates) {
347
- this._suspendedUpdates[propertyName] = property;
348
- }
349
- }
350
- else {
351
- if (!(defaultValueKey in this)) {
352
- this[defaultValueKey] = this[getDefault] ? this[getDefault]() : defaultValue;
353
- }
354
- this[setNative](value);
355
- }
356
- }
357
- }
358
- if (this.hasListeners(eventName)) {
359
- this.notify({
360
- object: this,
361
- eventName,
362
- propertyName,
363
- value,
364
- oldValue,
365
- });
366
- }
367
- if (affectsLayout) {
368
- this.requestLayout();
369
- }
370
- if (this.domNode) {
371
- if (reset) {
372
- this.domNode.attributeRemoved(propertyName);
373
- }
374
- else {
375
- this.domNode.attributeModified(propertyName, value);
376
- }
377
- }
378
- }
379
- };
279
+ this.coerceKey = Symbol(this.name + ':coerceKey');
280
+ }
281
+ coerce(target) {
282
+ const originalValue = this.coerceKey in target ? target[this.coerceKey] : this.defaultValue;
283
+ // need that to make coercing but also fire change events
284
+ target[this.name] = originalValue;
380
285
  }
381
286
  }
382
287
  export class InheritedProperty extends Property {
383
288
  constructor(options) {
384
289
  super(options);
385
- const name = options.name;
386
290
  const key = this.key;
387
- const defaultValue = options.defaultValue;
388
- const sourceKey = Symbol(name + ':valueSourceKey');
291
+ const sourceKey = Symbol(this.name + ':valueSourceKey');
389
292
  this.sourceKey = sourceKey;
390
293
  const setBase = this.set;
294
+ const property = this;
391
295
  const setFunc = (valueSource) => function (value) {
392
296
  const that = this;
393
297
  let unboxedValue;
@@ -397,11 +301,11 @@ export class InheritedProperty extends Property {
397
301
  const parent = that.parent;
398
302
  // If we have parent and it has non-default value we use as our inherited value.
399
303
  if (parent && parent[sourceKey] !== 0 /* Default */) {
400
- unboxedValue = parent[name];
304
+ unboxedValue = parent[property.name];
401
305
  newValueSource = 1 /* Inherited */;
402
306
  }
403
307
  else {
404
- unboxedValue = defaultValue;
308
+ unboxedValue = property.defaultValue;
405
309
  newValueSource = 0 /* Default */;
406
310
  }
407
311
  }
@@ -439,212 +343,133 @@ export class InheritedProperty extends Property {
439
343
  inheritableProperties.push(this);
440
344
  }
441
345
  }
442
- export class CssProperty {
443
- constructor(options) {
444
- const propertyName = options.name;
445
- this.name = propertyName;
446
- cssPropertyNames.push(options.cssName);
447
- this.cssName = `css:${options.cssName}`;
448
- this.cssLocalName = options.cssName;
449
- const key = Symbol(propertyName + ':propertyKey');
450
- this.key = key;
451
- const sourceKey = Symbol(propertyName + ':valueSourceKey');
452
- this.sourceKey = sourceKey;
453
- const getDefault = Symbol(propertyName + ':getDefault');
454
- this.getDefault = getDefault;
455
- const setNative = Symbol(propertyName + ':setNative');
456
- this.setNative = setNative;
457
- const defaultValueKey = Symbol(propertyName + ':nativeDefaultValue');
458
- this.defaultValueKey = defaultValueKey;
459
- const defaultValue = options.defaultValue;
460
- this.defaultValue = defaultValue;
461
- const eventName = propertyName + 'Change';
462
- let affectsLayout = options.affectsLayout;
463
- let equalityComparer = options.equalityComparer;
464
- let valueChanged = options.valueChanged;
465
- let valueConverter = options.valueConverter;
466
- this.overrideHandlers = function (options) {
467
- if (typeof options.equalityComparer !== 'undefined') {
468
- equalityComparer = options.equalityComparer;
469
- }
470
- if (typeof options.affectsLayout !== 'undefined') {
471
- affectsLayout = options.affectsLayout;
472
- }
473
- if (typeof options.valueChanged !== 'undefined') {
474
- valueChanged = options.valueChanged;
475
- }
476
- if (typeof options.valueConverter !== 'undefined') {
477
- valueConverter = options.valueConverter;
478
- }
479
- };
480
- const property = this;
481
- function setLocalValue(newValue) {
482
- const view = this.viewRef.get();
483
- if (!view) {
484
- Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
485
- return;
486
- }
487
- const reset = newValue === unsetValue || newValue === '';
488
- let value;
489
- if (reset) {
490
- value = defaultValue;
491
- delete this[sourceKey];
492
- }
493
- else {
494
- this[sourceKey] = 3 /* Local */;
495
- value = valueConverter && typeof newValue === 'string' ? valueConverter(newValue) : newValue;
496
- }
497
- const oldValue = key in this ? this[key] : defaultValue;
498
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
499
- if (changed) {
500
- if (reset) {
501
- delete this[key];
502
- if (valueChanged) {
503
- valueChanged(this, oldValue, value);
504
- }
505
- if (view[setNative]) {
506
- if (view._suspendNativeUpdatesCount) {
507
- if (view._suspendedUpdates) {
508
- view._suspendedUpdates[propertyName] = property;
509
- }
510
- }
511
- else {
512
- if (defaultValueKey in this) {
513
- view[setNative](this[defaultValueKey]);
514
- delete this[defaultValueKey];
515
- }
516
- else {
517
- view[setNative](defaultValue);
518
- }
519
- }
520
- }
521
- }
522
- else {
523
- this[key] = value;
524
- if (valueChanged) {
525
- valueChanged(this, oldValue, value);
526
- }
527
- if (view[setNative]) {
528
- if (view._suspendNativeUpdatesCount) {
529
- if (view._suspendedUpdates) {
530
- view._suspendedUpdates[propertyName] = property;
531
- }
532
- }
533
- else {
534
- if (!(defaultValueKey in this)) {
535
- this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
536
- }
537
- view[setNative](value);
538
- }
539
- }
540
- }
541
- if (this.hasListeners(eventName)) {
542
- this.notify({
543
- object: this,
544
- eventName,
545
- propertyName,
546
- value,
547
- oldValue,
548
- });
549
- }
550
- if (affectsLayout) {
551
- view.requestLayout();
552
- }
553
- }
346
+ function setCssFunc(property, valueSource) {
347
+ return function (newValue) {
348
+ const view = this.viewRef.get();
349
+ if (!view) {
350
+ Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
351
+ return;
554
352
  }
555
- function setCssValue(newValue) {
556
- const view = this.viewRef.get();
557
- if (!view) {
558
- Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
559
- return;
560
- }
353
+ const sourceKey = property.sourceKey;
354
+ if (valueSource === 2 /* Css */) {
561
355
  const currentValueSource = this[sourceKey] || 0 /* Default */;
562
356
  // We have localValueSource - NOOP.
563
357
  if (currentValueSource === 3 /* Local */) {
564
358
  return;
565
359
  }
566
- const reset = newValue === unsetValue || newValue === '';
567
- let value;
360
+ }
361
+ const defaultValue = property.defaultValue;
362
+ const key = property.key;
363
+ const reset = newValue === unsetValue || newValue === '';
364
+ let value;
365
+ if (reset) {
366
+ value = defaultValue;
367
+ delete this[sourceKey];
368
+ }
369
+ else {
370
+ this[sourceKey] = valueSource;
371
+ value = property.valueConverter && typeof newValue === 'string' ? property.valueConverter(newValue) : newValue;
372
+ }
373
+ const oldValue = key in this ? this[key] : defaultValue;
374
+ const changed = property.equalityComparer ? !property.equalityComparer(oldValue, value) : oldValue !== value;
375
+ if (changed) {
376
+ const setNative = property.setNative;
377
+ const defaultValueKey = property.defaultValueKey;
378
+ const propertyName = property.name;
379
+ const valueChanged = property.valueChanged;
380
+ const eventName = property.eventName;
568
381
  if (reset) {
569
- value = defaultValue;
570
- delete this[sourceKey];
571
- }
572
- else {
573
- value = valueConverter && typeof newValue === 'string' ? valueConverter(newValue) : newValue;
574
- this[sourceKey] = 2 /* Css */;
575
- }
576
- const oldValue = key in this ? this[key] : defaultValue;
577
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
578
- if (changed) {
579
- if (reset) {
580
- delete this[key];
581
- if (valueChanged) {
582
- valueChanged(this, oldValue, value);
382
+ delete this[key];
383
+ if (valueChanged) {
384
+ valueChanged(this, oldValue, value);
385
+ }
386
+ if (view[setNative]) {
387
+ if (view._suspendNativeUpdatesCount) {
388
+ if (view._suspendedUpdates) {
389
+ view._suspendedUpdates[propertyName] = property;
390
+ }
583
391
  }
584
- if (view[setNative]) {
585
- if (view._suspendNativeUpdatesCount) {
586
- if (view._suspendedUpdates) {
587
- view._suspendedUpdates[propertyName] = property;
588
- }
392
+ else {
393
+ if (defaultValueKey in this) {
394
+ view[setNative](this[defaultValueKey]);
395
+ delete this[defaultValueKey];
589
396
  }
590
397
  else {
591
- if (defaultValueKey in this) {
592
- view[setNative](this[defaultValueKey]);
593
- delete this[defaultValueKey];
594
- }
595
- else {
596
- view[setNative](defaultValue);
597
- }
398
+ view[setNative](defaultValue);
598
399
  }
599
400
  }
600
401
  }
601
- else {
602
- this[key] = value;
603
- if (valueChanged) {
604
- valueChanged(this, oldValue, value);
605
- }
606
- if (view[setNative]) {
607
- if (view._suspendNativeUpdatesCount) {
608
- if (view._suspendedUpdates) {
609
- view._suspendedUpdates[propertyName] = property;
610
- }
402
+ }
403
+ else {
404
+ this[key] = value;
405
+ if (valueChanged) {
406
+ valueChanged(this, oldValue, value);
407
+ }
408
+ if (view[setNative]) {
409
+ if (view._suspendNativeUpdatesCount) {
410
+ if (view._suspendedUpdates) {
411
+ view._suspendedUpdates[propertyName] = property;
611
412
  }
612
- else {
613
- if (!(defaultValueKey in this)) {
614
- this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
615
- }
616
- view[setNative](value);
413
+ }
414
+ else {
415
+ if (!(defaultValueKey in this)) {
416
+ const getDefault = property.getDefault;
417
+ this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
617
418
  }
419
+ view[setNative](value);
618
420
  }
619
421
  }
620
- if (this.hasListeners(eventName)) {
621
- this.notify({
622
- object: this,
623
- eventName,
624
- propertyName,
625
- value,
626
- oldValue,
627
- });
628
- }
629
- if (affectsLayout) {
630
- view.requestLayout();
631
- }
632
422
  }
423
+ if (this.hasListeners(eventName)) {
424
+ this.notify({
425
+ object: this,
426
+ eventName,
427
+ propertyName,
428
+ value,
429
+ oldValue,
430
+ });
431
+ }
432
+ if (property.affectsLayout) {
433
+ view.requestLayout();
434
+ }
435
+ }
436
+ };
437
+ }
438
+ export class CssProperty {
439
+ constructor(options) {
440
+ this.overrideHandlers = overrideHandlers(this);
441
+ this.overrideHandlers(options);
442
+ const propertyName = this.name;
443
+ CssProperty.properties[propertyName] = this;
444
+ if (this.cssLocalName && this.cssLocalName !== propertyName) {
445
+ CssProperty.properties[this.cssLocalName] = this;
633
446
  }
447
+ const key = Symbol(propertyName + ':propertyKey');
448
+ this.key = key;
449
+ const sourceKey = Symbol(propertyName + ':valueSourceKey');
450
+ this.sourceKey = sourceKey;
451
+ const getDefault = Symbol(propertyName + ':getDefault');
452
+ this.getDefault = getDefault;
453
+ const setNative = Symbol(propertyName + ':setNative');
454
+ this.setNative = setNative;
455
+ const defaultValueKey = Symbol(propertyName + ':nativeDefaultValue');
456
+ this.defaultValueKey = defaultValueKey;
457
+ this.eventName = propertyName + 'Change';
458
+ const property = this;
634
459
  function get() {
635
- return key in this ? this[key] : defaultValue;
460
+ return key in this ? this[key] : property.defaultValue;
636
461
  }
637
462
  this.cssValueDescriptor = {
638
463
  enumerable: true,
639
464
  configurable: true,
640
465
  get: get,
641
- set: setCssValue,
466
+ set: setCssFunc(this, 2 /* Css */),
642
467
  };
643
468
  this.localValueDescriptor = {
644
469
  enumerable: true,
645
470
  configurable: true,
646
471
  get: get,
647
- set: setLocalValue,
472
+ set: setCssFunc(this, 3 /* Local */),
648
473
  };
649
474
  cssSymbolPropertyMap[key] = this;
650
475
  }
@@ -652,6 +477,8 @@ export class CssProperty {
652
477
  if (this.registered) {
653
478
  throw new Error(`Property ${this.name} already registered.`);
654
479
  }
480
+ // we add it so that overrideHandlers might work
481
+ cssPropertyNames.push(this.cssLocalName);
655
482
  this.registered = true;
656
483
  Object.defineProperty(cls.prototype, this.name, this.localValueDescriptor);
657
484
  Object.defineProperty(cls.prototype, this.cssName, this.cssValueDescriptor);
@@ -663,28 +490,23 @@ export class CssProperty {
663
490
  return this.key in instance;
664
491
  }
665
492
  }
493
+ CssProperty.properties = {};
666
494
  CssProperty.prototype.isStyleProperty = true;
667
495
  export class CssAnimationProperty {
668
496
  constructor(options) {
669
- const propertyName = options.name;
670
- this.name = propertyName;
671
- cssPropertyNames.push(options.cssName);
497
+ this.overrideHandlers = overrideHandlers(this);
498
+ this.overrideHandlers(options);
499
+ const propertyName = this.name;
672
500
  CssAnimationProperty.properties[propertyName] = this;
673
- if (options.cssName && options.cssName !== propertyName) {
674
- CssAnimationProperty.properties[options.cssName] = this;
501
+ if (this.cssLocalName && this.cssLocalName !== propertyName) {
502
+ CssAnimationProperty.properties[this.cssLocalName] = this;
675
503
  }
676
- this._valueConverter = options.valueConverter;
677
- const cssLocalName = options.cssName || propertyName;
678
- this.cssLocalName = cssLocalName;
679
- const cssName = 'css:' + cssLocalName;
680
- this.cssName = cssName;
681
504
  const keyframeName = 'keyframe:' + propertyName;
682
505
  this.keyframe = keyframeName;
683
506
  const defaultName = 'default:' + propertyName;
684
507
  const defaultValueKey = Symbol(defaultName);
685
508
  this.defaultValueKey = defaultValueKey;
686
- this.defaultValue = options.defaultValue;
687
- const cssValue = Symbol(cssName);
509
+ const cssValue = Symbol(this.cssName);
688
510
  const styleValue = Symbol(`local:${propertyName}`);
689
511
  const keyframeValue = Symbol(keyframeName);
690
512
  const computedValue = Symbol('computed-value:' + propertyName);
@@ -694,7 +516,7 @@ export class CssAnimationProperty {
694
516
  this.getDefault = Symbol(propertyName + ':getDefault');
695
517
  const getDefault = this.getDefault;
696
518
  const setNative = (this.setNative = Symbol(propertyName + ':setNative'));
697
- const eventName = propertyName + 'Change';
519
+ this.eventName = propertyName + 'Change';
698
520
  const property = this;
699
521
  function descriptor(symbol, propertySource, enumerable, configurable, getsComputed) {
700
522
  return {
@@ -736,8 +558,8 @@ export class CssAnimationProperty {
736
558
  }
737
559
  }
738
560
  else {
739
- if (options.valueConverter && typeof boxedValue === 'string') {
740
- boxedValue = options.valueConverter(boxedValue);
561
+ if (property.valueConverter && typeof boxedValue === 'string') {
562
+ boxedValue = property.valueConverter(boxedValue);
741
563
  }
742
564
  this[symbol] = boxedValue;
743
565
  if (this[computedSource] <= propertySource) {
@@ -748,9 +570,9 @@ export class CssAnimationProperty {
748
570
  const value = this[computedValue];
749
571
  const source = this[computedSource];
750
572
  const isSet = source !== 0 /* Default */;
751
- const computedValueChanged = oldValue !== value && (!options.equalityComparer || !options.equalityComparer(oldValue, value));
752
- if (computedValueChanged && options.valueChanged) {
753
- options.valueChanged(this, oldValue, value);
573
+ const computedValueChanged = oldValue !== value && (!property.equalityComparer || !property.equalityComparer(oldValue, value));
574
+ if (computedValueChanged && property.valueChanged) {
575
+ property.valueChanged(this, oldValue, value);
754
576
  }
755
577
  if (view[setNative] && (computedValueChanged || isSet !== wasSet)) {
756
578
  if (view._suspendNativeUpdatesCount) {
@@ -761,7 +583,7 @@ export class CssAnimationProperty {
761
583
  else {
762
584
  if (isSet) {
763
585
  if (!wasSet && !(defaultValueKey in this)) {
764
- this[defaultValueKey] = view[getDefault] ? view[getDefault]() : options.defaultValue;
586
+ this[defaultValueKey] = view[getDefault] ? view[getDefault]() : property.defaultValue;
765
587
  }
766
588
  view[setNative](value);
767
589
  }
@@ -770,11 +592,12 @@ export class CssAnimationProperty {
770
592
  view[setNative](this[defaultValueKey]);
771
593
  }
772
594
  else {
773
- view[setNative](options.defaultValue);
595
+ view[setNative](property.defaultValue);
774
596
  }
775
597
  }
776
598
  }
777
599
  }
600
+ const eventName = property.eventName;
778
601
  if (computedValueChanged && this.hasListeners(eventName)) {
779
602
  this.notify({
780
603
  object: this,
@@ -784,6 +607,9 @@ export class CssAnimationProperty {
784
607
  oldValue,
785
608
  });
786
609
  }
610
+ if (property.affectsLayout) {
611
+ view.requestLayout();
612
+ }
787
613
  },
788
614
  };
789
615
  }
@@ -794,16 +620,18 @@ export class CssAnimationProperty {
794
620
  symbolPropertyMap[computedValue] = this;
795
621
  cssSymbolPropertyMap[computedValue] = this;
796
622
  this.register = (cls) => {
797
- cls.prototype[computedValue] = options.defaultValue;
623
+ // we add it so that overrideHandlers might work
624
+ cssPropertyNames.push(this.cssLocalName);
625
+ cls.prototype[computedValue] = this.defaultValue;
798
626
  cls.prototype[computedSource] = 0 /* Default */;
799
627
  cls.prototype[cssValue] = unsetValue;
800
628
  cls.prototype[styleValue] = unsetValue;
801
629
  cls.prototype[keyframeValue] = unsetValue;
802
630
  Object.defineProperty(cls.prototype, defaultName, defaultPropertyDescriptor);
803
- Object.defineProperty(cls.prototype, cssName, cssPropertyDescriptor);
631
+ Object.defineProperty(cls.prototype, this.cssName, cssPropertyDescriptor);
804
632
  Object.defineProperty(cls.prototype, propertyName, stylePropertyDescriptor);
805
- if (options.cssName && options.cssName !== options.name) {
806
- Object.defineProperty(cls.prototype, options.cssName, stylePropertyDescriptor);
633
+ if (this.cssLocalName && this.cssLocalName !== this.name) {
634
+ Object.defineProperty(cls.prototype, this.cssLocalName, stylePropertyDescriptor);
807
635
  }
808
636
  Object.defineProperty(cls.prototype, keyframeName, keyframePropertyDescriptor);
809
637
  };
@@ -832,200 +660,180 @@ export class CssAnimationProperty {
832
660
  }
833
661
  CssAnimationProperty.properties = {};
834
662
  CssAnimationProperty.prototype.isStyleProperty = true;
835
- export class InheritedCssProperty extends CssProperty {
836
- constructor(options) {
837
- super(options);
838
- const propertyName = options.name;
839
- const key = this.key;
840
- const sourceKey = this.sourceKey;
841
- const getDefault = this.getDefault;
842
- const setNative = this.setNative;
843
- const defaultValueKey = this.defaultValueKey;
844
- const eventName = propertyName + 'Change';
845
- let defaultValue = options.defaultValue;
846
- let affectsLayout = options.affectsLayout;
847
- let equalityComparer = options.equalityComparer;
848
- let valueChanged = options.valueChanged;
849
- let valueConverter = options.valueConverter;
850
- const property = this;
851
- this.overrideHandlers = function (options) {
852
- if (typeof options.equalityComparer !== 'undefined') {
853
- equalityComparer = options.equalityComparer;
854
- }
855
- if (typeof options.affectsLayout !== 'undefined') {
856
- affectsLayout = options.affectsLayout;
857
- }
858
- if (typeof options.valueChanged !== 'undefined') {
859
- valueChanged = options.valueChanged;
860
- }
861
- if (typeof options.valueConverter !== 'undefined') {
862
- valueConverter = options.valueConverter;
663
+ function setCssInheritedFunc(property, valueSource) {
664
+ return function (boxedValue) {
665
+ const view = this.viewRef.get();
666
+ if (!view) {
667
+ Trace.write(`${boxedValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
668
+ return;
669
+ }
670
+ const key = property.key;
671
+ const defaultValue = property.defaultValue;
672
+ const sourceKey = property.sourceKey;
673
+ const propertyName = property.name;
674
+ const reset = boxedValue === unsetValue || boxedValue === '';
675
+ const currentValueSource = this[sourceKey] || 0 /* Default */;
676
+ if (reset) {
677
+ // If we want to reset cssValue and we have localValue - return;
678
+ if (valueSource === 2 /* Css */ && currentValueSource === 3 /* Local */) {
679
+ return;
863
680
  }
864
- };
865
- const setFunc = (valueSource) => function (boxedValue) {
866
- const view = this.viewRef.get();
867
- if (!view) {
868
- Trace.write(`${boxedValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
681
+ }
682
+ else {
683
+ if (currentValueSource > valueSource) {
869
684
  return;
870
685
  }
871
- const reset = boxedValue === unsetValue || boxedValue === '';
872
- const currentValueSource = this[sourceKey] || 0 /* Default */;
873
- if (reset) {
874
- // If we want to reset cssValue and we have localValue - return;
875
- if (valueSource === 2 /* Css */ && currentValueSource === 3 /* Local */) {
876
- return;
877
- }
686
+ }
687
+ const oldValue = key in this ? this[key] : defaultValue;
688
+ let value;
689
+ let unsetNativeValue = false;
690
+ if (reset) {
691
+ // If unsetValue - we want to reset this property.
692
+ const parent = view.parent;
693
+ const style = parent ? parent.style : null;
694
+ // If we have parent and it has non-default value we use as our inherited value.
695
+ if (style && style[sourceKey] > 0 /* Default */) {
696
+ value = style[propertyName];
697
+ this[sourceKey] = 1 /* Inherited */;
698
+ this[key] = value;
878
699
  }
879
700
  else {
880
- if (currentValueSource > valueSource) {
881
- return;
882
- }
701
+ value = defaultValue;
702
+ delete this[sourceKey];
703
+ delete this[key];
704
+ unsetNativeValue = true;
883
705
  }
884
- const oldValue = key in this ? this[key] : defaultValue;
885
- let value;
886
- let unsetNativeValue = false;
887
- if (reset) {
888
- // If unsetValue - we want to reset this property.
889
- const parent = view.parent;
890
- const style = parent ? parent.style : null;
891
- // If we have parent and it has non-default value we use as our inherited value.
892
- if (style && style[sourceKey] > 0 /* Default */) {
893
- value = style[propertyName];
894
- this[sourceKey] = 1 /* Inherited */;
895
- this[key] = value;
896
- }
897
- else {
898
- value = defaultValue;
899
- delete this[sourceKey];
900
- delete this[key];
901
- unsetNativeValue = true;
902
- }
706
+ }
707
+ else {
708
+ this[sourceKey] = valueSource;
709
+ if (property.valueConverter && typeof boxedValue === 'string') {
710
+ value = property.valueConverter(boxedValue);
903
711
  }
904
712
  else {
905
- this[sourceKey] = valueSource;
906
- if (valueConverter && typeof boxedValue === 'string') {
907
- value = valueConverter(boxedValue);
908
- }
909
- else {
910
- value = boxedValue;
911
- }
912
- this[key] = value;
713
+ value = boxedValue;
913
714
  }
914
- const changed = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
915
- if (changed) {
916
- if (valueChanged) {
917
- valueChanged(this, oldValue, value);
918
- }
919
- if (view[setNative]) {
920
- if (view._suspendNativeUpdatesCount) {
921
- if (view._suspendedUpdates) {
922
- view._suspendedUpdates[propertyName] = property;
923
- }
715
+ this[key] = value;
716
+ }
717
+ const changed = property.equalityComparer ? !property.equalityComparer(oldValue, value) : oldValue !== value;
718
+ if (changed) {
719
+ const setNative = property.setNative;
720
+ const defaultValueKey = property.defaultValueKey;
721
+ const eventName = property.eventName;
722
+ const getDefault = property.getDefault;
723
+ if (property.valueChanged) {
724
+ property.valueChanged(this, oldValue, value);
725
+ }
726
+ if (view[setNative]) {
727
+ if (view._suspendNativeUpdatesCount) {
728
+ if (view._suspendedUpdates) {
729
+ view._suspendedUpdates[propertyName] = property;
924
730
  }
925
- else {
926
- if (unsetNativeValue) {
927
- if (defaultValueKey in this) {
928
- view[setNative](this[defaultValueKey]);
929
- delete this[defaultValueKey];
930
- }
931
- else {
932
- view[setNative](defaultValue);
933
- }
731
+ }
732
+ else {
733
+ if (unsetNativeValue) {
734
+ if (defaultValueKey in this) {
735
+ view[setNative](this[defaultValueKey]);
736
+ delete this[defaultValueKey];
934
737
  }
935
738
  else {
936
- if (!(defaultValueKey in this)) {
937
- this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
938
- }
939
- view[setNative](value);
940
- }
941
- }
942
- }
943
- if (this.hasListeners(eventName)) {
944
- this.notify({
945
- object: this,
946
- eventName,
947
- propertyName,
948
- value,
949
- oldValue,
950
- });
951
- }
952
- if (affectsLayout) {
953
- view.requestLayout();
954
- }
955
- view.eachChild((child) => {
956
- const childStyle = child.style;
957
- const childValueSource = childStyle[sourceKey] || 0 /* Default */;
958
- if (reset) {
959
- if (childValueSource === 1 /* Inherited */) {
960
- setDefaultFunc.call(childStyle, unsetValue);
739
+ view[setNative](defaultValue);
961
740
  }
962
741
  }
963
742
  else {
964
- if (childValueSource <= 1 /* Inherited */) {
965
- setInheritedFunc.call(childStyle, value);
743
+ if (!(defaultValueKey in this)) {
744
+ this[defaultValueKey] = view[getDefault] ? view[getDefault]() : defaultValue;
966
745
  }
746
+ view[setNative](value);
967
747
  }
968
- return true;
748
+ }
749
+ }
750
+ if (this.hasListeners(eventName)) {
751
+ this.notify({
752
+ object: this,
753
+ eventName,
754
+ propertyName,
755
+ value,
756
+ oldValue,
969
757
  });
970
758
  }
971
- };
972
- const setDefaultFunc = setFunc(0 /* Default */);
973
- const setInheritedFunc = setFunc(1 /* Inherited */);
974
- this.setInheritedValue = setInheritedFunc;
975
- this.cssValueDescriptor.set = setFunc(2 /* Css */);
976
- this.localValueDescriptor.set = setFunc(3 /* Local */);
759
+ if (property.affectsLayout) {
760
+ view.requestLayout();
761
+ }
762
+ view.eachChild((child) => {
763
+ const childStyle = child.style;
764
+ const childValueSource = childStyle[sourceKey] || 0 /* Default */;
765
+ if (reset) {
766
+ if (childValueSource === 1 /* Inherited */) {
767
+ property.setDefaultValue.call(childStyle, unsetValue);
768
+ }
769
+ }
770
+ else {
771
+ if (childValueSource <= 1 /* Inherited */) {
772
+ property.setInheritedValue.call(childStyle, value);
773
+ }
774
+ }
775
+ return true;
776
+ });
777
+ }
778
+ };
779
+ }
780
+ export class InheritedCssProperty extends CssProperty {
781
+ constructor(options) {
782
+ super(options);
783
+ const propertyName = options.name;
784
+ InheritedCssProperty.properties[propertyName] = this;
785
+ this.setDefaultValue = setCssInheritedFunc(this, 0 /* Default */);
786
+ this.setInheritedValue = setCssInheritedFunc(this, 1 /* Inherited */);
787
+ this.cssValueDescriptor.set = setCssInheritedFunc(this, 2 /* Css */);
788
+ this.localValueDescriptor.set = setCssInheritedFunc(this, 3 /* Local */);
977
789
  inheritableCssProperties.push(this);
978
790
  }
979
791
  }
792
+ InheritedCssProperty.properties = {};
793
+ function setShorthandFunc(property, valueSource) {
794
+ return function (newValue) {
795
+ const view = this.viewRef.get();
796
+ if (!view) {
797
+ Trace.write(`setLocalValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
798
+ return;
799
+ }
800
+ view._batchUpdate(() => {
801
+ for (const [p, v] of property.converter(newValue)) {
802
+ if (valueSource === 2 /* Css */) {
803
+ this[p.cssName] = v;
804
+ }
805
+ else {
806
+ this[p.name] = v;
807
+ }
808
+ }
809
+ });
810
+ };
811
+ }
980
812
  export class ShorthandProperty {
981
813
  constructor(options) {
982
- this.name = options.name;
814
+ this.overrideHandlers = overrideHandlers(this);
815
+ this.overrideHandlers(options);
983
816
  const key = Symbol(this.name + ':propertyKey');
817
+ ShorthandProperty.properties[this.name] = this;
984
818
  this.key = key;
985
- this.cssName = `css:${options.cssName}`;
986
- this.cssLocalName = `${options.cssName}`;
987
- const converter = options.converter;
988
- function setLocalValue(value) {
989
- const view = this.viewRef.get();
990
- if (!view) {
991
- Trace.write(`setLocalValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
992
- return;
993
- }
994
- view._batchUpdate(() => {
995
- for (const [p, v] of converter(value)) {
996
- this[p.name] = v;
997
- }
998
- });
999
- }
1000
- function setCssValue(value) {
1001
- const view = this.viewRef.get();
1002
- if (!view) {
1003
- Trace.write(`setCssValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
1004
- return;
1005
- }
1006
- view._batchUpdate(() => {
1007
- for (const [p, v] of converter(value)) {
1008
- this[p.cssName] = v;
1009
- }
1010
- });
1011
- }
1012
819
  this.cssValueDescriptor = {
1013
820
  enumerable: true,
1014
821
  configurable: true,
1015
822
  get: options.getter,
1016
- set: setCssValue,
823
+ set: setShorthandFunc(this, 2 /* Css */),
1017
824
  };
1018
825
  this.localValueDescriptor = {
1019
826
  enumerable: true,
1020
827
  configurable: true,
1021
828
  get: options.getter,
1022
- set: setLocalValue,
829
+ set: setShorthandFunc(this, 3 /* Local */),
1023
830
  };
831
+ const property = this;
1024
832
  this.propertyBagDescriptor = {
1025
833
  enumerable: false,
1026
834
  configurable: true,
1027
835
  set(value) {
1028
- converter(value).forEach(([property, value]) => {
836
+ property.converter(value).forEach(([property, value]) => {
1029
837
  this[property.cssLocalName] = value;
1030
838
  });
1031
839
  },
@@ -1045,9 +853,10 @@ export class ShorthandProperty {
1045
853
  Object.defineProperty(cls.prototype.PropertyBag, this.cssLocalName, this.propertyBagDescriptor);
1046
854
  }
1047
855
  }
1048
- function inheritablePropertyValuesOn(view) {
856
+ ShorthandProperty.properties = {};
857
+ function inheritablePropertyValuesOn(view, properties) {
1049
858
  const array = new Array();
1050
- for (const prop of inheritableProperties) {
859
+ for (const prop of properties) {
1051
860
  const sourceKey = prop.sourceKey;
1052
861
  const valueSource = view[sourceKey] || 0 /* Default */;
1053
862
  if (valueSource !== 0 /* Default */) {
@@ -1058,19 +867,6 @@ function inheritablePropertyValuesOn(view) {
1058
867
  }
1059
868
  return array;
1060
869
  }
1061
- function inheritableCssPropertyValuesOn(style) {
1062
- const array = new Array();
1063
- for (const prop of inheritableCssProperties) {
1064
- const sourceKey = prop.sourceKey;
1065
- const valueSource = style[sourceKey] || 0 /* Default */;
1066
- if (valueSource !== 0 /* Default */) {
1067
- // use prop.name as it will return value or default value.
1068
- // prop.key will return undefined if property is set the same value as default one.
1069
- array.push({ property: prop, value: style[prop.name] });
1070
- }
1071
- }
1072
- return array;
1073
- }
1074
870
  export const initNativeView = profile('"properties".initNativeView', function initNativeView(view) {
1075
871
  const wasSuspended = view.suspendRequestLayout;
1076
872
  view.suspendRequestLayout = true;
@@ -1224,8 +1020,14 @@ export function resetCSSProperties(style) {
1224
1020
  }
1225
1021
  }
1226
1022
  }
1023
+ export function propagateInheritableCssProperties(style, child) {
1024
+ return _propagateInheritableProperties(style, child, inheritableCssProperties);
1025
+ }
1227
1026
  export function propagateInheritableProperties(view, child) {
1228
- const inheritablePropertyValues = inheritablePropertyValuesOn(view);
1027
+ return _propagateInheritableProperties(view, child, inheritableProperties);
1028
+ }
1029
+ function _propagateInheritableProperties(view, child, properties) {
1030
+ const inheritablePropertyValues = inheritablePropertyValuesOn(view, properties);
1229
1031
  for (const pair of inheritablePropertyValues) {
1230
1032
  const prop = pair.property;
1231
1033
  const sourceKey = prop.sourceKey;
@@ -1235,17 +1037,6 @@ export function propagateInheritableProperties(view, child) {
1235
1037
  }
1236
1038
  }
1237
1039
  }
1238
- export function propagateInheritableCssProperties(parentStyle, childStyle) {
1239
- const inheritableCssPropertyValues = inheritableCssPropertyValuesOn(parentStyle);
1240
- for (const pair of inheritableCssPropertyValues) {
1241
- const prop = pair.property;
1242
- const sourceKey = prop.sourceKey;
1243
- const currentValueSource = childStyle[sourceKey] || 0 /* Default */;
1244
- if (currentValueSource <= 1 /* Inherited */) {
1245
- prop.setInheritedValue.call(childStyle, pair.value, 1 /* Inherited */);
1246
- }
1247
- }
1248
- }
1249
1040
  export function makeValidator(...values) {
1250
1041
  const set = new Set(values);
1251
1042
  return (value) => set.has(value);