@hanzogui/react-native-web-internals 3.0.6 → 4.3.1

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 (205) hide show
  1. package/dist/cjs/StyleSheet/__tests__/compiler-createReactDOMStyle-test.cjs +62 -37
  2. package/dist/cjs/StyleSheet/__tests__/compiler-test.cjs +129 -117
  3. package/dist/cjs/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.cjs +69 -30
  4. package/dist/cjs/StyleSheet/__tests__/index-test.cjs +127 -95
  5. package/dist/cjs/StyleSheet/__tests__/preprocess-test.cjs +26 -13
  6. package/dist/cjs/StyleSheet/__tests__/validate-test.cjs +30 -15
  7. package/dist/cjs/StyleSheet/compiler/createReactDOMStyle.cjs +141 -68
  8. package/dist/cjs/StyleSheet/compiler/hash.cjs +12 -10
  9. package/dist/cjs/StyleSheet/compiler/hyphenateStyleName.cjs +18 -14
  10. package/dist/cjs/StyleSheet/compiler/index.cjs +234 -173
  11. package/dist/cjs/StyleSheet/compiler/normalizeColor.cjs +27 -18
  12. package/dist/cjs/StyleSheet/compiler/normalizeValueWithProperty.cjs +30 -23
  13. package/dist/cjs/StyleSheet/compiler/resolveShadowValue.cjs +36 -32
  14. package/dist/cjs/StyleSheet/dom/createCSSStyleSheet.cjs +30 -15
  15. package/dist/cjs/StyleSheet/dom/createOrderedCSSStyleSheet.cjs +62 -37
  16. package/dist/cjs/StyleSheet/dom/index.cjs +56 -34
  17. package/dist/cjs/StyleSheet/index.cjs +25 -18
  18. package/dist/cjs/StyleSheet/preprocess.cjs +94 -81
  19. package/dist/cjs/StyleSheet/validate.cjs +67 -44
  20. package/dist/cjs/TextAncestorContext.cjs +13 -11
  21. package/dist/cjs/colorProps.cjs +22 -20
  22. package/dist/cjs/index.cjs +47 -45
  23. package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.cjs +19 -12
  24. package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.cjs +17 -11
  25. package/dist/cjs/modules/AccessibilityUtil/index.cjs +15 -13
  26. package/dist/cjs/modules/AccessibilityUtil/isDisabled.cjs +12 -10
  27. package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.cjs +45 -38
  28. package/dist/cjs/modules/AccessibilityUtil/propsToAriaRole.cjs +34 -30
  29. package/dist/cjs/modules/AssetRegistry/index.cjs +12 -10
  30. package/dist/cjs/modules/ImageLoader/index.cjs +117 -71
  31. package/dist/cjs/modules/InteractionManager.cjs +155 -99
  32. package/dist/cjs/modules/Platform/__tests__/index-test.cjs +21 -13
  33. package/dist/cjs/modules/Platform/index.cjs +12 -10
  34. package/dist/cjs/modules/TextInputState/index.cjs +28 -13
  35. package/dist/cjs/modules/UIManager/__tests__/index-test.cjs +77 -56
  36. package/dist/cjs/modules/UIManager/index.cjs +47 -42
  37. package/dist/cjs/modules/canUseDOM.cjs +13 -11
  38. package/dist/cjs/modules/createDOMProps/__tests__/index-test.cjs +75 -54
  39. package/dist/cjs/modules/createDOMProps/index.cjs +353 -145
  40. package/dist/cjs/modules/createEventHandle/__tests__/index-test.cjs +238 -160
  41. package/dist/cjs/modules/createEventHandle/index.cjs +46 -25
  42. package/dist/cjs/modules/dismissKeyboard/index.cjs +12 -10
  43. package/dist/cjs/modules/forwardedProps/index.cjs +137 -135
  44. package/dist/cjs/modules/getBoundingClientRect/index.cjs +18 -11
  45. package/dist/cjs/modules/invariant.cjs +21 -15
  46. package/dist/cjs/modules/isSelectionValid/index.cjs +18 -17
  47. package/dist/cjs/modules/isWebColor/index.cjs +12 -10
  48. package/dist/cjs/modules/mergeRefs/__tests__/index-test.cjs +21 -15
  49. package/dist/cjs/modules/mergeRefs/index.cjs +24 -21
  50. package/dist/cjs/modules/modality/__tests__/index-test.cjs +44 -17
  51. package/dist/cjs/modules/modality/index.cjs +148 -71
  52. package/dist/cjs/modules/multiplyStyleLengthValue/__tests__/index-test.cjs +18 -10
  53. package/dist/cjs/modules/multiplyStyleLengthValue/index.cjs +26 -20
  54. package/dist/cjs/modules/normalizeColor/index.cjs +22 -17
  55. package/dist/cjs/modules/pick/index.cjs +19 -11
  56. package/dist/cjs/modules/processColor/__tests__/index-test.cjs +43 -24
  57. package/dist/cjs/modules/processColor/index.cjs +32 -24
  58. package/dist/cjs/modules/requestIdleCallback/index.cjs +28 -26
  59. package/dist/cjs/modules/setValueForStyles/dangerousStyleValue.cjs +38 -18
  60. package/dist/cjs/modules/setValueForStyles/index.cjs +25 -14
  61. package/dist/cjs/modules/unitlessNumbers/index.cjs +68 -64
  62. package/dist/cjs/modules/useElementLayout/index.cjs +25 -20
  63. package/dist/cjs/modules/useEvent/__tests__/index-test.cjs +255 -173
  64. package/dist/cjs/modules/useEvent/index.cjs +40 -28
  65. package/dist/cjs/modules/useHover/__tests__/index-test.cjs +233 -124
  66. package/dist/cjs/modules/useHover/index.cjs +105 -62
  67. package/dist/cjs/modules/useLayoutEffect/index.cjs +26 -24
  68. package/dist/cjs/modules/useLocale/index.cjs +33 -30
  69. package/dist/cjs/modules/useLocale/isLocaleRTL.cjs +63 -58
  70. package/dist/cjs/modules/useMergeRefs/__tests__/index-test.cjs +54 -31
  71. package/dist/cjs/modules/useMergeRefs/index.cjs +26 -24
  72. package/dist/cjs/modules/usePlatformMethods/index.cjs +21 -14
  73. package/dist/cjs/modules/useStable/__tests__/index-test.cjs +60 -30
  74. package/dist/cjs/modules/useStable/index.cjs +29 -24
  75. package/dist/cjs/styleTypes.cjs +7 -5
  76. package/dist/cjs/types.cjs +7 -5
  77. package/dist/esm/StyleSheet/__tests__/compiler-createReactDOMStyle-test.mjs +53 -30
  78. package/dist/esm/StyleSheet/__tests__/compiler-createReactDOMStyle-test.mjs.map +1 -1
  79. package/dist/esm/StyleSheet/__tests__/compiler-test.mjs +129 -117
  80. package/dist/esm/StyleSheet/__tests__/compiler-test.mjs.map +1 -1
  81. package/dist/esm/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.mjs +60 -23
  82. package/dist/esm/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.mjs.map +1 -1
  83. package/dist/esm/StyleSheet/__tests__/index-test.mjs +118 -88
  84. package/dist/esm/StyleSheet/__tests__/index-test.mjs.map +1 -1
  85. package/dist/esm/StyleSheet/__tests__/preprocess-test.mjs +26 -13
  86. package/dist/esm/StyleSheet/__tests__/preprocess-test.mjs.map +1 -1
  87. package/dist/esm/StyleSheet/__tests__/validate-test.mjs +30 -15
  88. package/dist/esm/StyleSheet/__tests__/validate-test.mjs.map +1 -1
  89. package/dist/esm/StyleSheet/compiler/createReactDOMStyle.mjs +127 -56
  90. package/dist/esm/StyleSheet/compiler/createReactDOMStyle.mjs.map +1 -1
  91. package/dist/esm/StyleSheet/compiler/hyphenateStyleName.mjs +6 -4
  92. package/dist/esm/StyleSheet/compiler/hyphenateStyleName.mjs.map +1 -1
  93. package/dist/esm/StyleSheet/compiler/index.mjs +218 -159
  94. package/dist/esm/StyleSheet/compiler/index.mjs.map +1 -1
  95. package/dist/esm/StyleSheet/compiler/normalizeColor.mjs +13 -6
  96. package/dist/esm/StyleSheet/compiler/normalizeColor.mjs.map +1 -1
  97. package/dist/esm/StyleSheet/compiler/normalizeValueWithProperty.mjs +16 -11
  98. package/dist/esm/StyleSheet/compiler/normalizeValueWithProperty.mjs.map +1 -1
  99. package/dist/esm/StyleSheet/compiler/resolveShadowValue.mjs +22 -20
  100. package/dist/esm/StyleSheet/compiler/resolveShadowValue.mjs.map +1 -1
  101. package/dist/esm/StyleSheet/dom/createCSSStyleSheet.mjs +18 -5
  102. package/dist/esm/StyleSheet/dom/createCSSStyleSheet.mjs.map +1 -1
  103. package/dist/esm/StyleSheet/dom/createOrderedCSSStyleSheet.mjs +50 -27
  104. package/dist/esm/StyleSheet/dom/createOrderedCSSStyleSheet.mjs.map +1 -1
  105. package/dist/esm/StyleSheet/dom/index.mjs +41 -21
  106. package/dist/esm/StyleSheet/dom/index.mjs.map +1 -1
  107. package/dist/esm/StyleSheet/index.mjs +13 -8
  108. package/dist/esm/StyleSheet/index.mjs.map +1 -1
  109. package/dist/esm/StyleSheet/preprocess.mjs +80 -69
  110. package/dist/esm/StyleSheet/preprocess.mjs.map +1 -1
  111. package/dist/esm/StyleSheet/validate.mjs +55 -34
  112. package/dist/esm/StyleSheet/validate.mjs.map +1 -1
  113. package/dist/esm/TextAncestorContext.mjs +1 -1
  114. package/dist/esm/TextAncestorContext.mjs.map +1 -1
  115. package/dist/esm/colorProps.mjs +10 -10
  116. package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.mjs +10 -5
  117. package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.mjs.map +1 -1
  118. package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.mjs +8 -4
  119. package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.mjs.map +1 -1
  120. package/dist/esm/modules/AccessibilityUtil/propsToAccessibilityComponent.mjs +33 -28
  121. package/dist/esm/modules/AccessibilityUtil/propsToAccessibilityComponent.mjs.map +1 -1
  122. package/dist/esm/modules/AccessibilityUtil/propsToAriaRole.mjs +22 -20
  123. package/dist/esm/modules/AccessibilityUtil/propsToAriaRole.mjs.map +1 -1
  124. package/dist/esm/modules/ImageLoader/index.mjs +105 -61
  125. package/dist/esm/modules/ImageLoader/index.mjs.map +1 -1
  126. package/dist/esm/modules/InteractionManager.mjs +141 -87
  127. package/dist/esm/modules/InteractionManager.mjs.map +1 -1
  128. package/dist/esm/modules/Platform/__tests__/index-test.mjs +12 -6
  129. package/dist/esm/modules/Platform/__tests__/index-test.mjs.map +1 -1
  130. package/dist/esm/modules/TextInputState/index.mjs +16 -3
  131. package/dist/esm/modules/TextInputState/index.mjs.map +1 -1
  132. package/dist/esm/modules/UIManager/__tests__/index-test.mjs +68 -49
  133. package/dist/esm/modules/UIManager/__tests__/index-test.mjs.map +1 -1
  134. package/dist/esm/modules/UIManager/index.mjs +35 -32
  135. package/dist/esm/modules/UIManager/index.mjs.map +1 -1
  136. package/dist/esm/modules/canUseDOM.mjs +1 -1
  137. package/dist/esm/modules/canUseDOM.mjs.map +1 -1
  138. package/dist/esm/modules/createDOMProps/__tests__/index-test.mjs +66 -47
  139. package/dist/esm/modules/createDOMProps/__tests__/index-test.mjs.map +1 -1
  140. package/dist/esm/modules/createDOMProps/index.mjs +339 -133
  141. package/dist/esm/modules/createDOMProps/index.mjs.map +1 -1
  142. package/dist/esm/modules/createEventHandle/__tests__/index-test.mjs +222 -146
  143. package/dist/esm/modules/createEventHandle/__tests__/index-test.mjs.map +1 -1
  144. package/dist/esm/modules/createEventHandle/index.mjs +34 -15
  145. package/dist/esm/modules/createEventHandle/index.mjs.map +1 -1
  146. package/dist/esm/modules/forwardedProps/index.mjs +125 -125
  147. package/dist/esm/modules/forwardedProps/index.mjs.map +1 -1
  148. package/dist/esm/modules/getBoundingClientRect/index.mjs +6 -1
  149. package/dist/esm/modules/getBoundingClientRect/index.mjs.map +1 -1
  150. package/dist/esm/modules/invariant.mjs +9 -5
  151. package/dist/esm/modules/invariant.mjs.map +1 -1
  152. package/dist/esm/modules/isSelectionValid/index.mjs +6 -7
  153. package/dist/esm/modules/isSelectionValid/index.mjs.map +1 -1
  154. package/dist/esm/modules/mergeRefs/__tests__/index-test.mjs +8 -4
  155. package/dist/esm/modules/mergeRefs/__tests__/index-test.mjs.map +1 -1
  156. package/dist/esm/modules/mergeRefs/index.mjs +12 -11
  157. package/dist/esm/modules/mergeRefs/index.mjs.map +1 -1
  158. package/dist/esm/modules/modality/__tests__/index-test.mjs +42 -15
  159. package/dist/esm/modules/modality/__tests__/index-test.mjs.map +1 -1
  160. package/dist/esm/modules/modality/index.mjs +134 -59
  161. package/dist/esm/modules/modality/index.mjs.map +1 -1
  162. package/dist/esm/modules/multiplyStyleLengthValue/__tests__/index-test.mjs +9 -3
  163. package/dist/esm/modules/multiplyStyleLengthValue/__tests__/index-test.mjs.map +1 -1
  164. package/dist/esm/modules/multiplyStyleLengthValue/index.mjs +14 -10
  165. package/dist/esm/modules/multiplyStyleLengthValue/index.mjs.map +1 -1
  166. package/dist/esm/modules/normalizeColor/index.mjs +8 -5
  167. package/dist/esm/modules/normalizeColor/index.mjs.map +1 -1
  168. package/dist/esm/modules/pick/index.mjs +7 -1
  169. package/dist/esm/modules/pick/index.mjs.map +1 -1
  170. package/dist/esm/modules/processColor/__tests__/index-test.mjs +34 -17
  171. package/dist/esm/modules/processColor/__tests__/index-test.mjs.map +1 -1
  172. package/dist/esm/modules/processColor/index.mjs +8 -2
  173. package/dist/esm/modules/processColor/index.mjs.map +1 -1
  174. package/dist/esm/modules/requestIdleCallback/index.mjs +16 -16
  175. package/dist/esm/modules/requestIdleCallback/index.mjs.map +1 -1
  176. package/dist/esm/modules/setValueForStyles/dangerousStyleValue.mjs +24 -6
  177. package/dist/esm/modules/setValueForStyles/dangerousStyleValue.mjs.map +1 -1
  178. package/dist/esm/modules/setValueForStyles/index.mjs +13 -4
  179. package/dist/esm/modules/setValueForStyles/index.mjs.map +1 -1
  180. package/dist/esm/modules/unitlessNumbers/index.mjs +56 -54
  181. package/dist/esm/modules/unitlessNumbers/index.mjs.map +1 -1
  182. package/dist/esm/modules/useElementLayout/index.mjs +11 -8
  183. package/dist/esm/modules/useElementLayout/index.mjs.map +1 -1
  184. package/dist/esm/modules/useEvent/__tests__/index-test.mjs +240 -160
  185. package/dist/esm/modules/useEvent/__tests__/index-test.mjs.map +1 -1
  186. package/dist/esm/modules/useEvent/index.mjs +25 -15
  187. package/dist/esm/modules/useEvent/index.mjs.map +1 -1
  188. package/dist/esm/modules/useHover/__tests__/index-test.mjs +217 -110
  189. package/dist/esm/modules/useHover/__tests__/index-test.mjs.map +1 -1
  190. package/dist/esm/modules/useHover/index.mjs +90 -49
  191. package/dist/esm/modules/useHover/index.mjs.map +1 -1
  192. package/dist/esm/modules/useLocale/index.mjs +6 -5
  193. package/dist/esm/modules/useLocale/index.mjs.map +1 -1
  194. package/dist/esm/modules/useLocale/isLocaleRTL.mjs +51 -48
  195. package/dist/esm/modules/useLocale/isLocaleRTL.mjs.map +1 -1
  196. package/dist/esm/modules/useMergeRefs/__tests__/index-test.mjs +40 -19
  197. package/dist/esm/modules/useMergeRefs/__tests__/index-test.mjs.map +1 -1
  198. package/dist/esm/modules/usePlatformMethods/index.mjs +7 -2
  199. package/dist/esm/modules/usePlatformMethods/index.mjs.map +1 -1
  200. package/dist/esm/modules/useStable/__tests__/index-test.mjs +47 -19
  201. package/dist/esm/modules/useStable/__tests__/index-test.mjs.map +1 -1
  202. package/dist/esm/modules/useStable/index.mjs +5 -2
  203. package/dist/esm/modules/useStable/index.mjs.map +1 -1
  204. package/package.json +1 -1
  205. package/src/StyleSheet/compiler/normalizeColor.tsx +1 -1
@@ -3,48 +3,59 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var InteractionManager_exports = {};
22
24
  __export(InteractionManager_exports, {
23
25
  InteractionManager: () => InteractionManager
24
26
  });
25
27
  module.exports = __toCommonJS(InteractionManager_exports);
26
- var import_invariant = require("./invariant.cjs"),
27
- import_requestIdleCallback = require("./requestIdleCallback/index.cjs");
28
+ var import_invariant = require("./invariant.cjs");
29
+ var import_requestIdleCallback = require("./requestIdleCallback/index.cjs");
28
30
  class EventEmitter {
29
31
  _registry = {};
30
32
  addListener(eventType, listener, context) {
31
- const registrations = this._allocate(eventType),
32
- registration = {
33
- context,
34
- listener,
35
- remove: () => {
36
- registrations.delete(registration);
37
- }
38
- };
39
- return registrations.add(registration), registration;
33
+ const registrations = this._allocate(eventType);
34
+ const registration = {
35
+ context,
36
+ listener,
37
+ remove: () => {
38
+ registrations.delete(registration);
39
+ }
40
+ };
41
+ registrations.add(registration);
42
+ return registration;
40
43
  }
41
44
  emit(eventType, ...args) {
42
45
  const registrations = this._registry[eventType];
43
- if (registrations != null) for (const registration of Array.from(registrations)) registration.listener.apply(registration.context, args);
46
+ if (registrations != null) {
47
+ for (const registration of Array.from(registrations)) {
48
+ registration.listener.apply(registration.context, args);
49
+ }
50
+ }
44
51
  }
45
52
  _allocate(eventType) {
46
53
  let registrations = this._registry[eventType];
47
- return registrations == null && (registrations = /* @__PURE__ */new Set(), this._registry[eventType] = registrations), registrations;
54
+ if (registrations == null) {
55
+ registrations = /* @__PURE__ */new Set();
56
+ this._registry[eventType] = registrations;
57
+ }
58
+ return registrations;
48
59
  }
49
60
  }
50
61
  class TaskQueue {
@@ -53,9 +64,10 @@ class TaskQueue {
53
64
  constructor({
54
65
  onMoreTasks
55
66
  }) {
56
- this._onMoreTasks = onMoreTasks, this._queueStack = [{
67
+ this._onMoreTasks = onMoreTasks;
68
+ this._queueStack = [{
57
69
  tasks: [],
58
- popable: !0
70
+ popable: true
59
71
  }];
60
72
  }
61
73
  enqueueTasks(tasks) {
@@ -75,11 +87,18 @@ class TaskQueue {
75
87
  if (queue.length) {
76
88
  const task = queue.shift();
77
89
  try {
78
- typeof task == "object" && task && "gen" in task ? this._genPromise(task) : typeof task == "object" && task && "run" in task ? task.run() : ((0, import_invariant.invariant)(typeof task == "function", `Expected Function, SimpleTask, or PromiseTask, but got:
79
- ` + JSON.stringify(task, null, 2)), task());
90
+ if (typeof task === "object" && task && "gen" in task) {
91
+ this._genPromise(task);
92
+ } else if (typeof task === "object" && task && "run" in task) {
93
+ ;
94
+ task.run();
95
+ } else {
96
+ (0, import_invariant.invariant)(typeof task === "function", "Expected Function, SimpleTask, or PromiseTask, but got:\n" + JSON.stringify(task, null, 2));
97
+ task();
98
+ }
80
99
  } catch (e) {
81
100
  if (e instanceof Error) {
82
- const taskName = task && typeof task == "object" && "name" in task ? task.name : "";
101
+ const taskName = task && typeof task === "object" && "name" in task ? task.name : "";
83
102
  e.message = "TaskQueue: Error with task " + taskName + ": " + e.message;
84
103
  }
85
104
  throw e;
@@ -90,95 +109,132 @@ class TaskQueue {
90
109
  this._getCurrentQueue().push(task);
91
110
  }
92
111
  _getCurrentQueue() {
93
- const stackIdx = this._queueStack.length - 1,
94
- queue = this._queueStack[stackIdx];
95
- return queue.popable && queue.tasks.length === 0 && stackIdx > 0 ? (this._queueStack.pop(), this._getCurrentQueue()) : queue.tasks;
112
+ const stackIdx = this._queueStack.length - 1;
113
+ const queue = this._queueStack[stackIdx];
114
+ if (queue.popable && queue.tasks.length === 0 && stackIdx > 0) {
115
+ this._queueStack.pop();
116
+ return this._getCurrentQueue();
117
+ } else {
118
+ return queue.tasks;
119
+ }
96
120
  }
97
121
  _genPromise(task) {
98
- const stackIdx = this._queueStack.push({
99
- tasks: [],
100
- popable: !1
101
- }) - 1,
102
- stackItem = this._queueStack[stackIdx];
122
+ const length = this._queueStack.push({
123
+ tasks: [],
124
+ popable: false
125
+ });
126
+ const stackIdx = length - 1;
127
+ const stackItem = this._queueStack[stackIdx];
103
128
  task.gen().then(() => {
104
- stackItem.popable = !0, this.hasTasksToProcess() && this._onMoreTasks();
129
+ stackItem.popable = true;
130
+ if (this.hasTasksToProcess()) {
131
+ this._onMoreTasks();
132
+ }
105
133
  }).catch(ex => {
106
134
  setTimeout(() => {
107
- throw ex instanceof Error && (ex.message = `TaskQueue: Error resolving Promise in task ${task.name}: ${ex.message}`), ex;
135
+ if (ex instanceof Error) {
136
+ ex.message = `TaskQueue: Error resolving Promise in task ${task.name}: ${ex.message}`;
137
+ }
138
+ throw ex;
108
139
  }, 0);
109
140
  });
110
141
  }
111
142
  }
112
- const _emitter = new EventEmitter(),
113
- InteractionManager = {
114
- Events: {
115
- interactionStart: "interactionStart",
116
- interactionComplete: "interactionComplete"
117
- },
118
- /**
119
- * Schedule a function to run after all interactions have completed.
120
- */
121
- runAfterInteractions(task) {
122
- const tasks = [],
123
- promise = new Promise(resolve => {
124
- _scheduleUpdate(), task && tasks.push(task), tasks.push({
125
- run: resolve,
126
- name: "resolve " + (task && typeof task == "object" && "name" in task && task.name || "?")
127
- }), _taskQueue.enqueueTasks(tasks);
128
- });
129
- return {
130
- then: promise.then.bind(promise),
131
- done: promise.then.bind(promise),
132
- cancel: () => {
133
- _taskQueue.cancelTasks(tasks);
134
- }
135
- };
136
- },
137
- /**
138
- * Notify manager that an interaction has started.
139
- */
140
- createInteractionHandle() {
143
+ const _emitter = new EventEmitter();
144
+ const InteractionManager = {
145
+ Events: {
146
+ interactionStart: "interactionStart",
147
+ interactionComplete: "interactionComplete"
148
+ },
149
+ /**
150
+ * Schedule a function to run after all interactions have completed.
151
+ */
152
+ runAfterInteractions(task) {
153
+ const tasks = [];
154
+ const promise = new Promise(resolve => {
141
155
  _scheduleUpdate();
142
- const handle = ++_inc;
143
- return _addInteractionSet.add(handle), handle;
144
- },
145
- /**
146
- * Notify manager that an interaction has completed.
147
- */
148
- clearInteractionHandle(handle) {
149
- (0, import_invariant.invariant)(!!handle, "Must provide a handle to clear."), _scheduleUpdate(), _addInteractionSet.delete(handle), _deleteInteractionSet.add(handle);
150
- },
151
- addListener: _emitter.addListener.bind(_emitter),
152
- /**
153
- * Set deadline for task processing
154
- */
155
- setDeadline(deadline) {
156
- _deadline = deadline;
157
- }
156
+ if (task) {
157
+ tasks.push(task);
158
+ }
159
+ tasks.push({
160
+ run: resolve,
161
+ name: "resolve " + (task && typeof task === "object" && "name" in task && task.name || "?")
162
+ });
163
+ _taskQueue.enqueueTasks(tasks);
164
+ });
165
+ return {
166
+ then: promise.then.bind(promise),
167
+ done: promise.then.bind(promise),
168
+ cancel: () => {
169
+ _taskQueue.cancelTasks(tasks);
170
+ }
171
+ };
158
172
  },
159
- _interactionSet = /* @__PURE__ */new Set(),
160
- _addInteractionSet = /* @__PURE__ */new Set(),
161
- _deleteInteractionSet = /* @__PURE__ */new Set(),
162
- _taskQueue = new TaskQueue({
163
- onMoreTasks: _scheduleUpdate
164
- });
165
- let _nextUpdateHandle = null,
166
- _inc = 0,
167
- _deadline = -1;
173
+ /**
174
+ * Notify manager that an interaction has started.
175
+ */
176
+ createInteractionHandle() {
177
+ _scheduleUpdate();
178
+ const handle = ++_inc;
179
+ _addInteractionSet.add(handle);
180
+ return handle;
181
+ },
182
+ /**
183
+ * Notify manager that an interaction has completed.
184
+ */
185
+ clearInteractionHandle(handle) {
186
+ (0, import_invariant.invariant)(!!handle, "Must provide a handle to clear.");
187
+ _scheduleUpdate();
188
+ _addInteractionSet.delete(handle);
189
+ _deleteInteractionSet.add(handle);
190
+ },
191
+ addListener: _emitter.addListener.bind(_emitter),
192
+ /**
193
+ * Set deadline for task processing
194
+ */
195
+ setDeadline(deadline) {
196
+ _deadline = deadline;
197
+ }
198
+ };
199
+ const _interactionSet = /* @__PURE__ */new Set();
200
+ const _addInteractionSet = /* @__PURE__ */new Set();
201
+ const _deleteInteractionSet = /* @__PURE__ */new Set();
202
+ const _taskQueue = new TaskQueue({
203
+ onMoreTasks: _scheduleUpdate
204
+ });
205
+ let _nextUpdateHandle = null;
206
+ let _inc = 0;
207
+ let _deadline = -1;
168
208
  function _scheduleUpdate() {
169
- _nextUpdateHandle || (_deadline > 0 ? _nextUpdateHandle = setTimeout(_processUpdate) : _nextUpdateHandle = (0, import_requestIdleCallback.requestIdleCallback)(_processUpdate));
209
+ if (!_nextUpdateHandle) {
210
+ if (_deadline > 0) {
211
+ _nextUpdateHandle = setTimeout(_processUpdate);
212
+ } else {
213
+ _nextUpdateHandle = (0, import_requestIdleCallback.requestIdleCallback)(_processUpdate);
214
+ }
215
+ }
170
216
  }
171
217
  function _processUpdate() {
172
218
  _nextUpdateHandle = null;
173
219
  const interactionCount = _interactionSet.size;
174
- _addInteractionSet.forEach(handle => _interactionSet.add(handle)), _deleteInteractionSet.forEach(handle => _interactionSet.delete(handle));
220
+ _addInteractionSet.forEach(handle => _interactionSet.add(handle));
221
+ _deleteInteractionSet.forEach(handle => _interactionSet.delete(handle));
175
222
  const nextInteractionCount = _interactionSet.size;
176
- if (interactionCount !== 0 && nextInteractionCount === 0 ? _emitter.emit("interactionComplete") : interactionCount === 0 && nextInteractionCount !== 0 && _emitter.emit("interactionStart"), nextInteractionCount === 0) {
223
+ if (interactionCount !== 0 && nextInteractionCount === 0) {
224
+ _emitter.emit("interactionComplete");
225
+ } else if (interactionCount === 0 && nextInteractionCount !== 0) {
226
+ _emitter.emit("interactionStart");
227
+ }
228
+ if (nextInteractionCount === 0) {
177
229
  const begin = Date.now();
178
- for (; _taskQueue.hasTasksToProcess();) if (_taskQueue.processNext(), _deadline > 0 && Date.now() - begin >= _deadline) {
179
- _scheduleUpdate();
180
- break;
230
+ while (_taskQueue.hasTasksToProcess()) {
231
+ _taskQueue.processNext();
232
+ if (_deadline > 0 && Date.now() - begin >= _deadline) {
233
+ _scheduleUpdate();
234
+ break;
235
+ }
181
236
  }
182
237
  }
183
- _addInteractionSet.clear(), _deleteInteractionSet.clear();
238
+ _addInteractionSet.clear();
239
+ _deleteInteractionSet.clear();
184
240
  }
@@ -2,13 +2,15 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
- get: () => from[key],
10
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
- });
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
+ get: () => from[key],
11
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
+ });
13
+ }
12
14
  return to;
13
15
  };
14
16
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
@@ -18,7 +20,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
18
20
  // "default" to the CommonJS "module.exports" for node compatibility.
19
21
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
22
  value: mod,
21
- enumerable: !0
23
+ enumerable: true
22
24
  }) : target, mod));
23
25
  var import__ = __toESM(require("../index.cjs"), 1);
24
26
  describe("apis/Platform", () => {
@@ -27,7 +29,8 @@ describe("apis/Platform", () => {
27
29
  expect(import__.default.select({
28
30
  default: "default"
29
31
  })).toEqual("default");
30
- }), test('chooses "web"', () => {
32
+ });
33
+ test('chooses "web"', () => {
31
34
  expect(import__.default.select({
32
35
  android: "android",
33
36
  ios: "ios",
@@ -35,14 +38,19 @@ describe("apis/Platform", () => {
35
38
  default: "default"
36
39
  })).toEqual("web");
37
40
  });
38
- }), describe("isTesting", () => {
41
+ });
42
+ describe("isTesting", () => {
39
43
  const NODE_ENV_BACKUP = process.env.NODE_ENV;
40
44
  afterEach(() => {
41
45
  process.env.NODE_ENV = NODE_ENV_BACKUP;
42
- }), test('true when NODE_ENV is "test"', () => {
43
- process.env.NODE_ENV = "test", expect(import__.default.isTesting).toEqual(!0);
44
- }), test('false when NODE_ENV is not "test"', () => {
45
- process.env.NODE_ENV = "development", expect(import__.default.isTesting).toEqual(!1);
46
+ });
47
+ test('true when NODE_ENV is "test"', () => {
48
+ process.env.NODE_ENV = "test";
49
+ expect(import__.default.isTesting).toEqual(true);
50
+ });
51
+ test('false when NODE_ENV is not "test"', () => {
52
+ process.env.NODE_ENV = "development";
53
+ expect(import__.default.isTesting).toEqual(false);
46
54
  });
47
55
  });
48
56
  });
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var Platform_exports = {};
22
24
  __export(Platform_exports, {
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var TextInputState_exports = {};
22
24
  __export(TextInputState_exports, {
@@ -34,7 +36,10 @@ const TextInputState = {
34
36
  * If no text field is focused it returns null
35
37
  */
36
38
  currentlyFocusedField() {
37
- return document.activeElement !== this._currentlyFocusedNode && (this._currentlyFocusedNode = null), this._currentlyFocusedNode;
39
+ if (document.activeElement !== this._currentlyFocusedNode) {
40
+ this._currentlyFocusedNode = null;
41
+ }
42
+ return this._currentlyFocusedNode;
38
43
  },
39
44
  /**
40
45
  * @param {Object} TextInputID id of the text field to focus
@@ -42,7 +47,12 @@ const TextInputState = {
42
47
  * noop if the text field was already focused
43
48
  */
44
49
  focusTextInput(textFieldNode) {
45
- textFieldNode !== null && (this._currentlyFocusedNode = textFieldNode, document.activeElement !== textFieldNode && import_UIManager.UIManager.focus(textFieldNode));
50
+ if (textFieldNode !== null) {
51
+ this._currentlyFocusedNode = textFieldNode;
52
+ if (document.activeElement !== textFieldNode) {
53
+ import_UIManager.UIManager.focus(textFieldNode);
54
+ }
55
+ }
46
56
  },
47
57
  /**
48
58
  * @param {Object} textFieldNode id of the text field to focus
@@ -50,6 +60,11 @@ const TextInputState = {
50
60
  * noop if it wasn't focused
51
61
  */
52
62
  blurTextInput(textFieldNode) {
53
- textFieldNode !== null && (this._currentlyFocusedNode = null, document.activeElement === textFieldNode && import_UIManager.UIManager.blur(textFieldNode));
63
+ if (textFieldNode !== null) {
64
+ this._currentlyFocusedNode = null;
65
+ if (document.activeElement === textFieldNode) {
66
+ import_UIManager.UIManager.blur(textFieldNode);
67
+ }
68
+ }
54
69
  }
55
70
  };
@@ -2,13 +2,15 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
- get: () => from[key],
10
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
- });
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
+ get: () => from[key],
11
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
+ });
13
+ }
12
14
  return to;
13
15
  };
14
16
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
@@ -18,73 +20,92 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
18
20
  // "default" to the CommonJS "module.exports" for node compatibility.
19
21
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
22
  value: mod,
21
- enumerable: !0
23
+ enumerable: true
22
24
  }) : target, mod));
23
25
  var import__ = __toESM(require("../index.cjs"), 1);
24
26
  const createStyledNode = (name = "div", style = {}) => {
25
- const root = document.createElement(name);
26
- return Object.keys(style).forEach(prop => {
27
- root.style[prop] = style[prop];
28
- }), root;
29
- },
30
- componentStub = {
31
- _reactInternalInstance: {
32
- _currentElement: {
33
- _owner: {}
34
- },
35
- _debugID: 1
36
- }
37
- };
27
+ const root = document.createElement(name);
28
+ Object.keys(style).forEach(prop => {
29
+ root.style[prop] = style[prop];
30
+ });
31
+ return root;
32
+ };
33
+ const componentStub = {
34
+ _reactInternalInstance: {
35
+ _currentElement: {
36
+ _owner: {}
37
+ },
38
+ _debugID: 1
39
+ }
40
+ };
38
41
  describe("apis/UIManager", () => {
39
42
  describe("focus", () => {
40
43
  test('sets tabIndex="-1" on elements not programmatically focusable by default', () => {
41
44
  const node = createStyledNode();
42
- import__.default.focus(node), expect(node.getAttribute("tabIndex")).toEqual("-1");
43
- }), test(`doesn't set tabIndex="-1" on elements with an existing tabIndex`, () => {
45
+ import__.default.focus(node);
46
+ expect(node.getAttribute("tabIndex")).toEqual("-1");
47
+ });
48
+ test(`doesn't set tabIndex="-1" on elements with an existing tabIndex`, () => {
44
49
  const node = createStyledNode();
45
- node.tabIndex = 0, import__.default.focus(node), expect(node.getAttribute("tabIndex")).toEqual("0");
46
- }), test(`doesn't set tabIndex="-1" on elements focusable by default`, () => {
50
+ node.tabIndex = 0;
51
+ import__.default.focus(node);
52
+ expect(node.getAttribute("tabIndex")).toEqual("0");
53
+ });
54
+ test(`doesn't set tabIndex="-1" on elements focusable by default`, () => {
55
+ ;
47
56
  ["a", "input", "select", "textarea"].forEach(name => {
48
57
  const node = createStyledNode(name);
49
- import__.default.focus(node), expect(node.getAttribute("tabIndex")).toBeNull();
58
+ import__.default.focus(node);
59
+ expect(node.getAttribute("tabIndex")).toBeNull();
50
60
  });
51
61
  });
52
- }), describe("updateView", () => {
62
+ });
63
+ describe("updateView", () => {
53
64
  test("supports className alias for class", () => {
54
- const node = createStyledNode(),
55
- props = {
56
- className: "extra"
57
- };
58
- import__.default.updateView(node, props, componentStub), expect(node.getAttribute("class")).toEqual("extra");
59
- }), test("adds correct DOM styles to existing style", () => {
65
+ const node = createStyledNode();
66
+ const props = {
67
+ className: "extra"
68
+ };
69
+ import__.default.updateView(node, props, componentStub);
70
+ expect(node.getAttribute("class")).toEqual("extra");
71
+ });
72
+ test("adds correct DOM styles to existing style", () => {
60
73
  const node = createStyledNode("div", {
61
- color: "red"
62
- }),
63
- props = {
64
- style: {
65
- marginTop: 0,
66
- marginBottom: 0,
67
- opacity: 0
68
- }
69
- };
70
- import__.default.updateView(node, props, componentStub), expect(node.getAttribute("style")).toEqual("color: red; margin-top: 0px; margin-bottom: 0px; opacity: 0;");
71
- }), test("replaces input and textarea text", () => {
74
+ color: "red"
75
+ });
76
+ const props = {
77
+ style: {
78
+ marginTop: 0,
79
+ marginBottom: 0,
80
+ opacity: 0
81
+ }
82
+ };
83
+ import__.default.updateView(node, props, componentStub);
84
+ expect(node.getAttribute("style")).toEqual("color: red; margin-top: 0px; margin-bottom: 0px; opacity: 0;");
85
+ });
86
+ test("replaces input and textarea text", () => {
72
87
  const node = createStyledNode("textarea");
73
88
  node.value = "initial";
74
89
  const textProp = {
75
- text: "expected-text"
76
- },
77
- valueProp = {
78
- value: "expected-value"
79
- };
80
- import__.default.updateView(node, textProp), expect(node.value).toEqual("expected-text"), import__.default.updateView(node, valueProp), expect(node.value).toEqual("expected-value");
81
- }), test("sets other attribute values", () => {
82
- const node = createStyledNode(),
83
- props = {
84
- "aria-level": "4",
85
- "data-of-type": "string"
86
- };
87
- import__.default.updateView(node, props), expect(node.getAttribute("aria-level")).toEqual("4"), expect(node.getAttribute("data-of-type")).toEqual("string");
90
+ text: "expected-text"
91
+ };
92
+ const valueProp = {
93
+ value: "expected-value"
94
+ };
95
+ import__.default.updateView(node, textProp);
96
+ expect(node.value).toEqual("expected-text");
97
+ import__.default.updateView(node, valueProp);
98
+ expect(node.value).toEqual("expected-value");
99
+ });
100
+ test("sets other attribute values", () => {
101
+ const node = createStyledNode();
102
+ const props = {
103
+ "aria-level": "4",
104
+ "data-of-type": "string"
105
+ };
106
+ import__.default.updateView(node, props);
107
+ expect(node.getAttribute("aria-level")).toEqual("4");
108
+ expect(node.getAttribute("data-of-type")).toEqual("string");
88
109
  });
89
110
  });
90
111
  });